PageSourceSearch

https://torp.se/dist/client/assets/CenterContentSettingsModal-9SUSYd_F.js

js torp.se collected 2026-09-26 14:24:25 UTC 5,920 bytes, 1 lines download raw bytes

1import{a as v}from"./index-BX4p_2E3.js";import{l as k,m as E,T as w,M as B,i as V}from"./index-Brwi4r46.js";import{L as O}from"./LoadingSpinner-BysyIPFJ.js";import{C as U}from"./CheckBox-Jwm4IGc-.js";import{R as D}from"./RadioButton-C_m9BSRw.js";import{u as N}from"./use-i18n-hBPy9l0p.js";import{_ as T}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{r as h,p as g,o as n,w as I,c as l,F as u,a as d,m as C,t as c,d as f,b}from"./runtime-dom.esm-bundler-DjT8oBXG.js";import"./HubIcon-DH8D8TrY.js";import"./InputField-NK19VCkE.js";import"./debounce-B64wGVAr.js";import"./entry-client-B9_6MISb.js";import"react-dom/client";import"react";import"react/jsx-runtime";const F={name:"CenterContentSettingsModal",components:{CheckBox:U,ModalWrapper:B,TagSelector:w,RadioButton:D,LoadingSpinner:O},emits:["update:viewTitle","update:menuSelection"],setup(){return{i18n:N()}},data(){return{saving:!1,loading:!1,settings:null,serverSettings:null,menuItemSelections:[{id:0,name:this.i18n.itemEditor.noMenuItem},{id:1,name:this.i18n.itemEditor.customerClub},{id:2,name:this.i18n.itemEditor.brands}]}},computed:{...E({centerId:e=>e.centerId,culture:e=>e.culture}),settingsUrl(){return`/api/hub/${this.culture}/${this.centerId}/contentSettings`},savedFields:()=>["selectedStoreCategoryMenuItems","highlightStoreIds","menuSelection","selectedCenterServiceMenuItems"],highlightStorePlaceholder(){return this.highlightStoreIds.map(e=>e.length>0?this.i18n.itemEditor.storesAdded:`– ${this.i18n.itemEditor.choose} –`)},serviceMenuIdsPlaceholder(){return this.settings?.selectedCenterServiceMenuItems?.length?this.i18n.itemEditor.serviceMenuAdded:`– ${this.i18n.itemEditor.choose} –`},isDirty(){return!V(this.getSavableContent(),this.serverSettings)},highlightStoreIds(){return this.settings&&this.settings.storeCategoryMenuItems.map(e=>this.settings.highlightStoreIds.filter(t=>e.stores.map(a=>a.id).includes(t)))}},watch:{settingsUrl:{handler:"loadData",immediate:!0},"settings.selectedStoreCategoryMenuItems":{handler(){const e=this.settings.storeCategoryMenuItems.filter(t=>this.settings.selectedStoreCategoryMenuItems.indexOf(t.id)!==-1).map(t=>t.stores.map(a=>a.id)).flat();this.settings.highlightStoreIds=this.settings.highlightStoreIds.filter(t=>e.indexOf(t)!==-1)},deep:!0}},created(){this.$emit("update:viewTitle",this.i18n.dashboard?.contentSettings)},methods:{...k(["writeStatus"]),verifyMenuItemSelections(){if(!this.settings?.canSelectCustomerClub){const e=this.menuItemSelections.map(t=>t.id).indexOf(1);this.menuItemSelections.splice(e,1)}},updateSelectedStoreCategoryMenuItems(e){const t=this.settings.selectedStoreCategoryMenuItems.indexOf(e);t===-1?this.settings.selectedStoreCategoryMenuItems.push(e):this.settings.selectedStoreCategoryMenuItems.splice(t,1)},updateHighlightStoreIds(e,t){const a=[...this.highlightStoreIds];a[e]=t,this.settings.highlightStoreIds=a.flat()},close(){this.$router.back()},getSavableContent(){return this.settings?Object.fromEntries(this.savedFields.map(e=>[e,this.settings[e]])):{}},async loadData(e){this.loading=!0;const t=await v.get(e);this.settings=t.data,this.serverSettings=JSON.parse(JSON.stringify(this.getSavableContent())),this.verifyMenuItemSelections(),this.loading=!1},async save(){this.saving=!0,await v.post(this.settingsUrl,this.getSavableContent()).then(e=>{this.writeStatus({text:this.i18n.dashboard.settingsSaved,type:"success"}),this.close()}).catch(e=>{this.writeStatus({text:this.i18n.itemEditor.saveFailed,type:"success"})}),this.saving=!1}}},L={class:"margin-bottom--lg"},A={class:"line-title"},P={class:"margin-bottom"},R={class:"margin-bottom"},W={key:0},H={key:1,class:"margin-top margin-bottom--lg"};function J(e,t,a,o,s,r){const M=h("LoadingSpinner"),y=h("CheckBox"),S=h("TagSelector"),_=h("RadioButton"),x=h("ModalWrapper");return n(),g(x,{heading:o.i18n.dashboard.contentSettings,"can-save":r.isDirty,saving:s.saving,onSave:r.save,onClose:r.close},{description:I(()=>[d("p",null,c(o.i18n.dashboard.contentSettingsIntro),1)]),default:I(()=>[s.loading?(n(),g(M,{key:0})):(n(),l(u,{key:1},[d("section",L,[d("h2",A,c(o.i18n.dashboard.contentSettings),1),s.settings.storeCategoryMenuItems?.length>0?(n(),l(u,{key:0},[d("h3",P,c(o.i18n.itemEditor.storeCategoriesInMenu),1),(n(!0),l(u,null,f(s.settings.storeCategoryMenuItems,(i,m)=>(n(),l("div",{key:i.id},[b(y,{"model-value":s.settings.selectedStoreCategoryMenuItems.indexOf(i.id)!==-1,label:i.name,"onUpdate:modelValue":p=>
1r.updateSelectedStoreCategoryMenuItems(i.id)},null,8,["model-value","label","onUpdate:modelValue"]),s.settings.selectedStoreCategoryMenuItems.indexOf(i.id)!==-1?(n(),g(S,{key:0,"model-value":r.highlightStoreIds[m],heading:o.i18n.dashboard.highlightedStore,"label-text":r.highlightStorePlaceholder[m],"is-single-option":"","all-tags":i.stores,"onUpdate:modelValue":p=>r.updateHighlightStoreIds(m,p)},null,8,["model-value","heading","label-text","all-tags","onUpdate:modelValue"])):C("",!0)]))),128))],64)):C("",!0)]),d("h3",R,c(o.i18n.itemEditor.menuSelection),1),d("p",null,c(o.i18n.dashboard.contentSettingsIntroNote),1),(n(!0),l(u,null,f(s.menuItemSelections,i=>(n(),g(_,{key:i.id,label:i.name,"model-value":i.id===s.settings.menuSelection,name:"menuSelection",onSelected:m=>s.settings.menuSelection=i.id},null,8,["label","model-value","onSelected"]))),128)),s.settings.canSelectCustomerClub?(n(),l("section",H,[b(S,{modelValue:s.settings.selectedCenterServiceMenuItems,"onUpdate:modelValue":t[0]||(t[0]=i=>s.settings.selectedCenterServiceMenuItems=i),"max-tags":2,heading:o.i18n.dashboard.serviceMenuSelectionDropDown,"label-text":r.serviceMenuIdsPlaceholder,"all-tags":s.settings.centerServiceMenuItems},null,8,["modelValue","heading","label-text","all-tags"])])):(n(),l("div",W,[d("p",null,c(o.i18n.itemEditor.menuSelectionCustomerClubNotAvailable),1)]))],64))]),_:1},8,["heading","can-save","saving","onSave","onClose"])}const oe=T(F,[["render",J]]);export{oe as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.