Files
parts_website/static/dist/js/17.bundle.js

1 line
21 KiB
JavaScript

"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[17],{243:(t,e,a)=>{a.d(e,{v:()=>c});var n=a(595),o=a(143),i=a(402);function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function l(t,e){for(var a=0;a<e.length;a++){var n=e[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,u(n.key),n)}}function u(t){var e=function(t){if("object"!=r(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var a=e.call(t,"string");if("object"!=r(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==r(e)?e:e+""}var c=function(){function t(){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.title=titlePageCurrent,this.constructor===t)throw new Error("Cannot instantiate abstract class");if(!this.constructor.hash)throw new Error("Class ".concat(this.constructor.name," must have a static hash attribute."))}return e=t,a=[{key:"initialize",value:function(){throw new Error("Method 'initialize()' must be implemented.")}},{key:"sharedInitialize",value:function(){this.logInitialisation(),this.hookupCommonElements()}},{key:"logInitialisation",value:function(){console.log("Initializing "+this.title+" page")}},{key:"hookupCommonElements",value:function(){this.hookupNavigation(),this.hookupImagesLogo()}},{key:"hookupNavigation",value:function(){console.log("hooking up navigation");var t=document.querySelector(idOverlayHamburger).querySelectorAll("div."+flagRow).length;console.log("count nav options: ",t),initialiseEventHandler(idButtonHamburger,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation();var e=document.querySelector(idOverlayHamburger);e.classList.contains(flagCollapsed)?(e.classList.remove(flagCollapsed),e.classList.add(flagExpanded)):(e.classList.remove(flagExpanded),e.classList.add(flagCollapsed))}))})),this.hookupButtonNavHome(),this.hookupButtonNavServices(),this.hookupButtonNavContact(),this.hookupButtonNavUserAccount(),this.hookupButtonNavUserLogout(),this.hookupButtonNavUserLogin(),this.hookupButtonNavStoreHome(),this.hookupButtonNavStoreProductPermutations(),this.hookupButtonNavStoreStockItems(),this.hookupButtonNavAdminHome()}},{key:"hookupButtonNavHome",value:function(){initialiseEventHandler("."+flagNavHome,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),i.Q.navigateToHash(hashPageHome)}))}))}},{key:"hookupButtonNavServices",value:function(){initialiseEventHandler("."+flagNavServices,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),console.log("going to services page"),i.Q.navigateToHash(hashPageServices)}))}))}},{key:"hookupButtonNavContact",value:function(){initialiseEventHandler("."+flagNavContact,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),i.Q.navigateToHash(hashPageContact)}))}))}},{key:"hookupButtonNavUserAccount",value:function(){initialiseEventHandler("."+flagNavUserAccount,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),i.Q.navigateToHash(hashPageUserAccount)}))}))}},{key:"hookupButtonNavUserLogout",value:function(){initialiseEventHandler("."+flagNavUserLogout,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),i.Q.navigateToHash(hashPageUserLogout)}))}))}},{key:"hookupButtonNavUserLogin",value:function(){initialiseEventHandler("."+flagNavUserLogin,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),n.A.loginUser().then((function(t){t.Success?window.app.router.navigateToUrl(t[keyCallback],null,!1):alertError("Error",t.Message)}))}))}))}},{key:"hookupButtonNavStoreHome",value:function(){initialiseEventHandler("."+flagNavStoreHome,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),i.Q.navigateToHash(hashPageStoreHome)}))}))}},{key:"hookupButtonNavStoreProductCategories",value:function(){initialiseEventHandler("."+flagNavStoreProductCategories,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),i.Q.navigateToHash(hashPageStoreProductCategories)}))}))}},{key:"hookupButtonNavStoreProducts",value:function(){initialiseEventHandler("."+flagNavStoreProducts,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),i.Q.navigateToHash(hashPageStoreProducts)}))}))}},{key:"hookupButtonNavStoreProductPermutations",value:function(){initialiseEventHandler("."+flagNavStoreProductPermutations,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),i.Q.navigateToHash(hashPageStoreProductPermutations)}))}))}},{key:"hookupButtonNavStoreProductPrices",value:function(){initialiseEventHandler("."+flagNavStoreProductPrices,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),i.Q.navigateToHash(hashPageStoreProductPrices)}))}))}},{key:"hookupButtonNavStoreProductVariations",value:function(){initialiseEventHandler("."+flagNavStoreProductVariations,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),i.Q.navigateToHash(hashPageStoreProductVariations)}))}))}},{key:"hookupButtonNavStoreStockItems",value:function(){initialiseEventHandler("."+flagNavStoreStockItems,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),i.Q.navigateToHash(hashPageStoreStockItems)}))}))}},{key:"hookupButtonNavAdminHome",value:function(){initialiseEventHandler("."+flagNavAdminHome,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),i.Q.navigateToHash(hashPageAdminHome)}))}))}},{key:"hookupImagesLogo",value:function(){var t="img."+flagImageLogo;initialiseEventHandler(t,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),i.Q.navigateToHash(hashPageHome)}))}))}},{key:"hookupOverlayFromId",value:function(t){initialiseEventHandler(t,flagInitialised,(function(t){t.querySelector("button."+flagClose).addEventListener("click",(function(e){e.stopPropagation(),t.css("display","none")}))}))}},{key:"hookupButtonSave",value:function(){initialiseEventHandler("form."+flagFilter+" button."+flagSave,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),showOverlayConfirm()})),t.classList.add(flagCollapsed)}))}},{key:"hookupVideos",value:function(){initialiseEventHandler("video",flagInitialised,(function(t){t.addEventListener("mouseover",videoPlay(t)),t.addEventListener("mouseout",videoPause(t))}))}},{key:"leave",value:function(){if(console.log("Leaving "+this.title+" page"),_pageCurrent=null,this.constructor===t)throw new Error("Must implement leave() method.")}},{key:"setLocalStoragePage",value:function(t){setLocalStorage(this.constructor.hash,t)}},{key:"getLocalStoragePage",value:function(){return getLocalStorage(this.constructor.hash)}},{key:"toggleShowButtonsSaveCancel",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;null==e&&(e=document.querySelector("form."+flagFilter+" button."+flagSave)),null==a&&(a=document.querySelector("form."+flagFilter+" button."+flagCancel)),t?(a.classList.remove(flagCollapsed),e.classList.remove(flagCollapsed)):(a.classList.add(flagCollapsed),e.classList.add(flagCollapsed))}}],r=[{key:"isDirtyFilter",value:function(t){var e=o.A.isElementDirty(t);return e&&document.querySelectorAll(idTableMain+" tbody tr").remove(),e}}],a&&l(e.prototype,a),r&&l(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,a,r}()},17:(t,e,a)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){for(var a=0;a<e.length;a++){var n=e[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,d(n.key),n)}}function i(t,e,a){return e=u(e),function(t,e){if(e&&("object"==n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,r()?Reflect.construct(e,a||[],u(t).constructor):e.apply(t,a))}function r(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(r=function(){return!!t})()}function l(){return l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,a){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=u(t)););return t}(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(arguments.length<3?t:a):o.value}},l.apply(null,arguments)}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}function c(t,e){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},c(t,e)}function s(t,e,a){return(e=d(e))in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function d(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var a=e.call(t,"string");if("object"!=n(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}a.r(e),a.d(e,{PageStoreProductPermutations:()=>f});var f=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),i(this,e)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}(e,t),a=e,n=[{key:"initialize",value:function(){this.sharedInitialize(),hookupFilters(),hookupButtonsSaveCancel(),hookupTableMain(),hookupOverlayConfirm(savePermutations)}},{key:"hookupFilters",value:function(){initialiseEventHandler(idFilterCategory,flagInitialised,(function(t){console.log("hooking up filter category"),t.addEventListener("change",(function(t){loadPermutations()})),console.log("hooked up filter category")})),initialiseEventHandler(idFilterProduct,flagInitialised,(function(t){listProducts.forEach((function(e){e[attrIdCategory]==getElementCurrentValue(document.querySelectorAll(idFilterCategory))&&t.appendChild(document.createElement("<option>",e))})),t.addEventListener("change",(function(t){loadPermutations()}))})),initialiseEventHandler(idFilterIsOutOfStock,flagInitialised,(function(t){t.addEventListener("change",(function(t){loadPermutations()}))})),initialiseEventHandler(idFilterQuantityMin,flagInitialised,(function(t){t.addEventListener("change",(function(t){loadPermutations()}))})),initialiseEventHandler(idFilterQuantityMax,flagInitialised,(function(t){t.addEventListener("change",(function(t){loadPermutations()}))}))}},{key:"loadPermutations",value:function(){var t=document.querySelectorAll(idFormFiltersPermutations),e={};e[keyForm]=convertForm2JSON(t),e.csrf_token=e[keyForm].csrf_token,console.log("ajaxData:"),console.log(e),ajaxJSONData("permutations",mapHashToController(hashPageStorePermutationsPost),e,callbackLoadPermutations,!1,{"X-CSRFToken":e.csrf_token})}},{key:"callbackLoadPermutations",value:function(t){console.log("ajax:"),console.log(t.data);var e,a,n,o=document.querySelectorAll(idTableMain);(e=o.querySelector("tbody")).querySelector("tr").remove(),t.data.forEach((function(t){a=_rowBlank.cloneNode(!0),(a=document.querySelectorAll(a)).classList.remove(flagRowNew),console.log("applying data row: ",t),a.querySelector("td."+flagCategory+" select").value=t[attrIdCategory],n=a.querySelector("td."+flagProduct+" select"),listProducts.forEach((function(e){e[attrIdCategory]==t[attrIdCategory]&&n.appendChild(document.createElement("<option>",e))})),n.value=t[attrIdProduct],a.querySelector("td."+flagVariations+" textarea").value=t[flagVariations],a.querySelector("td."+flagQuantityStock+" input").value=t[flagQuantityStock],a.querySelector("td."+flagQuantityMin+" input").value=t[flagQuantityMin],a.querySelector("td."+flagQuantityMax+" input").value=t[flagQuantityMax],a.querySelector("td."+flagCostLocalVATIncl).innerHTML=t[flagCostLocalVATIncl],a.attr(attrIdCategory,t[flagCategory]),a.attr(attrIdProduct,t[flagProduct]),a.attr(attrIdPermutation,t[attrIdPermutation]),e.appendChild(a)}))}},{key:"hookupButtonsSaveCancel",value:function(){initialiseEventHandler(idButtonSave,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),showOverlayConfirm()}))})),initialiseEventHandler(idButtonCancel,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation(),loadPermutations()}))})),initialiseEventHandler(idButtonCancel,flagInitialised,(function(t){t.addEventListener("click",(function(t){t.stopPropagation();var e=document.querySelectorAll(idTableMain),a=_rowBlank.cloneNode(!0);(a=document.querySelectorAll(a)).classList.remove(flagRowNew),a.querySelector("td."+flagCategory+" select");var n=getElementCurrentValue(document.querySelectorAll(idFilterCategory));n=0==n?idCategoryDefault:n;var o=a.querySelector("td."+flagProduct+" select");productsByCategory[n].forEach((function(t){o.appendChild(document.createElement("<option>",t))})),e.querySelector("tbody").appendChild(a)}))}))}},{key:"savePermutations",value:function(){var t=getPermutations(!0);if(0!=t.length){var e={};e[keyPermutations]=t,e[keyForm]=convertForm2JSON(elForm),e.csrf_token=e[keyForm].csrf_token,e.comment=document.querySelectorAll(idTextareaConfirm).value,console.log("ajaxData:"),console.log(e),ajaxJSONData("permutations",mapHashToController(hashPageStorePermutationsPost),e,callbackLoadPermutations,!1,{})}else showOverlayError("No permutations to save")}},{key:"getPermutations",value:function(t){var e,a,n,o,i,r,l,u=document.querySelectorAll(idTableMain),c=[];return u.querySelector("tbody tr").each((function(u,s){s=document.querySelectorAll(s),t&&!s.classList.contains(flagDirty)||(a=s.querySelector("td."+flagCategory+" select"),n=s.querySelector("td."+flagProduct+" select"),o=s.querySelector("td."+flagVariations+" textarea"),i=s.querySelector("td."+flagQuantityStock+" input"),r=s.querySelector("td."+flagQuantityMin+" input"),l=s.querySelector("td."+flagQuantityMax+" input"),(e={})[attrIdCategory]=a.attr(attrValueCurrent),e[attrIdProduct]=n.attr(attrValueCurrent),e[attrIdPermutation]=s.attr(attrIdPermutation),e[flagVariations]=o.attr(attrValueCurrent),e[flagQuantityStock]=i.attr(attrValueCurrent),e[flagQuantityMin]=r.attr(attrValueCurrent),e[flagQuantityMax]=l.attr(attrValueCurrent),c.push(e))})),c}},{key:"hookupTableMain",value:function(){initialiseEventHandler(idTableMain,flagInitialised,(function(t){t.querySelectorAll("td."+flagCategory+" select").addEventListener("change",(function(t){handleChangeInputPermutations(this),ddlCategory=this,row=getRowFromElement(ddlCategory),ddlProduct=row.querySelector("td."+flagProduct+" select"),ddlProduct.querySelector("option").remove(),ddlProduct.appendChild(document.createElement("<option>",{value:"",text:"Select Product"})),listProducts.forEach((function(t){t[attrIdCategory]==getElementCurrentValue(ddlCategory)&&ddlProduct.appendChild(document.createElement("<option>",t))})),handleChangeInputPermutations(ddlProduct)})),t.querySelectorAll("change","td."+flagProduct+" select,td."+flagQuantityStock+" input,td."+flagQuantityMin+" input,td."+flagQuantityMax+" input").addEventListener("change",(function(t){handleChangeInputPermutations(this)})),t.querySelectorAll("click","td."+flagVariations+" textarea").addEventListener("change",(function(t){t.stopPropagation(),handleClickPermutationsInputVariations(this)})),t.querySelectorAll("click","td."+flagDetail+" button").addEventListener("change",(function(t){t.stopPropagation(),console.log("not implemented error: detail clicked")})),t.querySelectorAll("click","td."+flagVariations+" button."+flagAdd).addEventListener("change",(function(t){t.stopPropagation(),handleClickPermutationsVariationsButtonAdd(this)}))}));var t=table.querySelector("tr."+flagRowNew);console.log("row blank temp: ",t),_rowBlank=t.cloneNode(!0),table.querySelectorAll("tr."+flagRowNew).forEach((function(t){t.remove()}))}},{key:"handleChangeInputPermutations",value:function(t){console.log("handleChangeInputPermutations"),console.log("element value:",t.value);var e=getRowFromElement(t),a=document.querySelector(idFormFiltersPermutations),n=a.querySelector(idButtonCancel),o=a.querySelector(idButtonSave),i=isElementDirty(t);if(objJQuery.classList.contains(flagVariations)?t.setAttribute(attrValueCurrent,getProductVariationsText(t)):t.setAttribute(attrValueCurrent,getElementCurrentValue(t)),i!=isElementDirty(t)){isRowDirty(e);var r=getPermutations(!0);isEmpty(r)?(n.classList.add(flagCollapsed),o.classList.add(flagCollapsed)):(n.classList.remove(flagCollapsed),o.classList.remove(flagCollapsed))}}},{key:"isElementDirty",value:function(t){var e=t.attr(attrValuePrevious)!=t.attr(attrValueCurrent),a=getCellFromElement(t);return e?(t.classList.add(flagDirty),a.classList.add(flagDirty)):(t.classList.remove(flagDirty),a.classList.remove(flagDirty)),e}},{key:"isRowDirty",value:function(t){var e=t.querySelector("td."+flagCategory+" select"),a=t.querySelector("td."+flagProduct+" select"),n=t.querySelector("td."+flagVariations+" textarea"),o=t.querySelector("td."+flagQuantityStock+" input"),i=t.querySelector("td."+flagQuantityMin+" input"),r=t.querySelector("td."+flagQuantityMax+" input"),l=e.classList.contains(flagDirty)||a.classList.contains(flagDirty)||n.classList.contains(flagDirty)||o.classList.contains(flagDirty)||i.classList.contains(flagDirty)||r.classList.contains(flagDirty);return l?t.classList.add(flagDirty):t.classList.remove(flagDirty),l}},{key:"getProductVariationsText",value:function(t){return t=document.querySelectorAll(t),dictVariations[t.attr(attrIdVariation)].map((function(t,e){return t[keyNameVariationType]+": "+t[keyNameVariation]})).join(",\n")}},{key:"getElementProductVariations",value:function(t){var e=(t=document.querySelectorAll(t)).attr(attrValueCurrent),a=[];return isEmpty(e)||(e=e.split(",")).forEach((function(t){var e=t.split(":");2==e.length&&a.push(s(s({},attrIdVariationType,e[0].trim()),attrIdVariation,e[1].trim()))})),a}},{key:"handleClickPermutationsInputVariations",value:function(t){var e,a,n,o,i,r,l,u,c,s,d,f;t=document.querySelectorAll(t);var g=getElementProductVariations(t),p=document.createElement("<table>"),v=document.createElement("<thead>");n=document.createElement("<tr>");var y=document.createElement("<th>",{text:"Type"}),m=document.createElement("<th>",{text:"Name"}),h=document.createElement("<button>",{class:flagAdd,text:"+"}),k=document.createElement("<th>");k.appendChild(h),n.appendChild(y),n.appendChild(m),n.appendChild(k),v.appendChild(n),p.appendChild(v);var P=document.createElement("<tbody>");console.log("variations:",g),g.forEach((function(t,g){a=dictVariations[t[attrIdVariationType]],e=dictVariations[t[attrIdVariation]],o=document.createElement("<td>",{class:attrIdVariationType}),(r={class:attrIdVariationType,value:t[attrIdVariationType]})[attrValueCurrent]=e[attrIdVariationType],r[attrValuePrevious]=e[attrIdVariationType],i=document.createElement("<select>",r),listVariationTypes.forEach((function(t){dictVariationTypes[t],i.appendChild(document.createElement("<option>",{value:a[attrIdVariationType],text:a[keyNameVariationType],selected:t==a[attrIdVariationType]}))})),l=document.createElement("<td>",{class:attrIdVariation}),(c={class:attrIdVariation,value:t[attrIdVariation]})[attrValueCurrent]=e[attrIdVariation],c[attrValuePrevious]=e[attrIdVariation],u=document.createElement("<select>",c),listVariations.forEach((function(t){f=dictVariations[t],console.log("id_variation: ",t),console.log("tmpJsonVariation: ",f),u.appendChild(document.createElement("<option>",{value:f[attrIdVariation],text:f[keyNameVariation],selected:t==e[attrIdVariation]}))})),s=document.createElement("<td>",{class:flagDelete}),d=document.createElement("<button>",{class:flagDelete,text:"x"}),n=document.createElement("<tr>"),o.appendChild(i),n.appendChild(o),l.appendChild(u),n.appendChild(l),s.appendChild(d),n.appendChild(s),P.appendChild(n)})),p.appendChild(P);var S=t.parentElement;S.innerHTML="",S.appendChild(p),console.log("tblVariations: ",p)}},{key:"handleClickPermutationsVariationsButtonAdd",value:function(t){t=document.querySelectorAll(t);var e=getRowFromElement(t).querySelector("td."+flagVariations+" textarea"),a=e.value;a=isEmpty(a)?"":a+"\n",a+="Type: Variation\n",e.value=a,handleChangeInputPermutations(e),console.log("error: not implemented")}},{key:"leave",value:function(){var t,a,n;(t=e,a=this,"function"==typeof(n=l(u(1&3?t.prototype:t),"leave",a))?function(t){return n.apply(a,t)}:n)([])}}],n&&o(a.prototype,n),Object.defineProperty(a,"prototype",{writable:!1}),a;var a,n}(a(243).v);s(f,"hash",hashPageStoreProductPermutations)}}]);