FIX Wrap Injector transformation in DOMContentLoaded listener

This commit is contained in:
Garion Herman 2019-03-19 16:15:22 +13:00
parent 5581c11df8
commit 2c4587b0d9
2 changed files with 6 additions and 5 deletions

View File

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

View File

@ -1,4 +1,4 @@
/* global window */ /* global document window */
/** /**
* A quick hack to catch the uploadfield add file event * A quick hack to catch the uploadfield add file event
* and send the file ID to the bulkUploader component * and send the file ID to the bulkUploader component
@ -53,7 +53,8 @@ const bulkUploadFieldReducer = (originalReducer) => () => (state, { type, payloa
} }
} }
}; };
document.addEventListener('DOMContentLoaded', () => {
Injector.transform('bulkUploaderTransformation', (updater) => { Injector.transform('bulkUploaderTransformation', (updater) => {
updater.reducer('assetAdmin', bulkUploadFieldReducer); updater.reducer('assetAdmin', bulkUploadFieldReducer);
});
}); });