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

1 line
9.3 KiB
JavaScript

(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:"font-weight-bold text-muted",attrs:{for:"visibility"}},[t._v("Visibility")]),t._v(" "),i("select",{directives:[{name:"model",rawName:"v-model",value:t.collection.visibility,expression:"collection.visibility"}],staticClass:"custom-select",on:{change:function(e){var i=Array.prototype.filter.call(e.target.options,function(t){return t.selected}).map(function(t){return"_value"in t?t._value:t.value});t.$set(t.collection,"visibility",e.target.multiple?i:i[0])}}},[i("option",{attrs:{value:"public"}},[t._v("Public")]),t._v(" "),i("option",{attrs:{value:"private"}},[t._v("Followers Only")])])])]),t._v(" "),i("hr"),t._v(" "),i("p",[i("button",{staticClass:"btn btn-primary font-weight-bold btn-block",attrs:{type:"button"},on:{click:t.publish}},[t._v("Publish")])]),t._v(" "),i("p",[i("button",{staticClass:"btn btn-outline-primary font-weight-bold btn-block",attrs:{type:"button"},on:{click:t.save}},[t._v("Save")])]),t._v(" "),i("p",{staticClass:"mb-0"},[i("button",{staticClass:"btn btn-outline-secondary font-weight-bold btn-block",attrs:{type:"button"},on:{click:t.deleteCollection}},[t._v("Delete")])])])])])]),t._v(" "),i("div",{staticClass:"col-12 col-md-8 pt-3"},[i("div",[i("ul",{staticClass:"nav nav-tabs"},[i("li",{staticClass:"nav-item"},[i("a",{class:["add"==t.tab?"nav-link font-weight-bold bg-white active":"nav-link font-weight-bold text-muted"],attrs:{href:"#"},on:{click:function(e){e.preventDefault(),t.tab="add"}}},[t._v("Add Posts")])]),t._v(" "),i("li",{staticClass:"nav-item"},[i("a",{class:["all"==t.tab?"nav-link font-weight-bold bg-white active":"nav-link font-weight-bold text-muted"],attrs:{href:"#"},on:{click:function(e){e.preventDefault(),t.tab="all"}}},[t._v("Preview")])])])]),t._v(" "),i("div",{staticClass:"card rounded-0 shadow-none border border-top-0"},[i("div",{staticClass:"card-body",staticStyle:{height:"460px","overflow-y":"auto"}},["all"==t.tab?i("div",{staticClass:"row"},t._l(t.posts,function(e,o){return i("div",{staticClass:"col-4 p-1"},[i("a",{staticClass:"card info-overlay card-md-border-0",attrs:{href:e.url}},[i("div",{staticClass:"square"},["photo:album"==e.pf_type?i("span",{staticClass:"float-right mr-3 post-icon"},[i("i",{staticClass:"fas fa-images fa-2x"})]):t._e(),t._v(" "),"video"==e.pf_type?i("span",{staticClass:"float-right mr-3 post-icon"},[i("i",{staticClass:"fas fa-video fa-2x"})]):t._e(),t._v(" "),"video:album"==e.pf_type?i("span",{staticClass:"float-right mr-3 post-icon"},[i("i",{staticClass:"fas fa-film fa-2x"})]):t._e(),t._v(" "),i("div",{staticClass:"square-content",style:t.previewBackground(e)}),t._v(" "),i("div",{staticClass:"info-overlay-text"},[i("h5",{staticClass:"text-white m-auto font-weight-bold"},[i("span",[i("span",{staticClass:"far fa-heart fa-lg p-2 d-flex-inline"}),t._v(" "),i("span",{staticClass:"d-flex-inline"},[t._v(t._s(e.favourites_count))])]),t._v(" "),i("span",[i("span",{staticClass:"fas fa-retweet fa-lg p-2 d-flex-inline"}),t._v(" "),i("span",{staticClass:"d-flex-inline"},[t._v(t._s(e.reblogs_count))])])])])])])])}),0):t._e(),t._v(" "),"add"==t.tab?i("div",[i("div",{staticClass:"form-group"},[i("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"title"}},[t._v("Add Post by URL")]),t._v(" "),i("input",{directives:[{name:"model",rawName:"v-model",value:t.id,expression:"id"}],staticClass:"form-control",attrs:{type:"text",placeholder:"https://pixelfed.dev/p/admin/1"},domProps:{value:t.id},on:{input:function(e){e.target.composing||(t.id=e.target.value)}}}),t._v(" "),i("p",{staticClass:"help-text small text-muted"},[t._v("Only local, public posts can be added")])]),t._v(" "),i("div",{staticClass:"form-group pt-4"},[i("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"title"}},[t._v("Add Recent Post")]),t._v(" "),i("div",t._l(t.recentPosts,function(e,o){return i("div",{class:[t.selectedPost==e.id?"box-shadow border border-warning d-inline-block m-1":"d-inline-block m-1"],on:{click:function(i){return t.selectPost(e)}}},[i("div",{staticClass:"cursor-pointer",style:"width: 175px; height: 175px; "+t.previewBackground(e)})])}),0)]),t._v(" "),i("hr"),t._v(" "),i("button",{staticClass:"btn btn-primary font-weight-bold btn-block",attrs:{type:"button"},on:{click:t.addId}},[t._v("Add Post")])]):t._e(),t._v(" "),"order"==t.tab?i("div"):t._e()])])])]):t._e()])},[function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"col-12 col-md-6 offset-md-3 pt-5"},[e("div",{staticClass:"text-center pb-4"},[e("h1",[this._v("Create Collection")])])])}],!1,null,null,null);e.default=l.exports},"KHd+":function(t,e,i){"use strict";function o(t,e,i,o,s,l,a,n){var c,r="function"==typeof t?t.options:t;if(e&&(r.render=e,r.staticRenderFns=i,r._compiled=!0),o&&(r.functional=!0),l&&(r._scopeId="data-v-"+l),a?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),s&&s.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},r._ssrRegister=c):s&&(c=n?function(){s.call(this,this.$root.$options.shadowRoot)}:s),c)if(r.functional){r._injectStyles=c;var d=r.render;r.render=function(t,e){return c.call(e),d(t,e)}}else{var v=r.beforeCreate;r.beforeCreate=v?[].concat(v,c):[c]}return{exports:t,options:r}}i.d(e,"a",function(){return o})},iBgk:function(t,e,i){Vue.component("collection-compose",i("GicU").default)}},[[16,0]]]);