nextcloud/dist/comments-comments-app.js

3 lines
22 KiB
JavaScript
Raw Normal View History

/*! For license information please see comments-comments-app.js.LICENSE.txt */
(()=>{var e,s={57673:(e,s,n)=>{"use strict";var o=n(17499),a=n(31352),i=n(79753),r=n(45994),m=n(79954),c=n(4820),l=n(2324),d=n(20144),u=n(93455),p=n.n(u),h=n(10861),A=n.n(h),g=n(36272),C=n(92141),f=n(94603),j=n(80351),v=n.n(j),y=n(45400),_=n.n(y),x=n(12945),b=n.n(x),w=n(875),k=n.n(w),D=n(75925),N=n.n(D),I=n(12323),O=n.n(I),T=n(13408),M=n.n(T),E=n(39429);const B={name:"Moment",props:{timestamp:{type:Number,required:!0},format:{type:String,default:"LLL"}},computed:{title(){return v().unix(this.timestamp).format(this.format)},formatted(){return v().unix(this.timestamp).fromNow()}}};var S=n(51900);const z=(0,S.Z)(B,(function(){var t=this;return(0,t._self._c)("span",{staticClass:"live-relative-timestamp",attrs:{"data-timestamp":1e3*t.timestamp,title:t.title}},[t._v(t._s(t.formatted))])}),[],!1,null,null,null).exports,R=function(){return(0,i.generateRemoteUrl)("dav/comments")};function q(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const s=new DOMParser;let n=t;for(let t=0;t<e;t++)n=s.parseFromString(n,"text/html").documentElement.textContent;return n}var L,Z=n(14596);const P=(0,Z.eI)(R(),{headers:{"X-Requested-With":"XMLHttpRequest",requesttoken:null!==(L=(0,r.IH)())&&void 0!==L?L:""}});var $=n(64024),U=n(25108);const G={props:{id:{type:Number,default:null},message:{type:String,default:""},ressourceId:{type:[String,Number],required:!0}},data:()=>({deleted:!1,editing:!1,loading:!1}),methods:{onEdit(){this.editing=!0},onEditCancel(){this.editing=!1,this.updateLocalMessage(this.message)},async onEditComment(e){this.loading=!0;try{await async function(t,e,s,n){const o=["",t,e,s].join("/");return await P.customRequest(o,Object.assign({method:"PROPPATCH",data:'<?xml version="1.0"?>\n\t\t\t<d:propertyupdate\n\t\t\t\txmlns:d="DAV:"\n\t\t\t\txmlns:oc="http://owncloud.org/ns">\n\t\t\t<d:set>\n\t\t\t\t<d:prop>\n\t\t\t\t\t<oc:message>'.concat(n,"</oc:message>\n\t\t\t\t</d:prop>\n\t\t\t</d:set>\n\t\t\t</d:propertyupdate>")}))}(this.commentsType,this.ressourceId,this.id,e),this.logger.debug("Comment edited",{commentsType:this.commentsType,ressourceId:this.ressourceId,id:this.id,message:e}),this.$emit("update:message",e),this.editing=!1}catch(e){(0,$.x2)(t("comments","An error occurred while trying to edit the comment")),U.error(e)}finally{this.loading=!1}},onDeleteWithUndo(){this.deleted=!0;const e=setTimeout(this.onDelete,$.et);(0,$.yl)(t("comments","Comment deleted"),(()=>{clearTimeout(e),this.deleted=!1}))},async onDelete(){try{await async function(t,e,s){const n=["",t,e,s].join("/");await P.deleteFile(n)}(this.commentsType,this.ressourceId,this.id),this.logger.debug("Comment deleted",{commentsType:this.commentsType,ressourceId:this.ressourceId,id:this.id}),this.$emit("delete",this.id)}catch(e){(0,$.x2)(t("comments","An error occurred while trying to delete the comment")),U.error(e),this.deleted=!1}},async onNewComment(e){this.loading=!0;try{const t=await async function(t,e,s){const n=["",t,e].join("/"),o=await c.default.post(R()+n,{actorDisplayName:(0,r.ts)().displayName,actorId:(0,r.ts)().uid,actorType:"users",creationDateTime:(new Date).toUTCString(),message:s,objectType:"files",verb:"comment"}),a=n+"/"+parseInt(o.headers["content-location"].split("/").pop()),i=await P.stat(a,{details:!0}),m=i.data.props;return m.actorDisplayName=q(m.actorDisplayName,2),m.message=q(m.message,2),i.data}(this.commentsType,this.ressourceId,e);this.logger.debug("New comment posted",{commentsType:this.commentsType,ressourceId:this.ressourceId,newComment:t}),this.$emit("new",t),this.$emit("update:message",""),this.localMessage=""}catch(e){(0,$.x2)(t("comments","An error occurred while trying to create the comment")),U.error(e)}finally{this.loading=!1}}}},F={name:"Comment",components:{NcActionButton:_(),NcActions:b(),NcActionSeparator:k(),ArrowRight:E.default,NcAvatar:N(),NcButton:A(),Moment:z,NcRichContenteditable:O()},mixins:[M(),G],inheritAttrs:!1,props:{actorDisplayName:{type:String,required:!0},actorId:{type:String,required:!0},creationDateTime:{type:String,default:null},editor:{type:Boolean,default:!1},autoComplete:{type:Function
//# sourceMappingURL=comments-comments-app.js.map?v=789cbaedf693fb115e1e