관리-도구
편집 파일: CollectionsIndex.1a5c97a32ce998b7.js
/*! For license information please see CollectionsIndex.1a5c97a32ce998b7.js.LICENSE.txt */ "use strict";(self.webpackChunk=self.webpackChunk||[]).push([[5166],{89834:(t,e,r)=>{r.d(e,{A:()=>o});var n=r(76314),i=r.n(n)()((function(t){return t[1]}));i.push([t.id,".table td[data-v-01481067],.table th[data-v-01481067]{vertical-align:middle}.badge-outline-secondary[data-v-01481067]{background-color:#fff;border:1px solid #dee2e6;color:#6c757d}.fw-600[data-v-01481067]{font-weight:600}",""]);const o=i},12146:(t,e,r)=>{r.r(e),r.d(e,{default:()=>p});var n=r(72505),i=r.n(n);function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function a(){a=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},s="function"==typeof Symbol?Symbol:{},c=s.iterator||"@@iterator",l=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function d(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{d({},"")}catch(t){d=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),s=new A(n||[]);return i(a,"_invoke",{value:E(t,r,s)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",v="suspendedYield",y="executing",m="completed",g={};function b(){}function _(){}function w(){}var x={};d(x,c,(function(){return this}));var C=Object.getPrototypeOf,k=C&&C(C(I([])));k&&k!==r&&n.call(k,c)&&(x=k);var L=w.prototype=b.prototype=Object.create(x);function S(t){["next","throw","return"].forEach((function(e){d(t,e,(function(t){return this._invoke(e,t)}))}))}function $(t,e){function r(i,a,s,c){var l=h(t[i],t,a);if("throw"!==l.type){var u=l.arg,d=u.value;return d&&"object"==o(d)&&n.call(d,"__await")?e.resolve(d.__await).then((function(t){r("next",t,s,c)}),(function(t){r("throw",t,s,c)})):e.resolve(d).then((function(t){u.value=t,s(u)}),(function(t){return r("throw",t,s,c)}))}c(l.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function E(e,r,n){var i=p;return function(o,a){if(i===y)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var c=O(s,n);if(c){if(c===g)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===p)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=y;var l=h(e,r,n);if("normal"===l.type){if(i=n.done?m:v,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(i=m,n.method="throw",n.arg=l.arg)}}}function O(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,O(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=h(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(o(e)+" is not iterable")}return _.prototype=w,i(L,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:_,configurable:!0}),_.displayName=d(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===_||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,d(t,u,"GeneratorFunction")),t.prototype=Object.create(L),t},e.awrap=function(t){return{__await:t}},S($.prototype),d($.prototype,l,(function(){return this})),e.AsyncIterator=$,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new $(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(L),d(L,u,"Generator"),d(L,c,(function(){return this})),d(L,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(c&&l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;j(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function s(t,e,r,n,i,o,a){try{var s=t[o](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,i)}function c(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){s(o,n,i,a,c,"next",t)}function c(t){s(o,n,i,a,c,"throw",t)}a(void 0)}))}}const l={metaInfo:{title:"Store Collections Index"},data:function(){return{isLoading:!0,busy:!1,busyId:null,q:"",collections:[]}},computed:{sorted:function(){return this.collections.slice().sort((function(t,e){var r=null!=t.sort_order?t.sort_order:0,n=null!=e.sort_order?e.sort_order:0;return r!==n?r-n:String(t.title||"").localeCompare(String(e.title||""))}))},filtered:function(){var t=(this.q||"").toLowerCase();return t?this.sorted.filter((function(e){return String(e.title||"").toLowerCase().includes(t)||String(e.slug||"").toLowerCase().includes(t)})):this.sorted}},mounted:function(){this.fetch()},methods:{makeToast:function(t,e,r){this.$root&&this.$root.$bvToast&&this.$root.$bvToast.toast(e,{title:r,variant:t,solid:!0})},displayLimit:function(t){return null!=t?t:8},fetch:function(){var t=this;return c(a().mark((function e(){var r,n;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.isLoading=!0,e.prev=1,e.next=4,i().get("/admin/store/collections");case 4:r=e.sent,n=r&&r.data&&Array.isArray(r.data.data)?r.data.data:r&&r.data?r.data:[],Array.isArray(n)||(n=[]),t.collections=n,e.next=13;break;case 10:e.prev=10,e.t0=e.catch(1),t.makeToast("danger",t.$t("Failed_to_load"),t.$t("Failed"));case 13:return e.prev=13,t.isLoading=!1,e.finish(13);case 16:case"end":return e.stop()}}),e,null,[[1,10,13,16]])})))()},refresh:function(){this.fetch()},onSearch:function(){},displayOrder:function(t){return t+1},toggleActive:function(t){var e=this;return c(a().mark((function r(){var n;return a().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,e.busyId=t.id,n=t.is_active?1:0,r.next=5,i().put("/admin/store/collections/"+t.id,{is_active:n});case 5:e.makeToast("success",e.$t("Updated"),e.$t("Success")),r.next=12;break;case 8:r.prev=8,r.t0=r.catch(0),t.is_active=!t.is_active,e.makeToast("danger",e.$t("InvalidData"),e.$t("Failed"));case 12:return r.prev=12,e.busyId=null,r.finish(12);case 15:case"end":return r.stop()}}),r,null,[[0,8,12,15]])})))()},move:function(t,e){if(!(t<0||t>=this.filtered.length)){var r=t+e;if(!(r<0||r>=this.filtered.length)){var n=this.filtered.slice(),i=n.splice(t,1)[0];n.splice(r,0,i),this.collections=n,this.persistOrder()}}},persistOrder:function(){var t=this;return c(a().mark((function e(){var r,n,o,s;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.collections.length){e.next=2;break}return e.abrupt("return");case 2:t.busy=!0,e.prev=3,r=[],n=0;case 6:if(!(n<t.collections.length)){e.next=15;break}if(o=t.collections[n],s=10*(n+1),o.sort_order!==s){e.next=11;break}return e.abrupt("continue",12);case 11:r.push(i().put("/admin/store/collections/"+o.id,{sort_order:s}));case 12:n++,e.next=6;break;case 15:return e.next=17,Promise.all(r);case 17:return t.makeToast("success",t.$t("Order_saved"),t.$t("Success")),e.next=20,t.fetch();case 20:e.next=25;break;case 22:e.prev=22,e.t0=e.catch(3),t.makeToast("danger",t.$t("Could_not_save_order"),t.$t("Failed"));case 25:return e.prev=25,t.busy=!1,e.finish(25);case 28:case"end":return e.stop()}}),e,null,[[3,22,25,28]])})))()},destroy:function(t){var e=this;return c(a().mark((function r(){return a().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(confirm(e.$t("Confirm_Delete_This_Item"))){r.next=2;break}return r.abrupt("return");case 2:return r.prev=2,e.busyId=t.id,r.next=6,i().delete("/admin/store/collections/"+t.id);case 6:e.makeToast("success",e.$t("Deleted_successfully"),e.$t("Success")),e.collections=e.collections.filter((function(e){return e.id!==t.id})),r.next=13;break;case 10:r.prev=10,r.t0=r.catch(2),e.makeToast("danger",e.$t("Delete_failed"),e.$t("Failed"));case 13:return r.prev=13,e.busyId=null,r.finish(13);case 16:case"end":return r.stop()}}),r,null,[[2,10,13,16]])})))()}}};var u=r(85072),d=r.n(u),f=r(89834),h={insert:"head",singleton:!1};d()(f.A,h);f.A.locals;const p=(0,r(14486).A)(l,(function(){var t=this,e=t._self._c;return e("div",{staticClass:"main-content"},[e("breadcumb",{attrs:{page:t.$t("Collections"),folder:t.$t("Store")}}),t._v(" "),t.isLoading?e("div",{staticClass:"loading_page spinner spinner-primary mr-3"}):e("b-card",[e("div",{staticClass:"d-flex align-items-center justify-content-between flex-wrap mb-3"},[e("div",{staticClass:"d-flex align-items-center"},[e("b-input-group",[e("b-input-group-prepend",{attrs:{"is-text":""}},[e("i",{staticClass:"i-Search-People"})]),t._v(" "),e("b-form-input",{attrs:{placeholder:t.$t("Search")+"…"},on:{input:t.onSearch},model:{value:t.q,callback:function(e){t.q="string"==typeof e?e.trim():e},expression:"q"}}),t._v(" "),e("b-input-group-append",[e("b-button",{attrs:{variant:"outline-secondary",disabled:t.busy},on:{click:t.refresh}},[e("i",{staticClass:"i-Reload"})])],1)],1)],1),t._v(" "),e("div",{staticClass:"mt-2 mt-md-0"},[e("router-link",{staticClass:"btn btn-primary",attrs:{to:{name:"StoreCollectionsCreate"}}},[e("i",{staticClass:"i-Add"}),t._v(" "+t._s(t.$t("New"))+"\n ")])],1)]),t._v(" "),e("div",{staticClass:"table-responsive"},[e("table",{staticClass:"table table-hover align-middle"},[e("thead",{staticClass:"thead-light"},[e("tr",[e("th",{staticStyle:{width:"70px"}},[t._v("#")]),t._v(" "),e("th",[t._v(t._s(t.$t("Title")))]),t._v(" "),e("th",{staticClass:"d-none d-md-table-cell"},[t._v(t._s(t.$t("Slug")))]),t._v(" "),e("th",{staticClass:"text-center d-none d-md-table-cell",staticStyle:{width:"120px"}},[t._v(t._s(t.$t("Limit")))]),t._v(" "),e("th",{staticClass:"text-center d-none d-lg-table-cell",staticStyle:{width:"120px"}},[t._v(t._s(t.$t("Products")))]),t._v(" "),e("th",{staticClass:"text-right",staticStyle:{width:"300px"}},[t._v(t._s(t.$t("Actions")))])])]),t._v(" "),e("tbody",[t._l(t.filtered,(function(r,n){return e("tr",{key:r.id},[e("td",{staticClass:"text-muted"},[e("code",{staticClass:"small"},[t._v("#"+t._s(t.displayOrder(n)))])]),t._v(" "),e("td",[e("div",{staticClass:"fw-600"},[t._v(t._s(r.title))]),t._v(" "),r.description?e("div",{staticClass:"text-muted small",staticStyle:{"max-width":"520px"}},[t._v("\n "+t._s(r.description)+"\n ")]):t._e()]),t._v(" "),e("td",{staticClass:"d-none d-md-table-cell"},[e("span",{staticClass:"badge badge-outline-secondary"},[t._v(t._s(r.slug))])]),t._v(" "),e("td",{staticClass:"text-center d-none d-md-table-cell"},[t._v("\n "+t._s(t.displayLimit(r.limit))+"\n ")]),t._v(" "),e("td",{staticClass:"text-center d-none d-lg-table-cell"},[e("span",{staticClass:"badge badge-pill badge-light"},[t._v("\n "+t._s(null!=r.products_count?r.products_count:"—")+"\n ")])]),t._v(" "),e("td",{staticClass:"text-right"},[e("div",{staticClass:"btn-group btn-group-sm"},[e("router-link",{staticClass:"btn btn-outline-primary btn-sm",class:{disabled:t.busy},attrs:{to:{name:"StoreCollectionsEdit",params:{id:r.id}},title:"Edit"}},[e("i",{staticClass:"i-Pen-2"})]),t._v(" "),e("b-button",{attrs:{variant:"outline-danger",disabled:t.busyId===r.id,title:"Delete"},on:{click:function(e){return t.destroy(r)}}},[e("i",{staticClass:"i-Close"})])],1)])])})),t._v(" "),t.filtered.length?t._e():e("tr",[e("td",{staticClass:"text-center text-muted py-4",attrs:{colspan:"6"}},[t._v("\n "+t._s(t.$t("No_items"))+"\n ")])])],2)])])])],1)}),[],!1,null,"01481067",null).exports}}]);