PageSourceSearch

https://ticket.buildingthefuture.pt/assets/EditProduct-BqrPCVRx.js

js buildingthefuture.pt collected 2026-10-02 14:34:13 UTC 10,057 bytes, 1 lines download raw bytes

1import{d as we,h as u,J as $e,e as H,s as F,ax as ke,y as j,m as xe,o as c,c as v,f as q,g as B,F as z,A as te,z as ae,a as $,al as Ce,b as g,t as k,u as x,n as se,ad as Fe,_ as Pe,i as Ie,c6 as Re,c7 as Ve,c8 as Se,c9 as Ae,bs as Ee}from"./index-CECfxDsp.js";import{_ as Ue}from"./input.vue_vue_type_style_index_0_lang-DYWz1_NN.js";import{_ as oe}from"./checkbox.vue_vue_type_style_index_0_lang-CqUG8IxO.js";import{_ as qe}from"./cropper.vue_vue_type_style_index_0_lang-CoOM0uYD.js";import{s as le,m as Be,f as ve}from"./index-sKrBdEUS.js";import{b as De,a as Le,c as je,d as ze,e as Ne,f as Me}from"./categories-Cz3uxHUd.js";import{g as Je,i as Oe,u as Qe,d as Ge}from"./files-Bwxkdus4.js";import"./utils-DGnOM_Au.js";import"./isJson-BEZlTCKP.js";const He={class:"product-edit"},Ke={class:"title is-4"},Te={key:0,class:"d-flex align-center justify-center fill-height"},We={key:1},Xe={key:0,class:"product-categories",style:{"margin-top":"1.5rem"}},Ye={class:"title is-6"},Ze={key:1},et={class:"buttons"},tt={class:"title is-4"},at={key:0},st={key:1},ot={class:"figure"},lt=["src"],it={key:0,class:"buttons",style:{width:"100%"}},_t=we({__name:"EditProduct",setup(nt){const A=u({...Be}),K=u({isActive:!1,isCard:!0,showClose:!1}),_=u({}),p=u([]),f=u([...ve]),N=u([]),ie=u({}),T=u(!1),M=u(le()),J=u(!1),S=u(!1),O=u({image:"",onSelect:l=>{console.log(l)},aspectRatio:1}),D=u(!0),L=u(!1),ne=u(""),C=u(0),W=u(!1),X=u([]),{translations:i,contextEvent:pe,eventContextRoute:re}=Ie(),{triggerPopupErrors:P}=Ee();let Y=[],I=0,Q=0,ue="",Z=[],ce=-1,G=[],E=[],h={};const fe=l=>E.find(o=>o.active&&`product-category_${o.id}`===l.id)!==void 0,de=async()=>{var l,t;if(_.value&&_.value.form){M.value=le(),M.value.value=_.value.submitted,J.value=_.value.submitted,T.value=_.value.display_on_beamer||!1,ie.value.value=T.value;const e=(await Re(_.value.form)).data.results,a=(l=(await Ve(I)).data.results[0])==null?void 0:l.id;if(a){const y=await Se(a);p.value=y.data.results,f.value=[...ve];for(let n=0;n<p.value.length;n++){const r=p.value[n],R=e.find(m=>r.form_field===m.id);if(!R)continue;const d=(t=_.value.answers)==null?void 0:t.find(m=>{var w;return((w=m.question)==null?void 0:w.form_field)===R.id}),b=d?d.value:"";if(R.type_field>5&&R.type_field<10)if(b&&b!=="undefined"){f.value[n]={id:`product-${r.id}`,name:`product_${r.id}`,label:r.display_name,placeholder:r.placeholder,type:"file",onFileSelect:U=>me(U,n),value:""},j();const m=await Je(b);if(Oe(m)){F.commit("addPopup",{message:i.value.common.content_not_allowed,type:"danger",autohide:!0});return}const w=m.data.file,V=m.data.original_file_name;f.value[n]={...f.value[n],message:w,onDelete:()=>{Y.push(n),f.value[n]={...f.value[n],message:void 0},j()},value:{name:V||""}},p.value[n].answer={name:V||""}}else f.value[n]={id:`product-${r.id}`,name:`product_${r.id}`,label:r.display_name,placeholder:r.placeholder,type:"file",info:r.required?i.value.common.mandatory_field:void 0,onFileSelect:m=>me(m,n),value:b};else f.value[n]={id:`product-${r.id}`,name:`product_${r.id}`,label:r.display_name,placeholder:r.placeholder,type:R.name==="Description"?"textarea":"text",info:r.required?i.value.common.mandatory_field:void 0,value:b},p.value[n].answer=b;j()}}}else await F.dispatch("fetchProductById",{event:I,productId:C.value})},me=(l,t)=>{if(ue=l.name,l.name.match(/.(jpg|jpeg|png|gif)$/i)){const o=new FileReader;o.onload=e=>{e&&e.target&&e.target.result&&(O.value={...O.value,image:e.target.result},D.value=!0,L.value=!1,K.value.isActive=!0,ce=t)},o.readAsDataURL(l)}else f.value[t]={...f.value[t],value:"",message:i.value.common.file_not_image,error:!0},j()},ge=l=>{const t=new File([l],ue,{type:"image/png"}),o=window.URL||window.webkitURL;ne.value=o.createObjectURL(l),Z[ce]=t,D.value=!1,L.value=!0},ee=()=>{K.value.isActive=!1},_e=()=>{D.value=!0,L.value=!1},ye=async()=>{W.value=!0;let l=!1;await Ae(C.value).catch(t=>{P(t),l=!0}),W.value=!1,l||H.push(`${re.value}/manage-exhibitor/${Q}/products`)},be=async()=>{let l=!1;if(p.value.filter(t=>t.required).forEach(t=>{(!t.answer||t.answer==="")&&(f.value=f.value.map(o=>o.id===`product-${t.id}`?(l=!0,{...o,message:i.value.common.mandatory_field,error:!0}):o))}),l)F.commit("addPopup",{message:i.value.common.form_fields_errors,type:"danger",autohide:!0});else{S.value=!0,_.value.submitted=J.value,_.value.display_on_beamer=T.value;for(const o in Z){const e=Z[o],s=new FormData;s.append("file",e);const a=await Qe(s).catch(y=>{P(y)});a&&(p.value[o].answer=`${a.data.id}`)}for(const o in Y)await Ge(Y[o]).catch(e=>{P(e)});F.dispatch("editProduct",{payload:{questions:p.value,answers:_.value.answers,product:_.value},event:I,exhibitor:Q});const t=F.subscribe(o=>{o.type==="editProduct"&&(S.value=!1,o.payload.allActionsSuccessful&&(E.forEach(async e=>{if(e.active)await je({category:e.id,product:h.id}).catch(s=>{P(s)});else if(h.categories){const s=h.categories.find(a=>a.category===e.id);s&&await ze({category:s.id,product:h.id}).catch(a=>{P(a)})}}),G.forEach(async e=>{if(e.active)await Ne({subcategory:e.id,product:h.id}).catch(s=>{P(s)});else if(h.categories){const s=h.categories.filter(a=>a.subcategories.some(y=>y.subcategory===e.id)).map(a=>a.subcategories.find(y=>y.subcategory===e.id))[0];s&&await Me({subcategory:s.id,product:h.id}).catch(a=>{P(a)})}}
1),F.commit("addPopup",{message:i.value.common.saved,type:"success",autohide:!0}),H.push(`${re.value}/manage-exhibitor/${Q}/product/${C.value}`)),F.dispatch("fetchProductById",{event:I,productId:C.value}),t()),o.type==="setProductError"&&(S.value=!1,P(o.payload.error))})}};return $e(async()=>{S.value=!0;try{C.value=parseInt(H.currentRoute.value.params.product,10),I=pe.value.id,Q=parseInt(H.currentRoute.value.params.exhibitor,10),O.value.onSelect=ge,ie.value={id:"product-display_on_beamer",name:"product_display_on_beamer",value:!1,type:"checkbox",label:i.value.common.display_on_beamer,message:i.value.common.display_on_beamer_message,error:!1},_.value=await F.dispatch("fetchProductById",{event:I,productId:C.value}),M.value=le(),A.value.close&&(A.value.close=A.value.close.bind({},C.value));const{data:l}=await De({event:I});if(h=(await ke(C.value)).data,l&&l.results){const e=l.results,s=await Le({event:I});X.value=s.data.results,X.value.forEach(a=>{var R;const y=[],n=e.filter(d=>d.category===a.id),r=(R=h.categories)==null?void 0:R.some(d=>d.category===a.id);r&&E.push({id:a.id,active:!0}),n.forEach(d=>{var m;const b=(m=h.categories)==null?void 0:m.some(w=>{var V;return(V=w.subcategories)==null?void 0:V.some(U=>U.subcategory===d.id)});b&&G.push({id:d.id,active:!0}),y.push({id:`product-subcategory_${d.id}`,name:`product_subcategory_${d.id}`,value:!!b,type:"checkbox",label:d.name,onClick:w=>{const V=G.find(he=>he.id===d.id),U=w==="on";V?V.active=U:G.push({id:d.id,active:U})}})}),N.value.push({id:`product-category_${a.id}`,name:`product_category_${a.id}`,value:!!r,type:"checkbox",label:a.name,onClick:d=>{const b=d==="on",m=E.findIndex(w=>w.id===a.id);m>=0?E[m].active=b:E.push({id:a.id,active:b})},children:y})}),j()}await de();const o=F.subscribe(e=>{e.type==="setProducts"&&(de(),o())})}finally{S.value=!1}}),(l,t)=>{const o=xe("v-progress-circular");return c(),v("div",He,[q(Fe,{config:A.value},{header:B(()=>[g("h4",Ke,k(x(i).exhibitors.products.edit_product),1)]),footer:B(()=>[g("div",et,[g("button",{type:"button",class:"button is-light",onClick:t[1]||(t[1]=e=>A.value.close&&A.value.close(C.value))},k(x(i).common.close),1),g("button",{type:"button",class:se(["button is-danger",{"is-loading":W.value}]),onClick:t[2]||(t[2]=e=>ye())},k(x(i).common.delete),3),g("button",{type:"button",class:se(["button is-success is-pulled-right",{"is-loading":S.value}]),onClick:t[3]||(t[3]=e=>be())},[t[8]||(t[8]=g("span",{class:"material-icons-outlined",style:{"margin-right":"0.125rem"}}," save ",-1)),g("span",null,k(x(i).common.save),1)],2)])]),default:B(()=>[S.value?(c(),v("div",Te,[q(o,{indeterminate:"",size:65})])):f.value.length?(c(),v("div",We,[(c(!0),v(z,null,te(f.value,(e,s)=>(c(),v(z,null,[p.value[s]&&e&&(e.type==="text"||e.type==="file")?(c(),ae(Ue,{config:e,modelValue:p.value[s].answer,"onUpdate:modelValue":a=>p.value[s].answer=a,key:`input-question-${s}`},null,8,["config","modelValue","onUpdate:modelValue"])):$("",!0),p.value[s]&&e&&e.type==="textarea"?(c(),ae(Ce,{config:e,modelValue:p.value[s].answer,"onUpdate:modelValue":a=>p.value[s].answer=a,key:`textarea-question-${s}`},null,8,["config","modelValue","onUpdate:modelValue"])):$("",!0)],64))),256)),N.value.length>0?(c(),v("div",Xe,[g("h4",Ye,k(x(i).common.category),1),(c(!0),v(z,null,te(N.value,(e,s)=>(c(),v(z,{key:`checkbox-category-${s}`},[q(oe,{config:e},null,8,["config"]),e.children?(c(),v("div",{style:{margin:"0 0 1.5rem 1.5rem"},key:`div-subcategories-${s}`},[(c(!0),v(z,null,te(e.children,(a,y)=>(c(),ae(oe,{config:a,class:se({"is-hidden":!X.value.some(n=>fe(e))}),key:`checkbox-subcategory-${y}`},null,8,["config","class"]))),128))])):$("",!0)],64))),128))])):$("",!0),N.value.length>0?(c(),v("hr",Ze)):$("",!0),q(oe,{config:M.value,modelValue:J.value,"onUpdate:modelValue":t[0]||(t[0]=e=>J.value=e)},null,8,["config","modelValue"])])):$("",!0)]),_:1},8,["config"]),q(Pe,{config:K.value,id:"modal-cropper"},{header:B(()=>[g("h4",tt,k(x(i).exhibitors.onboarding.managedFields.crop_image),1)]),body:B(()=>[D.value?(c(),v("div",at,[q(qe,{config:O.value},null,8,["config"])])):$("",!0),L.value?(c(),v("div",st,[g("div",ot,[g("img",{src:ne.value,alt:"",loading:"lazy"},null,8,lt)])])):$("",!0)]),footer:B(()=>[L.value?(c(),v("div",it,[g("button",{type:"button",class:"button is-success is-pulled-right",onClick:t[4]||(t[4]=e=>ee())},k(x(i).common.confirm),1),g("button",{type:"button",class:"button is-light",onClick:t[5]||(t[5]=e=>ee())},k(x(i).common.cancel),1),g("button",{type:"button",class:"button is-light",onClick:t[6]||(t[6]=e=>_e())},k(x(i).exhibitors.onboarding.managedFields.crop_again),1)])):$("",!0),D.value?(c(),v("button",{key:1,type:"button",class:"button is-light",onClick:t[7]||(t[7]=e=>ee())},k(x(i).common.cancel),1)):$("",!0)]),_:1},8,["config"])])}}});
1export{_t 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.