{"version":3,"sources":["webpack:///./build-targets/portal/packages/core/functionality/patches/mdc-list.js","webpack:///./packages/core/functionality/keyEvents.js","webpack:///./build-targets/portal/packages/core/functionality/selectpicker.js","webpack:///./build-targets/portal/packages/core/functionality/materialMenus.js","webpack:///./packages/core/functionality/form.js","webpack:///./packages/core/functionality/childViews.js"],"names":["arrowNavigationPatch","list","arrowNavaigationPatched_","foundation","foundation_","focusPrevElement","_","wrap","index","prevIndex","wrapFocus_","adapter_","getListItemCount","listItemEl","listElements","classList","contains","cssClasses","LIST_ITEM_DISABLED_CLASS","call","focusNextElement","nextIndex","disabledListItemCheckboxPatch","disabledListItemCheckboxPatched_","prototype","initializeListType","this","setCheckedCheckboxOrRadioAtIndex","isChecked","toggleEl","querySelector","strings","CHECKBOX_RADIO_SELECTOR","checked","event","document","createEvent","initEvent","dispatchEvent","NAME","keysDown","subscribers","commandKeys","isKeyDown","key","isArray","_k","i","c","length","keys","indexOf","window","addEventListener","e","keyCode","which","push","defaultPrevented","execute","view","isFunction","apply","isString","console","warn","commandKey","metaKey","ctrlKey","isInput","$","target","is","each","subscriber","isShown","withinEl","el","keyEvents","events","k","global","requiresCommandKey","_key","allowInput","modifier","keyCount","includes","idx","splice","hasFunctionality","addInitializer","instance","opts","cid","on","icons","faCaretDown","icon","html","Props","refreshSelectpicker","$el","Plugins","Update","extendFunctionality","Register","selectpicker","name","multiple","updateMethod","options","styleBase","doneButtonText","style","container","liveSearch","isMobile","noneSelectedText","i18n","t","noneResultsText","template","caret","Destroy","selectPickerOptions","Initialize","purgeEls","querySelectorAll","getExcludedViews","Menu","constructor","anchorEl","dropdownToggle","parentElement","hoist","horizontal","destroyOnClose","onClosed","closed","bind","onOpen","opened","onAction","itemSelected","recalculatePosition","onClick","clicked","onTap","closest","ripple","MDCRipple","unbounded","onToggleClick","toggleClicked","onToggleTap","onToggleKeydown","toggleKeyedDown","menu","createMenu","_open","autoOpen","open","cleanUp","backdrop","body","removeChild","menuSurface_","isHoistedElement_","appendChild","root_","parentNode","destroy","_ignoreItemSelection","setTimeout","close","remove","onMenuClose","MDCMenu","list_","setVerticalOrientation","handleBodyTap_","evt","handleBodyClick","registerBodyTapListener_","deregisterBodyTapListener_","removeEventListener","listen","MDCMenuSurfaceFoundation","OPENED_EVENT","CLOSED_EVENT","reEnableTouchEventsTimeout","clearTimeout","off","defer","item","detail","onMenuItemSelect","MouseEvent","bubbles","cancelable","simulateClickBody","setFixedPosition","setAnchorCorner","Corner","BOTTOM_START","hoistMenuToBody","createElement","add","cancelItem","toggle","innerWidth","onMenuOpen","items","focus","menuSurface","dimensions_","getInnerDimensions","autoPosition_","preventDefault","stopPropagation","code","currentTarget","trigger","materialMenus","invoke","addMaterialMenu","show","els","map","blurred","cacheFormValues","_formValues","formChanged","formValues","cacheQueries","inputs","elName","id","type","checkForm","$submit","submitReady","enable","data","disable","failure","error","thing","model","isModel","collection","isCollection","submitting","rejectWith","arguments","removeClass","hide","fieldAdded","validator","$target","enabled","plugin","addField","revalidateFieldOnAdd","revalidateField","fieldMutating","_cacheFields","removeField","fieldMutated","fieldRemoved","fieldValidationFailure","fvf","fieldValidationSuccess","errorCache","submitted","element","attr","flushCachedFormValues","selector","formValidationFailure","set","getValidationErrors","input","dispatcher","eventStr","module","title","description","formValidationSuccess","values","$idx","all","slice","match","isNull","replace","isNumeric","prop","filter","val","topLevelName","join","isUndefined","reduce","memo","arrayToCsv","csvToArray","concat","checkedRadio","checkedBoxes","elIdx","validation","GetInstance","getInvalidFields","hideField","$form","plugins","$input","find","$formGroup","Invoke","nxIgnore","inputChanged","changeEvent","jQuery","Event","nxIgnores","hasClass","isValid","keydown","at","get","prepareForm","disableCache","renderForm","toggleClass","disabledCount","emptyCount","inputCount","not","$element","isAppend","value","restoreCachedFormValue","hasValue","trim","tooltip","$validationErrors","errorCacheView","setElement","render","isEmpty","whenShown","then","reset","state","inputName","has","setForm","v","setValue","setFormValidation","args","$submitButton","validate","showField","nxUnignore","submit","Deferred","confirmed","addClass","confirmMessage","submitArgs","cancelled","cancelEventStr","confirmedEventStr","confirmedMethod","cancelledMethod","once","extend","message","yesEvent","noEvent","confirmViewOpts","result","unescapeAttributeName","requiresChanges","success","__isModel__","__isCollection__","resolveWith","rest","hideOnSubmit","removeOnHide","resetOnSubmit","stopListening","removeOnSubmit","toggleField","bool","validateField","datepickerChanged","select2changed","__isForm__","isForm","change","setModel","resetOnShow","unsavedChanges","noProxy","isNew","validatorFields","CoreCollection","addSubView","FormErrorListView","fields","excluded","$field","isObject","framework","form","rendered","listenTo","dispatcherSubmitEvent","viewCollection","debounce","addChildViewListener","func","childViews","addChildViewListeners","getChildViewCollection","Error","removeChildViewListeners","addedChildViewModel","compartor","resetChildViews","removeChildView","childView","addChildView","append","newChildView","mainOptions","omit","__isView__","childCollection","isAppViewModel","__name__","_view","_viewQueue","isMyOriginalCollection","maxItems","childViewClass","viewClass","childViewProto","childId","childViewOptions","_childViewOptions","attributes","viewOptions","viewSpec","opt","childViewAttributes","draggable","undefined","href","_options","ex","log","childModelCount","appendTo","$childTargetEl","prependTo","previousChildView","after","lastAdded","noRender","renderedOnce","noShow","addChildViews","parentCollection","modelCids","pluck","models","breakItUp","totalLength","size","amount","delay","first","m","lazyLoad","initializeLazyLoad","start","lazyLoadIndex","forEach","partial","additionalOpts","childrenEl","forwardOnly","cleanUpChildViews","detachChildViews","detach","getChildViewByModel","hasOwnProperty","childViewCollection","lazyLoadedForward","reachedBeginning","reachedEnd","lazyLoadItems","totalItems","moveChildViewToIndex","oldIndex","newIndex","ignoreCollection","temp","end","ignoreEl","getIndex","silent","cv","from","to","prepareChildViews","_childViewFilterStr","$childSearchFilter","childViewTarget","childviewTarget","lazyloader","destroyMethod","initializeMethod","pluginObj","$pluginEl","initOpts","cb","LazyLoader","direction","removeAllChildViews","removeChildViewListener","empty","searchAndFilterChildren","str","attributeKey","minimumLength","hasResults","originalEvent","split","parseInt","toLowerCase","removeAttribute","shown","some","attrKey","getLabel","setAttribute","__isChildViews__","disableChildViews","isCh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AAGD,IAElD,GADAsY,EAAYT,EAAW1X,EAAKH,IACxBsY,EAAU7B,iBACb,OAAOC,EAAU4B,EAAYzV,CAE/B,GAKFA,EACEG,GAAG,gBAAiBH,EAASwZ,kBAC7BrZ,GAAG,iBAAkBH,EAAS8a,mBAC9B3a,GAAG,aAAcH,EAASuZ,mBAC1BpZ,GAAG,2BAA4BH,EAASiV,uBAMxC9U,GAAG,mBAAmB,KACtBH,EAASid,YAAY,IAErB9c,GAAG,UAAU,KACbzF,EAAE2N,OAAOrI,EAASgV,WAAY,UAAW,gBAAiBhV,EAAS,IAEnEG,GAAG,SAAS,KACZzF,EAAE2N,OAAOrI,EAASgV,WAAY,UAAW,eAAgBhV,EAAS,IAErE,GAAGrD,IAxEkDgC,C","file":"18.bundle.min.js?2.22.31.f488ddff.1688766848291","sourcesContent":["import {cssClasses, strings} from '@material/list/constants';\n\n/**\n * As of v2 they stopped checking disabled items\n * I can understand this from an accessibility standpoint, in a world where disabled items are visible\n * but in our theme we hide disabled list tiems from the user\n * @function\n * @param {MDCList} list Instance of mdc-list\n */\nexport const arrowNavigationPatch = (list) => {\n\t// Do not patch twice\n\tif (!list || list.arrowNavaigationPatched_) return;\n\n\tlist.arrowNavaigationPatched_ = true;\n\n\tconst foundation = list.foundation_;\n\n\tfoundation.focusPrevElement = _.wrap(\n\t\tfoundation.focusPrevElement,\n\t\t(focusPrevElement, index) => {\n\t\t\tlet prevIndex = index - 1;\n\t\t\tif (prevIndex < 0) {\n\t\t\t\t// Return early because first item is already focused.\n\t\t\t\tif (!foundation.wrapFocus_) return index;\n\t\t\t\tprevIndex = foundation.adapter_.getListItemCount() - 1;\n\t\t\t}\n\n\t\t\t// Skip disabled items\n\t\t\tconst listItemEl = list.listElements[prevIndex];\n\t\t\tif (\n\t\t\t\tlistItemEl &&\n\t\t\t\tlistItemEl.classList.contains(cssClasses.LIST_ITEM_DISABLED_CLASS)\n\t\t\t) {\n\t\t\t\treturn foundation.focusPrevElement(prevIndex);\n\t\t\t}\n\n\t\t\t// Carry on\n\t\t\treturn focusPrevElement.call(foundation, index);\n\t\t},\n\t);\n\n\tfoundation.focusNextElement = _.wrap(\n\t\tfoundation.focusNextElement,\n\t\t(focusNextElement, index) => {\n\t\t\tconst count = foundation.adapter_.getListItemCount();\n\t\t\tlet nextIndex = index + 1;\n\t\t\tif (nextIndex >= count) {\n\t\t\t\t// Return early because last item is already focused.\n\t\t\t\tif (!foundation.wrapFocus_) return index;\n\t\t\t\tnextIndex = 0;\n\t\t\t}\n\n\t\t\t// Skip disabled items\n\t\t\tconst listItemEl = list.listElements[nextIndex];\n\t\t\tif (\n\t\t\t\tlistItemEl &&\n\t\t\t\tlistItemEl.classList.contains(cssClasses.LIST_ITEM_DISABLED_CLASS)\n\t\t\t) {\n\t\t\t\treturn foundation.focusNextElement(nextIndex);\n\t\t\t}\n\n\t\t\t// Carry on\n\t\t\treturn focusNextElement.call(foundation, index);\n\t\t},\n\t);\n};\n\n/**\n * https://github.com/material-components/material-components-web/issues/4696\n * @function\n * @param {MDCList} list MDCList\n */\nexport const disabledListItemCheckboxPatch = (list) => {\n\t// Do not patch twice\n\tif (!list || list.disabledListItemCheckboxPatched_) return;\n\n\tlist.prototype.initializeListType = _.wrap(\n\t\tlist.prototype.initializeListType,\n\t\tfunction (initializeListType) {\n\t\t\tconst foundation = this.foundation_;\n\t\t\tconst adapter = foundation.adapter_;\n\n\t\t\tadapter.setCheckedCheckboxOrRadioAtIndex = (index, isChecked) => {\n\t\t\t\tconst listItem = this.listElements[index];\n\t\t\t\tconst toggleEl = listItem.querySelector(\n\t\t\t\t\tstrings.CHECKBOX_RADIO_SELECTOR,\n\t\t\t\t);\n\t\t\t\t// This is all this was overriden for\n\t\t\t\tif (!toggleEl) return;\n\n\t\t\t\ttoggleEl.checked = isChecked;\n\t\t\t\tconst event = document.createEvent('Event');\n\t\t\t\tevent.initEvent('change', true, true);\n\t\t\t\ttoggleEl.dispatchEvent(event);\n\t\t\t};\n\n\t\t\treturn initializeListType.call(this);\n\t\t},\n\t);\n};\n","/**\n * @module core/functionality/keyEvents\n */\n\nconst NAME = 'keyEvents';\n\nimport {keys} from '@netx/core-app/properties/keypress';\n\nlet keysDown = [];\nlet subscribers = {};\n\nconst commandKeys = [91, 93, 17];\n\n/**\n * @function\n * @param {array|number|string} key Key(s) to test\n * @return {boolean} Key(s) down\n */\nconst isKeyDown = key => {\n\tif (!_.isArray(key)) {\n\t\tkey = [key];\n\t}\n\n\tfor (let i = 0, c = key.length, _k; i < c; i++) {\n\t\t_k = keys[key[i]] || key[i];\n\t\tif (keysDown.indexOf(_k) < 0) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n};\n\nwindow.addEventListener('keydown', e => {\n\tlet keyCode = e.keyCode || e.which;\n\tkeysDown.indexOf(keyCode) < 0 && keysDown.push(keyCode);\n\n\tif (e.defaultPrevented) return true;\n\n\tconst execute = (event, view) => {\n\t\tkeysDown = [];\n\n\t\tif (_.isFunction(event)) {\n\t\t\tevent.apply(view, [e]);\n\t\t} else if (_.isString(event)) {\n\t\t\t_.isFunction(view[event])\n\t\t\t\t? view[event](e)\n\t\t\t\t: console.warn(`\"${event}\" method could not be found on view`);\n\t\t}\n\t};\n\n\tconst commandKey = e.metaKey || e.ctrlKey;\n\tconst isInput = $(e.target).is(':input');\n\n\t_.each(subscribers, subscriber => {\n\t\tconst view = subscriber.view;\n\t\tif (!view.isShown) return;\n\t\tconst withinEl = view.el.contains(e.target);\n\n\t\tconst keyEvents = subscriber.events;\n\n\t\t_.each(keyEvents, (event, k) => {\n\t\t\tif (!withinEl && !event.global) return;\n\n\t\t\tconst requiresCommandKey = event.commandKey || event.ctrlKey;\n\t\t\tif (requiresCommandKey && !commandKey) return;\n\n\t\t\tconst _key = keys[k] || k;\n\t\t\tif (isKeyDown(_key)) {\n\t\t\t\tif (!event.execute && !isInput) return execute(event, view);\n\n\t\t\t\tif (isInput && !event.allowInput) return;\n\n\t\t\t\tif (!event.modifier) {\n\t\t\t\t\tconst keyCount = keysDown.length;\n\t\t\t\t\tif (requiresCommandKey) {\n\t\t\t\t\t\tif (commandKey && keyCount === 2) {\n\t\t\t\t\t\t\texecute(event.execute, view);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (keyCount === 1) {\n\t\t\t\t\t\texecute(event.execute, view);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tisKeyDown(event.modifier) && execute(event.execute, view);\n\t\t\t}\n\t\t});\n\t});\n\treturn true;\n});\n\nwindow.addEventListener('keyup', e => {\n\tconst keyCode = e.keyCode || e.which;\n\n\tif (commandKeys.includes(keyCode)) {\n\t\tkeysDown = [];\n\t\twindow.keysDown = keysDown;\n\t\treturn;\n\t}\n\n\tconst idx = keysDown.indexOf(keyCode);\n\tidx > -1 && keysDown.splice(idx, 1);\n});\n\nexport default function(target) {\n\tif (!target || target.hasFunctionality(NAME)) return target;\n\n\ttarget.addInitializer((instance, opts = {}) => {\n\t\tif (opts.keyEvents) {\n\t\t\tsubscribers[instance.cid] = {\n\t\t\t\tview: instance,\n\t\t\t\tevents: opts.keyEvents,\n\t\t\t};\n\n\t\t\tinstance.on('removeHook', () => {\n\t\t\t\tdelete subscribers[instance.cid];\n\t\t\t});\n\t\t}\n\t}, NAME);\n\n\treturn target;\n}\n","const NAME = 'selectpicker';\n\nimport 'theme-libs/bootstrap-select';\nimport 'theme-libs/bootstrap-select-netx';\n\nimport {icon} from '@fortawesome/fontawesome-svg-core';\nimport {faCaretDown} from '@fortawesome/pro-solid-svg-icons';\nimport {purgeEls} from '@netx/core/lib/utils';\nimport {isMobile} from '@netx/core/lib/underscore-netx';\n\nconst icons = {\n\tfaCaretDown: icon(faCaretDown).html,\n};\n\nconst Props = {\n\t/** @method */\n\trefreshSelectpicker($el) {\n\t\tthis.Plugins.Update('selectpicker', $el);\n\t},\n};\n\nexport default function (target) {\n\tif (!target || target.hasFunctionality(NAME)) return target;\n\n\ttarget.extendFunctionality(Props);\n\n\ttarget.addInitializer((instance, opts = {}) => {\n\t\t// Selectpicker\n\t\tinstance.Plugins.Register({\n\t\t\tselectpicker: {\n\t\t\t\tname: 'selectpicker',\n\t\t\t\tmultiple: true,\n\t\t\t\tupdateMethod: 'refresh',\n\t\t\t\toptions: {\n\t\t\t\t\tstyleBase: 'mdc-button',\n\t\t\t\t\tdoneButtonText: instance.doneButtonText || 'done',\n\t\t\t\t\tstyle: '',\n\t\t\t\t\tcontainer: 'body',\n\t\t\t\t\tliveSearch: !isMobile(),\n\t\t\t\t\tnoneSelectedText: i18n.t('i18n.nothingSelected'),\n\t\t\t\t\t// This will be followed by \"search term\"\n\t\t\t\t\tnoneResultsText: i18n.t('i18n.noResultsMatchThing'),\n\t\t\t\t\ttemplate: {\n\t\t\t\t\t\tcaret: icons.faCaretDown,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\t// Hey, listen!\n\t\tinstance\n\t\t\t.on('preRenderHook', () => {\n\t\t\t\tinstance.Plugins.Destroy('selectpicker');\n\t\t\t})\n\t\t\t.on('postRenderHook', () => {\n\t\t\t\t// See if view wants to pass additional options at plugin init\n\t\t\t\tconst opts =\n\t\t\t\t\ttypeof instance.selectPickerOptions === 'function'\n\t\t\t\t\t\t? instance.selectPickerOptions()\n\t\t\t\t\t\t: instance.selectPickerOptions || {};\n\n\t\t\t\tinstance.Plugins.Initialize(\n\t\t\t\t\t'selectpicker',\n\t\t\t\t\tpurgeEls(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t...instance.el.querySelectorAll(\n\t\t\t\t\t\t\t\t'.selectpicker:not([data-autocomplete])',\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t],\n\t\t\t\t\t\tinstance.getExcludedViews(),\n\t\t\t\t\t),\n\t\t\t\t\topts,\n\t\t\t\t);\n\t\t\t});\n\t}, NAME);\n\n\treturn target;\n}\n","const NAME = 'materialMenus';\n\nimport {MDCMenu, Corner} from '@material/menu';\nimport {MDCMenuSurfaceFoundation} from '@material/menu-surface/foundation';\nimport {simulateClickBody} from '@netx/core/lib/utils';\n\nimport {MDCRipple} from '@material/ripple';\n\nimport {isMobile} from '@netx/core/lib/underscore-netx';\nimport {purgeEls} from '@netx/core/lib/utils';\n\nimport {arrowNavigationPatch} from './patches/mdc-list';\n\nclass Menu {\n\t/**\n\t * @method\n\t */\n\tconstructor(anchorEl, view, opts = {}) {\n\t\tthis.anchorEl = anchorEl;\n\t\tthis.view = view;\n\n\t\tconst el = (this.el = anchorEl.querySelector('.mdc-menu-surface'));\n\t\tconst dropdownToggle = (this.dropdownToggle = el.parentElement.querySelector(\n\t\t\t'.menu-button, .dropdown-toggle',\n\t\t));\n\n\t\tthis.hoist =\n\t\t\topts.hoist === true || el.classList.contains('mdc-menu--hoist');\n\t\tthis.horizontal =\n\t\t\topts.horizontal === true || el.classList.contains('mdc-menu--horizontal');\n\t\tthis.destroyOnClose = opts.destroyOnClose === true;\n\n\t\tel.addEventListener(\n\t\t\t'MDCMenuSurface:closed',\n\t\t\t(this.onClosed = this.closed.bind(this)),\n\t\t);\n\t\tel.addEventListener(\n\t\t\t'MDCMenuSurface:opened',\n\t\t\t(this.onOpen = this.opened.bind(this)),\n\t\t);\n\t\tel.addEventListener(\n\t\t\t'MDCList:action',\n\t\t\t(this.onAction = this.itemSelected.bind(this)),\n\t\t);\n\n\t\t// For our \"special\" menus that have dropdown in them\n\t\t// we need to not do this but until the facets refactor to the sidebar\n\t\t// we need this\n\t\t$(el)\n\t\t\t.on('shown.bs.dropdown', () => {\n\t\t\t\tthis.recalculatePosition();\n\t\t\t})\n\t\t\t.on('hidden.bs.dropdown', () => {\n\t\t\t\tthis.recalculatePosition();\n\t\t\t});\n\n\t\tel.addEventListener('click', (this.onClick = this.clicked.bind(this)));\n\t\tel.addEventListener('touchstart', (this.onTap = this.clicked.bind(this)));\n\t\tif (dropdownToggle) {\n\t\t\t// If in an mdc-list-item the ripple gets double applied\n\t\t\tif (!dropdownToggle.closest('.mdc-list-item__meta')) {\n\t\t\t\tthis.ripple = new MDCRipple(dropdownToggle);\n\t\t\t\tthis.ripple.unbounded = true;\n\t\t\t}\n\n\t\t\tdropdownToggle.addEventListener(\n\t\t\t\t'click',\n\t\t\t\t(this.onToggleClick = this.toggleClicked.bind(this)),\n\t\t\t);\n\t\t\tdropdownToggle.addEventListener(\n\t\t\t\t'touchstart',\n\t\t\t\t(this.onToggleTap = this.toggleClicked.bind(this)),\n\t\t\t);\n\t\t\tdropdownToggle.addEventListener(\n\t\t\t\t'keydown',\n\t\t\t\t(this.onToggleKeydown = this.toggleKeyedDown.bind(this)),\n\t\t\t);\n\t\t}\n\n\t\tif (!this.hoist) {\n\t\t\tthis.menu = this.createMenu(el); //new MDCMenu(el);\n\t\t}\n\n\t\tthis._open = false;\n\n\t\tif (\n\t\t\topts.autoOpen === true ||\n\t\t\tel.classList.contains('mdc-menu-surface--auto-open')\n\t\t) {\n\t\t\tthis.open();\n\t\t}\n\t}\n\n\t/** @method */\n\tcleanUp() {\n\t\tif (this.backdrop) {\n\t\t\tdocument.body.removeChild(this.backdrop);\n\t\t\tdelete this.backdrop;\n\t\t}\n\n\t\tconst menu = this.menu;\n\t\tif (!menu) return;\n\n\t\t// Put the element back - would be nice if the mdc-menu-surface did this\n\t\t// maybe they do and i missed it (like a config or whatever)\n\t\tif (this.hoist && menu.menuSurface_.foundation_.isHoistedElement_) {\n\t\t\tthis.anchorEl.appendChild(menu.root_.parentNode.removeChild(menu.root_));\n\t\t}\n\n\t\tmenu.destroy();\n\t\tdelete this.menu;\n\t}\n\n\t/**\n\t * @method\n\t * @param {event} e `click` event\n\t */\n\tclicked(e) {\n\t\t// When we click on an action our event listeners in core fire\n\t\t// but mdc list items (which live in mdc menus) can be triggered\n\t\t// by `space`, `enter` and `click`\n\t\t// So, when a click occurs we do not want to fire the action off in\n\t\t// here as to not have it fire twice\n\t\t// When we rework our actions we should keep this in mind\n\t\tif (e.target.classList.contains('nx-action')) {\n\t\t\tthis._ignoreItemSelection = true;\n\t\t\tsetTimeout(() => {\n\t\t\t\tthis._ignoreItemSelection = false;\n\t\t\t}, 20);\n\t\t}\n\t}\n\n\t/** @method */\n\tclose() {\n\t\tconst menu = this.menu;\n\t\tif (!menu || !menu.open) return;\n\n\t\tmenu.open = false;\n\t}\n\n\t/** @method */\n\tclosed() {\n\t\tif (!this._open) return;\n\t\tthis._open = false;\n\t\tthis.anchorEl.classList.remove('open');\n\n\t\tif (this.view.onMenuClose) {\n\t\t\tthis.view.onMenuClose(this.menu);\n\t\t}\n\n\t\tif (this.destroyOnClose) {\n\t\t\tthis.destroy();\n\t\t} else if (this.hoist) {\n\t\t\tthis.cleanUp();\n\t\t}\n\t}\n\n\t/** @method */\n\tcreateMenu() {\n\t\tconst menu = (this.menu = new MDCMenu(this.el));\n\t\tarrowNavigationPatch(menu.list_);\n\n\t\t// DAM-15440 - if the menu is open when the view re-renders,\n\t\t// the menu will not reopen, because this.menu.open remains falsely true\n\t\tmenu.open = false;\n\n\t\tif (this.horizontal) {\n\t\t\tmenu.list_.foundation_.setVerticalOrientation(false);\n\t\t}\n\n\t\t// Need to look into mdc's pull request\n\t\t// HACK\n\t\t// Support mobile \"tap\"\n\t\tmenu.menuSurface_.handleBodyTap_ = (evt) => {\n\t\t\treturn menu.menuSurface_.foundation_.handleBodyClick(evt);\n\t\t};\n\t\tmenu.menuSurface_.registerBodyTapListener_ = () => {\n\t\t\treturn document.body.addEventListener(\n\t\t\t\t'touchstart',\n\t\t\t\tmenu.menuSurface_.handleBodyTap_,\n\t\t\t);\n\t\t};\n\t\tmenu.menuSurface_.deregisterBodyTapListener_ = function () {\n\t\t\treturn document.body.removeEventListener(\n\t\t\t\t'touchstart',\n\t\t\t\tmenu.menuSurface_.handleBodyTap_,\n\t\t\t);\n\t\t};\n\t\tmenu.menuSurface_.listen(\n\t\t\tMDCMenuSurfaceFoundation.strings.OPENED_EVENT,\n\t\t\tmenu.menuSurface_.registerBodyTapListener_,\n\t\t);\n\t\tmenu.menuSurface_.listen(\n\t\t\tMDCMenuSurfaceFoundation.strings.CLOSED_EVENT,\n\t\t\tmenu.menuSurface_.deregisterBodyTapListener_,\n\t\t);\n\n\t\t// menu-surface/foundation is not checking if the menu is even open. So, it will\n\t\t// will add the `mdc-menu-surface--open` modifier class and immediately remove it\n\t\t// (as the menu animation does not need to occur), which makes the menu toggle light up\n\t\t// We use thae `mdc-menu-surface--open` to display that a menu toggle is active\n\t\tmenu.menuSurface_.foundation_.close = _.wrap(\n\t\t\tmenu.menuSurface_.foundation_.close,\n\t\t\t(close) => {\n\t\t\t\tif (!menu.open) return;\n\n\t\t\t\t// On mobile we wind up clicking on any element that is behind the menu\n\t\t\t\t// in that click position - do not allow any interactive clicks for 300ms\n\t\t\t\tthis.reEnableTouchEventsTimeout &&\n\t\t\t\t\tclearTimeout(this.reEnableTouchEventsTimeout);\n\t\t\t\tdocument.body.style['pointer-events'] = 'none';\n\n\t\t\t\tthis.reEnableTouchEventsTimeout = setTimeout(() => {\n\t\t\t\t\tdocument.body.style['pointer-events'] = '';\n\t\t\t\t}, 300);\n\n\t\t\t\tclose.call(menu.menuSurface_.foundation_);\n\t\t\t},\n\t\t);\n\n\t\treturn menu;\n\t}\n\n\t/** @method */\n\tdestroy() {\n\t\tif (this.dropdownToggle) {\n\t\t\tthis.dropdownToggle.removeEventListener('click', this.onToggleClick);\n\t\t\tthis.dropdownToggle.removeEventListener('touchstart', this.onToggleTap);\n\t\t\tdelete this.dropdownToggle;\n\t\t}\n\n\t\tthis.cleanUp();\n\t\tdelete this.menu;\n\n\t\tthis.ripple && this.ripple.destroy();\n\n\t\tconst el = this.el;\n\t\tel.removeEventListener('click', this.onClick);\n\t\tel.removeEventListener('touchstart', this.onTap);\n\t\tel.removeEventListener('MDCList:action', this.onAction);\n\t\tel.removeEventListener('MDCMenuSurface:closed', this.onClosed);\n\t\tel.removeEventListener('MDCMenuSurface:opened', this.onOpen);\n\t\t$(el).off('.bs.dropdown');\n\n\t\tdelete this.anchorEl;\n\t\tdelete this.el;\n\t\tdelete this.view;\n\t}\n\n\t/**\n\t * @method\n\t * @param {event} e `MDCList:action` event\n\t */\n\titemSelected(e) {\n\t\t// Defer because our `click` event comes immediately after `MDCList:action`\n\t\t// we want to know if it was via a `click` or other (`space`, `enter`)\n\t\t_.defer(() => {\n\t\t\tif (!this._ignoreItemSelection) {\n\t\t\t\tconst item = this.menu.list_.listElements[e.detail.index];\n\t\t\t\tif (!item || !item.classList.contains('nx-action')) {\n\t\t\t\t\tif (this.view.onMenuItemSelect) {\n\t\t\t\t\t\tthis.view.onMenuItemSelect(item, this.menu);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Pass along to our action event handler\n\t\t\t\tconst evt = new MouseEvent('click', {\n\t\t\t\t\tbubbles: false,\n\t\t\t\t\tcancelable: true,\n\t\t\t\t\tview: window,\n\t\t\t\t});\n\t\t\t\titem.dispatchEvent(evt);\n\t\t\t}\n\t\t});\n\t}\n\n\t/** @method */\n\topen() {\n\t\tconst el = this.el;\n\t\tlet menu = this.menu;\n\n\t\tsimulateClickBody();\n\n\t\tif (menu && menu.open) return;\n\n\t\tif (this.hoist) {\n\t\t\tmenu = this.createMenu();\n\t\t\tmenu.setFixedPosition(true);\n\t\t\tmenu.setAnchorCorner(Corner.BOTTOM_START);\n\t\t\tmenu.hoistMenuToBody();\n\n\t\t\tconst backdrop = (this.backdrop = document.createElement('div'));\n\t\t\tbackdrop.classList.add('mdc-menu-backdrop');\n\t\t\tdocument.body.appendChild(backdrop);\n\n\t\t\tconst cancelItem = el.querySelector('.mdc-list-item.cancel');\n\t\t\tcancelItem &&\n\t\t\t\tcancelItem.classList.toggle(\n\t\t\t\t\t'mdc-list-item--disabled',\n\t\t\t\t\twindow.innerWidth >= 767,\n\t\t\t\t);\n\t\t}\n\n\t\tif (!menu || menu.open) return;\n\n\t\tthis.reEnableTouchEventsTimeout &&\n\t\t\tclearTimeout(this.reEnableTouchEventsTimeout);\n\t\tmenu.root_.style['pointer-events'] = 'none';\n\n\t\tmenu.open = true;\n\t}\n\n\t/** @method */\n\topened() {\n\t\tif (this._open) return;\n\n\t\tconst menu = this.menu;\n\n\t\tthis._open = true;\n\t\tthis.anchorEl.classList.add('open');\n\n\t\tif (this.view.onMenuOpen) {\n\t\t\tthis.view.onMenuOpen(menu);\n\t\t}\n\n\t\t// keyboard accessibility\n\t\tmenu.items.length && menu.items[0].focus();\n\n\t\tthis.reEnableTouchEventsTimeout &&\n\t\t\tclearTimeout(this.reEnableTouchEventsTimeout);\n\t\tthis.reEnableTouchEventsTimeout = setTimeout(() => {\n\t\t\tmenu.root_.style['pointer-events'] = '';\n\t\t}, 300);\n\t}\n\n\t/** @method */\n\trecalculatePosition() {\n\t\tif (!this.menu || !this._open) return;\n\t\tconst menuSurface = this.menu.menuSurface_.foundation_;\n\t\tmenuSurface.dimensions_ = menuSurface.adapter_.getInnerDimensions();\n\t\tmenuSurface.autoPosition_();\n\t}\n\n\t/** @method */\n\ttoggle() {\n\t\tconst menu = this.menu;\n\t\t!menu || !menu.open ? this.open() : this.close();\n\t}\n\n\t/**\n\t * @method\n\t * @param {event} e `click` event\n\t */\n\ttoggleClicked(e) {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\n\t\tthis.open();\n\t}\n\t/**\n\t * @method\n\t * @param {event} e `keydown` event\n\t * open menus with enter/space\n\t *\n\t * todo: remove with react\n\t */\n\ttoggleKeyedDown(e) {\n\t\tconst code = e.which;\n\t\t// space or enter\n\t\tif (code === 13 || code === 32) {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\n\t\t\tif (e.currentTarget.classList.contains('menu-button')) {\n\t\t\t\t$(e.currentTarget).trigger('click.data-action-context');\n\t\t\t} else {\n\t\t\t\tthis.toggle();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport default function (target) {\n\tif (!target || target.hasFunctionality(NAME)) return target;\n\n\ttarget.addInitializer((instance, opts = {}) => {\n\t\tlet materialMenus = [];\n\n\t\tconst cleanUp = () => {\n\t\t\t_.invoke(materialMenus, 'destroy');\n\t\t\tmaterialMenus = [];\n\t\t};\n\n\t\tinstance.addMaterialMenu = (el, show) => {\n\t\t\tconst menu = new Menu(el, instance);\n\t\t\tmaterialMenus.push(menu);\n\t\t\tshow && menu.open();\n\t\t};\n\n\t\t// Hey, listen!\n\t\tinstance\n\t\t\t.on('preRenderHook', cleanUp)\n\t\t\t.on('removeHook', cleanUp)\n\t\t\t.on('renderedHook', () => {\n\t\t\t\tconst el = instance.el;\n\t\t\t\tconst els = el.classList.contains('mdc-menu-surface--anchor')\n\t\t\t\t\t? [el]\n\t\t\t\t\t: purgeEls(\n\t\t\t\t\t\t\t[...instance.el.querySelectorAll('.mdc-menu-surface--anchor')],\n\t\t\t\t\t\t\tinstance.getExcludedViews(),\n\t\t\t\t\t );\n\t\t\t\tmaterialMenus = els.map((anchorEl) => {\n\t\t\t\t\treturn new Menu(anchorEl, instance, opts.materialMenus);\n\t\t\t\t});\n\t\t\t});\n\t}, NAME);\n\n\treturn target;\n}\n","/**\n * @module core/functionality/form\n */\n\nconst NAME = 'form';\n\nimport CoreCollection from '../lib/netx-collection';\nimport FormErrorListView from '@netx/core-app/views/formErrorListView';\n\nimport {unescapeAttributeName} from '@netx/core/lib/underscore-netx';\n\nimport 'core-libs/formValidation-netx';\n\nexport const Props = {\n\t/**\n\t * Do anything you want when a field loses focus\n\t * @method\n\t * @param {event} e jQuery event\n\t */\n\tblurred(e) {\n\t\t//\n\t},\n\n\t/**\n\t * To support arbitrary re-rendering of the form at any time,\n\t * we cache all form values in _.formValues during preRender\n\t * and restore them (one by one) in postRender.\n\t * @see restoreCachedFormValue\n\t * @see flushCachedFormValues\n\t * @method\n\t */\n\tcacheFormValues() {\n\t\t//this._formValues = this.formChanged ? this.formValues() : {};\n\t\t// TODO: this sometimes fails, because subclasses override .formValues() in all sorts\n\t\t// of different ways. I had a note in here to not do that ... but it's been pretty useful.\n\t\t//\n\t\t// I think the solution is to call the non-overriden method, Netx.Views.FormView.protytpe.formValues(),\n\t\t// for just this specific case:\n\t\tthis._formValues = this.formChanged ? this.formValues() : {};\n\t},\n\n\t/**\n\t * You may want to override this.cacheQueries(), to cache more queries.\n\t * By default it caches jQuery queries, by name, for all form inputs. They are stored in the object this.inputs.\n\t * Example: if the template contains a form field named \"address\", it will be cached in this.inputs.$address .\n\t * (The leading $ is a naming convention to indicate a jQuery query.)\n\t * @method\n\t */\n\tcacheQueries() {\n\t\tthis.inputs = {};\n\n\t\t_.each(this.$(':input'), el => {\n\t\t\t// if element doesn't have a name, use id; if not that, fuggedaboutit.\n\t\t\tconst elName = el.name ? el.name : el.id;\n\n\t\t\tif (el.type == 'radio' || el.type == 'checkbox') {\n\t\t\t\t// Radios always come in groups, checkboxes sometimes do too.\n\t\t\t\t// If we haven't cached the complete group yet,\n\t\t\t\tif (!this.inputs[`$${elName}`]) {\n\t\t\t\t\t// cache it now.\n\t\t\t\t\tthis.inputs[`$${elName}`] = this.$(`:input[name=\"${elName}\"]`);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// or if the element is unnamed, discard it.\n\t\t\tif (elName) {\n\t\t\t\tthis.inputs[`$${elName}`] = this.$(el);\n\t\t\t}\n\t\t});\n\t},\n\n\t/**\n\t * this.checkForm() is called at render, and on every form change.\n\t * If your form needs to manipulate itself based on changes, override this method to do that.\n\t * By default, it enables or disables the submit button based on the return value of this.submitReady();\n\t * @method\n\t * @param {event} e jQueryEvent (optional)\n\t */\n\tcheckForm(e) {\n\t\t// if this form hasn't ever rendered, there's nothing we can do here.\n\t\tif (!this.$submit || !this.$submit.length) return;\n\n\t\tif (this.submitReady()) {\n\t\t\tthis.$submit.enable();\n\t\t\tif (this.$submit.data('enabled-label')) {\n\t\t\t\tthis.$submit.html(this.$submit.data('enabled-label'));\n\t\t\t}\n\t\t} else {\n\t\t\tthis.$submit.disable();\n\t\t\tif (this.$submit.data('disabled-label')) {\n\t\t\t\tthis.$submit.html(this.$submit.data('disabled-label'));\n\t\t\t}\n\t\t}\n\t},\n\n\t// /**\n\t// * this.clearForm() clears out all values in the form.\n\t// * http://stackoverflow.com/questions/680241/resetting-a-multi-stage-form-with-jquery\n\t// * @method\n\t// * @deprecated\n\t// * @todo This is all handled in our reset wrapper above.\n\t// */\n\t// clearForm() {\n\t// \tconsole.warn('formView.clearForm deprecated, gone in 8.13');\n\t// \tthis.$el.find('input:text, input:password, input:file, select, textarea').val('');\n\t// \tthis.$el.find('input:radio, input:checkbox').removeAttr('checked').removeAttr('selected');\n\t// \t// TODO: reset changes?\n\t// }\n\n\t/**\n\t * Is called when this.eventStr + \":error\" is triggered\n\t * @method\n\t * @param {string} error Error string\n\t */\n\tfailure(error, thing) {\n\t\t// Check that the failure was for us (comes from :error)\n\t\t// Our pattern has been to have the model/collection as the second argument passed back from the success event\n\t\tif (thing) {\n\t\t\tif (this.model && thing.isModel) {\n\t\t\t\tif (thing !== this.model) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else if (this.collection && thing.isCollection) {\n\t\t\t\tif (thing !== this.collection) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.submitting) {\n\t\t\tthis.submitting.rejectWith(this, arguments);\n\t\t\tdelete this.submitting;\n\t\t}\n\t\tthis.$el.removeClass('form-submitting');\n\t\tthis.$('.form-submitting').hide();\n\t},\n\n\t/**\n\t * A new input field was added\n\t * @method\n\t * @param e Field added event (nx)\n\t */\n\tfieldAdded(e) {\n\t\tconst validator = this.validator;\n\t\tconst $target = $(e.target);\n\t\tif (validator.enabled && validator.plugin) {\n\t\t\tvalidator.plugin.addField($target);\n\t\t\tif (this.revalidateFieldOnAdd) {\n\t\t\t\tvalidator.plugin.revalidateField($target);\n\t\t\t}\n\t\t}\n\t\t// Add reference to the cached queries\n\t\tif (this.inputs) {\n\t\t\tthis.inputs['$' + e.target.name] = $target;\n\t\t}\n\t},\n\n\t/**\n\t * An input field is being modifed, assume it will be non recoverable and remove from\n\t * the validation instance (will be added back in `this.fieldMutated` if the proper event is fired by the view in charge)\n\t * @method\n\t * @param e Field changing event (nx)\n\t */\n\tfieldMutating(e) {\n\t\tconst validator = this.validator;\n\n\t\tvalidator.enabled &&\n\t\t\tvalidator.plugin &&\n\t\t\tvalidator.plugin._cacheFields[e.target.name] &&\n\t\t\tvalidator.plugin.removeField($(e.target));\n\t},\n\n\t/**\n\t * Should be fired right after the input field has been mutated (see `this.fieldMutating`)\n\t * @method\n\t * @param e Field changed event (nx)\n\t */\n\tfieldMutated(e) {\n\t\tconst validator = this.validator;\n\t\tconst $target = $(e.target);\n\t\tif (validator.enabled && validator.plugin) {\n\t\t\tvalidator.plugin.addField($target).revalidateField($target);\n\t\t}\n\t\t// Add reference back to the cached queries\n\t\tif (this.inputs) {\n\t\t\tthis.inputs['$' + e.target.name] = $target;\n\t\t}\n\t},\n\n\t/**\n\t * Should be fired right before the filed is removed from the DOM\n\t * Important that the input is still in the DOM so we can properyly remove validation\n\t * @method\n\t * @param e Field removed event (nx)\n\t */\n\tfieldRemoved(e) {\n\t\tconst validator = this.validator;\n\n\t\tvalidator.enabled &&\n\t\t\tvalidator.plugin &&\n\t\t\tvalidator.plugin._cacheFields[e.target.name] &&\n\t\t\tvalidator.plugin.removeField($(e.target));\n\n\t\t// Remove cached query\n\t\tif (this.inputs) {\n\t\t\tdelete this.inputs['$' + e.target.name];\n\t\t}\n\t},\n\n\t/**\n\t * A field has been deemed invalid\n\t * @method\n\t * @param {event} e jQuery event\n\t * @param {object} fvf formValidation field object\n\t */\n\tfieldValidationFailure(e, fvf) {\n\t\t//console.log( \"field validation error\", e, fvf );\n\t\t// TODO: Revisit if you notice anything weird with tooltips on form errors. Does not seem to be needed anymore.\n\t\t// if(e.target.attributes.getNamedItem('data-fv-container') === null) {\n\t\t// \tvar $parent = data.element.parents('.form-group'),\n\t\t// \t\t$icon\t= $parent.find('.form-control-feedback[data-fv-icon-for=\"' + data.field + '\"]'),\n\t\t// \t\ttitle\t= $icon.data('bs.tooltip').getTitle();\n\t\t// \t// Destroy the old tooltip and create a new one positioned to the right\n\t\t// \t$icon.tooltip('destroy').tooltip({\n\t\t// \t\thtml: true,\n\t\t// \t\tplacement: 'right',\n\t\t// \t\ttitle: title\n\t\t// \t} );\n\t\t// }\n\t},\n\n\t/**\n\t * A field has been deemed valid\n\t * @method\n\t * @param {event} e jQuery event\n\t * @param {object} fvf formValidation field object\n\t */\n\tfieldValidationSuccess(e, fvf) {\n\t\t// console.log( \"field validation success\", e, fvf );\n\t\t// If we have submitted before then we obviously had some errors\n\t\tif (this.errorCache.length && this.submitted) {\n\t\t\tthis.errorCache.remove(fvf.element.attr('name'));\n\t\t}\n\t},\n\n\t/**\n\t * Clear all form values we may have cached during a render\n\t * @method\n\t * @see cacheFormValues\n\t * @see restoreCachedFormValue\n\t */\n\tflushCachedFormValues() {\n\t\tdelete this._formValues;\n\t},\n\n\t/**\n\t * this.focus() is called when the form is shown or rendered; override it to set form focus how you like it.\n\t * The default does this: http://stackoverflow.com/questions/267615/focusing-first-control-in-the-form-using-jquery\n\t * @method\n\t * @param {string} selector jQuery selector string\n\t */\n\tfocus(selector) {\n\t\tif (selector == null) {\n\t\t\tthis.$('form:not(.filter) :input:visible:enabled:first').focus();\n\t\t} else {\n\t\t\tthis.$(selector).focus();\n\t\t}\n\t},\n\n\t/**\n\t * The form was submitted but was invalid\n\t * @method\n\t * @param {event} e jQuery event\n\t * @fires (this.eventStr):validation:failure\n\t * @fires module:notification#notification\n\t */\n\tformValidationFailure(e) {\n\t\t// Set errors\n\t\tthis.errorCache.set(\n\t\t\t_.map(this.getValidationErrors(), input => {\n\t\t\t\treturn {\n\t\t\t\t\tid: input.name,\n\t\t\t\t\tname: input.name,\n\t\t\t\t\tinput: $(input),\n\t\t\t\t};\n\t\t\t}),\n\t\t);\n\n\t\tdispatcher.trigger(`${this.eventStr}:validation:failure`, this);\n\t\tthis.submitted = true;\n\t\t// We will need to rethink this as you cannot read the whole message in that little notification box.\n\t\tdispatcher.trigger('notification', {\n\t\t\tmodule: 'app',\n\t\t\ttitle: i18n.t('i18n.error'),\n\t\t\tdescription: i18n.t('i18n.invalidForm'),\n\t\t\ttype: 'danger',\n\t\t});\n\t},\n\n\t/**\n\t * Form was successfully validated\n\t * @method\n\t * @param {event} e jQuery event\n\t */\n\tformValidationSuccess(e) {\n\t\t// forward the event\n\t\tdispatcher.trigger(`${this.eventStr}:validation:success`, this);\n\t},\n\n\t/**\n\t * this.formValues() gathers the names and values of all the form inputs into one simple JS object for submission to a submit event handler.\n\t * This should not need to be overridden -- if it's not working, let's fix it.\n\t * @method\n\t * @return {object} Object containing input form values\n\t */\n\tformValues() {\n\t\t// HACK: the initial query caching can fail for the assetAttributes view, because its fields\n\t\t// all have templates that are still loading. We solved that for childViews ... so attrs should\n\t\t// just be converted to childViews. For now, make sure we get everything by caching once more.\n\t\t//\n\t\t// TODO: this shouldn't be necessary now that templates are preloaded. Remove this?\n\t\t// No, so much depends on this behavior apparently - that is how unknown (new) inputs magically found their way in to this.inputs.\n\t\tthis.cacheQueries();\n\n\t\tconst values = {};\n\t\t_.each(this.inputs, (i, $idx, all) => {\n\t\t\t// TODO: there's some oddness here:\n\t\t\t// At this point, i is a jquery selector,\n\t\t\t// but we're also using $(i) below -- which works, but is not necessary.\n\t\t\t// Also: use .is() to determine attr type & state, instead of all that .attr/.prop stuff.\n\t\t\t// In general this method needs cleanup & better doc, but it's working, so ...\n\n\t\t\t// '$foo' -> 'foo'\n\t\t\tlet idx = $idx.slice(1);\n\n\t\t\t// Skip any auto-generated form elements created by select2 -- they don't contain our data.\n\t\t\t// TODO: do this in cacheQueries() instead. (Never even cache these.)\n\t\t\tif (idx.match(/s2id_autogen\\d/)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If we have multiple inputs with array styled names (like attribute[0], attribute[1]);\n\t\t\tlet match = idx.match(/\\[(.*?)\\]/g);\n\n\t\t\tif (!_.isNull(match)) {\n\t\t\t\tif (match.length === 1) {\n\t\t\t\t\tidx = idx.replace(/\\[(.*?)\\]/, '');\n\t\t\t\t\tif (!values[idx]) {\n\t\t\t\t\t\tvalues[idx] = _.isNumeric(idx) ? [] : {};\n\t\t\t\t\t}\n\t\t\t\t\t// eslint-disable-next-line no-useless-escape\n\t\t\t\t\tvalues[idx][match[0].replace(/[\\[\\]']+/g, '')] =\n\t\t\t\t\t\ti.attr('type') == 'checkbox'\n\t\t\t\t\t\t\t? i.prop('checked')\n\t\t\t\t\t\t\t: i.attr('type') == 'radio'\n\t\t\t\t\t\t\t? i.filter(':checked').val()\n\t\t\t\t\t\t\t: i.val();\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\t// (like attribute[thing1][thing], attribute[thing2][thing])\n\t\t\t\t\tconst topLevelName = idx.replace(match.join(''), '');\n\t\t\t\t\tif (_.isUndefined(values[topLevelName])) {\n\t\t\t\t\t\tvalues[topLevelName] = {};\n\t\t\t\t\t}\n\t\t\t\t\t_.reduce(\n\t\t\t\t\t\tmatch,\n\t\t\t\t\t\t(memo, name, index, all) => {\n\t\t\t\t\t\t\t// eslint-disable-next-line no-useless-escape\n\t\t\t\t\t\t\tname = name.replace(/[\\[\\]']+/g, '');\n\t\t\t\t\t\t\tif (_.isUndefined(memo[name])) {\n\t\t\t\t\t\t\t\tmemo[name] =\n\t\t\t\t\t\t\t\t\tindex + 1 < all.length\n\t\t\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t\t\t: i.attr('type') == 'checkbox'\n\t\t\t\t\t\t\t\t\t\t? i.prop('checked')\n\t\t\t\t\t\t\t\t\t\t: i.attr('type') == 'radio'\n\t\t\t\t\t\t\t\t\t\t? i.filter(':checked').val()\n\t\t\t\t\t\t\t\t\t\t: i.val();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn memo[name];\n\t\t\t\t\t\t},\n\t\t\t\t\t\tvalues[topLevelName],\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If we have broken a multiselect into individual checkboxes, save only the box that's checked.\n\t\t\tmatch = idx.match(/-checkbox(\\d+)$/);\n\t\t\t// DEVNOTE: to match normal multiselect behavior, we need 'null' instead of empty array for no selection.\n\t\t\tif (!_.isNull(match)) {\n\t\t\t\tif (!values[match[1]]) {\n\t\t\t\t\tvalues[match[1]] = '';\n\t\t\t\t}\n\t\t\t\tif ($(i).prop('checked')) {\n\t\t\t\t\t// convert the csv to an array, append to it, then convert back\n\t\t\t\t\tvalues[match[1]] = _.arrayToCsv(\n\t\t\t\t\t\t_.csvToArray(values[match[1]]).concat($(i).val()),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// for multiselects, encode the array value as CSV.\n\t\t\tif (i.prop('multiple')) {\n\t\t\t\tvalues[idx] = _.arrayToCsv(i.val());\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If this is a radio button, find the radio button by this name that's actually checked\n\t\t\tif ($(i).attr('type') == 'radio') {\n\t\t\t\tconst checkedRadio = this.$(':input[name=\"' + i[0].name + '\"]:checked');\n\t\t\t\tif (checkedRadio.length) {\n\t\t\t\t\ti = checkedRadio;\n\t\t\t\t} else {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If this is a checkbox group, amalgamate the checked values.\n\t\t\tif (i.is(':checkbox') && i.length > 1) {\n\t\t\t\tconst checkedBoxes = this.$(':input[name=\"' + i[0].name + '\"]:checked');\n\t\t\t\t// convert to array of values:\n\t\t\t\tvalues[idx] = checkedBoxes.map(function(elIdx, el) {\n\t\t\t\t\treturn $(el).val();\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvalues[idx] = i.attr('type') == 'checkbox' ? i.prop('checked') : i.val();\n\t\t});\n\n\t\treturn values;\n\t},\n\n\t/**\n\t * Gets a jQuery array of invalid fields\n\t * @method\n\t * @return {array} Invalid fields\n\t */\n\tgetValidationErrors() {\n\t\tconst validation = this.Plugins.GetInstance('validation');\n\t\tif (validation) {\n\t\t\treturn validation.getInvalidFields();\n\t\t}\n\t\treturn [];\n\t},\n\n\t/**\n\t * Ok, there are some issues with trying to be agnostic and having input/select ui plugins that hide the original element\n\t * you still want that hidden element to be validated but it is almost impossible to know (without modifying code each time you add a plugin)\n\t * if the element was hidden intentionally (like we do in attribute forms) and when an element was hidden to manipulate the ui only.\n\t * Solution: rather than calling hide/show/toggle directly on the elements in the view- pass the elements through here.\n\t * It also handles bulk hiding (the validator will look at parents for the data-nx-ignore=\"validation\" attribute as well)\n\t * If validation is not turned on for whatever reason the element passed will be sent to where it would have gone\n\t * @param {element} input The jQuery element to hide\n\t */\n\thideField(...input) {\n\t\tconst inputs = [...input];\n\t\tconst $form = this.$form;\n\t\tconst plugins = this.Plugins;\n\t\tconst validation = this.validator.enabled;\n\n\t\t_.each(inputs, input => {\n\t\t\tlet $input = $(input);\n\t\t\tif (!$input.is(':input')) {\n\t\t\t\t$input = $input.find(':input');\n\t\t\t}\n\n\t\t\tlet $formGroup = $input.closest('.form-group');\n\t\t\tif (!$formGroup.length) {\n\t\t\t\t$formGroup = $input;\n\t\t\t}\n\n\t\t\tif (validation) {\n\t\t\t\t_.each($input, el => {\n\t\t\t\t\tel.name &&\n\t\t\t\t\t\tplugins.Invoke('validation', $form, 'updateStatus', [\n\t\t\t\t\t\t\tel.name,\n\t\t\t\t\t\t\t'VALID',\n\t\t\t\t\t\t]);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t$input.nxIgnore('validation');\n\t\t\t$formGroup.hide();\n\t\t});\n\t},\n\n\t/**\n\t * Tell FormView that a form changed happened.\n\t * It sets the formChanged flag, and calls checkForm() to potentially enable the submit button.\n\t * Form input change events are forwarded here (see events{} block).\n\t * Various other form tricks (like adding/removing inputs from the form) may also need to trigger this.\n\t * @method\n\t * @param {event} e Change event (optional)\n\t */\n\tinputChanged(e) {\n\t\tlet $target, changeEvent;\n\t\tif (e instanceof jQuery.Event) {\n\t\t\tchangeEvent = e;\n\t\t\t$target = this.$(changeEvent.target);\n\t\t\tif (\n\t\t\t\t$target.nxIgnores('change') ||\n\t\t\t\t$target.hasClass('select2-search__field')\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tthis.formChanged = true;\n\t\tthis.trigger('formChanged', $target);\n\t\tthis.checkForm(changeEvent);\n\t},\n\n\t/**\n\t * @method\n\t * @return {boolean}\n\t */\n\tisValid() {\n\t\treturn this.submitReady();\n\t},\n\n\t/**\n\t * this.keydown() checks if there are more erros and focus the input with the next error\n\t * @method\n\t * @param {event} e jQuery event\n\t */\n\tkeydown(e) {\n\t\tconst keyCode = e.keyCode || e.which;\n\t\t// Only care if it was an enter key\n\t\tif (keyCode === 13 && this.errorCache.length) {\n\t\t\tthis.errorCache\n\t\t\t\t.at(0)\n\t\t\t\t.get('input')\n\t\t\t\t.focus();\n\t\t}\n\t},\n\n\t/** @override */\n\tprepareForm() {\n\t\t// Cleanup\n\t\tthis.$form && this.$form.off();\n\t\tthis.validator.enabled = false;\n\t\tthis.Plugins.Destroy('validation');\n\n\t\tif (this.disableCache) {\n\t\t\t// Fresh start\n\t\t\tthis.formChanged = false;\n\t\t\tthis._formValues = {};\n\t\t} else {\n\t\t\tthis.cacheFormValues();\n\t\t}\n\t},\n\n\t/**\n\t * Do not override postRender() without calling the superclass imlementation (this._super ) explicity!\n\t * Sets up submit target and calls {@link #cacheQueries} and {@link #checkForm}.\n\t * @method\n\t */\n\trenderForm() {\n\t\t// Cache\n\t\tthis.$form = this.$('form:first');\n\t\tthis.$submit = this.$('[type=\"submit\"]');\n\t\tthis.$target = this.$('.target');\n\n\t\t/**\n\t\t * Form permissions:\n\t\t * Asset and category models have an 'allows' method that checks their internal permissions\n\t\t * against the current use ID and one of the default permission types (for instance, 'modify').\n\t\t *\n\t\t * If this.model.allows() is a method, and this.matrix is a string,\n\t\t * FormView will test that string using that function, and put the form into 'read-only' mode if the test fails:\n\t\t * the class 'read-only' will be added to the top-level element, and all inputs will be disabled.\n\t\t *\n\t\t * Individual form inputs that need to override this can set the HTML attrbute \"data-nx-matrix\"\n\t\t * to a different permision name (for instance, 'read') and that permission will be tested instead.\n\t\t */\n\n\t\t// https://jira.netx.net/browse/DAM-9780\n\t\t// We do not want to collide with `attributePermissions` and `permissionMatrix`\n\t\t// Really, we need to break the attribute code out of formView and let it do what it does best: forms\n\t\tlet readonly = false;\n\n\t\tthis.$el.toggleClass('read-only', readonly);\n\n\t\tlet disabledCount = 0;\n\t\tlet emptyCount = 0;\n\t\tlet inputCount = 0;\n\t\t// TODO: Start using form names and target our searches for inputs to that specific form\n\t\t// That way we can start utilizing nested forms without interference\n\t\t// Iterate over each input in the form:\n\t\t_.each(this.$(':input').not(':button'), element => {\n\t\t\tconst $element = $(element);\n\t\t\t// Is this input for toggling \"append value\"?\n\t\t\tconst isAppend = $element.hasClass('nx-append-value');\n\n\t\t\t// Track amount of inputs\n\t\t\t// Omit \"append value\" toggles\n\t\t\tif (!isAppend) {\n\t\t\t\tinputCount++;\n\t\t\t}\n\n\t\t\tconst $input = $element;\n\t\t\t// TODO: This code will never get hit because we explicitely set this to fale with no way to change it from the outside\n\t\t\t// Disable the input if we're read-only:\n\t\t\tif (readonly) {\n\t\t\t\tconst disableInput = !$input.nxIgnores('matrix');\n\n\t\t\t\t$input\n\t\t\t\t\t.prop('disabled', disableInput)\n\t\t\t\t\t.closest('.form-group')\n\t\t\t\t\t.toggleClass('read-only', disableInput);\n\n\t\t\t\t// Track the amount of disabled inputs\n\t\t\t\tif (disableInput) {\n\t\t\t\t\tdisabledCount++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// restore the value from before render, if any\n\t\t\tconst cachedValue = this.restoreCachedFormValue($element) || $input.val();\n\t\t\tconst value = cachedValue;\n\t\t\tlet hasValue = !_.isUndefined(value);\n\t\t\tif (hasValue) {\n\t\t\t\tif (_.isArray(value)) {\n\t\t\t\t\thasValue = value.length > 0;\n\t\t\t\t} else if (_.isString(value)) {\n\t\t\t\t\thasValue = value.trim() != '';\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Track the amount of empty inputs\n\t\t\tif (!isAppend && !hasValue) {\n\t\t\t\temptyCount++;\n\t\t\t}\n\t\t});\n\n\t\t// if our form has any backbone tooltips, initialize that piece of Backbone.\n\t\tthis.$('[data-toggle=\"tooltip\"]').tooltip();\n\n\t\tthis.cacheQueries();\n\n\t\t// Validation error list element\n\t\tthis.$validationErrors = this.$('[data-nx-control=\"validation-errors\"]');\n\t\tthis.errorCacheView.setElement(this.$validationErrors).render();\n\n\t\t// Are all the fileds disabled\n\t\tthis.$el.toggleClass(\n\t\t\t'all-fields-disabled',\n\t\t\t!_.isEmpty(this.inputs) && disabledCount >= inputCount,\n\t\t);\n\t\t// Are all the fields empty\n\t\tthis.$el.toggleClass(\n\t\t\t'all-fields-empty',\n\t\t\t!_.isEmpty(this.inputs) && emptyCount >= inputCount,\n\t\t);\n\n\t\t// DEVNOTE: X7 core code should not be making UX decisions like\n\t\t// determining whether a form field gains focus when shown. The\n\t\t// theme itself should decide when to utilize a formView's focus() method.\n\t\t// this.focus();\n\n\t\t// Most likely cases of this- modals\n\t\t// If the element is not visible then neither is any of its inputs\n\t\t// We can not get validation on inputs that are not visible\n\t\t// So let's wait to check the form until it is shown\n\t\tthis.whenShown.then(this.checkForm);\n\t},\n\n\t/**\n\t * this.reset() is intended to reset the form into a clean initial state.\n\t * The actual reset of the form is handled in a wrapper above.\n\t * This method is intended to provide child views the ability to reset private\n\t * variables, set up complex UI elements, etc.\n\t * this.reset() is called automatically when this.show() is called, if the\n\t * boolean this.resetOnShow is true and the view is not already visible in the DOM.\n\t * @method\n\t */\n\treset() {\n\t\tconst $form = this.$('form');\n\t\t// Vanilla reset\n\t\t$form.length && $form[0].reset();\n\t\t// Validator reset - only resets fields that would be validated\n\t\tthis.validator.enabled &&\n\t\t\tthis.Plugins.Invoke('validation', $form, 'resetForm');\n\n\t\t// Other\n\t\tthis.formChanged = false;\n\t\tthis.submitted = false;\n\t\t// If the submitting promise is still around for some reason\n\t\tif (this.submitting) {\n\t\t\t// And it is still in a pending state - reject\n\t\t\tthis.submitting.state() === 'pending' && this.submitting.rejectWith(this);\n\t\t\tdelete this.submitting;\n\t\t}\n\t},\n\n\t/**\n\t * Restore a single form value from the cache\n\t * @method\n\t * @param {object} element jQuery element\n\t * @return {mixed} Cached value\n\t * @see cacheFormValues\n\t * @see flushCachedFormValues\n\t */\n\trestoreCachedFormValue($element) {\n\t\tconst inputName = $element.attr('name');\n\t\tlet value;\n\n\t\tif (\n\t\t\tinputName == null ||\n\t\t\tinputName === false ||\n\t\t\t!this._formValues ||\n\t\t\t!_.has(this._formValues, inputName)\n\t\t)\n\t\t\treturn value;\n\n\t\t// We have to unpack the cache differently for different input types.\n\t\tif ($element.prop('multiple')) {\n\t\t\tvalue = _.csvToArray(this._formValues[inputName]);\n\t\t\t$element.val(value);\n\t\t\treturn value;\n\t\t}\n\t\tif ($element.attr('type') === 'checkbox') {\n\t\t\tvalue = this._formValues[inputName];\n\t\t\t$element.prop('checked', value);\n\t\t\treturn value;\n\t\t}\n\n\t\t// If it's a radio, we need to check the correct option in the group\n\t\tif ($element.attr('type') === 'radio') {\n\t\t\tvalue = this._formValues[inputName];\n\t\t\t$element.prop('checked', $element.val() === value);\n\t\t\treturn value;\n\t\t}\n\n\t\tvalue = this._formValues[inputName];\n\t\t$element.val(value);\n\t\treturn value;\n\t},\n\n\t/**\n\t * this.setForm(values) sets all inputs to the values given.\n\t * @method\n\t * @param {object} values Form values\n\t */\n\tsetForm(values) {\n\t\t_.each(values, (v, idx) => this.setValue(idx, v));\n\t},\n\n\t/**\n\t * this.setFormValidation() is called at postRender and initializes form validation\n\t * @method\n\t * @param {element} $form Form element\n\t */\n\tsetFormValidation($form) {\n\t\t$form = $form || this.$('form[data-nx-validate-form]');\n\n\t\t// Cleanup\n\t\tthis.Plugins.Destroy('validation');\n\t\tthis.validator.enabled = false;\n\n\t\tif (!$form.length) return;\n\n\t\tthis.validator.enabled = true;\n\t\tthis.Plugins.Initialize('validation', $form).then(instance => {\n\t\t\t// Store\n\t\t\tthis.validator.plugin = instance;\n\n\t\t\t// Pipe some events\n\t\t\t_.each(\n\t\t\t\t['err.form.fv', 'err.field.fv', 'success.form.fv', 'success.field.fv'],\n\t\t\t\tevent => {\n\t\t\t\t\t$form.off(event).on(event, (...args) => {\n\t\t\t\t\t\tthis.trigger(`validation:${event}`, ...args);\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t);\n\n\t\t\t// FV does a weird thing: it catches submit events, preventsDefault() on them,\n\t\t\t// and detects if they were due to a submit button click or not.\n\t\t\t// BUT it doesn't call stopPropagation() on them.\n\t\t\t// Then after validation succeeds, it triggers a new submit event\n\t\t\t// *only if* the original submit was from a button click. But\n\t\t\t// the original submit event propagates either way.\n\t\t\t//\n\t\t\t// So our submit event handler would get two submit events if form is valid & submit button was clicked,\n\t\t\t// but one otherwise, whether or not the form is valid. That's bizarre.\n\t\t\t//\n\t\t\t// FV's official policy is that you should give up on the submit event and listen\n\t\t\t// for their success event instead; however, that requires a lot of special-FV-handling\n\t\t\t// code, and not all our forms have FV on them. Either they don't understand\n\t\t\t// the problem well enough, or I don't understand their special needs yet ...\n\t\t\t//\n\t\t\t// FormView wants to get one event if validation succeeds, no events otherwise.\n\t\t\t// It wants to remain agnostic about where the event came from, and\n\t\t\t// whether or not fv is enabled.\n\t\t\t//\n\t\t\t// Here we override FV, to have it stopPropagation on the original event if\n\t\t\t// fv already detected a button click.\n\t\t\t//\n\t\t\t// TODO: test in all browsers, with all three submission techniques: click submit,\n\t\t\t// trigger submit event, or call view.submit().\n\t\t\t//\n\t\t\t// Tested in Chrome, works fine.\n\t\t\t// Tested in Safari, works fine.\n\t\t\t$form.off('submit.fv').on('submit.fv', e => {\n\t\t\t\t// fv does this.\n\t\t\t\te.preventDefault();\n\t\t\t\t// fv doesn't do this.\n\t\t\t\tinstance.$submitButton && e.stopPropagation();\n\t\t\t\tinstance.validate();\n\t\t\t});\n\n\t\t\t// Let the view know\n\t\t\tthis.trigger('validation:set', this, instance);\n\t\t});\n\t},\n\n\t/**\n\t * Set an individual form value.\n\t * @method\n\t * @param {string} input Input name\n\t * @param {string} value New input value\n\t */\n\tsetValue(input, value) {\n\t\tthis.$(':input')\n\t\t\t.filter(`[name=\"${input}\"]`)\n\t\t\t.val(value);\n\t},\n\n\t/**\n\t * Ok, there are some issues with trying to be agnostic and having input/select ui plugins that hide the original element\n\t * you still want that hidden element to be validated but it is almost impossible to know (without modifying code each time you add a plugin)\n\t * if the element was hidden intentionally (like we do in attribute forms) and when an element was hidden to manipulate the ui only.\n\t *\n\t * Solution: rather than calling hide/show/toggle directly on the elements in the view- pass the elements through here.\n\t * It also handles bulk hiding (the validator will look at parents for the data-nx-ignore=\"validation\" attribute as well)\n\t * If validation is not turned on for whatever reason the element passed will be sent to where it would have gone\n\t * @param {element} input The jQuery element to hide\n\t * @fires module:app#app:resize\n\t */\n\tshowField(...input) {\n\t\tconst inputs = [...input];\n\t\tconst $form = this.$form;\n\t\tconst plugins = this.Plugins;\n\t\tconst validation = this.validator.enabled;\n\n\t\t_.each(inputs, input => {\n\t\t\tlet $input = $(input);\n\t\t\tif (!$input.is(':input')) {\n\t\t\t\t$input = $input.find(':input');\n\t\t\t}\n\n\t\t\tlet $formGroup = $input.closest('.form-group');\n\t\t\tif (!$formGroup.length) {\n\t\t\t\t$formGroup = $input;\n\t\t\t}\n\n\t\t\t$input.nxUnignore('validation');\n\t\t\t$formGroup.show();\n\n\t\t\tif (validation) {\n\t\t\t\t_.each($input, el => {\n\t\t\t\t\tel.name &&\n\t\t\t\t\t\tplugins.Invoke('validation', $form, 'resetField', [el.name]);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t},\n\n\t/**\n\t * this.submit() submits the current form by triggering the event this.eventStr + \":confirmed\" on dispatcher,\n\t * with the arguments returned by this.submitArgs(). A controller should catch this event\n\t * and perform whatever steps are necessary.\n\t *\n\t * @method\n\t * @param {method} submit Submit method\n\t * @param {event} e Submit event\n\t * @fires (this.eventStr):cancelled\n\t * @fires (this.eventStr):confirmed\n\t */\n\tsubmit(e) {\n\t\t// The cake stops here:\n\t\tif (e && e.preventDefault) {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t} else {\n\t\t\t// There was no event argument, so we weren't called by an event handler.\n\t\t\t// Instead, other code called submit() directly.\n\t\t\t// However, that circumvents any form validation that might be present.\n\t\t\t// So we re-trigger a new submit event, which will call this method again\n\t\t\t// if validation succeeds.\n\t\t\t//\n\t\t\t// In other words, there isn't & should not be a difference between calling\n\t\t\t// this method and triggering a submit event. We are agnostic, and that is good!\n\t\t\treturn this.$('form:first').trigger('submit');\n\t\t}\n\n\t\t// Yes, the form may be valid ... but what if we disabled the submit for other reasons?\n\t\tif (!this.submitReady()) {\n\t\t\treturn this.checkForm();\n\t\t}\n\n\t\t// Let it be known\n\t\tthis.submitted = true;\n\n\t\t// Track our submit\n\t\tif (this.submitting && this.submitting.state() === 'pending') {\n\t\t\tthis.submitting.rejectWith(this);\n\t\t}\n\t\tthis.submitting = new $.Deferred();\n\n\t\tconst confirmed = () => {\n\t\t\tthis.$el.addClass('form-submitting');\n\n\t\t\t// Just submit it\n\t\t\t// Disable submit buttons\n\t\t\tthis.$('[type=\"submit\"]').disable();\n\n\t\t\t// DAM-15747 if there is a confirmMessage, then let\n\t\t\t// confirmView trigger the :confirmed event, no doubling down\n\t\t\tif (!this.confirmMessage) {\n\t\t\t\tdispatcher.trigger.apply(\n\t\t\t\t\tdispatcher,\n\t\t\t\t\t[this.eventStr + ':confirmed'].concat(this.submitArgs.apply(this)),\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.$('.form-submitting').show();\n\t\t};\n\n\t\tconst cancelled = () => {\n\t\t\tif (!this.submitting) return;\n\t\t\tthis.submitting.rejectWith(this);\n\t\t\tdelete this.submitting;\n\t\t};\n\n\t\tif (this.confirmMessage) {\n\t\t\t// Confirm before submit:\n\t\t\t// If we have a confirmation message, fire a confirmation modal\n\t\t\tconst cancelEventStr = `${this.eventStr}:cancelled`;\n\t\t\t// We do want fire our `:confirmed` event twice\n\t\t\tconst confirmedEventStr = `${this.eventStr}:confirmed`;\n\n\t\t\t// custom listener methods are safe to remove\n\t\t\tconst confirmedMethod = () => {\n\t\t\t\tdispatcher.off(cancelEventStr, cancelledMethod);\n\t\t\t\tconfirmed();\n\t\t\t};\n\t\t\tconst cancelledMethod = () => {\n\t\t\t\tdispatcher.off(confirmedEventStr, confirmedMethod);\n\t\t\t\t// Re-enable etc\n\t\t\t\tthis.checkForm();\n\t\t\t\tcancelled();\n\t\t\t};\n\t\t\tdispatcher.once(confirmedEventStr, confirmedMethod);\n\t\t\tdispatcher.once(cancelEventStr, cancelledMethod);\n\n\t\t\tdispatcher.trigger.apply(\n\t\t\t\tdispatcher,\n\t\t\t\t[\n\t\t\t\t\t'app:confirm',\n\t\t\t\t\t_.extend(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmessage: _.isFunction(this.confirmMessage)\n\t\t\t\t\t\t\t\t? this.confirmMessage()\n\t\t\t\t\t\t\t\t: this.confirmMessage,\n\t\t\t\t\t\t\tyesEvent: confirmedEventStr,\n\t\t\t\t\t\t\tnoEvent: cancelEventStr,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.confirmViewOpts,\n\t\t\t\t\t),\n\t\t\t\t].concat(this.submitArgs()),\n\t\t\t);\n\t\t} else {\n\t\t\t// just do it!\n\t\t\tconfirmed();\n\t\t}\n\n\t\treturn false;\n\t},\n\n\t/**\n\t * this.submitArgs() can be overriden to return an array of whatever args you want to pass.\n\t * by default we return three args: an object with all the input form values, our model or collection,\n\t * and this.args (which may be undefined)\n\t * @method\n\t * @return {array} Two element array: object containing input form values, and this.args\n\t */\n\tsubmitArgs() {\n\t\tconst formValues = this.formValues();\n\t\tlet _formValues = {};\n\n\t\t// Unescape our from value keys as they were escaped via the name when injecting attributes\n\t\t_.reduce(\n\t\t\tformValues,\n\t\t\t(result, value, key) => {\n\t\t\t\tresult[unescapeAttributeName(key)] = value;\n\t\t\t\treturn result;\n\t\t\t},\n\t\t\t_formValues,\n\t\t);\n\n\t\treturn [_formValues, this.model || this.collection].concat(this.args);\n\t},\n\n\t/**\n\t * submitReady() tests if the form can be submitted yet.\n\t * There is a wrapper above for this that checks form validation and the result of this method\n\t * Returns true by default; can be overridden with any submit-enable test you like.\n\t * @method\n\t * @return {boolean} Status of the submit action: ready or not.\n\t */\n\tsubmitReady() {\n\t\tconst validation = this.Plugins.GetInstance('validation');\n\t\treturn (\n\t\t\t(!validation || validation.isValid() !== false) &&\n\t\t\t(!this.requiresChanges || this.formChanged)\n\t\t);\n\t},\n\n\t/**\n\t * Is called when :success is triggered\n\t * @method\n\t * @param {Netx.Model|Netx.Collection} thing Netx.Model or Netx.Collection\n\t * @param {boolean} isNew Whether the model was new or not\n\t */\n\tsuccess(thing) {\n\t\t// Check that the success was for us (comes from :success)\n\t\t// Our pattern has been to have the model/collection as the first argument passed back from the success event\n\t\tif (thing) {\n\t\t\tif (this.model && thing.constructor.__isModel__) {\n\t\t\t\tif (thing !== this.model) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else if (this.collection && thing.constructor.__isCollection__) {\n\t\t\t\tif (thing !== this.collection) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Let the form know it is no longer changed (as data has most likely been saved)\n\t\tthis.formChanged = false;\n\t\t// Resolve submitting promise and pass back any arguments that may have come with the success\n\t\tif (this.submitting) {\n\t\t\tthis.submitting.resolveWith(this, _.rest(arguments));\n\t\t\tdelete this.submitting;\n\t\t}\n\t\t// Hide on submit\n\t\tif (this.hideOnSubmit) {\n\t\t\tif (!this.removeOnHide) {\n\t\t\t\t// Reset form\n\t\t\t\tif (this.resetOnSubmit) this.reset();\n\t\t\t}\n\t\t\tthis.hide();\n\t\t\tthis.stopListening(dispatcher, `${this.eventStr}:success`, this.success);\n\t\t}\n\t\t// Remove on submit\n\t\telse if (this.removeOnSubmit) {\n\t\t\t// Let hide handle the remove in case there are any theme related animations, etc\n\t\t\t// so set this.removeOnHide to true and call this.hide\n\t\t\tthis.removeOnHide = true;\n\t\t\tthis.hide();\n\t\t\tthis.stopListening(dispatcher, `${this.eventStr}:success`, this.success);\n\t\t}\n\t\t// Nothing\n\t\telse {\n\t\t\t// Reset form\n\t\t\tif (this.resetOnSubmit) this.reset();\n\t\t\t// Reset validation\n\t\t\tif (this.validator.enabled) {\n\t\t\t\tthis.setFormValidation();\n\t\t\t\tthis.checkForm();\n\t\t\t}\n\t\t}\n\n\t\tthis.formChanged = false;\n\t\tthis.$el.removeClass('form-submitting');\n\t\tthis.$('.form-submitting').hide();\n\t},\n\n\t/**\n\t * Ok, there are some issues with trying to be agnostic and having input/select ui plugins that hide the original element\n\t * you still want that hidden element to be validated but it is almost impossible to know (without modifying code each time you add a plugin)\n\t * if the element was hidden intentionally (like we do in attribute forms) and when an element was hidden to manipulate the ui only.\n\t * Solution: rather than calling hide/show/toggle directly on the elements in the view- pass the elements through here.\n\t * It also handles bulk hiding (the validator will look at parents for the data-nx-ignore=\"validation\" attribute as well)\n\t * If validation is not turned on for whatever reason the element passed will be sent to where it would have gone\n\t * @param {element} input The jQuery element to hide\n\t * @param {boolean} bool Hide/show boolean\n\t */\n\ttoggleField(input, bool) {\n\t\tthis[bool === true ? 'showField' : 'hideField'](input);\n\t},\n\n\t/**\n\t * Helper for validating field\n\t * @method\n\t * @param {element|string} input Input element or `name`\n\t */\n\tvalidateField(input) {\n\t\t// validateField does not seem to do much in this case\n\t\t// but revalidateField gets us what we want\n\t\tthis.validator.enabled &&\n\t\t\tthis.Plugins.Invoke('validation', this.$form, 'revalidateField', [input]);\n\t},\n\n\t//\n\t// HELPERS\n\t// When some plugins just can't get the field to fire a correct change\n\t//\n\t/**\n\t * datepicker just doesn't seem to fire the change event formValidation needs properly\n\t * @method\n\t */\n\tdatepickerChanged(e) {\n\t\t// TODO: The plugin fires a change event when the date picker is first shown... cannot seems to find a clean way to get around it\n\t\t// aside from editing their code.\n\t\t// It is in the `update` method and at the very bottom...\n\t\tthis.validateField($(e.target));\n\t},\n\n\t/**\n\t * select2 multiple just doesn't seem to fire the change event formValidation needs properly\n\t * @method\n\t */\n\tselect2changed(e) {\n\t\tthis.validateField($(e.target));\n\t},\n\n\t// /**\n\t// * Before child views are attached, search for form elements that will need validation attached.\n\t// */\n\t// hook_preChildren: function(){\n\t// \tthis._forms = this.$('form[data-nx-validate-form]');\n\t// },\n};\n\nexport default function(target) {\n\tif (!target || target.hasFunctionality(NAME)) return target;\n\n\ttarget.extendFunctionality(Props);\n\ttarget.__isForm__ = true;\n\n\ttarget.addInitializer((instance, opts = {}) => {\n\t\tinstance.isForm = true;\n\t\tinstance.$el.addClass('form-view');\n\t\tinstance.events = {\n\t\t\tsubmit: 'submit',\n\t\t\t'click .nx-cancel:first': 'cancel',\n\t\t\t'click [data-nx-control=\"close\"]:first': 'cancel',\n\t\t\t'change .select2-hidden-accessible': 'select2changed',\n\t\t\t'change [data-provide=\"datepicker\"]': 'datepickerChanged',\n\t\t\tchange: 'inputChanged',\n\t\t\tinput: 'inputChanged',\n\t\t\t// Used to check if we need to lead the user to another invalid field\n\t\t\t'blur input, select, textarea': 'blurred',\n\t\t\t// Used to check if we need to lead the user to another invalid field\n\t\t\t'keydown input': 'keydown',\n\t\t\t'keyup textarea': 'inputChanged',\n\t\t\t'click select': 'inputChanged',\n\t\t\t'nx.fieldAdded :input': 'fieldAdded',\n\t\t\t'nx.fieldMutated :input': 'fieldMutated',\n\t\t\t'nx.fieldMutating :input': 'fieldMutating',\n\t\t\t'nx.fieldRemoved :input': 'fieldRemoved',\n\t\t\t...instance.events,\n\t\t};\n\n\t\t/** @override */\n\t\tinstance.setModel = _.wrap(instance.setModel, (setModel, model, opts) => {\n\t\t\t// flush our cache when our model changes\n\t\t\tinstance.flushCachedFormValues();\n\t\t\tinstance.formChanged = false;\n\n\t\t\treturn setModel.call(instance, model, opts);\n\t\t});\n\n\t\t/** @override */\n\t\tinstance.show = _.wrap(instance.show, show => {\n\t\t\tif (!instance.isShown && instance.resetOnShow) {\n\t\t\t\tinstance.reset();\n\t\t\t}\n\t\t\treturn show.call(instance);\n\t\t});\n\n\t\tif (!instance.unsavedChanges) {\n\t\t\tinstance.unsavedChanges = (unsavedChanges, noProxy) => {\n\t\t\t\t// First check us:\n\t\t\t\t// We are a `formView` AND\n\t\t\t\t// We have changed OR\n\t\t\t\t// We have a model and it is new\n\t\t\t\tif (\n\t\t\t\t\tinstance.formChanged ||\n\t\t\t\t\t(instance.model && instance.model.isNew())\n\t\t\t\t) {\n\t\t\t\t\treturn instance;\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Alternately, this.eventStr is the prefix for both the submit & cancel events generated by the form.\n\t\t * For instance, if eventStr == 'module:foo',\n\t\t * form sumission will trigger 'module:foo:confirmed' on the dispatcher, and cancel will trigger 'module:foo:cancelled'.\n\t\t * @type {string}\n\t\t * @default\n\t\t */\n\t\tinstance.eventStr = opts.eventStr || 'module:foo';\n\n\t\t/**\n\t\t * this.confirmMessage contains a confirmation string that pops up in a confirmView before submission.\n\t\t * If you don't want any confirmation pop-up, undefine this property.\n\t\t * @type {string}\n\t\t * @default\n\t\t */\n\t\tinstance.confirmMessage = opts.confirmMessage || false; //'Warning! This process cannot be undone. Please confirm you want to execute this job on these assets.'\n\n\t\t/**\n\t\t * Should we diable caching values at `preRender`?\n\t\t * @type {boolean}\n\t\t * @default\n\t\t */\n\t\tinstance.disableCache = opts.disableCache === true;\n\n\t\tinstance.hideOnSubmit = opts.hideOnSubmit === true;\n\n\t\tinstance.removeOnSubmit = opts.removeOnSubmit === true;\n\n\t\tinstance.revalidateFieldOnAdd = opts.revalidateFieldOnAdd === true;\n\n\t\t/**\n\t\t * resetOnShow determines whether this.reset() will be called when the form is\n\t\t * first shown. Reset will only be called when this.show() is called on a form that\n\t\t * is not yet visible.\n\t\t * @type {boolean}\n\t\t * @default\n\t\t */\n\t\tinstance.resetOnShow = opts.resetOnShow === true;\n\n\t\t/**\n\t\t * Signifies that not only must a form be valid to submit but a change must have been made as well\n\t\t * @type {boolean}\n\t\t */\n\t\tinstance.requiresChanges = opts.requiresChanges !== false;\n\n\t\t/**\n\t\t * Whether to reset form on submit\n\t\t * @type {boolean}\n\t\t */\n\t\tinstance.resetOnSubmit = opts.resetOnSubmit !== false;\n\n\t\t/**\n\t\t * Custum validation\n\t\t * @memberOf Netx.Views.FormView\n\t\t * @alias validatorFields\n\t\t * @type {object}\n\t\t */\n\t\tinstance.validatorFields = opts.validatorFields || {};\n\n\t\t/**\n\t\t * Options for confirmViewModal when triggering a confirm on form submit\n\t\t * @memberOf Netx.Views.FormView\n\t\t * @alias confirmViewOpts\n\t\t * @type {Object}\n\t\t */\n\t\tinstance.confirmViewOpts = opts.confirmViewOpts || {};\n\n\t\t/**\n\t\t * Error cache\n\t\t * Stores invalid fields when validation is turned on\n\t\t * @memberOf Netx.Views.FormView\n\t\t * @alias errorCache\n\t\t * @type {Netx.Collection}\n\t\t */\n\t\tinstance.errorCache = new CoreCollection([]);\n\n\t\t/**\n\t\t * Error cache view\n\t\t * If your template has an element with [data-nx-control=\"validation-errors\"], then errors will be listed there automatically on a bad submit\n\t\t * @memberOf Netx.Views.FormView\n\t\t * @alias errorCacheView\n\t\t * @type {Netx.Views.FormErrorListView}\n\t\t */\n\t\tinstance.errorCacheView = instance.addSubView(\n\t\t\tnew FormErrorListView({\n\t\t\t\tcollection: instance.errorCache,\n\t\t\t}),\n\t\t);\n\n\t\t/**\n\t\t * Form validator object\n\t\t * @memberOf Netx.Views.FormView\n\t\t * @alias validator\n\t\t * @type {object}\n\t\t */\n\t\tinstance.validator = _.extend(\n\t\t\t{\n\t\t\t\tenabled: false,\n\t\t\t\tplugin: null,\n\t\t\t\tfields: {},\n\t\t\t},\n\t\t\topts.validator,\n\t\t);\n\n\t\t/**\n\t\t * @property {object} Plugins - Plugins for this view\n\t\t * @property {object} Plugins.validation - Validation\n\t\t */\n\t\tinstance.Plugins.Register({\n\t\t\tvalidation: {\n\t\t\t\tname: 'formValidation',\n\t\t\t\toptions: {\n\t\t\t\t\tmessage: i18n.t('i18n.valueIsNotValid'),\n\t\t\t\t\texcluded: [\n\t\t\t\t\t\t':disabled',\n\t\t\t\t\t\t($field, validator) => {\n\t\t\t\t\t\t\treturn $field.nxIgnores('validation');\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tfields:\n\t\t\t\t\t\t_.isObject(instance.validator) &&\n\t\t\t\t\t\t_.isObject(instance.validator.fields)\n\t\t\t\t\t\t\t? instance.validator.fields\n\t\t\t\t\t\t\t: {},\n\t\t\t\t\tframework: 'bootstrap',\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\t// If form values were passed, set them at render\n\t\tif (opts.form) {\n\t\t\tinstance.rendered.then(() => {\n\t\t\t\tinstance.setForm(opts.form);\n\t\t\t});\n\t\t}\n\n\t\t// Hey, listen!\n\t\tinstance\n\t\t\t.on('preRenderHook', instance.prepareForm)\n\t\t\t.on('postRenderHook', () => {\n\t\t\t\tinstance.renderForm();\n\t\t\t\t// We do not want to setFormValidation before the view has ran all the code\n\t\t\t\t// in its `postRender`\n\t\t\t\t_.defer(() => {\n\t\t\t\t\t// Set form validation\n\t\t\t\t\tinstance.setFormValidation();\n\t\t\t\t});\n\t\t\t})\n\t\t\t.listenTo(dispatcher, `${instance.eventStr}:success`, instance.success)\n\t\t\t.listenTo(dispatcher, `${instance.eventStr}:error`, instance.failure)\n\t\t\t.listenTo(\n\t\t\t\tinstance,\n\t\t\t\t'validation:err.form.fv',\n\t\t\t\tinstance.formValidationFailure,\n\t\t\t)\n\t\t\t.listenTo(\n\t\t\t\tinstance,\n\t\t\t\t'validation:err.field.fv',\n\t\t\t\tinstance.fieldValidationFailure,\n\t\t\t)\n\t\t\t.listenTo(\n\t\t\t\tinstance,\n\t\t\t\t'validation:success.form.fv',\n\t\t\t\tinstance.formValidationSuccess,\n\t\t\t)\n\t\t\t.listenTo(\n\t\t\t\tinstance,\n\t\t\t\t'validation:success.field.fv',\n\t\t\t\tinstance.fieldValidationSuccess,\n\t\t\t);\n\n\t\t// HTML-948: if the formview has .dispatcherSubmitEvent set, trigger form submit when dispatcher triggers that event\n\t\tif (instance.dispatcherSubmitEvent) {\n\t\t\tinstance.listenTo(\n\t\t\t\tdispatcher,\n\t\t\t\tinstance.dispatcherSubmitEvent,\n\t\t\t\tinstance.submit,\n\t\t\t);\n\t\t}\n\t\tif (instance.viewCollection) {\n\t\t\t// Each `childView` could have its own set inputs - when they render we need to:\n\t\t\t// Cache queries\n\t\t\t// Check the form (enable/disable submit) if applicable\n\t\t\tinstance.listenTo(\n\t\t\t\tinstance.viewCollection,\n\t\t\t\t'view:rendered',\n\t\t\t\t_.debounce(() => {\n\t\t\t\t\tinstance.cacheQueries();\n\t\t\t\t\tinstance.checkForm();\n\t\t\t\t}, 50),\n\t\t\t);\n\t\t}\n\t}, NAME);\n\n\treturn target;\n}\n","/**\n * @module core/functionality/childViews\n */\n\nconst NAME = 'childViews';\n\nimport LazyLoader from 'core-libs/nx-lazyloader';\n\nconst Props = {\n\t/**\n\t * @method\n\t * @param {string} event Event\n\t * @param {function} func Callback\n\t */\n\taddChildViewListener(event, func) {\n\t\t_.each(this.childViews, (v) => this.listenTo(v, event, func));\n\t},\n\n\t/**\n\t * Setup listeners on child views\n\t * @method\n\t * @private\n\t */\n\taddChildViewListeners() {\n\t\tconst collection = this.getChildViewCollection();\n\n\t\tif (!collection) {\n\t\t\tthrow new Error(\"Can't use child views without a collection\");\n\t\t}\n\n\t\tthis.removeChildViewListeners(collection);\n\n\t\t// Listen for child events:\n\t\t// ------------------------\n\t\t// Do we re-render on every add?\n\t\tthis.listenTo(collection, 'add', this.addedChildViewModel);\n\n\t\t// Sort has fired\n\t\t// TODO: Somewhere something is triggering sort - and it isn't backbone (because I know the compartor is not set and backbone will not sort without one)\n\t\t// This was causing us to render all the children in an asset gallery, and then immediately reset and re-add them\n\t\t// I have searched the codebase and can not find where this is happening, but it is possible this is a variable named event string...\n\t\t// Haven't gone deep enough in the debugger to spot it\n\t\t// Regardless, nothing should be bypassing this check and triggering `sort`\n\t\tif (collection.compartor) {\n\t\t\tthis.listenTo(collection, 'sort', this.resetChildViews);\n\t\t}\n\t\t// Respond to a remove on our collection by removing the view.\n\t\tthis.listenTo(collection, 'remove', this.removeChildView);\n\t\t// And if our collection is reset, update everything\n\t\tthis.listenTo(collection, 'reset', this.resetChildViews);\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * @method\n\t */\n\taddedChildViewModel(model) {\n\t\tthis.childView.reset ? this.render() : this.addChildView(model);\n\t},\n\n\t/**\n\t * Internal function to install one child view\n\t * @private\n\t * @param {Netx.Model} model Model\n\t * @returns {Netx.View} Child view\n\t */\n\taddChildView(model, append) {\n\t\tif (!model) return;\n\n\t\t// Recycling is good! Create storage for child views if it doesn't exist yet, indexed by model.cid.\n\t\tthis.childViews = this.childViews || {};\n\n\t\tlet childView = this.childViews[model.cid];\n\t\tlet newChildView = false;\n\n\t\t// Create main options\n\t\t// Loop over each thing in this.childView, excluding this.options.options, and execute\n\t\t// any value that may be a function\n\t\tconst mainOptions = {};\n\t\t_.each(_.omit(this.childView, 'options'), (v, k) => {\n\t\t\tlet val = v;\n\t\t\tif (_.isFunction(v) && !v.__isView__) {\n\t\t\t\tval = v.call(this, model);\n\t\t\t}\n\t\t\tmainOptions[k] = val;\n\t\t});\n\n\t\tconst childCollection = this.getChildViewCollection();\n\t\tconst isAppViewModel = model.constructor.__name__ === 'AppView';\n\n\t\tlet _view;\n\t\t// Check and see if it was in the view queue\n\t\tif (\n\t\t\t!childView &&\n\t\t\tmodel.get('queued') &&\n\t\t\tthis._viewQueue &&\n\t\t\tisAppViewModel\n\t\t) {\n\t\t\tif (this._viewQueue.get(model.id)) {\n\t\t\t\t_view = model.get('view');\n\t\t\t\tif (_view) {\n\t\t\t\t\t// Get the view\n\t\t\t\t\tchildView = this.childViews[model.cid] = _view;\n\t\t\t\t\t// Make sure it knows who its rightful owner is\n\t\t\t\t\tmodel.collection = this.viewCollection;\n\t\t\t\t\t// We are new!\n\t\t\t\t\tnewChildView = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Check and see if the view was already created via another `viewCollection`\n\t\tif (\n\t\t\t!childView &&\n\t\t\tisAppViewModel &&\n\t\t\tthis.viewCollection &&\n\t\t\t!model.isMyOriginalCollection(this.viewCollection)\n\t\t) {\n\t\t\t_view = model.get('view');\n\t\t\tif (_view) {\n\t\t\t\tchildView = this.childViews[model.cid] = _view;\n\t\t\t\t// We are new!\n\t\t\t\tnewChildView = true;\n\t\t\t}\n\t\t}\n\n\t\t// New childView\n\t\tif (!childView) {\n\t\t\t// Respect max items\n\t\t\t// Do it in here so we do not erroneously think we have exceeded our limits i nthe event of a detach re-add deal\n\t\t\tif (\n\t\t\t\tmainOptions.maxItems &&\n\t\t\t\t_.keys(this.childViews).length >= mainOptions.maxItems\n\t\t\t)\n\t\t\t\treturn;\n\n\t\t\t////////////////////////////////\n\t\t\t// CHILD VIEW SETUP\n\t\t\t////////////////////////////////\n\n\t\t\t// Child View class:\n\t\t\tconst childViewClass = mainOptions.viewClass;\n\n\t\t\t// if the child class isn't specified assume we do not want to output anything\n\t\t\tif (!childViewClass) return;\n\n\t\t\tconst childViewProto = childViewClass.prototype;\n\t\t\t// console.log( this, childViewClass );\n\t\t\tconst childViewModule = childViewProto.module\n\t\t\t\t? childViewProto.module\n\t\t\t\t: 'none';\n\n\t\t\t// Child View ID, if defined.\n\t\t\tconst childId = mainOptions.id ? {id: mainOptions.id} : {};\n\n\t\t\t// Child View options:\n\t\t\tlet childViewOptions = {};\n\t\t\tlet _childViewOptions = this.childView.options || {};\n\n\t\t\t// If we are an appView model, extend anything on the model to our childView options\n\t\t\tif (isAppViewModel) {\n\t\t\t\t_.each(model.attributes.viewOptions, (v, k) => {\n\t\t\t\t\tchildViewOptions[k] = v;\n\t\t\t\t});\n\t\t\t\tchildViewOptions.viewSpec = model;\n\t\t\t}\n\n\t\t\t// Check if any of our child view options are functions\n\t\t\tif (!_.isFunction(_childViewOptions)) {\n\t\t\t\t_.each(_.omit(_childViewOptions, 'template'), (opt, key) => {\n\t\t\t\t\tlet val = opt;\n\t\t\t\t\tif (\n\t\t\t\t\t\t// Do not execute method overrides - leave them as is\n\t\t\t\t\t\t_.isFunction(opt) &&\n\t\t\t\t\t\t!opt.__isView__\n\t\t\t\t\t) {\n\t\t\t\t\t\tval = opt.call(this, model);\n\t\t\t\t\t}\n\n\t\t\t\t\tchildViewOptions[key] = val;\n\t\t\t\t});\n\t\t\t\tif (_childViewOptions.template) {\n\t\t\t\t\tchildViewOptions.template = _childViewOptions.template;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Child View attributes:\n\t\t\tconst childViewAttributes = childViewOptions.attributes || {};\n\t\t\t// Check if any of our attributes are functions\n\t\t\t_.each(childViewAttributes, (attr, key, all) => {\n\t\t\t\tif (!_.isFunction(attr)) return;\n\t\t\t\tall[key] = attr.call(this, model);\n\t\t\t});\n\t\t\t// If draggable is true add the attibute draggable=\"true\" to the child view\n\t\t\tchildViewAttributes.draggable =\n\t\t\t\tmainOptions.draggable === true ? true : undefined;\n\t\t\tif (mainOptions.href) {\n\t\t\t\tchildViewAttributes.href = mainOptions.href;\n\t\t\t}\n\t\t\t////////////////////////////////\n\t\t\t// !CHILD VIEW SETUP\n\t\t\t////////////////////////////////\n\n\t\t\t////////////////////////////////\n\t\t\t// CHILD VIEW CREATION\n\t\t\t////////////////////////////////\n\t\t\tlet _options = {};\n\n\t\t\t// Only extend the model/collection if it is not AppView/AppViews\n\t\t\t// For edge cases see Netx.Views.AppModalCrumbsView\n\t\t\tif (childCollection.constructor.__name__ !== 'AppViews') {\n\t\t\t\t_options.collection = childCollection;\n\t\t\t}\n\t\t\tif (!isAppViewModel) {\n\t\t\t\t_options.model = model;\n\t\t\t}\n\n\t\t\t// Put them all together in order:\n\t\t\t// First the options we just defined\n\t\t\t// Then the options parsed in childView setup\n\t\t\t// Then the childId (which is collected from the parsed main options)\n\t\t\t// And lastly, the parsed attributes options\n\t\t\t_.extend(_options, childViewOptions, childId, {\n\t\t\t\tattributes: childViewAttributes,\n\t\t\t});\n\t\t\ttry {\n\t\t\t\t// Allow one last chance to take full control over what gets extended to the childView\n\t\t\t\tif (_.isFunction(_childViewOptions)) {\n\t\t\t\t\t_.extend(_options, _childViewOptions.call(this, model, _options));\n\t\t\t\t}\n\t\t\t} catch (ex) {\n\t\t\t\tconsole.log(ex);\n\t\t\t}\n\n\t\t\t// Create\n\t\t\tthis.childViews[model.cid] = childView = new childViewClass(_options);\n\n\t\t\t// If the model present on options is not of type Netx.Models.AppView then do not set the view\n\t\t\t// this will override the correct one\n\t\t\tif (\n\t\t\t\tisAppViewModel &&\n\t\t\t\t!(_options.model && _options.model.constructor.__name__ === 'AppView')\n\t\t\t) {\n\t\t\t\tmodel.set('view', childView);\n\t\t\t}\n\t\t\t// We are new!\n\t\t\tnewChildView = true;\n\t\t\t////////////////////////////////\n\t\t\t// !CHILD VIEW CREATION\n\t\t\t////////////////////////////////\n\t\t}\n\t\t// ! New childView\n\n\t\t// ////////////////////////////////////\n\t\t// // SET TARGET\n\t\t// ////////////////////////////////////\n\t\t// var target;\n\t\t// // If target is explicitly set to false, use this.$el\n\t\t// if( mainOptions.target === false ) {\n\t\t// \ttarget = this.$el;\n\t\t// }\n\t\t// // If set\n\t\t// else if( mainOptions.target ) {\n\t\t// \ttarget = this.$( mainOptions.target );\n\t\t// }\n\t\t// // Target was either not provided or could not be found\n\t\t// if ( !target || target.length === 0 ) {\n\t\t// \t// Try for .nx-childview or [data-nx-childviews] else use this.$el\n\t\t// \t// TODO: this must be better targeted - we need to make sure we do not wind up grabbing a nested childView element\n\t\t// \t// TODO: switch over to `.nx-childviews` for better performance\n\t\t// \tvar childviewTarget = this.$('.nx-childviews, [data-nx-childviews]');\n\t\t// \ttarget = childviewTarget.length ? childviewTarget.first() : this.$el;\n\t\t// }\n\t\t// ////////////////////////////////////\n\t\t// // !SET TARGET\n\t\t// ////////////////////////////////////\n\n\t\t////////////////////////////////////\n\t\t// POSITION IN DOM\n\t\t////////////////////////////////////\n\t\tconst childModelCount = childCollection.length;\n\t\tif (append === true) {\n\t\t\tchildView.$el.appendTo(this.$childTargetEl);\n\t\t} else {\n\t\t\t// Add the view in the specific order it appears in the collection.\n\t\t\t// NOTE: sometimes we are called by backbone with a model\n\t\t\t// that is identical to, but not the same as, some model in the collection --\n\t\t\t// for instance, if we call set() from a method parser, so the models haven't been unified yet.\n\t\t\t// This line works around that.\n\t\t\tlet idx = childCollection.indexOf(childCollection.get(model.id));\n\t\t\t// However, if the model has no ID, the previous search fails, but the simpler case works.\n\t\t\tif (idx === -1) {\n\t\t\t\tidx = childCollection.indexOf(model);\n\t\t\t}\n\t\t\t// Before\n\t\t\tif (idx === 0) {\n\t\t\t\tchildView.$el.prependTo(this.$childTargetEl);\n\t\t\t}\n\t\t\t// If we are the last view, append to the end of the target:\n\t\t\telse if (idx === childModelCount - 1) {\n\t\t\t\t// If there is a view all children element, insert before\n\t\t\t\tchildView.$el.appendTo(this.$childTargetEl);\n\t\t\t}\n\t\t\t// collection.indexOf(model) can return -1 if the model has no id.\n\t\t\telse if (idx === -1) {\n\t\t\t\tif (model.id) {\n\t\t\t\t\t// Otherwise, this really shouldn't happen unless something is using addChildView in an unsupported way.\n\t\t\t\t\tconsole.warn('adding child view not in childViews collection', model);\n\t\t\t\t}\n\t\t\t\t// Either way, we ought to add what we were asked to add, so append the model's view.\n\t\t\t\tchildView.$el.appendTo(this.$childTargetEl);\n\t\t\t}\n\t\t\t// After\n\t\t\telse {\n\t\t\t\t// Otherwise, insert this view after the previous model's view\n\t\t\t\tconst previousChildView = this.childViews[\n\t\t\t\t\tchildCollection.at(idx - 1).cid\n\t\t\t\t];\n\t\t\t\tpreviousChildView != null\n\t\t\t\t\t? previousChildView.$el.after(childView.el)\n\t\t\t\t\t: childView.$el.appendTo(this.$childTargetEl);\n\t\t\t}\n\t\t}\n\t\t////////////////////////////////////\n\t\t// !POSITION IN DOM\n\t\t////////////////////////////////////\n\n\t\t// Let the child view know it's just been added to its parent view\n\t\tchildView.trigger('addedToParent', this);\n\n\t\t// Let the view know a child view was added\n\t\tthis.trigger('addedChildView', childView);\n\n\t\tif (newChildView) {\n\t\t\tthis.trigger('addedNewChildView', childView)\n\t\t\t\t// Listeners for the life of the child view:\n\t\t\t\t// When removed\n\t\t\t\t.listenTo(childView, 'remove', () => {\n\t\t\t\t\tthis.trigger('removedChildView', childView).stopListening(childView);\n\t\t\t\t});\n\t\t}\n\n\t\t// The boolean lastAdded can be set true on a model before it is added to a collecton, to indicate that no more models are being added after this one.\n\t\t// This causes the addedChildViews event to be triggered on the parent collection's view after the child model view is rendered.\n\t\t// Use this for one-off additions to a view, to trigger post-rendering things (like grid resizing).\n\t\t// (Normal childView processing does not need to worry about this.)\n\t\t// TODO: This feels like a hack, but I don't have a better idea yet.\n\t\tif (model.lastAdded) {\n\t\t\tdelete model.lastAdded;\n\t\t\tthis.trigger('addedChildViews');\n\t\t}\n\n\t\tif (newChildView) {\n\t\t\t// Allow views to access info before the render actually oocurs on viewSpec related views\n\t\t\tif (isAppViewModel) {\n\t\t\t\t_.defer(() => {\n\t\t\t\t\t// Trigger first render. After that, the view will render itself on its own model's events.\n\t\t\t\t\t// TODO: views should decide when to render. They can listen for 'addedToParent' if they need to re-render when re-added.\n\t\t\t\t\t// For now - as I do not want to fix every view that is depending on this behavior\n\t\t\t\t\tif (mainOptions.noRender !== true && !childView.renderedOnce) {\n\t\t\t\t\t\tchildView.render();\n\t\t\t\t\t\t!mainOptions.noShow &&\n\t\t\t\t\t\t\tthis.whenShown.then(() => {\n\t\t\t\t\t\t\t\tchildView.show();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Trigger first render. After that, the view will render itself on its own model's events.\n\t\t\t\t// TODO: views should decide when to render. They can listen for 'addedToParent' if they need to re-render when re-added.\n\t\t\t\t// For now - as I do not want to fix every view that is depending on this behavior\n\t\t\t\tif (mainOptions.noRender !== true) {\n\t\t\t\t\tchildView.render();\n\t\t\t\t\t!mainOptions.noShow &&\n\t\t\t\t\t\tthis.whenShown.then(() => {\n\t\t\t\t\t\t\tchildView.show();\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Return new child view\n\t\treturn childView;\n\t},\n\n\t/**\n\t * Internal function to add one child view for each collection model\n\t * @method\n\t * @private\n\t * @todo Cleanup/reorganize?\n\t */\n\taddChildViews() {\n\t\t// Add child views, if required.\n\t\tconst addedCVs = [];\n\t\tconst parentCollection = this.getChildViewCollection();\n\n\t\t// We have a collection to work off of\n\t\tif (!parentCollection) return this;\n\n\t\t// Free all views from this.childViews that are not specific to models in parentCollection.\n\t\t// (NOTE: we could defer this block for performance if necessary.)\n\t\t// NOTE: any other code that stores views in this.childViews (to track rendering & lifecycle)\n\t\t// is totally incompatible with the childView system! We used to do that a lot,\n\t\t// but for best results, store such views by calling this.addSubView(view), which stores\n\t\t// them in this.subViews{}.\n\t\tconst modelCids = _.pluck(parentCollection.models, 'cid');\n\n\t\t_.each(this.childViews, (view, cid) => {\n\t\t\tif (modelCids.indexOf(cid) > -1) return;\n\t\t\tview.remove();\n\t\t\tdelete this.childViews[cid];\n\t\t});\n\n\t\tthis.trigger('addingChildViews', this);\n\t\t// Opting to break up the adding into chunks\n\t\tif (this.childView.breakItUp) {\n\t\t\tconst opts = _.isObject(this.childView.breakItUp)\n\t\t\t\t? this.childView.breakItUp\n\t\t\t\t: {};\n\t\t\tconst totalLength = this.childView.maxItems || parentCollection.length;\n\n\t\t\tthis.breakItUp(\n\t\t\t\t{\n\t\t\t\t\tsize: totalLength,\n\t\t\t\t\tamount: opts.amount || 50,\n\t\t\t\t\tdelay: opts.delay || 0,\n\t\t\t\t},\n\t\t\t\t(index) => {\n\t\t\t\t\tthis.addChildView(parentCollection.at(index), true);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tthis.trigger('addedChildViews', this);\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\t// We only want to display a certain number of childViews\n\t\telse if (this.childView.maxItems) {\n\t\t\t_.each(_.first(parentCollection.models, this.childView.maxItems), (m) =>\n\t\t\t\tthis.addChildView(m, true),\n\t\t\t);\n\t\t}\n\t\t// Lazy load children\n\t\telse if (this.childView.lazyLoad) {\n\t\t\tthis.Plugins.Destroy('lazyloader');\n\t\t\tthis.initializeLazyLoad();\n\n\t\t\tconst start = this.lazyLoadIndex;\n\t\t\tthis.lazyLoadIndex = start + 25;\n\n\t\t\tconst models = parentCollection.models.slice(start, this.lazyLoadIndex);\n\t\t\tmodels.forEach(_.partial(this.addChildView.bind(this), _, true));\n\n\t\t\tlet additionalOpts = this.childView.lazyLoad;\n\t\t\tif (_.isFunction(additionalOpts)) {\n\t\t\t\tadditionalOpts = additionalOpts.call(this);\n\t\t\t}\n\n\t\t\tmodels.length &&\n\t\t\t\tthis.Plugins.Initialize(\n\t\t\t\t\t'lazyloader',\n\t\t\t\t\tthis.$el,\n\t\t\t\t\t_.extend(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tchildrenEl: this.$childTargetEl[0],\n\t\t\t\t\t\t\ttarget: this,\n\t\t\t\t\t\t\tforwardOnly: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tadditionalOpts,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t}\n\t\t// Show everything we've got\n\t\telse {\n\t\t\tparentCollection.each((m) => this.addChildView(m, true));\n\t\t}\n\t},\n\n\t/** @method */\n\tcleanUpChildViews() {\n\t\t// Remove any children we may have.\n\t\t_.invoke(this.childViews, 'remove');\n\t\tdelete this.childViews;\n\t},\n\n\t/**\n\t * @method\n\t */\n\tdetachChildViews() {\n\t\t// protect child views from losing their event listeners:\n\t\t// remove them from this.$el before we call .html() on it.\n\t\t// http://tbranyen.com/post/missing-jquery-events-while-rendering\n\t\t_.each(this.childViews, (v) => v.$el.detach());\n\t},\n\n\t/**\n\t * @method\n\t * @param {Netx.Model} model Model\n\t * @return {Netx.View} Child view\n\t */\n\tgetChildViewByModel(model) {\n\t\tconst childViews = this.childViews;\n\n\t\t// Simplest way (should always work)\n\t\tlet childView = childViews[model.cid];\n\t\tif (childView) {\n\t\t\treturn childView;\n\t\t}\n\n\t\t// But if not, the next simple way is to get it via the order in the child view collection\n\t\tconst collection = this.getChildViewCollection();\n\t\tif (collection) {\n\t\t\tconst idx = collection.indexOf(model);\n\t\t\tchildView =\n\t\t\t\tidx > -1 && childViews[collection.at(collection.indexOf(model)).cid];\n\t\t\tif (childView.model === model) return childView;\n\t\t}\n\n\t\t// If SOMEHOW nothing above worked, loop ovet child views and find the first one that has\n\t\t// the modeltied to it\n\t\tfor (let key in childViews) {\n\t\t\tif (childViews.hasOwnProperty(key)) {\n\t\t\t\tchildView = childViews[key];\n\t\t\t\tif (childView.model.cid === model.cid) {\n\t\t\t\t\treturn childView;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\t/**\n\t * @method\n\t * @return {module:core/lib/netx-collection} Collection\n\t */\n\tgetChildViewCollection() {\n\t\t// View have a collection\n\t\t// This is to avoid the fact we try and push a different (t initialize in some childView parents\n\t\t// that is fine in itself - except for when you want loading classes to reflect that collection in the childView\n\t\tconst childViewCollection = this.childView.collection;\n\t\t// This is to avoid the fact we try and push a different collection in at initialize in some childView parents\n\t\t// that is fine in itself - except for when you want loading classes to reflect that collection in the childView\n\t\tlet parentCollection;\n\t\tif (childViewCollection) {\n\t\t\tparentCollection = _.isFunction(childViewCollection)\n\t\t\t\t? childViewCollection(this.model)\n\t\t\t\t: childViewCollection;\n\t\t}\n\t\treturn parentCollection || this.collection;\n\t},\n\n\t/**\n\t * @method\n\t */\n\tinitializeLazyLoad() {\n\t\tthis.lazyLoadedForward = this.reachedBeginning = true;\n\t\tthis.reachedEnd = false;\n\t\tthis.lazyLoadIndex = 0;\n\t},\n\n\t/**\n\t * @method\n\t * @return {number} Items loading\n\t */\n\tlazyLoadItems() {\n\t\tif (this.reachedEnd) return false;\n\n\t\tconst parentCollection = this.getChildViewCollection();\n\n\t\tconst pageSize = 3;\n\t\tconst totalItems = parentCollection.length;\n\n\t\t// Always forward\n\t\tthis.lazyLoadedForward = true;\n\n\t\tthis.reachedEnd = this.lazyLoadIndex >= totalItems - 1;\n\n\t\tconst start = this.lazyLoadIndex;\n\t\tthis.lazyLoadIndex = start + pageSize;\n\t\tparentCollection.models\n\t\t\t.slice(start, this.lazyLoadIndex)\n\t\t\t.forEach((model) => this.addChildView(model, true));\n\n\t\treturn totalItems === 0 ? 0 : false;\n\t},\n\n\t/**\n\t * @method\n\t * @param {number} oldIndex Old index\n\t * @param {number} newIndex New index\n\t * @param {object} opts Options\n\t * @property {object} opts - Options\n\t * @property {boolean} opts.ignoreCollection - If true, the child view collection model order will not be modified\n\t * @property {boolean} opts.ignoreEl - If true, the child view elements order will not be modified\n\t */\n\tmoveChildViewToIndex(oldIndex, newIndex, opts = {}) {\n\t\tif (newIndex === oldIndex) return this;\n\n\t\t// Child view collection\n\t\tconst collection = this.getChildViewCollection();\n\n\t\t// Assume the collection is up to date and it is a view trying to catch up (in cases where multiple views use the same child view collection)\n\t\t// in which case we are using the newIndex as our point of reference for data\n\t\tconst idx = opts.ignoreCollection ? newIndex : oldIndex;\n\n\t\t// Get the model being moved\n\t\tconst temp = collection.at(idx);\n\n\t\t// Get the child view being moved\n\t\tconst childView = this.getChildViewByModel(temp);\n\n\t\tif (!childView) return this;\n\n\t\t// Indexes\n\t\tlet start = oldIndex;\n\t\tlet end = newIndex;\n\t\t// We are modifying everything between the start and end of the move\n\t\t// Adjust if old index is after the new index, we want to increment from the lowest index\n\t\t// Add 1 to start so that we are not hitting the moving element again - that gets\n\t\tif (oldIndex > newIndex) {\n\t\t\tstart = newIndex + 1;\n\t\t\tend = oldIndex;\n\t\t}\n\n\t\t// Correct placement in DOM\n\t\tif (!opts.ignoreEl) {\n\t\t\t// Detach and preserve\n\t\t\tchildView.$el.detach();\n\n\t\t\t// Beginning\n\t\t\tif (newIndex === 0) {\n\t\t\t\tchildView.$el.prependTo(this.$childTargetEl);\n\t\t\t}\n\t\t\t// End\n\t\t\telse if (idx === collection.length - 1) {\n\t\t\t\tchildView.$el.appendTo(this.$childTargetEl);\n\t\t\t}\n\t\t\t// Otherwise, insert this view after the previous model's view\n\t\t\telse {\n\t\t\t\tconst previousChildView = this.getChildViewByModel(\n\t\t\t\t\tcollection.at(newIndex - 1),\n\t\t\t\t);\n\t\t\t\t!_.isUndefined(previousChildView)\n\t\t\t\t\t? previousChildView.$el.after(childView.el)\n\t\t\t\t\t: childView.$el.appendTo(this.$childTargetEl);\n\t\t\t}\n\t\t}\n\n\t\t// Correct placement in child view collection (that way subsequent re-renders will maintain the child view order)\n\t\tif (!opts.ignoreCollection && newIndex !== temp.getIndex()) {\n\t\t\t// Remove it, silently\n\t\t\tcollection.remove(temp, {silent: true});\n\t\t\t// Add it back in at the new index, silently (we will fire an event when this is over)\n\t\t\tcollection.add(temp, {at: newIndex, silent: true});\n\t\t}\n\n\t\t// Loop over and emit events to all sibling child views affected by this move\n\t\tfor (let i = start, cv; i <= end; i++) {\n\t\t\tcv = this.getChildViewByModel(collection.at(i));\n\t\t\tcv && cv.trigger('movedToIndex', cv, this, {from: i - 1, to: i});\n\t\t}\n\t\t// We moved\n\t\tchildView.trigger(\n\t\t\t'movedToIndex',\n\t\t\tchildView,\n\t\t\tthis,\n\t\t\t_.extend({}, opts, {from: oldIndex, to: newIndex}),\n\t\t);\n\n\t\t// Corrected placement in collection\n\t\tif (!opts.ignoreCollection) {\n\t\t\tcollection.trigger(\n\t\t\t\t'movedItem',\n\t\t\t\tcollection,\n\t\t\t\tchildView,\n\t\t\t\tthis,\n\t\t\t\t_.extend({}, opts, {from: oldIndex, to: newIndex}),\n\t\t\t);\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * @method\n\t */\n\tprepareChildViews() {\n\t\tif (!this.childView) return;\n\n\t\t// Wait until we have rendered, as childViews could be trying to add themselves before this.$el\n\t\t// has anything in it, in which case they wind up in the root of this.$el (for a brief second)\n\t\t// This method cleans up any existing listeners as well - so no need to manage that here\n\t\tthis.addChildViewListeners();\n\n\t\t// Put back child filter string if available\n\t\tif (this._childViewFilterStr) {\n\t\t\tconst $childSearchFilter = this.$('.nx-filter-children');\n\t\t\tif ($childSearchFilter.length) {\n\t\t\t\t$childSearchFilter.val(this._childViewFilterStr);\n\t\t\t}\n\t\t}\n\n\t\t// Unset before moving forward\n\t\tdelete this.$childTargetEl;\n\n\t\tconst childViewTarget = this.childView.target;\n\t\tif (childViewTarget === false) {\n\t\t\tthis.$childTargetEl = this.$el;\n\t\t} else if (childViewTarget) {\n\t\t\tif (_.isFunction(childViewTarget)) {\n\t\t\t\t// TODO: support this being a function so that we can have a way to do our split column childViews -\n\t\t\t\t// really, here we would negate `this.$childTargetEl` and in the `addChildView` method if `this.$childTargetEl` is undefined\n\t\t\t\t// we would check if it is a function - call the function and pass the child view's model and the view can tell us where it should be\n\t\t\t\t// appended\n\t\t\t} else {\n\t\t\t\tthis.$childTargetEl = this.$(childViewTarget);\n\t\t\t}\n\t\t}\n\t\t// Target was either not provided or could not be found\n\t\tif (!this.$childTargetEl || this.$childTargetEl.length === 0) {\n\t\t\tconst childviewTarget = this.$('.nx-childviews:first');\n\t\t\tthis.$childTargetEl = childviewTarget.length\n\t\t\t\t? childviewTarget.first()\n\t\t\t\t: this.$el;\n\t\t}\n\n\t\tif (this.childView.lazyLoad) {\n\t\t\tthis.Plugins.Register({\n\t\t\t\tlazyloader: {\n\t\t\t\t\tname: 'LazyLoader',\n\t\t\t\t\tdestroyMethod(instance) {\n\t\t\t\t\t\tthis.off(instance.destroy());\n\t\t\t\t\t},\n\t\t\t\t\tinitializeMethod(pluginObj, $pluginEl, initOpts, cb) {\n\t\t\t\t\t\tconst instance = new LazyLoader(\n\t\t\t\t\t\t\t$pluginEl[0],\n\t\t\t\t\t\t\t_.extend({}, pluginObj.options, initOpts),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcb(instance);\n\t\t\t\t\t},\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tdirection: 'horizontal',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// Add child views, if defined.\n\t\tthis.addChildViews();\n\t},\n\n\t/**\n\t * @method\n\t */\n\tremoveAllChildViews() {\n\t\t_.invoke(this.childViews, 'remove');\n\t\tthis.childViews = {};\n\t},\n\n\t/**\n\t * Respond to collection remove events by removing the associated childView, if it exists.\n\t * @method\n\t * @private\n\t * @param {Netx.Model} model Model\n\t */\n\tremoveChildView(model, collection, opts = {}) {\n\t\tconst childView = this.childViews[model.cid];\n\t\tif (!childView) return;\n\n\t\tthis.stopListening(childView);\n\t\tchildView.remove();\n\t\tdelete this.childViews[model.cid];\n\t\tthis.trigger('removedChildView', childView);\n\t\treturn childView;\n\t},\n\n\t/**\n\t * @method\n\t * @param {string} event Event\n\t * @param {function} func Callback\n\t */\n\tremoveChildViewListener(event, func) {\n\t\t_.each(this.childViews, (v) => this.stopListening(v, event, func));\n\t},\n\n\t/**\n\t * Remove listners on child views\n\t * @method\n\t */\n\tremoveChildViewListeners(collection) {\n\t\treturn this.stopListening(collection, 'add', this.addedChildViewModel)\n\t\t\t.stopListening(collection, 'sort', this.resetChildViews)\n\t\t\t.stopListening(collection, 'remove', this.removeChildView)\n\t\t\t.stopListening(collection, 'reset', this.resetChildViews)\n\t\t\t.stopListening('addedChildViews');\n\t},\n\n\t/**\n\t * Internal function to reset the child views to match the current collection\n\t * @method\n\t * @private\n\t */\n\tresetChildViews() {\n\t\tconst collection = this.getChildViewCollection();\n\n\t\tif (!collection.length) {\n\t\t\tthis.Plugins.Destroy('lazyloader');\n\t\t\tthis.$childTargetEl.empty();\n\t\t\t_.invoke(this.childViews, 'remove');\n\t\t\tthis.childViews = {};\n\t\t\treturn this;\n\t\t}\n\n\t\t// Detach all child views we have.\n\t\tthis.detachChildViews();\n\t\t// this.trigger('childViewsReset');\n\t\t// Add back the ones we want.\n\t\tthis.addChildViews();\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * Provided a search event, loop over child views and check a particular key, on its model, for the searched value\n\t * @method\n\t * @param {event} e Search event\n\t */\n\tsearchAndFilterChildren(e) {\n\t\t// Search str\n\t\tlet str = '';\n\t\tlet attributeKey = [];\n\t\tlet minimumLength = 2;\n\t\tlet hasResults = true;\n\n\t\tif (e && e.originalEvent) {\n\t\t\t// This ends here - do not want parent views to get this event\n\t\t\te.stopPropagation();\n\t\t\tconst $target = this.$(e.target);\n\n\t\t\t// Do not interfere with children\n\t\t\tif (this.$childTargetEl.find($target).length) return;\n\n\t\t\tif ($target.attr('data-nx-search-key')) {\n\t\t\t\tattributeKey = $target.attr('data-nx-search-key').split(',');\n\t\t\t}\n\t\t\tminimumLength =\n\t\t\t\tparseInt($target.attr('data-nx-search-minLength')) || minimumLength;\n\t\t\tstr = e.originalEvent.detail || '';\n\t\t}\n\n\t\t// Store so we can put back after renders\n\t\tthis._childViewFilterStr = str;\n\n\t\t// Lowercase it\n\t\tstr = str.toLowerCase();\n\n\t\tif (str.length < minimumLength) {\n\t\t\t// show all child search views\n\t\t\t_.each(this.childViews, (cv) => cv.$el.show());\n\t\t\tthis.el.removeAttribute('data-nx-no-matches');\n\t\t} else if (str.length >= minimumLength) {\n\t\t\tlet shown = 0;\n\t\t\t// hide all search views that don't match this string\n\t\t\t_.each(this.childViews, (cv) => {\n\t\t\t\tconst model = cv.model;\n\t\t\t\tlet show = attributeKey.some((attrKey) => {\n\t\t\t\t\tconst value = model.get(attrKey);\n\t\t\t\t\treturn value != null && value.toLowerCase().includes(str);\n\t\t\t\t});\n\t\t\t\t// Fallback to model title\n\t\t\t\tif (!show) {\n\t\t\t\t\tshow = model.getLabel().toLowerCase().includes(str);\n\t\t\t\t}\n\t\t\t\tshow && shown++;\n\t\t\t\tcv.$el.toggle(show);\n\n\t\t\t\t// make sure the first child view\n\t\t\t\t// is tabable when filtering\n\t\t\t\tif (show && shown === 1) {\n\t\t\t\t\tcv.$el.attr('tabindex', '0');\n\t\t\t\t}\n\t\t\t});\n\n\t\t\thasResults = shown > 0;\n\n\t\t\tshown === 0\n\t\t\t\t? this.el.setAttribute('data-nx-no-matches', true)\n\t\t\t\t: this.el.removeAttribute('data-nx-no-matches');\n\t\t}\n\n\t\tthis.trigger('filteredChildren', this, hasResults);\n\n\t\treturn hasResults;\n\t},\n};\n\nexport default function (target) {\n\tif (!target || target.hasFunctionality(NAME)) return target;\n\n\ttarget.extendFunctionality(Props);\n\ttarget.__isChildViews__ = true;\n\n\ttarget.addInitializer((instance, opts = {}) => {\n\t\t// As we transition over to react we may find ourselves still stuck with views that extended views\n\t\t// that utilize child functionality - rather than making it so we have to jump through a million hoopd\n\t\t// or rewrite the thing entirely... just provide a quick way to opt out\n\t\tif (opts.disableChildViews === true) return;\n\n\t\tinstance.isChildViews = true;\n\t\tinstance.childViews = {};\n\n\t\t// Simply add an `` to the tmeplate and you can filter the children\n\t\t// It defaults to comparing the search string to the model attribute `name` - if you need to compare to a different attribute use `data-nx-search-key=\"myDesiredKey\"`\n\t\t// It defaults to a minimum input length of 2 before filtering, if you need to modify this use `data-nx-search-minLength=\"5\"`\n\t\tinstance.events['search .nx-filter-children'] = 'searchAndFilterChildren';\n\t\t/**\n\t\t * Store so that we can put back after renders\n\t\t * @memberOf Netx.View\n\t\t * @alias _childViewFilterStr\n\t\t * @type {string}\n\t\t */\n\t\tinstance._childViewFilterStr = '';\n\n\t\tinstance.childView = opts.childView;\n\n\t\t// Wrap the excluded views method\n\t\tinstance.getExcludedViews = _.wrap(\n\t\t\tinstance.getExcludedViews,\n\t\t\t(getExcludedViews) => {\n\t\t\t\treturn _.pluck(instance.childViews, 'el').concat(\n\t\t\t\t\tgetExcludedViews.call(instance),\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\n\t\tif (!instance.unsavedChanges) {\n\t\t\tinstance.unsavedChanges = (unsavedChanges, noProxy) => {\n\t\t\t\tlet hasUnsavedChanges = false;\n\t\t\t\tconst childViews = instance.childViews;\n\t\t\t\tconst keys = _.keys(childViews);\n\t\t\t\tfor (let i = 0, c = keys.length, childView; i < c; i++) {\n\t\t\t\t\tchildView = childViews[keys[i]];\n\t\t\t\t\tif (childView.unsavedChanges()) {\n\t\t\t\t\t\treturn noProxy ? childView : instance;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\t// Hey, listen!\n\t\tinstance\n\t\t\t.on('preRenderHook', instance.detachChildViews)\n\t\t\t.on('postRenderHook', instance.prepareChildViews)\n\t\t\t.on('removeHook', instance.cleanUpChildViews)\n\t\t\t.on('bindCollectionEventsHook', instance.addChildViewListeners)\n\t\t\t//.on('unbindCollectionEventsHook', instance.removeChildViewListeners)\n\t\t\t// cancel loading classes if child views are added.\n\t\t\t// This passes the childView to showLoaded which hurts the loading class removal\n\t\t\t// We no longer check that thing is of model or collection in showLoaded\n\t\t\t// this.listenTo(this, \"addedChildView\", _.debounce( this.showLoaded, 100 ) );\n\t\t\t.on('addedChildViews', () => {\n\t\t\t\tinstance.showLoaded();\n\t\t\t})\n\t\t\t.on('hidden', () => {\n\t\t\t\t_.invoke(instance.childViews, 'trigger', 'hiddenByProxy', instance);\n\t\t\t})\n\t\t\t.on('shown', () => {\n\t\t\t\t_.invoke(instance.childViews, 'trigger', 'shownByProxy', instance);\n\t\t\t});\n\t}, NAME);\n\n\treturn target;\n}\n"],"sourceRoot":""}