3245-3245.js 12 KB

12
  1. "use strict";(self.webpackChunknextcloud=self.webpackChunknextcloud||[]).push([[3245],{30843:(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__input[data-v-d45d77be],.systemtags-picker__note[data-v-d45d77be]{position:sticky;z-index:9;background-color:var(--color-main-background)}.systemtags-picker__input[data-v-d45d77be]{display:flex;top:0;gap:8px;padding-block-end:8px;align-items:flex-end}.systemtags-picker__tags[data-v-d45d77be]{padding-block:8px;gap:var(--default-grid-baseline);display:flex;flex-direction:column}.systemtags-picker__tags .systemtags-picker__tag-create[data-v-d45d77be] span{text-align:start}.systemtags-picker__tags .systemtags-picker__tag-create-subline[data-v-d45d77be]{font-weight:normal}.systemtags-picker__note[data-v-d45d77be]{bottom:0;padding-block:8px}.systemtags-picker__note[data-v-d45d77be] .notecard{min-height:2lh;align-items:center}.systemtags-picker__note>div[data-v-d45d77be]{margin:0 !important}.systemtags-picker--done[data-v-d45d77be] .empty-content__icon{opacity:1}.nc-chip[data-v-d45d77be]{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,CAEC,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=o},93245:(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),p=s(32036),h=s(94219),m=s(34196),A=s(84237),u=s(80910),y=s(82182);const C={name:"TagIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}};var f=s(14486);const v=(0,f.A)(C,(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,_={name:"CheckCircleIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},b=(0,f.A)(_,(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 k=s(27577),N=s(12686),T=s(82528);const w=(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 x=(0,a.pM)({name:"SystemTagPicker",components:{CheckIcon:b,NcButton:d.A,NcCheckboxRadioSwitch:g.A,NcChip:p.A,NcDialog:h.A,NcEmptyContent:m.A,NcLoadingIcon:A.A,NcNoteCard:u.A,NcTextField:y.A,PlusIcon:k.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:{sortedTags(){return[...this.tags].sort(((t,e)=>t.displayName.localeCompare(e.displayName,(0,l.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,l.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,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,T.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,T.VZ)(t),s=await(0,T.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,o.Qg)(t?.message||(0,l.t)("systemtags","Failed to create tag"))}finally{this.status=S.BASE}},async onSubmit(){this.status=S.LOADING,w.debug("Applying tags",{toAdd:this.toAdd,toRemove:this.toRemove});try{for(const t of this.toAdd){const{etag:e,objects:s}=await(0,T.b0)(t,"files"),a=[...new Set([...s.map((t=>t.id)).filter(Boolean),...this.nodes.map((t=>t.fileid)).filter(Boolean)])];await(0,T.T0)(t,"files",a.map((t=>({id:t,type:"files"}))),e)}for(const t of this.toRemove){const{etag:e,objects:s}=await(0,T.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,T.T0)(t,"files",i.map((t=>({id:t,type:"files"}))),e)}}catch(t){return w.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 L=s(85072),E=s.n(L),I=s(97825),B=s.n(I),R=s(77659),$=s.n(R),D=s(55056),G=s.n(D),P=s(10540),z=s.n(P),M=s(41113),F=s.n(M),O=s(30843),q={};q.styleTagTransform=F(),q.setAttributes=G(),q.insert=$().bind(null,"head"),q.domAPI=B(),q.insertStyleElement=z(),E()(O.A,q),O.A&&O.A.locals&&O.A.locals;const Z=(0,f.A)(x,(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("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("div",{staticClass:"systemtags-picker__tags",attrs:{"data-cy-systemtags-picker-tags":""}},[t._l(t.filteredTags,(function(s){return e("NcCheckboxRadioSwitch",{key:s.id,staticClass:"systemtags-picker__tag",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")])})),t._v(" "),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._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()],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,"d45d77be",null).exports}}]);
  2. //# sourceMappingURL=3245-3245.js.map?v=ea4a545366c852653e01