1
0
Fork 0
forked from mirror/pixelfed
pixelfed/public/js/collectioncompose.js

19 lines
15 KiB
JavaScript
Raw Normal View History

2024-07-10 06:11:42 +00:00
(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([["/js/collectioncompose"],{"./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/CollectionCompose.vue?vue&type=script&lang=js":
/*!******************************************************************************************************************************************************************************************************************!*\
!*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/CollectionCompose.vue?vue&type=script&lang=js ***!
\******************************************************************************************************************************************************************************************************************/(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>o});const o={props:["collection-id","profile-id"],data:function(){return{config:window.App.config,loaded:!1,limit:8,step:1,title:"",description:"",collection:{title:"",description:"",visibility:"draft"},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(),axios.get("/api/pixelfed/v1/accounts/verify_credentials").then((function(t){window._sharedData.curUser=t.data,window.App.util.navatar()}))},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(){var t=this.config.uploader.max_collection_length;if(this.posts.length>=t)swal("Error","You can only add "+t+" posts per collection","error");else{var e=this.id,s=window.location.origin,o=e.split("/");if(e.slice(0,s.length)!==s&&(swal("Invalid URL","You can only add posts from this instance","error"),this.id=""),e.includes("/i/web/post/")||e.includes("/p/")){var i=o[o.length-1];return console.log("adding "+i),void this.addToIds(i)}swal("Invalid URL","Invalid URL","error"),this.id=""}},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,limit:40}}).then((function(e){t.recentPosts=e.data.filter((function(e){var s=t.posts.map((function(t){return t.id}));return("public"==e.visibility||"unlisted"==e.visibility)&&0==e.sensitive&&-1==s.indexOf(e.id)}))}))},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.url})).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="/"}))}}}},"./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/CollectionCompose.vue?vue&type=template&id=2e26dc26":
/*!*****************************************************************************************************************************************************************************************************************************************************************************************************!*\
!*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/CollectionCompose.vue?vue&type=template&id=2e26dc26 ***!
\*****************************************************************************************************************************************************************************************************************************************************************************************************/(t,e,s)=>{"use strict";s.r(e),s.d(e,{render:()=>o,staticRenderFns:()=>i});var o=function(){var t=this,e=t._self._c;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",maxlength:"50"},domProps:{value:t.collection.title},on:{input:function(e){e.target.composing||t.$set(t.collection,"title",e.target.value)}}}),t._v(" "),e("div",{staticClass:"text-right small text-muted"},[e("span",[t._v(t._s(t.collection.title?t.collection.title.length:0)+"/50")])])]),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.description"}],staticClass:"form-control",attrs:{id:"description",placeholder:"Example description here",rows:"3",maxlength:"500"},domProps:{value:t.collection.description},on:{input:function(e){e.target.composing||t.$set(t.collection,"description",e.target.value)}}}),t._v(" "),e("div",{staticClass:"text-right small text-muted"},[e("span",[t._v(t._s(t.collection.description?t.collection.description.length:0)+"/500")])])]),t._v(" "),e("div",{staticClass:"form-group"},[e("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"visibility"}},[t._v("Visibility")]),t._v(" "),e("select",{directives:[{name:"model",rawName:"v-model",value:t.collection.visibility,expression:"collection.visibility"}],staticClass:"custom-select",on:{change:function(e){var s=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?s:s[0])}}},[e("option",{attrs:{value:"public"}},[t._v("Public")]),t._v(" "),e("option",{attrs:{value:"private"}},[t._v("Followers Only")]),t._v(" "),e("option",{attrs:{value:"draft"}},[t._v("Draft")])])])]),t._v(" "),e("hr"),t._v(" "),e("p",[t.posts.length>0&&"draft"!=t.collection.visibility?e("button",{staticClass:"btn btn-primary font-weight-bold btn-block",attrs:{type:"button"},on:{click:t.publish}},[t._v("Publish")]):e("button",{staticClass:"btn btn-primary font-weight-bold btn-block disabled",attrs:{type:"button",disabled:""}},[t._v("Publish")])]),t._v(" "),e("p",[e("button",{staticClass:"btn btn-outline-primary font-weight-bold btn-block",attrs:{type:"button"},on:{click:t.save}},[t._v("Save")])]),t._v(" "),e("p",{staticClass:"mb-0"},[e("button",{staticClass:"btn btn-outline-secondary font-weight-bold btn-block",attrs:{type:"button"},on:{click:t.deleteCollection}},[t._v("Delete")])])])])])]),t._v(" "),e("div",{staticClass:"col-12 col-md-8 pt-3"},[e("div",[e("ul",{staticClass:"nav nav-tabs"},[e("li",{staticClass:"nav-item"},[e("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(" "),e("li",{staticClass:"nav-item"},[e("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(" "),e("div",{staticClass:"card rounded
/*!**************************************************!*\
!*** ./resources/assets/js/collectioncompose.js ***!
\**************************************************/(t,e,s)=>{Vue.component("collection-compose",s(/*! ./components/CollectionCompose.vue */"./resources/assets/js/components/CollectionCompose.vue").default)},"./resources/assets/js/components/CollectionCompose.vue":
/*!**************************************************************!*\
!*** ./resources/assets/js/components/CollectionCompose.vue ***!
\**************************************************************/(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>n});var o=s(/*! ./CollectionCompose.vue?vue&type=template&id=2e26dc26 */"./resources/assets/js/components/CollectionCompose.vue?vue&type=template&id=2e26dc26"),i=s(/*! ./CollectionCompose.vue?vue&type=script&lang=js */"./resources/assets/js/components/CollectionCompose.vue?vue&type=script&lang=js"),l={};for(const t in i)"default"!==t&&(l[t]=()=>i[t]);s.d(e,l);var a=(0,s(/*! !../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js */"./node_modules/vue-loader/lib/runtime/componentNormalizer.js").default)(i.default,o.render,o.staticRenderFns,!1,null,null,null);a.options.__file="resources/assets/js/components/CollectionCompose.vue";const n=a.exports},"./resources/assets/js/components/CollectionCompose.vue?vue&type=script&lang=js":
/*!**************************************************************************************!*\
!*** ./resources/assets/js/components/CollectionCompose.vue?vue&type=script&lang=js ***!
\**************************************************************************************/(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>l});var o=s(/*! -!../../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./CollectionCompose.vue?vue&type=script&lang=js */"./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/CollectionCompose.vue?vue&type=script&lang=js"),i={};for(const t in o)"default"!==t&&(i[t]=()=>o[t]);s.d(e,i);const l=o.default},"./resources/assets/js/components/CollectionCompose.vue?vue&type=template&id=2e26dc26":
/*!********************************************************************************************!*\
!*** ./resources/assets/js/components/CollectionCompose.vue?vue&type=template&id=2e26dc26 ***!
\********************************************************************************************/(t,e,s)=>{"use strict";s.r(e);var o=s(/*! -!../../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../../node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[2]!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./CollectionCompose.vue?vue&type=template&id=2e26dc26 */"./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/CollectionCompose.vue?vue&type=template&id=2e26dc26"),i={};for(const t in o)"default"!==t&&(i[t]=()=>o[t]);s.d(e,i)}},t=>{t.O(0,["/js/vendor"],(()=>{return e="./resources/assets/js/collectioncompose.js",t(t.s=e);var e}));t.O()}]);