GridFieldBulkEditingTools/client/dist/js/main.js
2023-02-01 15:28:37 +13:00

1 line
5.9 KiB
JavaScript

!function(){"use strict";var e={157:function(e,t,i){var s;((s=i(311))&&s.__esModule?s:{default:s}).default.entwine("ss",(e=>{window.bulkTools={gridfieldRefresh(e,t){t.isError||(t.isDestructive?this.removeGridFieldRows(e,t.records.success):this.updateGridFieldRows(e,t.records.success),this.failedGridFieldRows(e,t.records.failed))},getGridFieldRow(e,t){return e.find(`.ss-gridfield-item[data-id="${t.id}"][data-class="${t.class}"]`)},cleanGridFieldRow(e){return e.removeClass("bt-deleted bt-failed bt-updated").removeAttr("bt-error")},removeGridFieldRows(e,t){t.forEach((function(t){this.getGridFieldRow(e,t).addClass("bt-deleted").fadeOut(2e3)}),this),e.entwine(".").entwine("ss").delay(2e3).reload()},failedGridFieldRows(e,t){t.forEach((function(t){this.getGridFieldRow(e,t).addClass("bt-failed").attr("bt-error",t.message)}),this)},updateGridFieldRows(t,i){t.find(".ss-gridfield-item.ss-gridfield-no-items").remove(),i.forEach((function(i){const s=this.getGridFieldRow(t,i),d=e(i.row).addClass("bt-updated");1===s.length?s.replaceWith(d):t.find(".ss-gridfield-items").prepend(d)}),this)}}}))},572:function(e,t,i){var s=n(i(311)),d=n(i(754));function n(e){return e&&e.__esModule?e:{default:e}}s.default.entwine("colymba",(e=>{e(".bulkManagerOptions").entwine({onmatch(){const t=this.parents("thead"),i=t.find("tr"),s=t.find([".filter-header",".sortable-header"].join(",")),d=i.index(this);let n=i.length-1;s.each(((e,t)=>{const s=i.index(t);s<n&&(n=s)})),d>n&&i.eq(n).insertAfter(e(this))}}),e("td.col-bulkSelect").entwine({onmouseover(){e(this).parents(".ss-gridfield-item").find(".edit-link").removeClass("edit-link").addClass("tempDisabledEditLink")},onmouseout(){e(this).parents(".ss-gridfield-item").find(".tempDisabledEditLink").addClass("edit-link").removeClass("tempDisabledEditLink")},onclick(t){const i=e(t.target).find("input");e(i).prop("checked")?e(i).prop("checked",!1):e(i).prop("checked",!0)}}),e("td.col-bulkSelect input").entwine({onmatch(){},onunmatch(){},onclick(){e(this).parents(".grid-field__table").find("input.bulkSelectAll").prop("checked","")}}),e("input.bulkSelectAll").entwine({onclick(){const t=e(this).prop("checked");e(this).parents(".grid-field__table").find("td.col-bulkSelect input").prop("checked",t).trigger("change")},getSelectRecordsID(){return e(this).parents(".grid-field__table").find("td.col-bulkSelect input:checked").map((function(){return parseInt(e(this).data("record"),10)})).get()}}),e("select.bulkActionName").entwine({onchange(){const t=e(this).val(),i=e(this).parents(".bulkManagerOptions").find(".doBulkActionButton"),s=i.data("config");if(e.each(s,((e,s)=>{e!==t&&i.removeClass(s.buttonClasses)})),t){if(i.removeClass("disabled"),i.addClass(s[t].buttonClasses).addClass("btn-outline-secondary"),s[t].icon){const e=i.find("img");e.length?e.attr("src",s[t].icon):i.prepend(`<img src="${s[t].icon}" alt="" />`)}else i.find("img").remove();s[t].destructive?i.addClass("btn-outline-danger"):i.removeClass("btn-outline-danger")}else i.addClass("disabled")}}),e(".doBulkActionButton").entwine({getActionURL(e,t){const i=(new Date).getTime();let s=t.split("?"),d="";return e&&(d=`/${e}`),s=s[1]?`${s[0]+d}?${s[1]}&cacheBuster=${i}`:`${s[0]+d}?cacheBuster=${i}`,s},onclick(){const t=e(this).parents(".bulkManagerOptions").find("select.bulkActionName").val(),i=e(this).parents(".bulkManagerOptions").find("input.bulkSelectAll:first").getSelectRecordsID();this.doBulkAction(t,i)},doBulkAction(t,i){const{bulkTools:s}=window,n=e(this).parents(".bulkManagerOptions"),a=n.find("a.doBulkActionButton"),r=n.find(".message"),l=a.data("config");let o=this.getActionURL(t,e(this).data("url"));const c={records:i};if(i.length<=0)return alert(d.default._t("GRIDFIELD_BULK_MANAGER.BULKACTION_EMPTY_SELECT")),!1;if(l[t].destructive&&!confirm(d.default._t("GRIDFIELD_BULK_MANAGER.CONFIRM_DESTRUCTIVE_ACTION")))return!1;if(a.addClass("loading"),r.removeClass("static show error warning"),l[t].xhr)e.ajax({url:o,data:c,type:"POST",context:e(this)}).always((function(t){let i=t;a.removeClass("loading"),t.responseText&&(i=JSON.parse(t.responseText)),r.html(i.message),i.isError?r.addClass("static error"):i.isWarning?r.addClass("show warning"):r.addClass("show"),s.gridfieldRefresh(e(this).parents(".ss-gridfield"),i)}));else{o=`${o}&${`records[]=${i.join("&records[]=")}`}`,window.location.href=o}return!0}})}))},453:function(e,t,i){var s;((s=i(311))&&s.__esModule?s:{default:s}).default.entwine("colymba",(e=>{e("#bulkEditToggle").entwine({onclick(){const t=this.parents("form").find(".ss-toggle .ui-accordion-header");let i=this.data("state");i=i&&"close"!==i?"close":"open",t.each((function(){const t=e(this);"open"!==i||t.hasClass("ui-state-active")||t.click(),"close"===i&&t.hasClass("ui-state-active")&&t.click()})),this.data("state",i)}}),e(".bulkEditingFieldHolder").entwine({onchange(){this.removeClass("updated"),this.hasClass("hasUpdate")||this.addClass("hasUpdate")}})}))},545:function(e,t,i){var s=n(i(311)),d=n(i(648));function n(e){return e&&e.__esModule?e:{default:e}}const{bulkTools:a}=window,r=e=>()=>(t,i)=>{let{type:d,payload:n}=i;switch(d){case"UPLOADFIELD_ADD_FILE":return-1!==n.fieldId.indexOf("_BU")&&n.file.id&&(e=>{const t=(0,s.default)(`#${e.fieldId}`),i=t.parents(".ss-gridfield"),d=t.data("schema");s.default.ajax(d.data.attachFileEndpoint.url,{method:d.data.attachFileEndpoint.method,data:{fileID:e.file.id}}).done((e=>{a.gridfieldRefresh(i,e)}))})(n),e(t,{type:d,payload:n});case"UPLOADFIELD_UPLOAD_SUCCESS":return-1!==n.fieldId.indexOf("_BU")&&(e=>{const t=(0,s.default)(`#${e.fieldId}`).parents(".ss-gridfield");a.gridfieldRefresh(t,e.json.bulkTools)})(n),e(t,{type:d,payload:n});default:return e(t,{type:d,payload:n})}};document.addEventListener("DOMContentLoaded",(()=>{d.default.transform("bulkUploaderTransformation",(e=>{e.reducer("assetAdmin",r)}))}))},648:function(e){e.exports=Injector},754:function(e){e.exports=i18n},311:function(e){e.exports=jQuery}},t={};function i(s){var d=t[s];if(void 0!==d)return d.exports;var n=t[s]={exports:{}};return e[s](n,n.exports,i),n.exports}i(157),i(572),i(453),i(545)}();