pixelfed/public/js/collectioncompose.js

1 line
9.3 KiB
JavaScript
Raw Normal View History

2019-07-18 02:05:52 +00:00
(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{16:function(t,e,i){t.exports=i("iBgk")},GicU:function(t,e,i){"use strict";i.r(e);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(e){t.collection=e.data})},mounted:function(){this.fetchRecentPosts(),this.fetchItems()},methods:{addToIds:function(t){var e=this;axios.post("/api/local/collection/item",{collection_id:this.collectionId,post_id:t}).then(function(t){e.fetchItems(),e.fetchRecentPosts(),e.tab="all",e.id=""}).catch(function(t){swal("Invalid URL","The post you entered was invalid","error"),e.id=""})},fetchItems:function(){var t=this;axios.get("/api/local/collection/items/"+this.collectionId).then(function(e){t.posts=e.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,e=window.location.origin,i=t.split("/");t.slice(0,e.length)!==e&&(swal("Invalid URL","You can only add posts from this instance","error"),this.id=""),t.slice(0,e.length+3)===e+"/p/"&&6===i.length||(swal("Invalid URL","Invalid URL","error"),this.id=""),this.addToIds(i[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/v1/accounts/"+this.profileId+"/statuses",{params:{only_media:!0,min_id:1}}).then(function(e){t.recentPosts=e.data.filter(function(e){var i=t.posts.map(function(t){return t.id});return"public"==e.visibility&&0==e.sensitive&&-1==i.indexOf(e.id)}).slice(0,3)})},selectPost:function(t){this.selectedPost=t.id,this.id=t.url},publish:function(){axios.post("/api/local/collection/"+this.collectionId+"/publish").then(function(t){window.location.href=t.data})},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=i("KHd+"),l=Object(s.a)(o,function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"container"},[t.loaded?i("div",{staticClass:"row"},[t._m(0),t._v(" "),i("div",{staticClass:"col-12 col-md-4 pt-3"},[i("div",{staticClass:"card rounded-0 shadow-none border ",staticStyle:{"min-height":"440px"}},[i("div",{staticClass:"card-body"},[i("div",[i("form",[i("div",{staticClass:"form-group"},[i("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"title"}},[t._v("Title")]),t._v(" "),i("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(e){e.target.composing||t.$set(t.collection,"title",e.target.value)}}})]),t._v(" "),i("div",{staticClass:"form-group"},[i("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"description"}},[t._v("Description")]),t._v(" "),i("textarea",{directives:[{name:"model",rawName:"v-model",value:t.collection.description,expression:"collection.description"}],staticClass:"form-control",attrs:{id:"description",placeholder:"Example description here",rows:"3"},domProps:{value:t.collection.description},on:{input:function(e){e.target.composing||t.$set(t.collection,"description",e.target.value)}}})]),t._v(" "),i("div",{staticClass:"form-group"},[i("label",{staticClass:"