12 |
- "use strict";(self.webpackChunknextcloud=self.webpackChunknextcloud||[]).push([[5365],{90685:(t,e,s)=>{s.d(e,{A:()=>l});var a=s(71354),i=s.n(a),o=s(76314),n=s.n(o)()(i());n.push([t.id,".systemtags-picker__input[data-v-a70e877c],.systemtags-picker__note[data-v-a70e877c]{position:sticky;z-index:9;background-color:var(--color-main-background)}.systemtags-picker__input[data-v-a70e877c]{display:flex;top:0;gap:8px;padding-block-end:8px;align-items:flex-end}.systemtags-picker__tags[data-v-a70e877c]{padding-block:8px;gap:var(--default-grid-baseline);display:flex;flex-direction:column}.systemtags-picker__tags li[data-v-a70e877c]{display:flex;align-items:center;justify-content:space-between;width:100%}.systemtags-picker__tags li[data-v-a70e877c] .checkbox-radio-switch{width:100%}.systemtags-picker__tags li[data-v-a70e877c] .checkbox-radio-switch .checkbox-content{max-width:none;box-sizing:border-box;min-height:calc(var(--default-grid-baseline)*2 + var(--default-clickable-area))}.systemtags-picker__tags .systemtags-picker__tag-color button[data-v-a70e877c]{margin-inline-start:calc(var(--default-grid-baseline)*2)}.systemtags-picker__tags .systemtags-picker__tag-color button span.pencil-icon[data-v-a70e877c]{display:none;color:var(--color-main-text)}.systemtags-picker__tags .systemtags-picker__tag-color button:focus .pencil-icon[data-v-a70e877c],.systemtags-picker__tags .systemtags-picker__tag-color button:hover .pencil-icon[data-v-a70e877c],.systemtags-picker__tags .systemtags-picker__tag-color button[aria-expanded=true] .pencil-icon[data-v-a70e877c]{display:block}.systemtags-picker__tags .systemtags-picker__tag-color button:focus .circle-icon[data-v-a70e877c],.systemtags-picker__tags .systemtags-picker__tag-color button:focus .circle-outline-icon[data-v-a70e877c],.systemtags-picker__tags .systemtags-picker__tag-color button:hover .circle-icon[data-v-a70e877c],.systemtags-picker__tags .systemtags-picker__tag-color button:hover .circle-outline-icon[data-v-a70e877c],.systemtags-picker__tags .systemtags-picker__tag-color button[aria-expanded=true] .circle-icon[data-v-a70e877c],.systemtags-picker__tags .systemtags-picker__tag-color button[aria-expanded=true] .circle-outline-icon[data-v-a70e877c]{display:none}.systemtags-picker__tags .systemtags-picker__tag-create[data-v-a70e877c] span{text-align:start}.systemtags-picker__tags .systemtags-picker__tag-create-subline[data-v-a70e877c]{font-weight:normal}.systemtags-picker__note[data-v-a70e877c]{bottom:0;padding-block:8px}.systemtags-picker__note[data-v-a70e877c] .notecard{min-height:2lh;align-items:center}.systemtags-picker__note>div[data-v-a70e877c]{margin:0 !important}.systemtags-picker--done[data-v-a70e877c] .empty-content__icon{opacity:1}.nc-chip[data-v-a70e877c]{display:inline !important}","",{version:3,sources:["webpack://./apps/systemtags/src/components/SystemTagPicker.vue"],names:[],mappings:"AAEA,qFAEC,eAAA,CACA,SAAA,CACA,6CAAA,CAGD,2CACC,YAAA,CACA,KAAA,CACA,OAAA,CACA,qBAAA,CACA,oBAAA,CAGD,0CACC,iBAAA,CACA,gCAAA,CACA,YAAA,CACA,qBAAA,CAEA,6CACC,YAAA,CACA,kBAAA,CACA,6BAAA,CACA,UAAA,CAGA,oEACC,UAAA,CAEA,sFAEC,cAAA,CAEA,qBAAA,CACA,+EAAA,CAKH,+EACC,wDAAA,CAEA,gGACC,YAAA,CACA,4BAAA,CAMA,oTACC,aAAA,CAED,goBAEC,YAAA,CAMF,8EACC,gBAAA,CAED,iFACC,kBAAA,CAKH,0CACC,QAAA,CACA,iBAAA,CAEA,oDAEC,cAAA,CACA,kBAAA,CAGD,8CACC,mBAAA,CAIF,+DACC,SAAA,CAID,0BACC,yBAAA",sourceRoot:""}]);const l=n},5365:(t,e,s)=>{s.r(e),s.d(e,{default:()=>tt});var a=s(85471),i=s(61338),o=s(53334),n=s(42838),l=s(85168),c=s(17334),r=s.n(c),g=s(70580),d=s.n(g),p=s(70995),A=s(32073),u=s(89918),m=s(56798),h=s(94219),y=s(28326),C=s(59892),_=s(40083),f=s(82182);const v={name:"CheckCircleIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}};var k=s(14486);const b=(0,k.A)(v,(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:"true","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,N={name:"CircleIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},w=(0,k.A)(N,(function(){var t=this,e=t._self._c;return e("span",t._b({staticClass:"material-design-icon circle-icon",attrs:{"aria-hidden":t.title?null:"true","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,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z"}},[t.title?e("title",[t._v(t._s(t.title))]):t._e()])])])}),[],!1,null,null,null).exports,x={name:"CircleOutlineIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},S=(0,k.A)(x,(function(){var t=this,e=t._self._c;return e("span",t._b({staticClass:"material-design-icon circle-outline-icon",attrs:{"aria-hidden":t.title?null:"true","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,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z"}},[t.title?e("title",[t._v(t._s(t.title))]):t._e()])])])}),[],!1,null,null,null).exports;var T=s(2413),E=s(96078);const I={name:"TagIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},L=(0,k.A)(I,(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:"true","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;var B=s(82528),R=s(12686),$=s(51113),P=s(25631);const z=r()(B.Gw,500),D=getComputedStyle(document.body).getPropertyValue("--color-main-background").replace("#","")||((0,$.j2)()?"000000":"ffffff");var G;!function(t){t.BASE="base",t.LOADING="loading",t.CREATING_TAG="creating-tag",t.DONE="done"}(G||(G={}));const M=(0,a.pM)({name:"SystemTagPicker",components:{CheckIcon:b,CircleIcon:w,CircleOutlineIcon:S,NcButton:p.A,NcCheckboxRadioSwitch:A.A,NcChip:u.A,NcColorPicker:m.A,NcDialog:h.A,NcEmptyContent:y.A,NcLoadingIcon:C.A,NcNoteCard:_.A,NcTextField:f.A,PencilIcon:T.A,PlusIcon:E.A,TagIcon:L},props:{nodes:{type:Array,required:!0}},setup:()=>({emit:i.Ic,Status:G,t:o.t}),data:()=>({status:G.BASE,opened:!0,openedPicker:!1,input:"",tags:[],tagList:{},toAdd:[],toRemove:[]}),computed:{sortedTags(){return[...this.tags].sort(((t,e)=>t.displayName.localeCompare(e.displayName,(0,o.Z0)(),{ignorePunctuation:!0})))},filteredTags(){return""===this.input.trim()?this.sortedTags:this.sortedTags.filter((t=>t.displayName.normalize().includes(this.input.normalize())))},hasChanges(){return this.toAdd.length>0||this.toRemove.length>0},canCreateTag(){return""!==this.input.trim()&&!this.tags.some((t=>t.displayName.trim().toLocaleLowerCase()===this.input.trim().toLocaleLowerCase()))},statusMessage(){if(0===this.toAdd.length&&0===this.toRemove.length)return"";if(1===this.toAdd.length&&1===this.toRemove.length)return(0,o.n)("systemtags","{tag1} will be set and {tag2} will be removed from 1 file.","{tag1} will be set and {tag2} will be 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,o.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,o.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}),l=(0,o.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}),c=(0,o.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?l:0===this.toAdd.length&&this.toRemove.length>1?c:this.toAdd.length>1&&1===this.toRemove.length?`${l} ${n}`:1===this.toAdd.length&&this.toRemove.length>1?`${i} ${c}`:`${l} ${c}`}},beforeMount(){(0,B.un)().then((t=>{this.tags=t})),this.tagList=this.nodes.reduce(((t,e)=>(((0,R.rA)(e)||[]).forEach((e=>{t[e]=(t[e]||0)+1})),t)),{})},methods:{formatTagChip(t){const e=this.$refs.chip.$el.cloneNode(!0);if(t.color){const s=this.tagListStyle(t);Object.entries(s).forEach((t=>{let[s,a]=t;e.style.setProperty(s,a)}))}return e.outerHTML.replace("%s",d()((0,n.sanitize)(t.displayName)))},formatTagName:t=>t.userVisible?t.userAssignable?t.displayName:(0,o.t)("systemtags","{displayName} (restricted)",{displayName:t.displayName}):(0,o.t)("systemtags","{displayName} (hidden)",{displayName:t.displayName}),onColorChange(t,e){t.color=e.replace("#",""),z(t)},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=G.CREATING_TAG;try{const t={displayName:this.input.trim(),userAssignable:!0,userVisible:!0,canAssign:!0},e=await(0,B.VZ)(t),s=await(0,B.xI)(e);this.tags.push(s),this.input="",this.onCheckUpdate(s,!0),await this.$nextTick();const a=this.$el.querySelector(`input[type="checkbox"][label="${s.displayName}"]`);a?.scrollIntoView({behavior:"instant",block:"center",inline:"center"})}catch(t){(0,l.Qg)(t?.message||(0,o.t)("systemtags","Failed to create tag"))}finally{this.status=G.BASE}},async onSubmit(){this.status=G.LOADING,P.A.debug("Applying tags",{toAdd:this.toAdd,toRemove:this.toRemove});try{for(const t of this.toAdd){const{etag:e,objects:s}=await(0,B.b0)(t,"files"),a=[...new Set([...s.map((t=>t.id)).filter(Boolean),...this.nodes.map((t=>t.fileid)).filter(Boolean)])];await(0,B.T0)(t,"files",a.map((t=>({id:t,type:"files"}))),e)}for(const t of this.toRemove){const{etag:e,objects:s}=await(0,B.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,B.T0)(t,"files",i.map((t=>({id:t,type:"files"}))),e)}}catch(t){return P.A.error("Failed to apply tags",{error:t}),(0,l.Qg)((0,o.t)("systemtags","Failed to apply tags changes")),void(this.status=G.BASE)}const t=[];this.toAdd.forEach((e=>{this.nodes.forEach((s=>{const a=[...(0,R.rA)(s)||[],e.displayName].sort(((t,e)=>t.localeCompare(e,(0,o.Z0)(),{ignorePunctuation:!0})));(0,R.Pq)(s,a),t.push(s)}))})),this.toRemove.forEach((e=>{this.nodes.forEach((s=>{const a=[...(0,R.rA)(s)||[]].filter((t=>t!==e.displayName)).sort(((t,e)=>t.localeCompare(e,(0,o.Z0)(),{ignorePunctuation:!0})));(0,R.Pq)(s,a),t.push(s)}))})),t.forEach((t=>(0,i.Ic)("systemtags:node:updated",t))),this.status=G.DONE,setTimeout((()=>{this.opened=!1,this.$emit("close",!0)}),2e3)},onCancel(){this.opened=!1,(0,l.cf)((0,o.t)("systemtags","File tags modification canceled")),this.$emit("close",null)},tagListStyle(t){if(!t.color)return{"--color-circle-icon":"var(--color-text-maxcontrast)"};const e=(0,$.W7)(`#${t.color}`,`#${D}`),s=(0,$.Pj)(e)?"#000000":"#ffffff";return{"--color-circle-icon":"var(--color-primary-element)","--color-primary":e,"--color-primary-text":s,"--color-primary-element":e,"--color-primary-element-text":s}}}});var O=s(85072),F=s.n(O),j=s(97825),q=s.n(j),Z=s(77659),V=s.n(Z),H=s(55056),U=s.n(H),Y=s(10540),K=s.n(Y),Q=s(41113),W=s.n(Q),J=s(90685),X={};X.styleTagTransform=W(),X.setAttributes=U(),X.insert=V().bind(null,"head"),X.domAPI=q(),X.insertStyleElement=K(),F()(J.A,X),J.A&&J.A.locals&&J.A.locals;const tt=(0,k.A)(M,(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":"","can-close":t.status!==t.Status.LOADING,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("div",{staticClass:"systemtags-picker__input"},[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)],1),t._v(" "),e("ul",{staticClass:"systemtags-picker__tags",attrs:{"data-cy-systemtags-picker-tags":""}},[t._l(t.filteredTags,(function(s){return e("li",{key:s.id,staticClass:"systemtags-picker__tag",style:t.tagListStyle(s),attrs:{"data-cy-systemtags-picker-tag":s.id}},[e("NcCheckboxRadioSwitch",{staticClass:"systemtags-picker__tag-checkbox",attrs:{checked:t.isChecked(s),disabled:!s.canAssign,indeterminate:t.isIndeterminate(s),label:s.displayName},on:{"update:checked":function(e){return t.onCheckUpdate(s,e)}}},[t._v("\n\t\t\t\t\t"+t._s(t.formatTagName(s))+"\n\t\t\t\t")]),t._v(" "),e("NcColorPicker",{staticClass:"systemtags-picker__tag-color",attrs:{"data-cy-systemtags-picker-tag-color":s.id,value:`#${s.color}`,shown:t.openedPicker},on:{"update:shown":function(e){t.openedPicker=e},"update:value":function(e){return t.onColorChange(s,e)},submit:function(e){t.openedPicker=!1}}},[e("NcButton",{attrs:{"aria-label":t.t("systemtags","Change tag color"),type:"tertiary"},scopedSlots:t._u([{key:"icon",fn:function(){return[s.color?e("CircleIcon",{attrs:{size:24,"fill-color":"var(--color-circle-icon)"}}):e("CircleOutlineIcon",{attrs:{size:24,"fill-color":"var(--color-circle-icon)"}}),t._v(" "),e("PencilIcon")]},proxy:!0}],null,!0)})],1)],1)})),t._v(" "),e("li",[t.canCreateTag?e("NcButton",{staticClass:"systemtags-picker__tag-create",attrs:{disabled:t.status===t.Status.CREATING_TAG,alignment:"start","native-type":"submit",type:"tertiary","data-cy-systemtags-picker-button-create":""},on:{click:t.onNewTag},scopedSlots:t._u([{key:"icon",fn:function(){return[e("PlusIcon")]},proxy:!0}],null,!1,1789392498)},[t._v("\n\t\t\t\t\t"+t._s(t.input.trim())),e("br"),t._v(" "),e("span",{staticClass:"systemtags-picker__tag-create-subline"},[t._v(t._s(t.t("systemtags","Create new tag")))])]):t._e()],1)],2),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,"a70e877c",null).exports}}]);
- //# sourceMappingURL=5365-5365.js.map?v=fa27a4e19e53f6fa6123
|