@crystaldesign/diva-web-planner-react 26.11.0-rc.1 → 26.11.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see 3596.diva-web-planner-react.umd.min.js.LICENSE.txt */
|
|
2
|
-
"use strict";(self.webpackChunkCrystaldesignDivaWebPlannerReact=self.webpackChunkCrystaldesignDivaWebPlannerReact||[]).push([[3596],{33596:(e,t,i)=>{i.r(t),i.d(t,{default:()=>v});var r=i(84658),s=i(12952),n=i(13125),l=i(43860),a=i(80248),c=i(50747),o=i.n(c),d=i(69369),h=i(37609),u=i(35215),f=i(69821);function ownKeys(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}var g=d.ZP.initLog("Planner","WEB-PLANNER-LOGIC"),v=function(){return(0,l.Z)((function ShelfPlanner(e,t){if((0,n.Z)(this,ShelfPlanner),(0,a.Z)(this,"article",void 0),(0,a.Z)(this,"grids",[]),(0,a.Z)(this,"isVisible",void 0),(0,a.Z)(this,"showOnRule",void 0),(0,a.Z)(this,"showAfterOPT",void 0),(0,a.Z)(this,"data",void 0),(0,a.Z)(this,"freeArticlesPossible",{}),(0,a.Z)(this,"freeArticlesPlanned",{}),(0,a.Z)(this,"gridAllowedOnCells",void 0),(0,a.Z)(this,"gridAllowedOntoArticles",void 0),(0,a.Z)(this,"takePlaceOnOtherGrids",void 0),(0,a.Z)(this,"disableCellsByElement",void 0),(0,a.Z)(this,"montageOptions",[]),(0,a.Z)(this,"shelfDebugStack",[]),(0,a.Z)(this,"shelfDebugSeq",0),(0,a.Z)(this,"restorePending",void 0),(0,a.Z)(this,"stashedAccessoires",{}),this.article=t,this.restorePending=!!t.shelfPlanData,this.disableCellsByElement=e.DisableCells,this.data=e,this.showAfterOPT=e.ShowAfterOPT,this.showOnRule=e.ShowOnRule?d.ZP.getRuleByFormula(e.ShowOnRule,t.catalogCodex,t.CatalogData.multiselectOptions):void 0,this.gridAllowedOnCells=e.GridAllowedOnCells,this.gridAllowedOntoArticles=e.GridAllowedOntoArticles,this.takePlaceOnOtherGrids=e.TakePlaceOnOtherGrids,this.initFreeArticles(),e.ShelfPlanner&&e.ShelfPlanner.length>0){for(var i=0;i<e.ShelfPlanner.length;i++)this.creatNewGrid(i),this.updateDisabledCells();this.montageOptions=(0,s.Z)(new Set(this.grids.reduce((function(e,t){return e=e.concat(t.montageOptionsList)}),[])))}}),[{key:"logShelfDebug",value:function logShelfDebug(e){this.shelfDebugStack.push(function _objectSpread(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(i),!0).forEach((function(t){(0,a.Z)(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({seq:this.shelfDebugSeq++},e)),this.shelfDebugStack.length>500&&this.shelfDebugStack.splice(0,this.shelfDebugStack.length-500)}},{key:"initFreeArticles",value:function initFreeArticles(){if(this.data.ShelfPlanner)for(var e=0;e<this.data.ShelfPlanner.length;e++){var t=this.data.ShelfPlanner[e];if(t.initAccArr)for(var i=0;i<t.initAccArr.length;i++){var r=t.initAccArr[i];r.noPrice&&(void 0===this.freeArticlesPossible[r.Codex]&&(this.freeArticlesPossible[r.Codex]=0),this.freeArticlesPossible[r.Codex]+=r.Quantity)}}}},{key:"IsVisible",get:function get(){return this.isVisible}},{key:"RestorePending",get:function get(){return this.restorePending},set:function set(e){this.restorePending=e}},{key:"setIsVisible",value:(C=(0,r.Z)(o().mark((function _callee(e){return o().wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:if(this.isVisible==e){t.next=13;break}if(this.logShelfDebug({phase:"visibility",action:e?"plannerShown":"plannerHidden",detail:e?void 0:"showOnRule/visibility turned false — all placed accessories are deleted"}),!e){t.next=11;break}if(this.isVisible=e,this.article.shelfPlanData){t.next=9;break}return t.next=7,this.onConfigChanged({});case 7:return t.next=9,this.initAccList();case 9:t.next=13;break;case 11:return t.next=13,this.deleteAllAcc();case 13:this.isVisible=e;case 14:case"end":return t.stop()}}),_callee,this)}))),function setIsVisible(e){return C.apply(this,arguments)})},{key:"onConfigChanged",value:(y=(0,r.Z)(o().mark((function _callee2(e){var t,i,r,s,n,l,a,c,d,h,u,f;return o().wrap((function _callee2$(o){for(;;)switch(o.prev=o.next){case 0:for(t=!1,i=[],r=0;r<this.grids.length;r++)i.push(this.grids[r].onConfigChanged());s=0;case 4:if(!(s<i.length)){o.next=13;break}if(i[s].length){o.next=7;break}return o.abrupt("continue",10);case 7:n=this.grids[s],i[s].includes("disableGridRule")&&this.logShelfDebug({phase:"configChanged",action:n.DisabledByRule?"gridDisabledByRule":"gridEnabledByRule",gridIndex:n.ShelfIndex,detail:n.ShowOnRule}),i[s].includes("heightGridRule")&&this.logShelfDebug({phase:"configChanged",action:"gridRecreated",gridIndex:n.ShelfIndex,detail:"HeightGridCellCountOnRule match changed — grid rebuilt (cell count / placeable accessories can change), its accessories are deleted"});case 10:s++,o.next=4;break;case 13:l=0;case 14:if(!(l<i.length)){o.next=23;break}if(i[l].length){o.next=17;break}return o.abrupt("continue",20);case 17:return this.stashAccessoiresOfGrid(l),o.next=20,this.grids[l].deleteAllAccOfGrid();case 20:l++,o.next=14;break;case 23:a=0;case 24:if(!(a<i.length)){o.next=40;break}if(i[a].length){o.next=27;break}return o.abrupt("continue",37);case 27:if(i[a].includes("heightGridRule")&&(this.creatNewGrid(a),t=!0),c=this.grids[a],!i[a].includes("heightGridRule")&&!i[a].includes("disableGridRule")||c.DisabledByRule){o.next=37;break}if(!this.restorePending){o.next=32;break}return o.abrupt("continue",37);case 32:return o.next=34,this.placeStashedAccessoiresOfGrid(a);case 34:if(o.sent){o.next=37;break}return o.next=37,this.initAccList(a);case 37:a++,o.next=24;break;case 40:if(t||!Object.keys(e).length){o.next=51;break}d=this.activeGrids,h=0;case 43:if(!(h<d.length)){o.next=51;break}if(f=d[h],!(null!==(u=f.DisableCellsByMeasures)&&void 0!==u&&u.options.find((function(t){return Object.keys(e).includes("OPT"+t.opt)}))||f.disableCellsByRules)){o.next=48;break}return t=!0,o.abrupt("break",51);case 48:h++,o.next=43;break;case 51:t&&this.updateDisabledCells();case 52:case"end":return o.stop()}}),_callee2,this)}))),function onConfigChanged(e){return y.apply(this,arguments)})},{key:"creatNewGrid",value:function creatNewGrid(e){this.grids[e]=new u.Z(e,this.article,this.data),this.grids[e].onConfigChanged()}},{key:"stashAccessoiresOfGrid",value:function stashAccessoiresOfGrid(e){var t=this.collectAccessoiresToStash(this.grids[e]);t.length&&(this.stashedAccessoires[e]=t)}},{key:"collectAccessoiresToStash",value:function collectAccessoiresToStash(e){for(var t=[],i=0;i<e.Cells.length;i++){var r=e.Cells[i],s=r.Article;if(r.InUse===i&&s){for(var n={},l=s.shelfPlanner,a=0;a<(null!==(c=null==l?void 0:l.grids.length)&&void 0!==c?c:0);a++){var c,o=l.grids[a],d=l.collectAccessoiresToStash(o);d.length&&(n[o.ShelfIndex]=d)}t.push({articleCodex:s.articleCodex,cellIndex:i,noMove:r.NoMove,noDelete:r.NoDelete,quantity:s.quantity,variantValues:s.VariantValues,accessoires:n})}}return t}},{key:"placeStashedAccessoiresOfGrid",value:(x=(0,r.Z)(o().mark((function _callee3(e){var t;return o().wrap((function _callee3$(i){for(;;)switch(i.prev=i.next){case 0:if(null!=(t=this.stashedAccessoires[e])&&t.length){i.next=3;break}return i.abrupt("return",0);case 3:return delete this.stashedAccessoires[e],i.next=6,this.placeStashedAccessoiresInGrid(e,t);case 6:return i.abrupt("return",i.sent);case 7:case"end":return i.stop()}}),_callee3,this)}))),function placeStashedAccessoiresOfGrid(e){return x.apply(this,arguments)})},{key:"placeStashedAccessoiresByGrid",value:(p=(0,r.Z)(o().mark((function _callee4(e){var t,i,r,s;return o().wrap((function _callee4$(n){for(;;)switch(n.prev=n.next){case 0:t=Object.keys(e),i=0;case 2:if(!(i<t.length)){n.next=14;break}return s=Number(t[i]),n.next=6,null===(r=this.getGridByIndex(s))||void 0===r?void 0:r.deleteAllAccOfGrid();case 6:return n.next=8,this.placeStashedAccessoiresInGrid(s,e[s]);case 8:if(n.sent){n.next=11;break}return n.next=11,this.initAccList(s);case 11:i++,n.next=2;break;case 14:case"end":return n.stop()}}),_callee4,this)}))),function placeStashedAccessoiresByGrid(e){return p.apply(this,arguments)})},{key:"placeStashedAccessoiresInGrid",value:(A=(0,r.Z)(o().mark((function _callee5(e,t){var i,r,s,n,l,a,c;return o().wrap((function _callee5$(o){for(;;)switch(o.prev=o.next){case 0:if(i=0,r=this.getGridByIndex(e)){o.next=4;break}return o.abrupt("return",i);case 4:s=0;case 5:if(!(s<t.length)){o.next=28;break}return n=t[s],r.ActAccessoire=n.articleCodex,o.next=10,h.Z.addAccessorieOnShelfPlanner(this.article.set,e,n.cellIndex,this.article.basketId,{noMove:n.noMove,noDelete:n.noDelete,byInit:!0});case 10:if(l=o.sent,r.ActAccessoire=void 0,a=!1===l||void 0===l.index?void 0:l,c=null==a?void 0:a.accessoire,a&&c){o.next=17;break}return g.error(new d.GE("shelfaccessoire of a switched off grid does not fit anymore and gets dropped",{code:"WC_0015",custom:{stashed:n,gridName:r.GridName,result:l,parentPosNr:this.article.posNr,parentArticleCodex:this.article.articleCodex,parentBasketId:this.article.basketId}})),o.abrupt("continue",25);case 17:if(c.quantity=n.quantity,i++,!Object.keys(n.variantValues).length){o.next=22;break}return o.next=22,f.Z.updateCfgValues(c,n.variantValues,{});case 22:if(!c.shelfPlanner){o.next=25;break}return o.next=25,c.shelfPlanner.placeStashedAccessoiresByGrid(n.accessoires);case 25:s++,o.next=5;break;case 28:return o.abrupt("return",i);case 29:case"end":return o.stop()}}),_callee5,this)}))),function placeStashedAccessoiresInGrid(e,t){return A.apply(this,arguments)})},{key:"initAccList",value:(k=(0,r.Z)(o().mark((function _callee6(e){var t,i,r,s,n,l,a,c,d,u,f,g;return o().wrap((function _callee6$(o){for(;;)switch(o.prev=o.next){case 0:t=this.activeGrids,i=0;case 2:if(!(i<t.length)){o.next=37;break}if(r=t[i],void 0===e||r.ShelfIndex===e){o.next=6;break}return o.abrupt("continue",34);case 6:if(r.InitAccArr){o.next=8;break}return o.abrupt("continue",34);case 8:s=0;case 9:if(!(s<r.InitAccArr.length)){o.next=34;break}n=r.InitAccArr[s],l=0;case 12:if(!(l<n.initRH.length)){o.next=31;break}return r.ActAccessoire=n.Codex,this.logShelfDebug({phase:"initAccessories",action:"initAccessoryRequested",gridIndex:r.ShelfIndex,cellIndex:n.initRH[l],articleCodex:n.Codex,detail:"from InitAccArr — a missing matching accessoryPlaced entry right after means the init placement failed"}),o.next=17,h.Z.addAccessorieOnShelfPlanner(this.article.set,r.ShelfIndex,n.initRH[l],r.basketId,{noMove:n.noMove,noDelete:n.noDelete,byInit:!0});case 17:if(!n.replaceFromParent){o.next=27;break}if(!(c=this.getShelfParentShelfId())||null===(a=this.article.accessoireParentArticle)||void 0===a||!a.shelfPlanner){o.next=27;break}if(!((d=this.article.accessoireParentArticle.shelfPlanner.getAccessorireByCodex(c,n.Codex))&&d.length>0)){o.next=27;break}if(f=d[0],void 0===(g=null===(u=f.shelfPlanner)||void 0===u?void 0:u.getRHOnParentArticle())||void 0===f.relatedToShelfGrid){o.next=27;break}return o.next=27,h.Z.deleteAccessorieOnShelfPlanner(this.article.set,f.relatedToShelfGrid,g,this.article.accessoireParentArticle.basketId);case 27:r.ActAccessoire=void 0;case 28:l++,o.next=12;break;case 31:s++,o.next=9;break;case 34:i++,o.next=2;break;case 37:case"end":return o.stop()}}),_callee6,this)}))),function initAccList(e){return k.apply(this,arguments)})},{key:"getAccessorireByCodex",value:function getAccessorireByCodex(e,t){var i=this.grids.find((function(t){return t.ShelfId==e})),r=[];if(i)for(var s in i.Accessoires)i.Accessoires[s].articleCodex==t&&r.push(i.Accessoires[s]);return r}},{key:"triggerVisibility",value:(b=(0,r.Z)(o().mark((function _callee7(e){var t,i,r,s,n,l,a;return o().wrap((function _callee7$(c){for(;;)switch(c.prev=c.next){case 0:t=[],i=[],r=0;case 3:if(!(r<this.grids.length)){c.next=13;break}if((s=this.grids[r]).VisitOption){c.next=7;break}return c.abrupt("continue",10);case 7:if(!i.includes(s.VisitOption)&&!t.includes(s.VisitOption)){c.next=9;break}return c.abrupt("continue",10);case 9:e&&(s.gridGroup==e||s.alternativeGridGroups.includes(e))?(i.push(s.VisitOption),t.includes(s.VisitOption)&&t.splice(t.indexOf(s.VisitOption),1)):t.push(s.VisitOption);case 10:r++,c.next=3;break;case 13:n=0;case 14:if(!(n<[].concat(i,t).length)){c.next=23;break}if(l=[].concat(i,t)[n],!(a=this.article.getArticleOptionState((this.article.CatalogData.isIDMFormat?"":"OPT")+l))){c.next=20;break}return c.next=20,f.Z.updateOption(this.article,a.optionCodex,i.includes(l)?"OPVMIT":"OPVOHNE");case 20:n++,c.next=14;break;case 23:case"end":return c.stop()}}),_callee7,this)}))),function triggerVisibility(e){return b.apply(this,arguments)})},{key:"deleteAllAcc",value:(v=(0,r.Z)(o().mark((function _callee8(){var e;return o().wrap((function _callee8$(t){for(;;)switch(t.prev=t.next){case 0:this.article.shelfPlanData=void 0,this.restorePending=!1,e=0;case 3:if(!(e<this.grids.length)){t.next=9;break}return t.next=6,this.grids[e].deleteAllAccOfGrid();case 6:e++,t.next=3;break;case 9:case"end":return t.stop()}}),_callee8,this)}))),function deleteAllAcc(){return v.apply(this,arguments)})},{key:"GridAllowedOnCells",get:function get(){return this.gridAllowedOnCells}},{key:"GridAllowedOntoArticles",get:function get(){return this.gridAllowedOntoArticles}},{key:"TakePlaceOnOtherGrids",get:function get(){return this.takePlaceOnOtherGrids}},{key:"tryFitOnShelfOfGrid",value:function tryFitOnShelfOfGrid(e,t,i){var r=i.shelfHeight,s=this.grids[e];if(!r||isNaN(r))return alert("Der artikel: "+i.name+" hat keine RH hinterlegt! Der Metatag 'HEIGHTGRIDUSED' ist: "+i.shelfHeight),!1;var n=!1,l=this.doesTakePlaceOnOtherGrids(i)?this.activeGrids:[s];if(s.checkAccessoireInGridRules(i))return{type:"notAllowedByMaxQuantityReached",size:r};for(var a=0;a<l.length;a++)if(!1===(n=l[a].tryFitOnShelf(i,t,i.shelfPlanner))||"doesNotFit"===n.type||n.type.startsWith("notAllowed")||void 0===n.index)return n;return n}},{key:"getFreeSpacesOfAccessoireOfGrids",value:function getFreeSpacesOfAccessoireOfGrids(e,t){for(var i=this.grids,r={},s=0;s<i.length;s++){var n=i[s];n.DisabledByRule||(r[n.GridName]={freeCells:n.getFreeSpacesOfAccessoire(t),idx:s})}return r}},{key:"getPlannedSpacesOfGrids",value:function getPlannedSpacesOfGrids(){for(var e=this.grids,t={},i=0;i<e.length;i++){var r=e[i];r.DisabledByRule||(t[r.GridName]={accessories:r.getPlannedSpaces(),idx:i})}return t}},{key:"deleteAccessoireOfCellInGrid",value:(c=(0,r.Z)(o().mark((function _callee9(e,t){var i,r,s,n,l,a;return o().wrap((function _callee9$(c){for(;;)switch(c.prev=c.next){case 0:if(i=this.grids[e],r=i.Cells[t].InUse,(n=i.Cells.find((function(e){return e.OnBoard==r})))?(s=n.InUse,n.Article):(s=t,l=i.Cells[t].Article),!l){c.next=8;break}return this.checkForNewFreeAccessoire(l,e),c.next=8,this.handleDeleteTakePlaceOnOtherGrids(e,s,l);case 8:return c.next=10,i.deleteAccessoireInCells(s);case 10:return(a=c.sent)&&this.logShelfDebug({phase:"placement",action:"accessoryDeleted",gridIndex:e,cellIndex:s,articleCodex:a.articleCodex,articleName:a.name}),c.abrupt("return",a);case 13:case"end":return c.stop()}}),_callee9,this)}))),function deleteAccessoireOfCellInGrid(e,t){return c.apply(this,arguments)})},{key:"checkForNewFreeAccessoire",value:function checkForNewFreeAccessoire(e,t){if(void 0!==this.freeArticlesPossible[e.articleCodex]&&e.noPrice){this.freeArticlesPlanned[e.articleCodex]-=e.quantity;var i=this.grids[t];for(var r in i.Accessoires)i.Accessoires[r].articleCodex!=e.articleCodex||i.Accessoires[r].noPrice||(i.Accessoires[r].noPrice=!0,this.freeArticlesPlanned[i.Accessoires[r].articleCodex]+=e.quantity)}}},{key:"handleDeleteTakePlaceOnOtherGrids",value:(i=(0,r.Z)(o().mark((function _callee10(e,t,i){var r,s,n,l,a,c,d;return o().wrap((function _callee10$(o){for(;;)switch(o.prev=o.next){case 0:if(i.shelfHeight){o.next=2;break}return o.abrupt("return");case 2:if(i.shelfHeightAbove)for(r=0;r<i.shelfHeightAbove;r++)(null==(n=this.grids[e].Cells[t+i.shelfHeight+r])||null===(s=n.Article)||void 0===s?void 0:s.basketId)===i.basketId&&n.ClearInUse();if(i.shelfHeightBelow)for(l=0;l<i.shelfHeightBelow;l++)(null==(c=this.grids[e].Cells[t-(l+1)])||null===(a=c.Article)||void 0===a?void 0:a.basketId)===i.basketId&&c.ClearInUse();if(!this.doesTakePlaceOnOtherGrids(i)){o.next=14;break}d=0;case 6:if(!(d<this.grids.length)){o.next=14;break}if(d!==e){o.next=9;break}return o.abrupt("continue",11);case 9:return o.next=11,this.grids[d].deleteAccessoireInCells(t);case 11:d++,o.next=6;break;case 14:case"end":return o.stop()}}),_callee10,this)}))),function handleDeleteTakePlaceOnOtherGrids(e,t,r){return i.apply(this,arguments)})},{key:"addAccessoireInCellInGrid",value:(t=(0,r.Z)(o().mark((function _callee11(e,t,i,r,s){var n,l,a;return o().wrap((function _callee11$(c){for(;;)switch(c.prev=c.next){case 0:n=this.doesTakePlaceOnOtherGrids(e)?this.activeGrids:[this.grids[t]],l=0;case 2:if(!(l<n.length)){c.next=13;break}if(!(a=n[l]).DisabledByRule){c.next=7;break}return this.logShelfDebug({phase:"placement",action:"placementSkippedGridDisabled",gridIndex:a.ShelfIndex,cellIndex:i,articleCodex:e.articleCodex}),c.abrupt("continue",10);case 7:return this.logShelfDebug({phase:"placement",action:"accessoryPlaced",gridIndex:a.ShelfIndex,cellIndex:i,articleCodex:e.articleCodex,articleName:e.name,detail:r+(a.ShelfIndex!==t?" (placeholder via TakePlaceOnOtherGrids)":"")}),c.next=10,n[l].addAccessoireInCells(i,e,r,a.ShelfIndex!==t||(null==s?void 0:s.noMove),a.ShelfIndex!==t||(null==s?void 0:s.noDelete),a.ShelfIndex!==t||void 0);case 10:l++,c.next=2;break;case 13:this.checkForFreeAccessoire(e);case 14:case"end":return c.stop()}}),_callee11,this)}))),function addAccessoireInCellInGrid(e,i,r,s,n){return t.apply(this,arguments)})},{key:"checkForFreeAccessoire",value:function checkForFreeAccessoire(e){void 0!==this.freeArticlesPossible[e.articleCodex]&&(void 0===this.freeArticlesPlanned[e.articleCodex]||this.freeArticlesPossible[e.articleCodex]>this.freeArticlesPlanned[e.articleCodex])&&(e.noPrice=!0,void 0===this.freeArticlesPlanned[e.articleCodex]&&(this.freeArticlesPlanned[e.articleCodex]=0),this.freeArticlesPlanned[e.articleCodex]+=e.quantity)}},{key:"doesTakePlaceOnOtherGrids",value:function doesTakePlaceOnOtherGrids(e){var t,i=null===(t=e.shelfPlanner)||void 0===t?void 0:t.takePlaceOnOtherGrids;if(i)for(var r=0;r<i.length;r++)if(i[r].onParent==this.article.articleCodex)return!0;return!1}},{key:"accessoires",get:function get(){for(var e={},t=this.activeGrids,i=0;i<t.length;i++)for(var r in t[i].Accessoires)e[r]=t[i].Accessoires[r];return Object.keys(e).length>0?e:void 0}},{key:"DisableCellsByElement",get:function get(){return this.disableCellsByElement}},{key:"getActAccessoireOfGrid",value:function getActAccessoireOfGrid(e){return this.grids[e].ActAccessoire}},{key:"setActAccessoireOfGrid",value:function setActAccessoireOfGrid(e,t){for(var i=!1,r=this.GridsOrGroupById(e),s=0;s<r.length;s++){var n=r[s];t&&n.getArticleRelationsById(e).includes(t)?n.ActAccessoire!==t&&(n.ActAccessoire=t,i=!0):n.ActAccessoire=void 0}return i}},{key:"generateShelfPlandata",value:function generateShelfPlandata(){for(var e,t=[],i=this.grids.filter((function(e){return!e.DisabledByRule||e.Cells.some((function(e){return e.InUse===e.Index&&e.Article}))})),r=0;r<i.length;r++){for(var s=[],n=i[r],l=0;l<n.Cells.length;l++){var a,c,o=n.Cells[l];if(s.push({inUse:o.InUse,noDelete:o.NoDelete,noMove:o.NoMove,onBoard:o.OnBoard}),n.ShelfIndex!=r&&(s[l].gridIndex=n.ShelfIndex),o.InUse==l)s[l].usedArticleData={Codex:null===(a=o.Article)||void 0===a?void 0:a.articleCodex,BasketID:null===(c=o.Article)||void 0===c?void 0:c.basketId}}t.push(s)}return{ShelfPlanner2:t,DoorPlannerData:null===(e=this.article.doorPlanner)||void 0===e?void 0:e.getMovedData(this.article.basketId)}}},{key:"getShelfPlannerAccessoires3DValues",value:function getShelfPlannerAccessoires3DValues(e){for(var t=this.activeGrids,i=0;i<t.length;i++)for(var r=t[i],s=0;s<r.Cells.length;s++){var n=r.Cells[s];if(n.InUse==s&&n.Article&&n.Article.model3DName&&!n.OnlyPlaceHolder){var l,a=n.Index;"vertikal"==r.Direction&&1!=this.article.CatalogData.useShelfPlannerRTV&&(a=r.Cells.length-1-n.Index),e.push({basketId:null===(l=n.Article)||void 0===l?void 0:l.basketId,gridId:r.ShelfIndex,gridName:r.GridName,model:n.Article.model3DName,parentBasketId:this.article.basketId,parentElementId:this.getShelfElementId(),rh:a}),n.Article.shelfPlanner&&(e=e.concat(n.Article.shelfPlanner.getShelfPlannerAccessoires3DValues([])))}}return e}},{key:"getShelfElementId",value:function getShelfElementId(){var e;if(null!==(e=this.article.accessoireParentArticle)&&void 0!==e&&e.shelfPlanner&&void 0!==this.article.relatedToShelfGrid&&this.grids.length>0){var t=this.getRHOnParentArticle();return this.article.accessoireParentArticle.shelfPlanner.getShelfElementId()+"."+this.article.relatedToShelfGrid+"."+t}return this.article.elementId.toString()}},{key:"getRHOnParentArticle",value:function getRHOnParentArticle(){var e,t=this;if(void 0!==this.article.relatedToShelfGrid)return null===(e=this.article.accessoireParentArticle)||void 0===e||null===(e=e.shelfPlanner)||void 0===e||null===(e=e.grids[this.article.relatedToShelfGrid].Cells.find((function(e){var i;return(null===(i=e.Article)||void 0===i?void 0:i.basketId)==t.article.basketId})))||void 0===e?void 0:e.InUse}},{key:"getShelfPlannerItems",value:function getShelfPlannerItems(e){for(var t=[],i=this.article.CatalogData,r=this.GridsOrGroupById(e),s=0;s<r.length;s++){var n=r[s].getArticleRelationsById(e);if(null!=n&&n.length)for(var l=function _loop(){var e=n[a];if(i.checkIfArticleCodexExists(e)){var r=i.getCatalogArticleByArticleCodex(e);if(!r||t.find((function(e){return e.articleCodex===r.articleCodex})))return 1;t.push({articleCodex:r.articleCodex,configStepKeys:[],image:r.image?i.getCatImageURL(r.image,""):void 0,name:r.name,longDescription:r.longDescription,price:i.dontShowBasePrice?0:Number(r.articlePrice),width:r.width,height:r.height,depth:r.depth,cellSize:r.shelfHeight,metaData:r.metaDataView,accessoireFamily:r.accessoireFamily,contentItemId:r.contentItemId,groupContentItemId:r.groupContentItemId,partlistcodexes:r.possiblePartlistCodexes})}},a=0;a<n.length;a++)l()}return{accessoires:t,grids:r}}},{key:"getShelfParentShelfId",value:function getShelfParentShelfId(){var e;if(void 0!==this.article.relatedToShelfGrid)return null===(e=this.article.accessoireParentArticle)||void 0===e||null===(e=e.shelfPlanner)||void 0===e||null===(e=e.grids[this.article.relatedToShelfGrid])||void 0===e?void 0:e.ShelfId}},{key:"updateOnDockingChanged",value:function updateOnDockingChanged(e){("AVL"==e&&"RH_OVER_AVL"==this.disableCellsByElement||"AVR"==e&&"RH_OVER_AVR"==this.disableCellsByElement)&&this.updateDisabledCells()}},{key:"updateDisabledCells",value:function updateDisabledCells(){this.updateDisabledCellsOnDockedElements(),this.checkOnDockedHeight()}},{key:"updateDisabledCellsOnDockedElements",value:function updateDisabledCellsOnDockedElements(){var e,t=this.activeGrids,i=this.article.dockedOnAV("L"),r=this.article.dockedOnAV("R");if("RH_OVER_AVR"==this.disableCellsByElement&&i)null===(e=i.shelfPlanner)||void 0===e||e.disableCellsByDockedShelfs(t[0].getCellCount("AVL"));else if("RH_OVER_AVL"==this.disableCellsByElement&&r){var s;null===(s=r.shelfPlanner)||void 0===s||s.disableCellsByDockedShelfs(t[0].getCellCount("AVR"))}}},{key:"checkOnDockedHeight",value:function checkOnDockedHeight(){var e=this.article.dockedOnAV("R"),t=this.article.dockedOnAV("L");null!=e&&e.shelfPlanner&&e.shelfPlanner.activeGrids.length>0&&"RH_OVER_AVR"==this.disableCellsByElement?this.disableCellsByDockedShelfs(e.shelfPlanner.activeGrids[0].getCellCount("AVL")):null!=t&&t.shelfPlanner&&t.shelfPlanner.activeGrids.length>0&&"RH_OVER_AVL"==this.disableCellsByElement?this.disableCellsByDockedShelfs(t.shelfPlanner.activeGrids[0].getCellCount("AVR")):this.disableCellsByDockedShelfs()}},{key:"disableCellsByDockedShelfs",value:(e=(0,r.Z)(o().mark((function _callee12(e){var t,i,r,s=this;return o().wrap((function _callee12$(n){for(;;)switch(n.prev=n.next){case 0:t=this.activeGrids,i=o().mark((function _loop2(){var i,n,l,a,c,d,u,f,g,v;return o().wrap((function _loop2$(o){for(;;)switch(o.prev=o.next){case 0:for(i=t[r],n=i.getCellCount(),l=i.getDisabledCellsByRule(),c=a=null==e||e>n?n:e;c<i.Cells.length;c++)l.push(c);d=l.filter((function(e){return i.Cells[e]&&!i.Cells[e].IsDisabled})),u=i.Cells.filter((function(e,t){return e.IsDisabled&&!l.includes(t)})).length,(d.length||u)&&s.logShelfDebug({phase:"docking",action:"disabledCellsUpdated",gridIndex:i.ShelfIndex,detail:"newlyDisabled=[".concat(d.slice(0,30).join(","),"] reEnabled=").concat(u," ")+"(sources: DisableCellsByRules/measures=".concat(i.getDisabledCellsByRule().length,", beyond cellCount/docking cap=").concat(i.Cells.length-a,"); ")+"an occupied cell that gets disabled deletes its accessory"}),f=0;case 9:if(!(f<l.length)){o.next=18;break}if((g=i.Cells[l[f]]).InUse!=l[f]){o.next=14;break}return o.next=14,h.Z.deleteAccessorieOnShelfPlanner(s.article.set,i.ShelfIndex,g.InUse,i.basketId);case 14:g.IsDisabled=!0;case 15:f++,o.next=9;break;case 18:v=0;case 19:if(!(v<i.Cells.length)){o.next=26;break}if(!l.includes(v)){o.next=22;break}return o.abrupt("continue",23);case 22:i.Cells[v].IsDisabled=!1;case 23:v++,o.next=19;break;case 26:case"end":return o.stop()}}),_loop2)})),r=0;case 3:if(!(r<t.length)){n.next=8;break}return n.delegateYield(i(),"t0",5);case 5:r++,n.next=3;break;case 8:case"end":return n.stop()}}),_callee12,this)}))),function disableCellsByDockedShelfs(t){return e.apply(this,arguments)})},{key:"getGridByGridName",value:function getGridByGridName(e){return this.grids.find((function(t){return t.GridName==e}))}},{key:"getGridByIndex",value:function getGridByIndex(e){return this.grids.find((function(t){return t.ShelfIndex==e}))}},{key:"GridsOrGroupById",value:function GridsOrGroupById(e){return this.activeGrids.filter((function(t){return t.ShelfId==e||t.group==e||t.alternativeGridGroups.includes(e)}))}},{key:"getSelectedAccessoireById",value:function getSelectedAccessoireById(e){var t;return null===(t=this.GridsOrGroupById(e).find((function(t){if(t.ActAccessoire&&t.getArticleRelationsById(e).includes(t.ActAccessoire))return t})))||void 0===t?void 0:t.ActAccessoire}},{key:"getCellIndexOfBasketId",value:function getCellIndexOfBasketId(e,t){var i;return null===(i=this.getGridByIndex(e))||void 0===i?void 0:i.getIndexOfBasketId(t)}},{key:"allGrids",get:function get(){return this.grids}},{key:"activeGrids",get:function get(){return this.grids.filter((function(e){return!e.DisabledByRule}))}},{key:"allMontageOptions",get:function get(){return this.montageOptions}},{key:"getRelatedToGridIdByArticleCodex",value:function getRelatedToGridIdByArticleCodex(e,t){var i=this.grids[t].getGridIdByArticleCodex(e);if(i)return i;for(var r=0;r<this.grids.length;r++){var s=this.grids[r].getGridIdByArticleCodex(e);if(s)return s}}}]);var e,t,i,c,v,b,k,A,p,x,y,C}()}}]);
|
|
2
|
+
"use strict";(self.webpackChunkCrystaldesignDivaWebPlannerReact=self.webpackChunkCrystaldesignDivaWebPlannerReact||[]).push([[3596],{33596:(e,t,i)=>{i.r(t),i.d(t,{default:()=>v});var r=i(84658),s=i(12952),n=i(13125),l=i(43860),a=i(80248),c=i(50747),d=i.n(c),o=i(69369),h=i(37609),u=i(35215),f=i(69821);function ownKeys(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}var g=o.ZP.initLog("Planner","WEB-PLANNER-LOGIC"),v=function(){return(0,l.Z)((function ShelfPlanner(e,t){if((0,n.Z)(this,ShelfPlanner),(0,a.Z)(this,"article",void 0),(0,a.Z)(this,"grids",[]),(0,a.Z)(this,"isVisible",void 0),(0,a.Z)(this,"showOnRule",void 0),(0,a.Z)(this,"showAfterOPT",void 0),(0,a.Z)(this,"data",void 0),(0,a.Z)(this,"freeArticlesPossible",{}),(0,a.Z)(this,"freeArticlesPlanned",{}),(0,a.Z)(this,"gridAllowedOnCells",void 0),(0,a.Z)(this,"gridAllowedOntoArticles",void 0),(0,a.Z)(this,"takePlaceOnOtherGrids",void 0),(0,a.Z)(this,"disableCellsByElement",void 0),(0,a.Z)(this,"montageOptions",[]),(0,a.Z)(this,"shelfDebugStack",[]),(0,a.Z)(this,"shelfDebugSeq",0),(0,a.Z)(this,"restorePending",void 0),(0,a.Z)(this,"stashedAccessoires",{}),this.article=t,this.restorePending=!!t.shelfPlanData,this.disableCellsByElement=e.DisableCells,this.data=e,this.showAfterOPT=e.ShowAfterOPT,this.showOnRule=e.ShowOnRule?o.ZP.getRuleByFormula(e.ShowOnRule,t.catalogCodex,t.CatalogData.multiselectOptions):void 0,this.gridAllowedOnCells=e.GridAllowedOnCells,this.gridAllowedOntoArticles=e.GridAllowedOntoArticles,this.takePlaceOnOtherGrids=e.TakePlaceOnOtherGrids,this.initFreeArticles(),e.ShelfPlanner&&e.ShelfPlanner.length>0){for(var i=0;i<e.ShelfPlanner.length;i++)this.creatNewGrid(i),this.updateDisabledCells();this.montageOptions=(0,s.Z)(new Set(this.grids.reduce((function(e,t){return e=e.concat(t.montageOptionsList)}),[])))}}),[{key:"logShelfDebug",value:function logShelfDebug(e){this.shelfDebugStack.push(function _objectSpread(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(i),!0).forEach((function(t){(0,a.Z)(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({seq:this.shelfDebugSeq++},e)),this.shelfDebugStack.length>500&&this.shelfDebugStack.splice(0,this.shelfDebugStack.length-500)}},{key:"initFreeArticles",value:function initFreeArticles(){if(this.data.ShelfPlanner)for(var e=0;e<this.data.ShelfPlanner.length;e++){var t=this.data.ShelfPlanner[e];if(t.initAccArr)for(var i=0;i<t.initAccArr.length;i++){var r=t.initAccArr[i];r.noPrice&&(void 0===this.freeArticlesPossible[r.Codex]&&(this.freeArticlesPossible[r.Codex]=0),this.freeArticlesPossible[r.Codex]+=r.Quantity)}}}},{key:"IsVisible",get:function get(){return this.isVisible}},{key:"RestorePending",get:function get(){return this.restorePending},set:function set(e){this.restorePending=e}},{key:"setIsVisible",value:(C=(0,r.Z)(d().mark((function _callee(e){return d().wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:if(this.isVisible==e){t.next=13;break}if(this.logShelfDebug({phase:"visibility",action:e?"plannerShown":"plannerHidden",detail:e?void 0:"showOnRule/visibility turned false — all placed accessories are deleted"}),!e){t.next=11;break}if(this.isVisible=e,this.article.shelfPlanData){t.next=9;break}return t.next=7,this.onConfigChanged({});case 7:return t.next=9,this.initAccList();case 9:t.next=13;break;case 11:return t.next=13,this.deleteAllAcc();case 13:this.isVisible=e;case 14:case"end":return t.stop()}}),_callee,this)}))),function setIsVisible(e){return C.apply(this,arguments)})},{key:"onConfigChanged",value:(y=(0,r.Z)(d().mark((function _callee2(e){var t,i,r,s,n,l,a,c,o,h,u,f,g;return d().wrap((function _callee2$(d){for(;;)switch(d.prev=d.next){case 0:for(t=!1,i=[],r=this.grids.map((function(e){return e.CurrentLoadedRuleIndex})),s=0;s<this.grids.length;s++)i.push(this.grids[s].onConfigChanged());n=0;case 5:if(!(n<i.length)){d.next=14;break}if(i[n].length){d.next=8;break}return d.abrupt("continue",11);case 8:l=this.grids[n],i[n].includes("disableGridRule")&&this.logShelfDebug({phase:"configChanged",action:l.DisabledByRule?"gridDisabledByRule":"gridEnabledByRule",gridIndex:l.ShelfIndex,detail:l.ShowOnRule}),i[n].includes("heightGridRule")&&this.logShelfDebug({phase:"configChanged",action:"gridRecreated",gridIndex:l.ShelfIndex,detail:"HeightGridCellCountOnRule match changed — grid rebuilt (cell count / placeable accessories can change), its accessories are deleted"});case 11:n++,d.next=5;break;case 14:a=0;case 15:if(!(a<i.length)){d.next=24;break}if(i[a].length){d.next=18;break}return d.abrupt("continue",21);case 18:return this.stashAccessoiresOfGrid(a,r[a]),d.next=21,this.grids[a].deleteAllAccOfGrid();case 21:a++,d.next=15;break;case 24:c=0;case 25:if(!(c<i.length)){d.next=41;break}if(i[c].length){d.next=28;break}return d.abrupt("continue",38);case 28:if(i[c].includes("heightGridRule")&&(this.creatNewGrid(c),t=!0),o=this.grids[c],!i[c].includes("heightGridRule")&&!i[c].includes("disableGridRule")||o.DisabledByRule){d.next=38;break}if(!this.restorePending){d.next=33;break}return d.abrupt("continue",38);case 33:return d.next=35,this.placeStashedAccessoiresOfGrid(c);case 35:if(d.sent){d.next=38;break}return d.next=38,this.initAccList(c);case 38:c++,d.next=25;break;case 41:if(t||!Object.keys(e).length){d.next=52;break}h=this.activeGrids,u=0;case 44:if(!(u<h.length)){d.next=52;break}if(g=h[u],!(null!==(f=g.DisableCellsByMeasures)&&void 0!==f&&f.options.find((function(t){return Object.keys(e).includes("OPT"+t.opt)}))||g.disableCellsByRules)){d.next=49;break}return t=!0,d.abrupt("break",52);case 49:u++,d.next=44;break;case 52:t&&this.updateDisabledCells();case 53:case"end":return d.stop()}}),_callee2,this)}))),function onConfigChanged(e){return y.apply(this,arguments)})},{key:"creatNewGrid",value:function creatNewGrid(e){this.grids[e]=new u.Z(e,this.article,this.data),this.grids[e].onConfigChanged()}},{key:"stashAccessoiresOfGrid",value:function stashAccessoiresOfGrid(e,t){var i=this.collectAccessoiresToStash(this.grids[e]);i.length&&(this.stashedAccessoires[this.stashKey(e,t)]=i)}},{key:"stashKey",value:function stashKey(e,t){return e+"#"+t}},{key:"collectAccessoiresToStash",value:function collectAccessoiresToStash(e){for(var t=[],i=0;i<e.Cells.length;i++){var r=e.Cells[i],s=r.Article;if(r.InUse===i&&s){for(var n={},l=s.shelfPlanner,a=0;a<(null!==(c=null==l?void 0:l.grids.length)&&void 0!==c?c:0);a++){var c,d=l.grids[a],o=l.collectAccessoiresToStash(d);o.length&&(n[d.ShelfIndex]={ruleIndex:d.CurrentLoadedRuleIndex,accessoires:o})}t.push({articleCodex:s.articleCodex,cellIndex:i,noMove:r.NoMove,noDelete:r.NoDelete,quantity:s.quantity,variantValues:s.VariantValues,accessoires:n})}}return t}},{key:"placeStashedAccessoiresOfGrid",value:(x=(0,r.Z)(d().mark((function _callee3(e){var t,i;return d().wrap((function _callee3$(r){for(;;)switch(r.prev=r.next){case 0:if(t=this.stashKey(e,this.grids[e].CurrentLoadedRuleIndex),null!=(i=this.stashedAccessoires[t])&&i.length){r.next=4;break}return r.abrupt("return",0);case 4:return delete this.stashedAccessoires[t],r.next=7,this.placeStashedAccessoiresInGrid(e,i);case 7:return r.abrupt("return",r.sent);case 8:case"end":return r.stop()}}),_callee3,this)}))),function placeStashedAccessoiresOfGrid(e){return x.apply(this,arguments)})},{key:"placeStashedAccessoiresByGrid",value:(A=(0,r.Z)(d().mark((function _callee4(e){var t,i,r,s,n;return d().wrap((function _callee4$(l){for(;;)switch(l.prev=l.next){case 0:t=Object.keys(e),i=0;case 2:if(!(i<t.length)){l.next=18;break}if(r=Number(t[i]),s=this.getGridByIndex(r),n=e[r],s&&s.CurrentLoadedRuleIndex===n.ruleIndex){l.next=8;break}return l.abrupt("continue",15);case 8:return l.next=10,s.deleteAllAccOfGrid();case 10:return l.next=12,this.placeStashedAccessoiresInGrid(r,n.accessoires);case 12:if(l.sent){l.next=15;break}return l.next=15,this.initAccList(r);case 15:i++,l.next=2;break;case 18:case"end":return l.stop()}}),_callee4,this)}))),function placeStashedAccessoiresByGrid(e){return A.apply(this,arguments)})},{key:"placeStashedAccessoiresInGrid",value:(p=(0,r.Z)(d().mark((function _callee5(e,t){var i,r,s,n,l,a,c;return d().wrap((function _callee5$(d){for(;;)switch(d.prev=d.next){case 0:if(i=0,r=this.getGridByIndex(e)){d.next=4;break}return d.abrupt("return",i);case 4:s=0;case 5:if(!(s<t.length)){d.next=28;break}return n=t[s],r.ActAccessoire=n.articleCodex,d.next=10,h.Z.addAccessorieOnShelfPlanner(this.article.set,e,n.cellIndex,this.article.basketId,{noMove:n.noMove,noDelete:n.noDelete,byInit:!0});case 10:if(l=d.sent,r.ActAccessoire=void 0,a=!1===l||void 0===l.index?void 0:l,c=null==a?void 0:a.accessoire,a&&c){d.next=17;break}return g.error(new o.GE("shelfaccessoire of a switched off grid does not fit anymore and gets dropped",{code:"WC_0015",custom:{stashed:n,gridName:r.GridName,result:l,parentPosNr:this.article.posNr,parentArticleCodex:this.article.articleCodex,parentBasketId:this.article.basketId}})),d.abrupt("continue",25);case 17:if(c.quantity=n.quantity,i++,!Object.keys(n.variantValues).length){d.next=22;break}return d.next=22,f.Z.updateCfgValues(c,n.variantValues,{});case 22:if(!c.shelfPlanner){d.next=25;break}return d.next=25,c.shelfPlanner.placeStashedAccessoiresByGrid(n.accessoires);case 25:s++,d.next=5;break;case 28:return d.abrupt("return",i);case 29:case"end":return d.stop()}}),_callee5,this)}))),function placeStashedAccessoiresInGrid(e,t){return p.apply(this,arguments)})},{key:"initAccList",value:(k=(0,r.Z)(d().mark((function _callee6(e){var t,i,r,s,n,l,a,c,o,u,f,g;return d().wrap((function _callee6$(d){for(;;)switch(d.prev=d.next){case 0:t=this.activeGrids,i=0;case 2:if(!(i<t.length)){d.next=37;break}if(r=t[i],void 0===e||r.ShelfIndex===e){d.next=6;break}return d.abrupt("continue",34);case 6:if(r.InitAccArr){d.next=8;break}return d.abrupt("continue",34);case 8:s=0;case 9:if(!(s<r.InitAccArr.length)){d.next=34;break}n=r.InitAccArr[s],l=0;case 12:if(!(l<n.initRH.length)){d.next=31;break}return r.ActAccessoire=n.Codex,this.logShelfDebug({phase:"initAccessories",action:"initAccessoryRequested",gridIndex:r.ShelfIndex,cellIndex:n.initRH[l],articleCodex:n.Codex,detail:"from InitAccArr — a missing matching accessoryPlaced entry right after means the init placement failed"}),d.next=17,h.Z.addAccessorieOnShelfPlanner(this.article.set,r.ShelfIndex,n.initRH[l],r.basketId,{noMove:n.noMove,noDelete:n.noDelete,byInit:!0});case 17:if(!n.replaceFromParent){d.next=27;break}if(!(c=this.getShelfParentShelfId())||null===(a=this.article.accessoireParentArticle)||void 0===a||!a.shelfPlanner){d.next=27;break}if(!((o=this.article.accessoireParentArticle.shelfPlanner.getAccessorireByCodex(c,n.Codex))&&o.length>0)){d.next=27;break}if(f=o[0],void 0===(g=null===(u=f.shelfPlanner)||void 0===u?void 0:u.getRHOnParentArticle())||void 0===f.relatedToShelfGrid){d.next=27;break}return d.next=27,h.Z.deleteAccessorieOnShelfPlanner(this.article.set,f.relatedToShelfGrid,g,this.article.accessoireParentArticle.basketId);case 27:r.ActAccessoire=void 0;case 28:l++,d.next=12;break;case 31:s++,d.next=9;break;case 34:i++,d.next=2;break;case 37:case"end":return d.stop()}}),_callee6,this)}))),function initAccList(e){return k.apply(this,arguments)})},{key:"getAccessorireByCodex",value:function getAccessorireByCodex(e,t){var i=this.grids.find((function(t){return t.ShelfId==e})),r=[];if(i)for(var s in i.Accessoires)i.Accessoires[s].articleCodex==t&&r.push(i.Accessoires[s]);return r}},{key:"triggerVisibility",value:(b=(0,r.Z)(d().mark((function _callee7(e){var t,i,r,s,n,l,a;return d().wrap((function _callee7$(c){for(;;)switch(c.prev=c.next){case 0:t=[],i=[],r=0;case 3:if(!(r<this.grids.length)){c.next=13;break}if((s=this.grids[r]).VisitOption){c.next=7;break}return c.abrupt("continue",10);case 7:if(!i.includes(s.VisitOption)&&!t.includes(s.VisitOption)){c.next=9;break}return c.abrupt("continue",10);case 9:e&&(s.gridGroup==e||s.alternativeGridGroups.includes(e))?(i.push(s.VisitOption),t.includes(s.VisitOption)&&t.splice(t.indexOf(s.VisitOption),1)):t.push(s.VisitOption);case 10:r++,c.next=3;break;case 13:n=0;case 14:if(!(n<[].concat(i,t).length)){c.next=23;break}if(l=[].concat(i,t)[n],!(a=this.article.getArticleOptionState((this.article.CatalogData.isIDMFormat?"":"OPT")+l))){c.next=20;break}return c.next=20,f.Z.updateOption(this.article,a.optionCodex,i.includes(l)?"OPVMIT":"OPVOHNE");case 20:n++,c.next=14;break;case 23:case"end":return c.stop()}}),_callee7,this)}))),function triggerVisibility(e){return b.apply(this,arguments)})},{key:"deleteAllAcc",value:(v=(0,r.Z)(d().mark((function _callee8(){var e;return d().wrap((function _callee8$(t){for(;;)switch(t.prev=t.next){case 0:this.article.shelfPlanData=void 0,this.restorePending=!1,e=0;case 3:if(!(e<this.grids.length)){t.next=9;break}return t.next=6,this.grids[e].deleteAllAccOfGrid();case 6:e++,t.next=3;break;case 9:case"end":return t.stop()}}),_callee8,this)}))),function deleteAllAcc(){return v.apply(this,arguments)})},{key:"GridAllowedOnCells",get:function get(){return this.gridAllowedOnCells}},{key:"GridAllowedOntoArticles",get:function get(){return this.gridAllowedOntoArticles}},{key:"TakePlaceOnOtherGrids",get:function get(){return this.takePlaceOnOtherGrids}},{key:"tryFitOnShelfOfGrid",value:function tryFitOnShelfOfGrid(e,t,i){var r=i.shelfHeight,s=this.grids[e];if(!r||isNaN(r))return alert("Der artikel: "+i.name+" hat keine RH hinterlegt! Der Metatag 'HEIGHTGRIDUSED' ist: "+i.shelfHeight),!1;var n=!1,l=this.doesTakePlaceOnOtherGrids(i)?this.activeGrids:[s];if(s.checkAccessoireInGridRules(i))return{type:"notAllowedByMaxQuantityReached",size:r};for(var a=0;a<l.length;a++)if(!1===(n=l[a].tryFitOnShelf(i,t,i.shelfPlanner))||"doesNotFit"===n.type||n.type.startsWith("notAllowed")||void 0===n.index)return n;return n}},{key:"getFreeSpacesOfAccessoireOfGrids",value:function getFreeSpacesOfAccessoireOfGrids(e,t){for(var i=this.grids,r={},s=0;s<i.length;s++){var n=i[s];n.DisabledByRule||(r[n.GridName]={freeCells:n.getFreeSpacesOfAccessoire(t),idx:s})}return r}},{key:"getPlannedSpacesOfGrids",value:function getPlannedSpacesOfGrids(){for(var e=this.grids,t={},i=0;i<e.length;i++){var r=e[i];r.DisabledByRule||(t[r.GridName]={accessories:r.getPlannedSpaces(),idx:i})}return t}},{key:"deleteAccessoireOfCellInGrid",value:(c=(0,r.Z)(d().mark((function _callee9(e,t){var i,r,s,n,l,a;return d().wrap((function _callee9$(c){for(;;)switch(c.prev=c.next){case 0:if(i=this.grids[e],r=i.Cells[t].InUse,(n=i.Cells.find((function(e){return e.OnBoard==r})))?(s=n.InUse,n.Article):(s=t,l=i.Cells[t].Article),!l){c.next=8;break}return this.checkForNewFreeAccessoire(l,e),c.next=8,this.handleDeleteTakePlaceOnOtherGrids(e,s,l);case 8:return c.next=10,i.deleteAccessoireInCells(s);case 10:return(a=c.sent)&&this.logShelfDebug({phase:"placement",action:"accessoryDeleted",gridIndex:e,cellIndex:s,articleCodex:a.articleCodex,articleName:a.name}),c.abrupt("return",a);case 13:case"end":return c.stop()}}),_callee9,this)}))),function deleteAccessoireOfCellInGrid(e,t){return c.apply(this,arguments)})},{key:"checkForNewFreeAccessoire",value:function checkForNewFreeAccessoire(e,t){if(void 0!==this.freeArticlesPossible[e.articleCodex]&&e.noPrice){this.freeArticlesPlanned[e.articleCodex]-=e.quantity;var i=this.grids[t];for(var r in i.Accessoires)i.Accessoires[r].articleCodex!=e.articleCodex||i.Accessoires[r].noPrice||(i.Accessoires[r].noPrice=!0,this.freeArticlesPlanned[i.Accessoires[r].articleCodex]+=e.quantity)}}},{key:"handleDeleteTakePlaceOnOtherGrids",value:(i=(0,r.Z)(d().mark((function _callee10(e,t,i){var r,s,n,l,a,c,o;return d().wrap((function _callee10$(d){for(;;)switch(d.prev=d.next){case 0:if(i.shelfHeight){d.next=2;break}return d.abrupt("return");case 2:if(i.shelfHeightAbove)for(r=0;r<i.shelfHeightAbove;r++)(null==(n=this.grids[e].Cells[t+i.shelfHeight+r])||null===(s=n.Article)||void 0===s?void 0:s.basketId)===i.basketId&&n.ClearInUse();if(i.shelfHeightBelow)for(l=0;l<i.shelfHeightBelow;l++)(null==(c=this.grids[e].Cells[t-(l+1)])||null===(a=c.Article)||void 0===a?void 0:a.basketId)===i.basketId&&c.ClearInUse();if(!this.doesTakePlaceOnOtherGrids(i)){d.next=14;break}o=0;case 6:if(!(o<this.grids.length)){d.next=14;break}if(o!==e){d.next=9;break}return d.abrupt("continue",11);case 9:return d.next=11,this.grids[o].deleteAccessoireInCells(t);case 11:o++,d.next=6;break;case 14:case"end":return d.stop()}}),_callee10,this)}))),function handleDeleteTakePlaceOnOtherGrids(e,t,r){return i.apply(this,arguments)})},{key:"addAccessoireInCellInGrid",value:(t=(0,r.Z)(d().mark((function _callee11(e,t,i,r,s){var n,l,a;return d().wrap((function _callee11$(c){for(;;)switch(c.prev=c.next){case 0:n=this.doesTakePlaceOnOtherGrids(e)?this.activeGrids:[this.grids[t]],l=0;case 2:if(!(l<n.length)){c.next=13;break}if(!(a=n[l]).DisabledByRule){c.next=7;break}return this.logShelfDebug({phase:"placement",action:"placementSkippedGridDisabled",gridIndex:a.ShelfIndex,cellIndex:i,articleCodex:e.articleCodex}),c.abrupt("continue",10);case 7:return this.logShelfDebug({phase:"placement",action:"accessoryPlaced",gridIndex:a.ShelfIndex,cellIndex:i,articleCodex:e.articleCodex,articleName:e.name,detail:r+(a.ShelfIndex!==t?" (placeholder via TakePlaceOnOtherGrids)":"")}),c.next=10,n[l].addAccessoireInCells(i,e,r,a.ShelfIndex!==t||(null==s?void 0:s.noMove),a.ShelfIndex!==t||(null==s?void 0:s.noDelete),a.ShelfIndex!==t||void 0);case 10:l++,c.next=2;break;case 13:this.checkForFreeAccessoire(e);case 14:case"end":return c.stop()}}),_callee11,this)}))),function addAccessoireInCellInGrid(e,i,r,s,n){return t.apply(this,arguments)})},{key:"checkForFreeAccessoire",value:function checkForFreeAccessoire(e){void 0!==this.freeArticlesPossible[e.articleCodex]&&(void 0===this.freeArticlesPlanned[e.articleCodex]||this.freeArticlesPossible[e.articleCodex]>this.freeArticlesPlanned[e.articleCodex])&&(e.noPrice=!0,void 0===this.freeArticlesPlanned[e.articleCodex]&&(this.freeArticlesPlanned[e.articleCodex]=0),this.freeArticlesPlanned[e.articleCodex]+=e.quantity)}},{key:"doesTakePlaceOnOtherGrids",value:function doesTakePlaceOnOtherGrids(e){var t,i=null===(t=e.shelfPlanner)||void 0===t?void 0:t.takePlaceOnOtherGrids;if(i)for(var r=0;r<i.length;r++)if(i[r].onParent==this.article.articleCodex)return!0;return!1}},{key:"accessoires",get:function get(){for(var e={},t=this.activeGrids,i=0;i<t.length;i++)for(var r in t[i].Accessoires)e[r]=t[i].Accessoires[r];return Object.keys(e).length>0?e:void 0}},{key:"DisableCellsByElement",get:function get(){return this.disableCellsByElement}},{key:"getActAccessoireOfGrid",value:function getActAccessoireOfGrid(e){return this.grids[e].ActAccessoire}},{key:"setActAccessoireOfGrid",value:function setActAccessoireOfGrid(e,t){for(var i=!1,r=this.GridsOrGroupById(e),s=0;s<r.length;s++){var n=r[s];t&&n.getArticleRelationsById(e).includes(t)?n.ActAccessoire!==t&&(n.ActAccessoire=t,i=!0):n.ActAccessoire=void 0}return i}},{key:"generateShelfPlandata",value:function generateShelfPlandata(){for(var e,t=[],i=this.grids.filter((function(e){return!e.DisabledByRule||e.Cells.some((function(e){return e.InUse===e.Index&&e.Article}))})),r=0;r<i.length;r++){for(var s=[],n=i[r],l=0;l<n.Cells.length;l++){var a,c,d=n.Cells[l];if(s.push({inUse:d.InUse,noDelete:d.NoDelete,noMove:d.NoMove,onBoard:d.OnBoard}),n.ShelfIndex!=r&&(s[l].gridIndex=n.ShelfIndex),d.InUse==l)s[l].usedArticleData={Codex:null===(a=d.Article)||void 0===a?void 0:a.articleCodex,BasketID:null===(c=d.Article)||void 0===c?void 0:c.basketId}}t.push(s)}return{ShelfPlanner2:t,DoorPlannerData:null===(e=this.article.doorPlanner)||void 0===e?void 0:e.getMovedData(this.article.basketId)}}},{key:"getShelfPlannerAccessoires3DValues",value:function getShelfPlannerAccessoires3DValues(e){for(var t=this.activeGrids,i=0;i<t.length;i++)for(var r=t[i],s=0;s<r.Cells.length;s++){var n=r.Cells[s];if(n.InUse==s&&n.Article&&n.Article.model3DName&&!n.OnlyPlaceHolder){var l,a=n.Index;"vertikal"==r.Direction&&1!=this.article.CatalogData.useShelfPlannerRTV&&(a=r.Cells.length-1-n.Index),e.push({basketId:null===(l=n.Article)||void 0===l?void 0:l.basketId,gridId:r.ShelfIndex,gridName:r.GridName,model:n.Article.model3DName,parentBasketId:this.article.basketId,parentElementId:this.getShelfElementId(),rh:a}),n.Article.shelfPlanner&&(e=e.concat(n.Article.shelfPlanner.getShelfPlannerAccessoires3DValues([])))}}return e}},{key:"getShelfElementId",value:function getShelfElementId(){var e;if(null!==(e=this.article.accessoireParentArticle)&&void 0!==e&&e.shelfPlanner&&void 0!==this.article.relatedToShelfGrid&&this.grids.length>0){var t=this.getRHOnParentArticle();return this.article.accessoireParentArticle.shelfPlanner.getShelfElementId()+"."+this.article.relatedToShelfGrid+"."+t}return this.article.elementId.toString()}},{key:"getRHOnParentArticle",value:function getRHOnParentArticle(){var e,t=this;if(void 0!==this.article.relatedToShelfGrid)return null===(e=this.article.accessoireParentArticle)||void 0===e||null===(e=e.shelfPlanner)||void 0===e||null===(e=e.grids[this.article.relatedToShelfGrid].Cells.find((function(e){var i;return(null===(i=e.Article)||void 0===i?void 0:i.basketId)==t.article.basketId})))||void 0===e?void 0:e.InUse}},{key:"getShelfPlannerItems",value:function getShelfPlannerItems(e){for(var t=[],i=this.article.CatalogData,r=this.GridsOrGroupById(e),s=0;s<r.length;s++){var n=r[s].getArticleRelationsById(e);if(null!=n&&n.length)for(var l=function _loop(){var e=n[a];if(i.checkIfArticleCodexExists(e)){var r=i.getCatalogArticleByArticleCodex(e);if(!r||t.find((function(e){return e.articleCodex===r.articleCodex})))return 1;t.push({articleCodex:r.articleCodex,configStepKeys:[],image:r.image?i.getCatImageURL(r.image,""):void 0,name:r.name,longDescription:r.longDescription,price:i.dontShowBasePrice?0:Number(r.articlePrice),width:r.width,height:r.height,depth:r.depth,cellSize:r.shelfHeight,metaData:r.metaDataView,accessoireFamily:r.accessoireFamily,contentItemId:r.contentItemId,groupContentItemId:r.groupContentItemId,partlistcodexes:r.possiblePartlistCodexes})}},a=0;a<n.length;a++)l()}return{accessoires:t,grids:r}}},{key:"getShelfParentShelfId",value:function getShelfParentShelfId(){var e;if(void 0!==this.article.relatedToShelfGrid)return null===(e=this.article.accessoireParentArticle)||void 0===e||null===(e=e.shelfPlanner)||void 0===e||null===(e=e.grids[this.article.relatedToShelfGrid])||void 0===e?void 0:e.ShelfId}},{key:"updateOnDockingChanged",value:function updateOnDockingChanged(e){("AVL"==e&&"RH_OVER_AVL"==this.disableCellsByElement||"AVR"==e&&"RH_OVER_AVR"==this.disableCellsByElement)&&this.updateDisabledCells()}},{key:"updateDisabledCells",value:function updateDisabledCells(){this.updateDisabledCellsOnDockedElements(),this.checkOnDockedHeight()}},{key:"updateDisabledCellsOnDockedElements",value:function updateDisabledCellsOnDockedElements(){var e,t=this.activeGrids,i=this.article.dockedOnAV("L"),r=this.article.dockedOnAV("R");if("RH_OVER_AVR"==this.disableCellsByElement&&i)null===(e=i.shelfPlanner)||void 0===e||e.disableCellsByDockedShelfs(t[0].getCellCount("AVL"));else if("RH_OVER_AVL"==this.disableCellsByElement&&r){var s;null===(s=r.shelfPlanner)||void 0===s||s.disableCellsByDockedShelfs(t[0].getCellCount("AVR"))}}},{key:"checkOnDockedHeight",value:function checkOnDockedHeight(){var e=this.article.dockedOnAV("R"),t=this.article.dockedOnAV("L");null!=e&&e.shelfPlanner&&e.shelfPlanner.activeGrids.length>0&&"RH_OVER_AVR"==this.disableCellsByElement?this.disableCellsByDockedShelfs(e.shelfPlanner.activeGrids[0].getCellCount("AVL")):null!=t&&t.shelfPlanner&&t.shelfPlanner.activeGrids.length>0&&"RH_OVER_AVL"==this.disableCellsByElement?this.disableCellsByDockedShelfs(t.shelfPlanner.activeGrids[0].getCellCount("AVR")):this.disableCellsByDockedShelfs()}},{key:"disableCellsByDockedShelfs",value:(e=(0,r.Z)(d().mark((function _callee12(e){var t,i,r,s=this;return d().wrap((function _callee12$(n){for(;;)switch(n.prev=n.next){case 0:t=this.activeGrids,i=d().mark((function _loop2(){var i,n,l,a,c,o,u,f,g,v;return d().wrap((function _loop2$(d){for(;;)switch(d.prev=d.next){case 0:for(i=t[r],n=i.getCellCount(),l=i.getDisabledCellsByRule(),c=a=null==e||e>n?n:e;c<i.Cells.length;c++)l.push(c);o=l.filter((function(e){return i.Cells[e]&&!i.Cells[e].IsDisabled})),u=i.Cells.filter((function(e,t){return e.IsDisabled&&!l.includes(t)})).length,(o.length||u)&&s.logShelfDebug({phase:"docking",action:"disabledCellsUpdated",gridIndex:i.ShelfIndex,detail:"newlyDisabled=[".concat(o.slice(0,30).join(","),"] reEnabled=").concat(u," ")+"(sources: DisableCellsByRules/measures=".concat(i.getDisabledCellsByRule().length,", beyond cellCount/docking cap=").concat(i.Cells.length-a,"); ")+"an occupied cell that gets disabled deletes its accessory"}),f=0;case 9:if(!(f<l.length)){d.next=18;break}if((g=i.Cells[l[f]]).InUse!=l[f]){d.next=14;break}return d.next=14,h.Z.deleteAccessorieOnShelfPlanner(s.article.set,i.ShelfIndex,g.InUse,i.basketId);case 14:g.IsDisabled=!0;case 15:f++,d.next=9;break;case 18:v=0;case 19:if(!(v<i.Cells.length)){d.next=26;break}if(!l.includes(v)){d.next=22;break}return d.abrupt("continue",23);case 22:i.Cells[v].IsDisabled=!1;case 23:v++,d.next=19;break;case 26:case"end":return d.stop()}}),_loop2)})),r=0;case 3:if(!(r<t.length)){n.next=8;break}return n.delegateYield(i(),"t0",5);case 5:r++,n.next=3;break;case 8:case"end":return n.stop()}}),_callee12,this)}))),function disableCellsByDockedShelfs(t){return e.apply(this,arguments)})},{key:"getGridByGridName",value:function getGridByGridName(e){return this.grids.find((function(t){return t.GridName==e}))}},{key:"getGridByIndex",value:function getGridByIndex(e){return this.grids.find((function(t){return t.ShelfIndex==e}))}},{key:"GridsOrGroupById",value:function GridsOrGroupById(e){return this.activeGrids.filter((function(t){return t.ShelfId==e||t.group==e||t.alternativeGridGroups.includes(e)}))}},{key:"getSelectedAccessoireById",value:function getSelectedAccessoireById(e){var t;return null===(t=this.GridsOrGroupById(e).find((function(t){if(t.ActAccessoire&&t.getArticleRelationsById(e).includes(t.ActAccessoire))return t})))||void 0===t?void 0:t.ActAccessoire}},{key:"getCellIndexOfBasketId",value:function getCellIndexOfBasketId(e,t){var i;return null===(i=this.getGridByIndex(e))||void 0===i?void 0:i.getIndexOfBasketId(t)}},{key:"allGrids",get:function get(){return this.grids}},{key:"activeGrids",get:function get(){return this.grids.filter((function(e){return!e.DisabledByRule}))}},{key:"allMontageOptions",get:function get(){return this.montageOptions}},{key:"getRelatedToGridIdByArticleCodex",value:function getRelatedToGridIdByArticleCodex(e,t){var i=this.grids[t].getGridIdByArticleCodex(e);if(i)return i;for(var r=0;r<this.grids.length;r++){var s=this.grids[r].getGridIdByArticleCodex(e);if(s)return s}}}]);var e,t,i,c,v,b,k,p,A,x,y,C}()}}]);
|