You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nextcloud/dist/systemtags-admin.js

3 lines
14 KiB
JavaScript

/*! For license information please see systemtags-admin.js.LICENSE.txt */
(()=>{"use strict";var t,e,s,a={40167:(t,e,s)=>{var a=s(85471),i=s(92457),r=s(46222),n=s(88837),l=s(53334),o=s(85168),d=s(9518),c=s(67607),g=s(5212),u=s(82182),m=s(71654);const p={userVisible:!0,userAssignable:!0,canAssign:!0};s(26287);var h=s(44719);const y=(0,s(63814).dC)("dav"),v=(0,h.UU)(y),b=t=>{v.setHeaders({"X-Requested-With":"XMLHttpRequest",requesttoken:null!=t?t:""})};(0,i.zo)(b),b((0,i.do)());const f=(0,s(53529).YK)().setApp("systemtags").detectUser().build();var A;!function(t){t.Public="Public",t.Restricted="Restricted",t.Invisible="Invisible"}(A||(A={}));const T=[{id:A.Public,label:(0,l.Tl)("systemtags","Public")},{id:A.Restricted,label:(0,l.Tl)("systemtags","Restricted")},{id:A.Invisible,label:(0,l.Tl)("systemtags","Invisible")}],_=(t,e)=>({[[!0,!0].join(",")]:A.Public,[[!0,!1].join(",")]:A.Restricted,[[!1,!1].join(",")]:A.Invisible}[[t,e].join(",")]),C=a.Ay.extend({name:"SystemTagForm",components:{NcButton:d.A,NcLoadingIcon:r.A,NcSelect:c.A,NcSelectTags:g.A,NcTextField:u.A},props:{tags:{type:Array,required:!0}},data:()=>({loading:!1,tagLevelOptions:T,selectedTag:null,errorMessage:"",tagName:"",tagLevel:A.Public}),watch:{selectedTag(t){this.tagName=t?t.displayName:"",this.tagLevel=t?_(t.userVisible,t.userAssignable):A.Public}},computed:{isCreating(){return null===this.selectedTag},isCreateDisabled(){return""===this.tagName},isUpdateDisabled(){var t,e,s;return""===this.tagName||(null===(t=this.selectedTag)||void 0===t?void 0:t.displayName)===this.tagName&&_(null===(e=this.selectedTag)||void 0===e?void 0:e.userVisible,null===(s=this.selectedTag)||void 0===s?void 0:s.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:l.Tl,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,l.Tl)("systemtags",'Missing "Content-Location" header')),new Error((0,l.Tl)("systemtags",'Missing "Content-Location" header'))}catch(t){throw f.error((0,l.Tl)("systemtags","Failed to create tag"),{error:t}),new Error((0,l.Tl)("systemtags","Failed to create tag"))}})(t),s={...t,id:e};this.$emit("tag:created",s),(0,o.Te)((0,l.Tl)("systemtags","Created tag")),this.reset()}catch(t){this.errorMessage=(0,l.Tl)("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{var e;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>'.concat(t.displayName,"</oc:display-name>\n\t\t\t\t<oc:user-visible>").concat(t.userVisible,"</oc:user-visible>\n\t\t\t\t<oc:user-assignable>").concat(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,l.Tl)("systemtags","Failed to update tag"),{error:t}),new Error((0,l.Tl)("systemtags","Failed to update tag"))}})(t),this.selectedTag=t,this.$emit("tag:updated",t),(0,o.Te)((0,l.Tl)("systemtags","Updated tag")),null===(e=this.$refs.tagNameInput)||void 0===e||e.focus()}catch(t){this.errorMessage=(0,l.Tl)("systemtags","Failed to update tag")}this.loa
//# sourceMappingURL=systemtags-admin.js.map?v=4619a8e89cd82b01889c