"use strict";(self.webpackChunknextcloud=self.webpackChunknextcloud||[]).push([[6028],{20530:(t,e,s)=>{s.d(e,{A:()=>l});var a=s(71354),i=s.n(a),n=s(76314),o=s.n(n)()(i());o.push([t.id,".systemtags-picker__create[data-v-272b44d0],.systemtags-picker__note[data-v-272b44d0]{position:sticky;z-index:9;background-color:var(--color-main-background)}.systemtags-picker__create[data-v-272b44d0]{display:flex;top:0;gap:8px;padding-block-end:8px;align-items:flex-end}.systemtags-picker__create button[data-v-272b44d0]{flex-shrink:0}.systemtags-picker__note[data-v-272b44d0]{bottom:0;padding-block:8px}.systemtags-picker__note[data-v-272b44d0] .notecard{min-height:2lh;align-items:center}.systemtags-picker__note>div[data-v-272b44d0]{margin:0 !important}.systemtags-picker--done[data-v-272b44d0] .empty-content__icon{opacity:1}.nc-chip[data-v-272b44d0]{display:inline !important}","",{version:3,sources:["webpack://./apps/systemtags/src/components/SystemTagPicker.vue"],names:[],mappings:"AAEA,sFAEC,eAAA,CACA,SAAA,CACA,6CAAA,CAGD,4CACC,YAAA,CACA,KAAA,CACA,OAAA,CACA,qBAAA,CACA,oBAAA,CAEA,mDACC,aAAA,CAIF,0CACC,QAAA,CACA,iBAAA,CAEA,oDAEC,cAAA,CACA,kBAAA,CAGD,8CACC,mBAAA,CAIF,+DACC,SAAA,CAID,0BACC,yBAAA",sourceRoot:""}]);const l=o},16028:(t,e,s)=>{s.r(e),s.d(e,{default:()=>Z});var a=s(85471),i=s(61338),n=s(42838),o=s(85168),l=s(53334),r=s(70580),c=s.n(r),d=s(18740),g=s(32073),h=s(32036),p=s(94219),m=s(34196),u=s(84237),A=s(80910),y=s(82182);const f={name:"TagIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}};var C=s(14486);const v=(0,C.A)(f,(function(){var t=this,e=t._self._c;return e("span",t._b({staticClass:"material-design-icon tag-icon",attrs:{"aria-hidden":!t.title||null,"aria-label":t.title,role:"img"},on:{click:function(e){return t.$emit("click",e)}}},"span",t.$attrs,!1),[e("svg",{staticClass:"material-design-icon__svg",attrs:{fill:t.fillColor,width:t.size,height:t.size,viewBox:"0 0 24 24"}},[e("path",{attrs:{d:"M5.5,7A1.5,1.5 0 0,1 4,5.5A1.5,1.5 0 0,1 5.5,4A1.5,1.5 0 0,1 7,5.5A1.5,1.5 0 0,1 5.5,7M21.41,11.58L12.41,2.58C12.05,2.22 11.55,2 11,2H4C2.89,2 2,2.89 2,4V11C2,11.55 2.22,12.05 2.59,12.41L11.58,21.41C11.95,21.77 12.45,22 13,22C13.55,22 14.05,21.77 14.41,21.41L21.41,14.41C21.78,14.05 22,13.55 22,13C22,12.44 21.77,11.94 21.41,11.58Z"}},[t.title?e("title",[t._v(t._s(t.title))]):t._e()])])])}),[],!1,null,null,null).exports,b={name:"CheckCircleIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},_=(0,C.A)(b,(function(){var t=this,e=t._self._c;return e("span",t._b({staticClass:"material-design-icon check-circle-icon",attrs:{"aria-hidden":!t.title||null,"aria-label":t.title,role:"img"},on:{click:function(e){return t.$emit("click",e)}}},"span",t.$attrs,!1),[e("svg",{staticClass:"material-design-icon__svg",attrs:{fill:t.fillColor,width:t.size,height:t.size,viewBox:"0 0 24 24"}},[e("path",{attrs:{d:"M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M10 17L5 12L6.41 10.59L10 14.17L17.59 6.58L19 8L10 17Z"}},[t.title?e("title",[t._v(t._s(t.title))]):t._e()])])])}),[],!1,null,null,null).exports;var N=s(12686),k=s(82528);const T=(0,s(35947).YK)().setApp("systemtags").detectUser().build();var S;!function(t){t.BASE="base",t.LOADING="loading",t.CREATING_TAG="creating-tag",t.DONE="done"}(S||(S={}));const w=(0,a.pM)({name:"SystemTagPicker",components:{CheckIcon:_,NcButton:d.A,NcCheckboxRadioSwitch:g.A,NcChip:h.A,NcDialog:p.A,NcEmptyContent:m.A,NcLoadingIcon:u.A,NcNoteCard:A.A,NcTextField:y.A,TagIcon:v},props:{nodes:{type:Array,required:!0}},setup:()=>({emit:i.Ic,Status:S,t:l.t}),data:()=>({status:S.BASE,opened:!0,input:"",tags:[],tagList:{},toAdd:[],toRemove:[]}),computed:{filteredTags(){return""===this.input.trim()?this.tags:this.tags.filter((t=>t.displayName.normalize().includes(this.input.normalize())))},hasChanges(){return this.toAdd.length>0||this.toRemove.length>0},statusMessage(){if(0===this.toAdd.length&&0===this.toRemove.length)return"";if(1===this.toAdd.length&&1===this.toRemove.length)return(0,l.n)("systemtags","{tag1} will be set and {tag2} will be removed from 1 file.","{tag1} and {tag2} will be set and removed from {count} files.",this.nodes.length,{tag1:this.formatTagChip(this.toAdd[0]),tag2:this.formatTagChip(this.toRemove[0]),count:this.nodes.length},{escape:!1});const t=this.toAdd.map(this.formatTagChip),e=t.pop(),s=this.toRemove.map(this.formatTagChip),a=s.pop(),i=(0,l.n)("systemtags","{tag} will be set to 1 file.","{tag} will be set to {count} files.",this.nodes.length,{tag:e,count:this.nodes.length},{escape:!1}),n=(0,l.n)("systemtags","{tag} will be removed from 1 file.","{tag} will be removed from {count} files.",this.nodes.length,{tag:a,count:this.nodes.length},{escape:!1}),o=(0,l.n)("systemtags","{tags} and {lastTag} will be set to 1 file.","{tags} and {lastTag} will be set to {count} files.",this.nodes.length,{tags:t.join(", "),lastTag:e,count:this.nodes.length},{escape:!1}),r=(0,l.n)("systemtags","{tags} and {lastTag} will be removed from 1 file.","{tags} and {lastTag} will be removed from {count} files.",this.nodes.length,{tags:s.join(", "),lastTag:a,count:this.nodes.length},{escape:!1});return 1===this.toAdd.length&&0===this.toRemove.length?i:0===this.toAdd.length&&1===this.toRemove.length?n:this.toAdd.length>1&&0===this.toRemove.length?o:0===this.toAdd.length&&this.toRemove.length>1?r:this.toAdd.length>1&&1===this.toRemove.length?`${o} ${n}`:1===this.toAdd.length&&this.toRemove.length>1?`${i} ${r}`:`${o} ${r}`}},beforeMount(){(0,k.un)().then((t=>{this.tags=t})),this.tagList=this.nodes.reduce(((t,e)=>(((0,N.rA)(e)||[]).forEach((e=>{t[e]=(t[e]||0)+1})),t)),{})},methods:{formatTagChip(t){return this.$refs.chip.$el.outerHTML.replace("%s",c()((0,n.sanitize)(t.displayName)))},formatTagName:t=>t.userVisible?t.userAssignable?t.displayName:(0,l.t)("systemtags","{displayName} (restricted)",{displayName:t.displayName}):(0,l.t)("systemtags","{displayName} (hidden)",{displayName:t.displayName}),isChecked(t){return t.displayName in this.tagList&&this.tagList[t.displayName]===this.nodes.length},isIndeterminate(t){return t.displayName in this.tagList&&0!==this.tagList[t.displayName]&&this.tagList[t.displayName]!==this.nodes.length},onCheckUpdate(t,e){e?(this.toAdd.push(t),this.toRemove=this.toRemove.filter((e=>e.id!==t.id)),this.tagList[t.displayName]=this.nodes.length):(this.toRemove.push(t),this.toAdd=this.toAdd.filter((e=>e.id!==t.id)),this.tagList[t.displayName]=0)},async onNewTag(){this.status=S.CREATING_TAG;try{const t={displayName:this.input.trim(),userAssignable:!0,userVisible:!0,canAssign:!0},e=await(0,k.VZ)(t),s=await(0,k.xI)(e);this.tags.push(s),this.input="",this.onCheckUpdate(s,!0)}catch(t){(0,o.Qg)(t?.message||(0,l.t)("systemtags","Failed to create tag"))}finally{this.status=S.BASE}},async onSubmit(){this.status=S.LOADING,T.debug("Applying tags",{toAdd:this.toAdd,toRemove:this.toRemove});try{for(const t of this.toAdd){const{etag:e,objects:s}=await(0,k.b0)(t,"files"),a=[...new Set([...s.map((t=>t.id)).filter(Boolean),...this.nodes.map((t=>t.fileid)).filter(Boolean)])];await(0,k.T0)(t,"files",a.map((t=>({id:t,type:"files"}))),e)}for(const t of this.toRemove){const{etag:e,objects:s}=await(0,k.b0)(t,"files"),a=new Set(this.nodes.map((t=>t.fileid))),i=s.map((t=>t.id)).filter(((t,e,s)=>!a.has(t)&&s.indexOf(t)===e));await(0,k.T0)(t,"files",i.map((t=>({id:t,type:"files"}))),e)}}catch(t){return T.error("Failed to apply tags",{error:t}),(0,o.Qg)((0,l.t)("systemtags","Failed to apply tags changes")),void(this.status=S.BASE)}const t=[];this.toAdd.forEach((e=>{this.nodes.forEach((s=>{const a=[...(0,N.rA)(s)||[],e.displayName].sort(((t,e)=>t.localeCompare(e,(0,l.Z0)(),{ignorePunctuation:!0})));(0,N.Pq)(s,a),t.push(s)}))})),this.toRemove.forEach((e=>{this.nodes.forEach((s=>{const a=[...(0,N.rA)(s)||[]].filter((t=>t!==e.displayName)).sort(((t,e)=>t.localeCompare(e,(0,l.Z0)(),{ignorePunctuation:!0})));(0,N.Pq)(s,a),t.push(s)}))})),t.forEach((t=>(0,i.Ic)("systemtags:node:updated",t))),this.status=S.DONE,setTimeout((()=>{this.opened=!1,this.$emit("close",!0)}),2e3)},onCancel(){this.opened=!1,(0,o.cf)((0,l.t)("systemtags","File tags modification canceled")),this.$emit("close",null)}}});var E=s(85072),x=s.n(E),L=s(97825),I=s.n(L),R=s(77659),B=s.n(R),D=s(55056),$=s.n(D),G=s(10540),z=s.n(G),M=s(41113),P=s.n(M),F=s(20530),O={};O.styleTagTransform=P(),O.setAttributes=$(),O.insert=B().bind(null,"head"),O.domAPI=I(),O.insertStyleElement=z(),x()(F.A,O),F.A&&F.A.locals&&F.A.locals;const Z=(0,C.A)(w,(function(){var t=this,e=t._self._c;return t._self._setupProxy,e("NcDialog",{staticClass:"systemtags-picker",class:"systemtags-picker--"+t.status,attrs:{"data-cy-systemtags-picker":"",name:t.t("systemtags","Manage tags"),open:t.opened,"close-on-click-outside":"","out-transition":""},on:{"update:open":t.onCancel},scopedSlots:t._u([{key:"actions",fn:function(){return[e("NcButton",{attrs:{disabled:t.status!==t.Status.BASE,type:"tertiary","data-cy-systemtags-picker-button-cancel":""},on:{click:t.onCancel}},[t._v("\n\t\t\t"+t._s(t.t("systemtags","Cancel"))+"\n\t\t")]),t._v(" "),e("NcButton",{attrs:{disabled:!t.hasChanges||t.status!==t.Status.BASE,"data-cy-systemtags-picker-button-submit":""},on:{click:t.onSubmit}},[t._v("\n\t\t\t"+t._s(t.t("systemtags","Apply changes"))+"\n\t\t")])]},proxy:!0}])},[t.status===t.Status.LOADING||t.status===t.Status.DONE?e("NcEmptyContent",{attrs:{name:t.t("systemtags","Applying tags changes…")},scopedSlots:t._u([{key:"icon",fn:function(){return[t.status===t.Status.LOADING?e("NcLoadingIcon"):e("CheckIcon",{attrs:{"fill-color":"var(--color-success)"}})]},proxy:!0}],null,!1,1067531430)}):[e("form",{staticClass:"systemtags-picker__create",on:{submit:function(e){return e.stopPropagation(),e.preventDefault(),t.onNewTag.apply(null,arguments)}}},[e("NcTextField",{attrs:{value:t.input,label:t.t("systemtags","Search or create tag"),"data-cy-systemtags-picker-input":""},on:{"update:value":function(e){t.input=e}}},[e("TagIcon",{attrs:{size:20}})],1),t._v(" "),e("NcButton",{attrs:{disabled:t.status===t.Status.CREATING_TAG,"native-type":"submit","data-cy-systemtags-picker-input-submit":""}},[t._v("\n\t\t\t\t"+t._s(t.t("systemtags","Create tag"))+"\n\t\t\t")])],1),t._v(" "),t.filteredTags.length>0?e("div",{staticClass:"systemtags-picker__tags",attrs:{"data-cy-systemtags-picker-tags":""}},t._l(t.filteredTags,(function(s){return e("NcCheckboxRadioSwitch",{key:s.id,attrs:{label:s.displayName,checked:t.isChecked(s),indeterminate:t.isIndeterminate(s),disabled:!s.canAssign,"data-cy-systemtags-picker-tag":s.id},on:{"update:checked":function(e){return t.onCheckUpdate(s,e)}}},[t._v("\n\t\t\t\t"+t._s(t.formatTagName(s))+"\n\t\t\t")])})),1):e("NcEmptyContent",{attrs:{name:t.t("systemtags","No tags found")},scopedSlots:t._u([{key:"icon",fn:function(){return[e("TagIcon")]},proxy:!0}])}),t._v(" "),e("div",{staticClass:"systemtags-picker__note"},[t.hasChanges?e("NcNoteCard",{attrs:{type:"info"}},[e("span",{domProps:{innerHTML:t._s(t.statusMessage)}})]):e("NcNoteCard",{attrs:{type:"info"}},[t._v("\n\t\t\t\t"+t._s(t.t("systemtags","Select or create tags to apply to all selected files"))+"\n\t\t\t")])],1)],t._v(" "),t._v(" "),e("div",{directives:[{name:"show",rawName:"v-show",value:!1,expression:"false"}]},[e("NcChip",{ref:"chip",attrs:{text:"%s",type:"primary","no-close":""}})],1)],2)}),[],!1,null,"272b44d0",null).exports}}]); //# sourceMappingURL=6028-6028.js.map?v=5ce1128bba38461a1848