nextcloud/dist/systemtags-admin.js

3 рядки
13 KiB
JavaScript

/*! For license information please see systemtags-admin.js.LICENSE.txt */
(()=>{"use strict";var t,e,s,a={27498:(t,e,s)=>{var a=s(20144),r=s(77958),i=s(87604),n=s(90580),o=s(31352),l=s(64024),d=s(29497),c=s(77723),g=s(35380),u=s(49368),m=s(36906);const p={userVisible:!0,userAssignable:!0,canAssign:!0};s(93664);var h=s(79753),y=s(14596);const b=(0,h.generateRemoteUrl)("dav"),v=(0,y.eI)(b,{headers:{requesttoken:(0,r.IH)()??""}}),f=(0,s(17499).IY)().setApp("systemtags").detectUser().build();var A;!function(t){t.Public="Public",t.Restricted="Restricted",t.Invisible="Invisible"}(A||(A={}));const _=[{id:A.Public,label:(0,o.Iu)("systemtags","Public")},{id:A.Restricted,label:(0,o.Iu)("systemtags","Restricted")},{id:A.Invisible,label:(0,o.Iu)("systemtags","Invisible")}],C=(t,e)=>({[[!0,!0].join(",")]:A.Public,[[!0,!1].join(",")]:A.Restricted,[[!1,!1].join(",")]:A.Invisible}[[t,e].join(",")]),x=a.default.extend({name:"SystemTagForm",components:{NcButton:d.Z,NcLoadingIcon:i.Z,NcSelect:c.Z,NcSelectTags:g.Z,NcTextField:u.Z},props:{tags:{type:Array,required:!0}},data:()=>({loading:!1,tagLevelOptions:_,selectedTag:null,errorMessage:"",tagName:"",tagLevel:A.Public}),watch:{selectedTag(t){this.tagName=t?t.displayName:"",this.tagLevel=t?C(t.userVisible,t.userAssignable):A.Public}},computed:{isCreating(){return null===this.selectedTag},isCreateDisabled(){return""===this.tagName},isUpdateDisabled(){return""===this.tagName||this.selectedTag?.displayName===this.tagName&&C(this.selectedTag?.userVisible,this.selectedTag?.userAssignable)===this.tagLevel},isResetDisabled(){return this.isCreating?""===this.tagName&&this.tagLevel===A.Public:null===this.selectedTag},userVisible(){return{[A.Public]:!0,[A.Restricted]:!0,[A.Invisible]:!1}[this.tagLevel]},userAssignable(){return{[A.Public]:!0,[A.Restricted]:!1,[A.Invisible]:!1}[this.tagLevel]},tagProperties(){return{displayName:this.tagName,userVisible:this.userVisible,userAssignable:this.userAssignable}}},methods:{t:o.Iu,async handleSubmit(){this.isCreating?await this.create():await this.update()},async create(){const t={...p,...this.tagProperties};this.loading=!0;try{const e=await(async t=>{const e=(t=>{const e={...t};return e.name&&!e.displayName||(e.name=e.displayName,delete e.displayName),e})(t);try{const{headers:t}=await v.customRequest("/systemtags",{method:"POST",data:e}),s=t.get("content-location");if(s)return(t=>{const e=t.indexOf("?");e>0&&(t=t.substring(0,e));const s=t.split("/");let a;do{a=s[s.length-1],s.pop()}while(!a&&s.length>0);return Number(a)})(s);throw f.error((0,o.Iu)("systemtags",'Missing "Content-Location" header')),new Error((0,o.Iu)("systemtags",'Missing "Content-Location" header'))}catch(t){throw f.error((0,o.Iu)("systemtags","Failed to create tag"),{error:t}),new Error((0,o.Iu)("systemtags","Failed to create tag"))}})(t),s={...t,id:e};this.$emit("tag:created",s),(0,l.s$)((0,o.Iu)("systemtags","Created tag")),this.reset()}catch(t){this.errorMessage=(0,o.Iu)("systemtags","Failed to create tag")}this.loading=!1},async update(){if(null===this.selectedTag)return;const t={...this.selectedTag,...this.tagProperties};this.loading=!0;try{await(async t=>{const e="/systemtags/"+t.id,s=`<?xml version="1.0"?>\n\t<d:propertyupdate xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">\n\t\t<d:set>\n\t\t\t<d:prop>\n\t\t\t\t<oc:display-name>${t.displayName}</oc:display-name>\n\t\t\t\t<oc:user-visible>${t.userVisible}</oc:user-visible>\n\t\t\t\t<oc:user-assignable>${t.userAssignable}</oc:user-assignable>\n\t\t\t</d:prop>\n\t\t</d:set>\n\t</d:propertyupdate>`;try{await v.customRequest(e,{method:"PROPPATCH",data:s})}catch(t){throw f.error((0,o.Iu)("systemtags","Failed to update tag"),{error:t}),new Error((0,o.Iu)("systemtags","Failed to update tag"))}})(t),this.selectedTag=t,this.$emit("tag:updated",t),(0,l.s$)((0,o.Iu)("systemtags","Updated tag")),this.$refs.tagNameInput?.focus()}catch(t){this.errorMessage=(0,o.Iu)("systemtags","Failed to update tag")}this.loading=!1},async handleDelete(){if(null!==this.selectedTag){this.loading=!0;try{await(async t=>{const e="/systemtags/"+this.selectedTag.id;try{await v.deleteFile(e)}catch(t){throw f.error((0,o.Iu)("systemtags","Faile
//# sourceMappingURL=systemtags-admin.js.map?v=92c5d639d4324321dcdf