1
0
Fork 0
pixelfed/public/js/collectioncompose.js

1 line
9.7 KiB
JavaScript
Raw Normal View History

2019-10-16 03:47:06 +00:00
(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{17:function(t,i,e){t.exports=e("iBgk")},GicU:function(t,i,e){"use strict";e.r(i);var o={props:["collection-id","profile-id"],data:function(){return{loaded:!1,limit:8,step:1,title:"",description:"",visibility:"private",collection:{title:"",description:"",visibility:"public"},id:"",posts:[],tab:"add",tabs:["all","add","order"],recentPosts:[],selectedPost:""}},beforeMount:function(){var t=this;axios.get("/api/local/collection/"+this.collectionId).then(function(i){t.collection=i.data})},mounted:function(){this.fetchRecentPosts(),this.fetchItems()},methods:{addToIds:function(t){var i=this;axios.post("/api/local/collection/item",{collection_id:this.collectionId,post_id:t}).then(function(t){i.fetchItems(),i.fetchRecentPosts(),i.tab="all",i.id=""}).catch(function(t){swal("Invalid URL","The post you entered was invalid","error"),i.id=""})},fetchItems:function(){var t=this;axios.get("/api/local/collection/items/"+this.collectionId).then(function(i){t.posts=i.data,t.loaded=!0})},addId:function(){if(this.posts.length>=18)swal("Error","You can only add 18 posts per collection","error");else{var t=this.id,i=window.location.origin,e=t.split("/");t.slice(0,i.length)!==i&&(swal("Invalid URL","You can only add posts from this instance","error"),this.id=""),t.slice(0,i.length+3)===i+"/p/"&&6===e.length||(swal("Invalid URL","Invalid URL","error"),this.id=""),this.addToIds(e[5])}},previewUrl:function(t){return t.sensitive?"/storage/no-preview.png?v="+(new Date).getTime():t.media_attachments[0].preview_url},previewBackground:function(t){return"background-image: url("+this.previewUrl(t)+");background-size:cover;"},fetchRecentPosts:function(){var t=this;axios.get("/api/pixelfed/v1/accounts/"+this.profileId+"/statuses",{params:{only_media:!0,min_id:1}}).then(function(i){t.recentPosts=i.data.filter(function(i){var e=t.posts.map(function(t){return t.id});return"public"==i.visibility&&0==i.sensitive&&-1==e.indexOf(i.id)}).slice(0,3)})},selectPost:function(t){this.selectedPost=t.id,this.id=t.url},publish:function(){0!=this.posts.length?axios.post("/api/local/collection/"+this.collectionId+"/publish",{title:this.collection.title,description:this.collection.description,visibility:this.collection.visibility}).then(function(t){window.location.href=t.data}).catch(function(t){swal("Something went wrong","There was a problem with your request, please try again later.","error")}):swal("Error","You cannot publish an empty collection")},save:function(){axios.post("/api/local/collection/"+this.collectionId,{title:this.collection.title,description:this.collection.description,visibility:this.collection.visibility}).then(function(t){swal("Saved!","You have successfully saved this collection.","success")})},deleteCollection:function(){window.confirm("Are you sure you want to delete this collection?")&&axios.delete("/api/local/collection/"+this.collectionId).then(function(t){window.location.href="/"})}}},s=e("KHd+"),l=Object(s.a)(o,function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("div",{staticClass:"container"},[t.loaded?e("div",{staticClass:"row"},[t._m(0),t._v(" "),e("div",{staticClass:"col-12 col-md-4 pt-3"},[e("div",{staticClass:"card rounded-0 shadow-none border ",staticStyle:{"min-height":"440px"}},[e("div",{staticClass:"card-body"},[e("div",[e("form",[e("div",{staticClass:"form-group"},[e("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"title"}},[t._v("Title")]),t._v(" "),e("input",{directives:[{name:"model",rawName:"v-model",value:t.collection.title,expression:"collection.title"}],staticClass:"form-control",attrs:{type:"text",id:"title",placeholder:"Collection Title"},domProps:{value:t.collection.title},on:{input:function(i){i.target.composing||t.$set(t.collection,"title",i.target.value)}}})]),t._v(" "),e("div",{staticClass:"form-group"},[e("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"description"}},[t._v("Description")]),t._v(" "),e("textarea",{directives:[{name:"model",rawName:"v-model",value:t.collection.description,expression:"collection.descriptio