You are viewing an old version of this page. View the current version.

Compare with Current Restore this Version View Page History

« Previous Version 107 Next »

ثبت دارایی جدید

Could not load insight objects by given object type = '752'




ثبت مدل جدید

Could not load insight objects by given object type = '755'
Could not load insight objects by given object type = '646'
Could not load insight objects by given object type = '604'
Could not load insight objects by given object type = '754'



ثبت عنوان دستگاه جدید

Could not load insight objects by given object type = '754'




ثبت گروه بندی جدید

Could not load insight objects by given object type = '754'




تأمین
مدیریت فرآیند تأمین تجهیزات پزشکی
ویرایش صفحه
کاربر مدیکیو خوش آمدید
مدیریت تجهیزات
بخش موردنظر خود را انتخاب کنید.
"]; for (var i = 1; i <= 4; i++) { var cls = "mq-flow-step-v50"; if (i < step) cls += " done"; if (i === step) cls += " active"; steps += '
' + '' + i + '' + '' + labels[i - 1] + '' + '
'; } head.innerHTML = '
' + '
' + '
' + title + '
' + '
' + (subtitle || "") + '
' + '
' + '' + '
' + '
' + steps + '
'; panel.insertBefore(head, panel.firstChild); var close = head.querySelector(".mq-flow-close-v50"); if (close) { close.onclick = function (e) { e.preventDefault(); e.stopPropagation(); mqCloseRegistrationFlowV50(true); }; } } function mqFlowFindFieldV50(panel, fieldName) { var form = mqFlowGetFormV50(panel); if (!form) return null; return mqFindNamedField(form, fieldName) || mqFindModelFieldV46(form, fieldName, MQ_FORM_LABELS[fieldName] || ""); } function mqFlowFieldRowV50(panel, fieldName) { var form = mqFlowGetFormV50(panel); if (!form) return null; var field = mqFlowFindFieldV50(panel, fieldName); if (!field) return null; return ( (field.closest && field.closest("tr")) || (field.closest && field.closest(".field-group")) || (field.closest && field.closest(".control-group")) || field.parentElement ); } function mqFlowSetLabelV50(panel, fieldName, text) { var form = mqFlowGetFormV50(panel); var field = mqFlowFindFieldV50(panel, fieldName); if (!form || !field) return; var id = field.getAttribute && field.getAttribute("id"); var label = id ? form.querySelector('label[for="' + id + '"]') : null; var row = mqFlowFieldRowV50(panel, fieldName); if (!label && row) label = row.querySelector("label"); if (!label) return; var required = label.querySelector(".aui-iconfont-required, .required, .cf_required"); if (required) { label.innerHTML = ""; label.appendChild(document.createTextNode(text + " ")); label.appendChild(required); } else { label.textContent = text; } } function mqFlowHideAllRowsExceptV50(panel, fieldName) { var form = mqFlowGetFormV50(panel); if (!form) return; var rows = form.querySelectorAll("tr, .field-group, .control-group"); for (var i = 0; i < rows.length; i++) { rows[i].classList.add("mq-flow-hidden-row-v50"); } var target = mqFlowFieldRowV50(panel, fieldName); if (target) target.classList.remove("mq-flow-hidden-row-v50"); } function mqFlowShowAllRowsV50(panel) { if (!panel) return; var rows = panel.querySelectorAll(".mq-flow-hidden-row-v50"); for (var i = 0; i < rows.length; i++) { rows[i].classList.remove("mq-flow-hidden-row-v50"); } } function mqFlowSelectedTextV50(panel, fieldName) { var field = mqFlowFindFieldV50(panel, fieldName); if (!field) return ""; var row = mqFlowFieldRowV50(panel, fieldName); if (row) { var rendered = row.querySelector( ".select2-chosen, .select2-selection__rendered, .aui-select2-choice .select2-chosen" ); if (rendered) { var txt = mqNormalizeTextV46(rendered.textContent || "") .replace(/^×\s*/, "") .trim(); if ( txt && txt !== "انتخاب کنید" && txt !== "Select" && txt !== "Choose" ) { return txt; } } } return mqNormalizeTextV46(field.value || ""); } function mqFlowHasSelectionV50(panel, fieldName) { var field = mqFlowFindFieldV50(panel, fieldName); if (!field) return false; var value = mqNormalizeTextV46(field.value || ""); if (value) return true; return !!mqFlowSelectedTextV50(panel, fieldName); } function mqFlowClearExceptV50(panel, keepNames) { var form = mqFlowGetFormV50(panel); if (!form) return; var keep = {}; (keepNames || []).forEach(function (n) { keep[n] = true; }); var controls = form.querySelectorAll("input[name], textarea[name], select[name]"); for (var i = 0; i < controls.length; i++) { var c = controls[i]; var name = c.name || ""; if (!name || keep[name] || c.type === "hidden" || c.type === "submit" || c.type === "button") { continue; } if (c.type === "checkbox" || c.type === "radio") { c.checked = false; } else { c.value = ""; } try { if (window.AJS && AJS.$) { var $c = AJS.$(c); if ($c.data("select2") || $c.hasClass("select2-offscreen") || $c.hasClass("select2-hidden-accessible")) { try { $c.select2("val", ""); } catch (ignoreS2v) {} try { $c.trigger("change"); } catch (ignoreS2c) {} } } } catch (ignore) {} } } function mqFlowRefreshReferenceV50(panel, fieldName) { var field = mqFlowFindFieldV50(panel, fieldName); if (!field) return; try { var jq = (window.AJS && AJS.$) ? AJS.$ : (window.jQuery || null); if (!jq) return; var $field = jq(field); try { $field.select2("close"); } catch (ignore1) {} try { $field.trigger("change"); } catch (ignore2) {} } catch (ignore) {} } function mqFlowBuildSelectorFooterV50(panel, opts) { var old = panel.querySelector(".mq-flow-footer-v50"); if (old) old.parentNode.removeChild(old); var footer = document.createElement("div"); footer.className = "mq-flow-footer-v50"; footer.innerHTML = '' + ''; panel.appendChild(footer); var plus = footer.querySelector(".mq-flow-plus-v50"); var next = footer.querySelector(".mq-flow-next-v50"); var back = footer.querySelector(".mq-flow-back-v50"); if (plus) plus.onclick = opts.onPlus; if (next) next.onclick = opts.onNext; if (back) back.onclick = function () { mqFlowShowSelectorStepV50(opts.backStep); }; } function mqFlowBuildCreateBackV50(panel, stepBack) { var old = panel.querySelector(".mq-flow-create-actions-v50"); if (old) old.parentNode.removeChild(old); var bar = document.createElement("div"); bar.className = "mq-flow-create-actions-v50"; bar.innerHTML = ''; panel.appendChild(bar); var btn = bar.querySelector("button"); if (btn) btn.onclick = function () { mqFlowShowSelectorStepV50(stepBack); }; } function mqFlowPrepareSelectorPanelV50(panel, step, fieldName, title, subtitle, labelText, plusLabel, createKey, nextStep, backStep) { mqFlowRemoveUiV50(panel); mqFlowActivateV50(panel); panel.classList.add("mq-flow-selector-v50"); mqFlowBuildHeadV50(panel, step, title, subtitle); mqFlowHideAllRowsExceptV50(panel, fieldName); mqFlowSetLabelV50(panel, fieldName, labelText); mqFlowBuildSelectorFooterV50(panel, { plusLabel: plusLabel, backStep: backStep, onPlus: function () { mqFlowShowCreateV50(createKey, step); }, onNext: function () { if (!mqFlowHasSelectionV50(panel, fieldName)) { showToast("ابتدا «" + labelText + "» را انتخاب کنید."); return; } mqFlowShowSelectorStepV50(nextStep); } }); var field = mqFlowFindFieldV50(panel, fieldName); if (field) { window.setTimeout(function () { /* * V50.2: * Do NOT autofocus Select2. ConfiForms remote pickers open an * orphan dropdown at the page corner when focused while the * registration panel is being restyled. Keep the picker closed * until the user clicks it. */ mqCloseSelect2Dropdowns(document); var form = mqFlowGetFormV50(panel); var visual = mqReferenceVisualV46(form, field); if (visual && visual.style) { visual.style.setProperty('display', 'block', 'important'); visual.style.setProperty('visibility', 'visible', 'important'); visual.style.setProperty('opacity', '1', 'important'); visual.style.setProperty('width', '100%', 'important'); visual.style.setProperty('max-width', '100%', 'important'); visual.style.setProperty('min-width', '0', 'important'); } var row = mqFlowFieldRowV50(panel, fieldName); if (row && row.style) { row.style.setProperty('display', '', 'important'); row.style.setProperty('visibility', 'visible', 'important'); row.style.setProperty('opacity', '1', 'important'); row.style.setProperty('width', '100%', 'important'); row.style.setProperty('max-width', '100%', 'important'); } }, 90); } } function mqFlowShowSelectorStepV50(step) { if (!mqFlowStateV50.open) { return; } mqFlowStateV50.step = step; mqFlowStateV50.mode = "selector"; /* ======================================================== STEP 1 : GROUP ======================================================== */ if (step === 1) { mqFlowEnsurePanelV50( "equipmentTitle", function (panel) { if ( !mqFlowStateV50 .initialized .equipmentTitle ) { mqResetConfiFormV48( panel ); mqFlowStateV50 .initialized .equipmentTitle = true; } mqFlowPrepareSelectorPanelV50( panel, 1, "equipmentTitleGroup", "انتخاب گروه", "گروه موجود را انتخاب کنید؛ اگر وجود ندارد، از دکمه + گروه جدید را ثبت کنید.", "گروه", "گروه", "classification", 2, 0 ); } ); return; } /* ======================================================== STEP 2 : EQUIPMENT TITLE ======================================================== */ if (step === 2) { mqFlowEnsurePanelV50( "model", function (panel) { if ( !mqFlowStateV50 .initialized .model ) { mqResetConfiFormV48( panel ); mqFlowStateV50 .initialized .model = true; } mqFlowPrepareSelectorPanelV50( panel, 2, "deviceTitle", "انتخاب عنوان دستگاه", "عنوان دستگاه موجود را انتخاب کنید؛ اگر وجود ندارد، از دکمه + عنوان دستگاه جدید را ثبت کنید.", "عنوان دستگاه", "عنوان دستگاه", "equipmentTitle", 3, 1 ); } ); return; } /* ======================================================== STEP 3 : MODEL ======================================================== */ if (step === 3) { mqFlowEnsurePanelV50( "asset", function (panel) { if ( !mqFlowStateV50 .initialized .asset ) { mqResetConfiFormV48( panel ); mqFlowStateV50 .initialized .asset = true; } mqFlowPrepareSelectorPanelV50( panel, 3, "deviceModel", "انتخاب مدل", "مدل موجود را انتخاب کنید؛ اگر وجود ندارد، از دکمه + مدل جدید را ثبت کنید.", "مدل", "مدل", "model", 4, 2 ); } ); return; } /* ======================================================== STEP 4 : DEVICE ======================================================== */ if (step === 4) { mqFlowShowAssetCreateV50(); return; } } function mqFlowShowCreateV50( key, returnStep ) { if (!mqFlowStateV50.open) { return; } mqFlowStateV50.mode = "create-" + key; mqFlowEnsurePanelV50( key, function (panel) { mqFlowRemoveUiV50( panel ); mqFlowActivateV50( panel ); panel.classList.add( "mq-flow-create-v50" ); /* ==================================================== GROUP ==================================================== */ if ( key === "classification" ) { mqResetConfiFormV48( panel ); mqFlowBuildHeadV50( panel, 1, "ثبت گروه جدید", "نام گروه و در صورت نیاز گروه والد را وارد کنید." ); } /* ==================================================== EQUIPMENT TITLE ==================================================== */ else if ( key === "equipmentTitle" ) { /* * گروه انتخاب شده باید حفظ شود. */ mqFlowClearExceptV50( panel, [ "equipmentTitleGroup" ] ); mqFlowBuildHeadV50( panel, 2, "ثبت عنوان دستگاه جدید", "گروه انتخاب‌شده حفظ می‌شود؛ عنوان دستگاه را وارد و ثبت کنید." ); } /* ==================================================== MODEL ==================================================== */ else if ( key === "model" ) { /* * عنوان دستگاه انتخاب شده حفظ شود. */ mqFlowClearExceptV50( panel, [ "deviceTitle" ] ); try { mqEnhanceLiveModelPanel( panel ); } catch ( ignoreEnhanceModelV50 ) {} mqFlowBuildHeadV50( panel, 3, "ثبت مدل جدید", "عنوان دستگاه انتخاب‌شده حفظ می‌شود؛ مشخصات مدل را تکمیل و ثبت کنید." ); } mqFlowShowAllRowsV50( panel ); mqFlowBuildCreateBackV50( panel, returnStep ); } ); } function mqFlowShowAssetCreateV50() { mqFlowEnsurePanelV50( "asset", function (panel) { mqFlowStateV50.step = 4; mqFlowStateV50.mode = "asset"; mqFlowRemoveUiV50( panel ); mqFlowActivateV50( panel ); panel.classList.add( "mq-flow-asset-v50" ); try { mqEnhanceLiveAssetPanel( panel ); } catch ( ignoreEnhanceAssetV50 ) {} mqFlowShowAllRowsV50( panel ); mqFlowBuildHeadV50( panel, 4, "ثبت دستگاه", "مدل انتخاب شده است؛ اطلاعات نهایی دستگاه را تکمیل و ثبت کنید." ); mqFlowBuildCreateBackV50( panel, 3 ); } ); } function mqEnsureRegistrationFlowBackdropV50() { var backdrop = document.getElementById("mqRegistrationFlowBackdropV50"); if (backdrop) return backdrop; backdrop = document.createElement("div"); backdrop.id = "mqRegistrationFlowBackdropV50"; backdrop.setAttribute("aria-hidden", "true"); document.body.appendChild(backdrop); return backdrop; } function openMediQRegistrationFlowV50() { if (mqFlowStateV50.open) return; mqFlowStateV50.open = true; mqFlowStateV50.step = 1; mqFlowStateV50.mode = "selector"; mqFlowStateV50.activePanel = null; mqFlowStateV50.initialized = {}; try { window.sessionStorage.removeItem("mediqAssetDraft"); window.sessionStorage.removeItem("mediqOpenAssetAfterReload"); } catch (ignore) {} mqCloseSelect2Dropdowns(document); document.body.classList.add("mq-flow-open-v50"); var backdrop = mqEnsureRegistrationFlowBackdropV50(); backdrop.classList.add("open"); backdrop.setAttribute("aria-hidden", "false"); mqFlowShowSelectorStepV50(1); } function mqCloseRegistrationFlowV50(resetAll) { mqCloseSelect2Dropdowns(document); var keys = ["classification", "equipmentTitle", "model", "asset"]; for (var i = 0; i < keys.length; i++) { var panel = mqFlowGetPanelV50(keys[i]); if (!panel) continue; mqFlowRemoveUiV50(panel); if (resetAll) { try { mqResetConfiFormV48(panel); } catch (ignoreResetV50) {} } } mqFlowDeactivateCurrentV50(); var backdrop = document.getElementById("mqRegistrationFlowBackdropV50"); if (backdrop) { backdrop.classList.remove("open"); backdrop.setAttribute("aria-hidden", "true"); } document.body.classList.remove("mq-flow-open-v50"); mqFlowStateV50.open = false; mqFlowStateV50.step = 1; mqFlowStateV50.mode = "selector"; mqFlowStateV50.activePanel = null; mqFlowStateV50.initialized = {}; } /* Replace the old bottom-up asset opener with the new top-down flow. */ var mqLegacyOpenAssetV50 = openMediQAssetForm; openMediQAssetForm = function () { openMediQRegistrationFlowV50(); }; /* Final ConfiForms callback for the top-down flow. */ (function mqBindTopDownSubmitV50() { var previousSubmitV50 = window.onCFSubmitFinished; window.onCFSubmitFinished = function (formName) { if (mqFlowStateV50.open) { if (formName === "mediqNewClassification") { showToast("طبقه‌بندی ثبت شد؛ آن را از لیست انتخاب کنید."); mqFlowShowSelectorStepV50(1); window.setTimeout(function () { var p = mqFlowGetPanelV50("equipmentTitle"); if (p) mqFlowRefreshReferenceV50(p, "equipmentTitleGroup"); }, 180); return; } if (formName === "mediqNewEquipmentTitle") { showToast("عنوان دستگاه ثبت شد؛ آن را از لیست انتخاب کنید."); mqFlowShowSelectorStepV50(2); window.setTimeout(function () { var p = mqFlowGetPanelV50("model"); if (p) mqFlowRefreshReferenceV50(p, "deviceTitle"); }, 180); return; } if (formName === "mediqNewModel") { showToast("مدل ثبت شد؛ آن را از لیست انتخاب کنید."); mqFlowShowSelectorStepV50(3); window.setTimeout(function () { var p = mqFlowGetPanelV50("asset"); if (p) mqFlowRefreshReferenceV50(p, "deviceModel"); }, 180); return; } if (formName === "mediqNewAsset") { try { window.sessionStorage.setItem("mediqResumeView", "newAsset-purchased"); } catch (ignoreResumeV50) {} mqCloseRegistrationFlowV50(true); showToast("دارایی با موفقیت ثبت شد."); window.setTimeout(function () { window.location.reload(); }, 450); return; } } if (typeof previousSubmitV50 === "function") { return previousSubmitV50.apply(this, arguments); } }; })(); /* ESC closes the whole top-down flow. */ document.addEventListener("keydown", function (e) { if (e.key !== "Escape") return; if (!mqFlowStateV50.open) return; e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); mqCloseRegistrationFlowV50(true); }, true); /* ============================================================ MEDIQ V50.5 - SELECT2 SAFE FIX (NO DOM REPARENT) Important: NEVER move/reparent a live ConfiForms Select2 node. Moving it breaks its Ajax positioning/events. We only restyle it in-place and position the floating dropdown when it opens. ============================================================ */ function mqV505JQ(){ return (window.AJS && AJS.$) ? AJS.$ : (window.jQuery || null); } function mqV505FieldVisual(panel, fieldName){ var field = mqFlowFindFieldV50(panel, fieldName); if (!field) return null; if (field.classList && (field.classList.contains('select2-container') || field.classList.contains('aui-select2-container'))) { return { field: field, visual: field }; } var id = field.getAttribute && field.getAttribute('id'); if (id) { var byId = document.getElementById('s2id_' + id); if (byId) return { field: field, visual: byId }; } var form = mqFlowGetFormV50(panel); var visual = form ? mqReferenceVisualV46(form, field) : null; if (visual && visual !== field && visual.classList && (visual.classList.contains('select2-container') || visual.classList.contains('aui-select2-container'))) { return { field: field, visual: visual }; } var row = mqFlowFieldRowV50(panel, fieldName); if (row) { var inRow = row.querySelector('.select2-container, .aui-select2-container'); if (inRow) return { field: field, visual: inRow }; } var jq = mqV505JQ(); if (jq) { try { var c = jq(field).select2('container'); if (c && c.length && c[0]) return { field: field, visual: c[0] }; } catch(ignoreV505Container) {} } return { field: field, visual: null }; } function mqV505MakeAncestorsVisible(node, stopAt){ var cur = node; var guard = 0; while (cur && cur !== stopAt && guard++ < 14) { try { cur.style.setProperty('visibility','visible','important'); cur.style.setProperty('opacity','1','important'); cur.style.setProperty('max-width','100%','important'); cur.style.setProperty('min-width','0','important'); if (cur.classList && (cur.classList.contains('mq-nested-ref-wrap-v48') || cur.classList.contains('mq-reference-control-wrap-v46'))) { cur.style.setProperty('display','block','important'); cur.style.setProperty('width','100%','important'); cur.style.setProperty('overflow','visible','important'); cur.style.setProperty('position','relative','important'); } } catch(ignoreV505Ancestor) {} cur = cur.parentElement; } } function mqV505OpenDrop(){ return document.querySelector( '.select2-drop.select2-drop-active,' + '.aui-select2-drop.select2-drop-active,' + '.select2-dropdown[aria-hidden="false"]' ); } function mqV505PositionDropdown(visual){ if (!visual || !document.body.classList.contains('mq-flow-open-v50')) return; var drop = mqV505OpenDrop(); if (!drop) return; var rect; try { rect = visual.getBoundingClientRect(); } catch(ignoreRect) { return; } if (!rect || rect.width < 10 || rect.height < 1) return; var vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0); var width = Math.max(260, rect.width); if (width > vw - 24) width = vw - 24; var left = rect.left; if (left + width > vw - 12) left = vw - width - 12; if (left < 12) left = 12; try { drop.style.setProperty('display','block','important'); drop.style.setProperty('visibility','visible','important'); drop.style.setProperty('opacity','1','important'); drop.style.setProperty('position','fixed','important'); drop.style.setProperty('left', Math.round(left) + 'px','important'); drop.style.setProperty('right','auto','important'); drop.style.setProperty('top', Math.round(rect.bottom + 4) + 'px','important'); drop.style.setProperty('width', Math.round(width) + 'px','important'); drop.style.setProperty('min-width', Math.round(width) + 'px','important'); drop.style.setProperty('max-width', Math.round(width) + 'px','important'); drop.style.setProperty('z-index','2147483640','important'); drop.style.setProperty('direction','rtl','important'); drop.style.setProperty('text-align','right','important'); drop.style.setProperty('pointer-events','auto','important'); } catch(ignoreDropStyle) {} } function mqV505BindPicker(panel, fieldName){ if (!panel || !fieldName) return false; var pair = mqV505FieldVisual(panel, fieldName); if (!pair || !pair.field) return false; var field = pair.field; var visual = pair.visual; var row = mqFlowFieldRowV50(panel, fieldName); if (row) { row.classList.remove('mq-flow-hidden-row-v50'); try { row.style.setProperty('display','table-row','important'); row.style.setProperty('visibility','visible','important'); row.style.setProperty('opacity','1','important'); row.style.setProperty('width','100%','important'); row.style.setProperty('max-width','100%','important'); row.style.setProperty('overflow','visible','important'); } catch(ignoreRow) {} } mqV505MakeAncestorsVisible(visual || field, panel); if (visual) { try { visual.style.setProperty('display','block','important'); visual.style.setProperty('visibility','visible','important'); visual.style.setProperty('opacity','1','important'); visual.style.setProperty('width','100%','important'); visual.style.setProperty('max-width','100%','important'); visual.style.setProperty('min-width','0','important'); visual.style.setProperty('position','relative','important'); visual.style.setProperty('left','auto','important'); visual.style.setProperty('right','auto','important'); visual.style.setProperty('top','auto','important'); visual.style.setProperty('transform','none','important'); visual.style.setProperty('margin','0','important'); visual.style.setProperty('box-sizing','border-box','important'); } catch(ignoreVisualStyle) {} } var jq = mqV505JQ(); if (jq) { try { var $field = jq(field); $field.off('.mqV505'); $field.on('select2-open.mqV505 select2:open.mqV505', function(){ window.setTimeout(function(){ mqV505PositionDropdown(visual || field); }, 0); window.setTimeout(function(){ mqV505PositionDropdown(visual || field); }, 35); window.setTimeout(function(){ mqV505PositionDropdown(visual || field); }, 120); }); $field.on('select2-selected.mqV505 select2:select.mqV505 change.mqV505', function(){ /* Keep the current wizard step. Selection alone must NEVER open create mode. */ window.setTimeout(function(){ mqV505BindPicker(panel, fieldName); }, 20); }); } catch(ignoreBindV505) {} } if (visual && !visual.getAttribute('data-mq-v505-click')) { visual.setAttribute('data-mq-v505-click','1'); visual.addEventListener('click', function(){ window.setTimeout(function(){ mqV505PositionDropdown(visual); }, 25); window.setTimeout(function(){ mqV505PositionDropdown(visual); }, 100); }, true); } return !!visual; } function mqV505RepairActive(){ if (!mqFlowStateV50.open) return; var panel = mqFlowStateV50.activePanel; if (!panel) return; /* Remove any host accidentally left by V50.4 or older experiments. We DO NOT move the live Select2 node; only remove empty hosts. */ var hosts = panel.querySelectorAll('.mq-flow-picker-host-v504'); for (var h=0; h vw - 12) left = vw - width - 12; if (left < 12) left = 12; try { drop.classList.remove('mq-v506-orphan'); drop.classList.remove('mq-v506-current-drop'); drop.classList.remove('select2-display-none'); /* Old cleanup code may have left inline display:none. */ drop.style.setProperty('display', 'block', 'important'); drop.style.setProperty('visibility', 'visible', 'important'); drop.style.setProperty('opacity', '1', 'important'); drop.style.setProperty('pointer-events', 'auto', 'important'); drop.style.setProperty('position', 'fixed', 'important'); drop.style.setProperty('left', Math.round(left) + 'px', 'important'); drop.style.setProperty('right', 'auto', 'important'); drop.style.setProperty('top', Math.round(rect.bottom + 4) + 'px', 'important'); drop.style.setProperty('width', Math.round(width) + 'px', 'important'); drop.style.setProperty('min-width', Math.round(width) + 'px', 'important'); drop.style.setProperty('max-width', Math.round(width) + 'px', 'important'); drop.style.setProperty('z-index', '2147483640', 'important'); drop.style.setProperty('direction', 'rtl', 'important'); drop.style.setProperty('text-align', 'right', 'important'); } catch (ignoreV54DropStyle) {} } function mqV54ResetClosedDrops() { var drops = document.querySelectorAll('.select2-drop, .aui-select2-drop, .select2-dropdown'); for (var i = 0; i < drops.length; i++) { var d = drops[i]; var active = d.classList.contains('select2-drop-active') && !d.classList.contains('select2-display-none'); if (active) continue; try { d.style.removeProperty('position'); d.style.removeProperty('left'); d.style.removeProperty('right'); d.style.removeProperty('top'); d.style.removeProperty('width'); d.style.removeProperty('min-width'); d.style.removeProperty('max-width'); d.style.removeProperty('z-index'); d.style.removeProperty('direction'); d.style.removeProperty('text-align'); d.style.removeProperty('pointer-events'); d.style.removeProperty('visibility'); d.style.removeProperty('opacity'); } catch (ignoreV54Reset) {} } } /* Keep the public V50.5 position hook working for old listeners. */ mqV505PositionDropdown = function (visual) { mqV54RevealAndPosition(visual, mqV54OpenToken); }; /* ------------------------------------------------------------ Robust picker binding. Native Select2 gets the first chance to open. If it does not, we explicitly call select2('open') on the original field. ------------------------------------------------------------ */ mqV505BindPicker = function (panel, fieldName) { if (!panel || !fieldName) return false; var pair = mqV505FieldVisual(panel, fieldName); if (!pair || !pair.field) return false; var field = pair.field; var visual = pair.visual; var row = mqFlowFieldRowV50(panel, fieldName); if (row) { row.classList.remove('mq-flow-hidden-row-v50'); try { row.style.removeProperty('display'); row.style.setProperty('visibility', 'visible', 'important'); row.style.setProperty('opacity', '1', 'important'); row.style.setProperty('width', '100%', 'important'); row.style.setProperty('max-width', '100%', 'important'); row.style.setProperty('overflow', 'visible', 'important'); } catch (ignoreV54Row) {} } if (visual) { mqV505MakeAncestorsVisible(visual, panel); try { visual.style.setProperty('display', 'block', 'important'); visual.style.setProperty('visibility', 'visible', 'important'); visual.style.setProperty('opacity', '1', 'important'); visual.style.setProperty('width', '100%', 'important'); visual.style.setProperty('max-width', '100%', 'important'); visual.style.setProperty('min-width', '0', 'important'); visual.style.setProperty('position', 'relative', 'important'); visual.style.setProperty('margin', '0', 'important'); visual.style.setProperty('box-sizing', 'border-box', 'important'); visual.style.setProperty('pointer-events', 'auto', 'important'); } catch (ignoreV54Visual) {} } var $ = mqV54JQ(); if (!$) return !!visual; try { var $field = $(field); /* Re-bind if ConfiForms created a fresh field element. */ $field.off('.mqV505').off('.mqV506').off('.mqV51').off('.mqV54'); $field.on('select2-open.mqV54 select2:open.mqV54', function () { mqV54OpenToken++; var token = mqV54OpenToken; var v = visual || field; window.setTimeout(function () { mqV54RevealAndPosition(v, token); }, 0); window.setTimeout(function () { mqV54RevealAndPosition(v, token); }, 35); window.setTimeout(function () { mqV54RevealAndPosition(v, token); }, 100); window.setTimeout(function () { mqV54RevealAndPosition(v, token); }, 220); }); $field.on( 'select2-selected.mqV54 select2:select.mqV54 change.mqV54', function () { /* ConfiForms may redraw this field after selection. */ window.setTimeout(function () { mqV54ApplyOnly(panel); mqV505RepairActive(); }, 30); window.setTimeout(function () { mqV54ApplyOnly(panel); mqV505RepairActive(); }, 180); window.setTimeout(function () { mqV54ApplyOnly(panel); mqV505RepairActive(); }, 500); } ); $field.on('select2-close.mqV54 select2:close.mqV54', function () { mqV54OpenToken++; window.setTimeout(mqV54ResetClosedDrops, 0); window.setTimeout(mqV54ResetClosedDrops, 120); }); /* Explicit-open fallback for old AUI Select2/Insight fields. */ if (visual && visual.getAttribute('data-mq-v54-open') !== '1') { visual.setAttribute('data-mq-v54-open', '1'); var wasOpenOnDown = false; visual.addEventListener('mousedown', function (e) { if (e && e.target && e.target.closest && e.target.closest('.select2-search-choice-close, .select2-selection__clear')) { return; } wasOpenOnDown = !!mqV54ActiveDrop(); }, true); visual.addEventListener('click', function (e) { if (e && e.target && e.target.closest && e.target.closest('.select2-search-choice-close, .select2-selection__clear')) { return; } var v = visual; window.setTimeout(function () { var alreadyOpen = !!mqV54ActiveDrop(); if (!alreadyOpen && !wasOpenOnDown) { try { $field.select2('open'); } catch (ignoreV54Open) {} } window.setTimeout(function () { var token = ++mqV54OpenToken; mqV54RevealAndPosition(v, token); }, 0); window.setTimeout(function () { mqV54RevealAndPosition(v, mqV54OpenToken); }, 80); }, 0); }, false); } } catch (ignoreV54Bind) {} return !!visual; }; /* ------------------------------------------------------------ Re-apply after ConfiForms redraws the currently active panel. ------------------------------------------------------------ */ try { var mqV54Observer = new MutationObserver(function () { if (!mqFlowStateV50.open) return; window.clearTimeout(mqV54Timer); mqV54Timer = window.setTimeout(function () { var panel = document.querySelector('.mq-flow-active-panel-v50'); if (!panel) return; mqV54ApplyOnly(panel); mqV505RepairActive(); var drop = mqV54ActiveDrop(); if (drop) { var stepField = null; if (mqFlowStateV50.mode === 'selector') { if (mqFlowStateV50.step === 1) stepField = 'equipmentTitleGroup'; if (mqFlowStateV50.step === 2) stepField = 'deviceTitle'; if (mqFlowStateV50.step === 3) stepField = 'deviceModel'; } if (stepField) { var pair = mqV505FieldVisual(panel, stepField); if (pair && pair.visual) { mqV54RevealAndPosition(pair.visual, mqV54OpenToken); } } } }, 70); }); mqV54Observer.observe(document.body, { childList: true, subtree: true }); } catch (ignoreV54Observer) {} window.addEventListener('resize', function () { if (!mqFlowStateV50.open) return; mqV505RepairActive(); }, true); /* ============================================================ INITIAL ============================================================ */ bindTree(); var mqResumeView = ""; try { mqResumeView = window.sessionStorage.getItem("mediqResumeView") || ""; if (mqResumeView) { window.sessionStorage.removeItem("mediqResumeView"); } } catch (e) {} if (mqResumeView === "newAsset-purchased") { state.selectedAssetSection = "purchased"; renderAssetSections("newAsset"); var mqOpenAssetAfterReload = false; try { mqOpenAssetAfterReload = window.sessionStorage.getItem("mediqOpenAssetAfterReload") === "1"; if (mqOpenAssetAfterReload) window.sessionStorage.removeItem("mediqOpenAssetAfterReload"); } catch (ignoreOpen) {} if (mqOpenAssetAfterReload) { window.setTimeout(function () { openMediQAssetForm(); }, 500); } } else if (mqResumeView === "editAsset") { renderEditAssetWorkspace(); } else { renderEquipment(); } })();