Make BulkManager injectable, add getBulkActions(), fix typos (#163)

* NEW Make BulkManager injectable, add getBulkActions() and fix some typos
* update doc block returns
This commit is contained in:
Robbie Averill 2018-02-26 21:47:40 +13:00 committed by Thierry François
parent 8bf9b620b0
commit 0c9b696b8d
4 changed files with 46 additions and 28 deletions

View File

@ -1 +1 @@
!function(t){function e(i){if(n[i])return n[i].exports;var a=n[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,e),a.l=!0,a.exports}var n={};e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){n(1),n(2),t.exports=n(3)},function(t,e){!function(t){t.entwine("ss",function(t){t.entwine("colymba",function(t){t(".bulkManagerOptions").entwine({onmatch:function(){var e=this.parents("thead"),n=e.find("tr"),i=[".filter-header",".sortable-header"],a=e.find(i.join(",")),s=n.index(this),o=n.length-1;a.each(function(t,e){var i=n.index(e);i<o&&(o=i)}),s>o&&n.eq(o).insertAfter(t(this))},onunmatch:function(){}}),t("td.col-bulkSelect").entwine({onmatch:function(){},onunmatch:function(){},onmouseover:function(){t(this).parents(".ss-gridfield-item").find(".edit-link").removeClass("edit-link").addClass("tempDisabledEditLink")},onmouseout:function(){t(this).parents(".ss-gridfield-item").find(".tempDisabledEditLink").addClass("edit-link").removeClass("tempDisabledEditLink")},onclick:function(e){var n=t(e.target).find("input");t(n).prop("checked")?t(n).prop("checked",!1):t(n).prop("checked",!0)}}),t("td.col-bulkSelect input").entwine({onmatch:function(){},onunmatch:function(){},onclick:function(e){t(this).parents(".grid-field__table").find("input.bulkSelectAll").prop("checked","")}}),t("input.bulkSelectAll").entwine({onmatch:function(){},onunmatch:function(){},onclick:function(){var e=t(this).prop("checked");t(this).parents(".grid-field__table").find("td.col-bulkSelect input").prop("checked",e).trigger("change")},getSelectRecordsID:function(){return t(this).parents(".grid-field__table").find("td.col-bulkSelect input:checked").map(function(){return parseInt(t(this).data("record"))}).get()}}),t("select.bulkActionName").entwine({onmatch:function(){},onunmatch:function(){},onchange:function(e){var n=t(this).val(),i=t(this).parents(".bulkManagerOptions"),a=i.find(".doBulkActionButton"),s=a.data("config");if(t.each(s,function(t,e){t!=n&&a.removeClass(e.buttonClasses)}),a.addClass(s[n].buttonClasses).addClass("btn-outline-secondary"),s[n].icon){var o=a.find("img");o.length?o.attr("src",s[n].icon):a.prepend('<img src="'+s[n].icon+'" alt="" />')}else a.find("img").remove();s[n].destructive?a.addClass("btn-outline-danger"):a.removeClass("btn-outline-danger")}}),t(".doBulkActionButton").entwine({onmatch:function(){},onunmatch:function(){},getActionURL:function(t,e){var n=(new Date).getTime();return e=e.split("?"),t=t?"/"+t:"",e=e[1]?e[0]+t+"?"+e[1]+"&cacheBuster="+n:e[0]+t+"?cacheBuster="+n},onclick:function(e){var n=t(this).parents(".bulkManagerOptions"),i=n.find("select.bulkActionName").val(),a=t(this).parents(".bulkManagerOptions").find("input.bulkSelectAll:first").getSelectRecordsID();this.doBulkAction(i,a)},doBulkAction:function(e,n,i,a){var s=t(this).parents(".bulkManagerOptions"),o=s.find("a.doBulkActionButton"),d=o.data("config"),l=this.getActionURL(e,t(this).data("url")),r={records:n};if(n.length<=0)return void alert(ss.i18n._t("GRIDFIELD_BULK_MANAGER.BULKACTION_EMPTY_SELECT"));if(d[e].destructive&&!confirm(ss.i18n._t("GRIDFIELD_BULK_MANAGER.CONFIRM_DESTRUCTIVE_ACTION")))return i&&a&&i.call(a,!1),!1;if(o.addClass("loading"),d[e].xhr)t.ajax({url:l,data:r,type:"POST",context:t(this)}).done(function(e,n,s){o.removeClass("loading"),i&&a?i.call(a,e):t(this).parents(".ss-gridfield").entwine(".").entwine("ss").reload()});else{l=l+"&"+("records[]="+n.join("&records[]=")),window.location.href=l}}})})})}(jQuery)},function(t,e){!function(t){t.entwine("colymba",function(t){t("#bulkEditToggle").entwine({onmatch:function(){},onunmatch:function(){},onclick:function(e){var n=this.parents("form").find(".ss-toggle .ui-accordion-header"),i=this.data("state");i=i&&"close"!==i?"close":"open",n.each(function(){var e=t(this);"open"!==i||e.hasClass("ui-state-active")||e.click(),"close"===i&&e.hasClass("ui-state-active")&&e.click()}),this.data("state",i)}}),t(".bulkEditingFieldHolder").entwine({onmatch:function(){},onunmatch:function(){},onchange:function(){this.removeClass("updated"),this.hasClass("hasUpdate")||this.addClass("hasUpdate")}})})}(jQuery)},function(t,e){!function(t){t.entwine("ss",function(t){t.entwine("colymba",function(t){t(".bulkUploader").entwine({onmatch:function(){var t=this.parents("thead").find("tr"),e=this.clone();t.index(this)>1&&(e.insertAfter(t.eq(0)),this.remove())},onunmatch:function(){}}),t("ul.ss-uploadfield-files").entwine({onmatch:function(){},onunmatch:function(){},trackProgress:function(){var t=this.find("li.ss-uploadfield-item"),e=t.length,n=t.filter(".done"),i=n.length,a=t.not(n).find(".ui-state-warning-text,.ui-state-error-text"),s=a.length;this.parents(".ss-uploadfield").find(".colymba-bulkupload-buttons").refresh(e,i,s)}}),t("li.ss-uploadfield-item").entwine({onmatch:function(){this.parents("ul.ss-uploadfield-files").trackProgress()},onunmatch:function(){t("ul.ss-uploadfield-files").trackProgress()}}),t("li.ss-uploadfield-item .ui-state-warning-text,li.ss-uploadfield-item .ui-state-error-text").entwine({onmatch:function(){this.parents("ul.ss-uploadfield-files").trackProgress()},onunmatch:function(){t("ul.ss-uploadfield-files").trackProgress()}}),t(".colymba-bulkupload-buttons").entwine({onmatch:function(){},onunmatch:function(){},refresh:function(t,e,n){var i=this.find(".colymba-bulkupload-info"),a=this.find(".bulkUploadEditButton"),s=this.find(".bulkUploadCancelButton"),o=this.find(".bulkUploadFinishButton"),d=this.find(".bulkUploadClearErrorButton");t>0?(this.css({display:"block"}),i.html(ss.i18n.sprintf(ss.i18n._t("GRIDFIELD_BULK_UPLOAD.PROGRESS_INFO"),t,e,n)),s.removeClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","false").removeAttr("disabled"),e+n<t?this.hasClass("loading")||(this.addClass("loading"),o.addClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","true").attr("disabled","disabled")):(this.removeClass("loading"),o.removeClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","false").removeAttr("disabled")),t===e?a.removeClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","false").removeAttr("disabled"):a.addClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","true").attr("disabled","true"),n>0?d.removeClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","false").removeAttr("disabled"):d.addClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","true").attr("disabled","true")):(this.css({display:"none"}).removeClass("loading"),a.addClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","true").attr("disabled","true"),s.addClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","true").attr("disabled","true"),o.addClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","true").attr("disabled","true"),d.addClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","true").attr("disabled","true"))}}),t(".bulkUploadClearErrorButton:not(.ui-state-disabled)").entwine({onmatch:function(){this.removeClass("action")},onunmatch:function(){},onclick:function(e){var n=this.parents(".bulkUpload"),i=n.find("li.ss-uploadfield-item .ui-state-warning-text,li.ss-uploadfield-item .ui-state-error-text").parents("li");t(i.get().reverse()).each(function(e,n){t(this).remove()})}}),t(".bulkUploadCancelButton:not(.ui-state-disabled)").entwine({onmatch:function(){this.removeClass("action")},onunmatch:function(){},onclick:function(){var e,n=this.parents(".bulkUpload"),i=n.find("li.ss-uploadfield-item"),a=i.filter("[data-recordid]"),s=i.not(a),o=n.parents(".ss-gridfield-table").find(".doBulkActionButton");s.each(function(e,n){t(this).remove()}),o.length>0&&(e=a.map(function(){return parseInt(t(this).data("recordid"))}).get(),this.addClass("loading"),o.doBulkAction("delete",e,this.cancelCallback,this))},cancelCallback:function(e){var n,i=this.parents(".bulkUpload"),a=i.find("li.ss-uploadfield-item");e&&(n=e.records,a.each(function(e,i){var a=t(this),s=parseInt(a.data("recordid"));-1!==n.indexOf(s)&&a.remove()}),t(this).parents(".ss-gridfield").entwine(".").entwine("ss").reload()),this.removeClass("loading")}}),t(".bulkUploadFinishButton:not(.ui-state-disabled)").entwine({onmatch:function(){this.removeClass("action")},onunmatch:function(){},onclick:function(){var e=this.parents(".bulkUpload"),n=e.find("li.ss-uploadfield-item");this.addClass("loading"),n.each(function(e,n){t(this).remove()}),t(this).parents(".ss-gridfield").entwine(".").entwine("ss").reload(),this.removeClass("loading")}}),t(".bulkUploadEditButton:not(.ui-state-disabled)").entwine({onmatch:function(){this.removeClass("action")},onunmatch:function(){},onclick:function(){var e,n=this.parents(".bulkUpload"),i=n.find("li.ss-uploadfield-item"),a=i.filter("[data-recordid]"),s=n.parents(".ss-gridfield-table").find(".doBulkActionButton");s.length>0&&(this.addClass("loading"),e=a.map(function(){return parseInt(t(this).data("recordid"))}).get(),s.doBulkAction("bulkedit",e))}})})})}(jQuery)}]); !function(t){function n(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.l=!0,s.exports}var e={};n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=0)}([function(t,n,e){e(1),e(2),t.exports=e(3)},function(t,n){!function(t){t.entwine("ss",function(t){t.entwine("colymba",function(t){t(".bulkManagerOptions").entwine({onmatch:function(){var n=this.parents("thead"),e=n.find("tr"),i=[".filter-header",".sortable-header"],s=n.find(i.join(",")),a=e.index(this),o=e.length-1;s.each(function(t,n){var i=e.index(n);i<o&&(o=i)}),a>o&&e.eq(o).insertAfter(t(this))},onunmatch:function(){}}),t("td.col-bulkSelect").entwine({onmatch:function(){},onunmatch:function(){},onmouseover:function(){t(this).parents(".ss-gridfield-item").find(".edit-link").removeClass("edit-link").addClass("tempDisabledEditLink")},onmouseout:function(){t(this).parents(".ss-gridfield-item").find(".tempDisabledEditLink").addClass("edit-link").removeClass("tempDisabledEditLink")},onclick:function(n){var e=t(n.target).find("input");t(e).prop("checked")?t(e).prop("checked",!1):t(e).prop("checked",!0)}}),t("td.col-bulkSelect input").entwine({onmatch:function(){},onunmatch:function(){},onclick:function(n){t(this).parents(".grid-field__table").find("input.bulkSelectAll").prop("checked","")}}),t("input.bulkSelectAll").entwine({onmatch:function(){},onunmatch:function(){},onclick:function(){var n=t(this).prop("checked");t(this).parents(".grid-field__table").find("td.col-bulkSelect input").prop("checked",n).trigger("change")},getSelectRecordsID:function(){return t(this).parents(".grid-field__table").find("td.col-bulkSelect input:checked").map(function(){return parseInt(t(this).data("record"))}).get()}}),t("select.bulkActionName").entwine({onmatch:function(){},onunmatch:function(){},onchange:function(n){var e=t(this).val(),i=t(this).parents(".bulkManagerOptions"),s=i.find(".doBulkActionButton"),a=s.data("config");if(t.each(a,function(t,n){t!=e&&s.removeClass(n.buttonClasses)}),s.addClass(a[e].buttonClasses).addClass("btn-outline-secondary"),a[e].icon){var o=s.find("img");o.length?o.attr("src",a[e].icon):s.prepend('<img src="'+a[e].icon+'" alt="" />')}else s.find("img").remove();a[e].destructive?s.addClass("btn-outline-danger"):s.removeClass("btn-outline-danger")}}),t(".doBulkActionButton").entwine({onmatch:function(){},onunmatch:function(){},getActionURL:function(t,n){var e=(new Date).getTime();return n=n.split("?"),t=t?"/"+t:"",n=n[1]?n[0]+t+"?"+n[1]+"&cacheBuster="+e:n[0]+t+"?cacheBuster="+e},onclick:function(n){var e=t(this).parents(".bulkManagerOptions"),i=e.find("select.bulkActionName").val(),s=t(this).parents(".bulkManagerOptions").find("input.bulkSelectAll:first").getSelectRecordsID();this.doBulkAction(i,s)},doBulkAction:function(n,e,i,s){var a=t(this).parents(".bulkManagerOptions"),o=a.find("a.doBulkActionButton"),l=o.data("config"),d=this.getActionURL(n,t(this).data("url")),r={records:e};if(e.length<=0)return void alert(ss.i18n._t("GRIDFIELD_BULK_MANAGER.BULKACTION_EMPTY_SELECT"));if(l[n].destructive&&!confirm(ss.i18n._t("GRIDFIELD_BULK_MANAGER.CONFIRM_DESTRUCTIVE_ACTION")))return i&&s&&i.call(s,!1),!1;if(o.addClass("loading"),l[n].xhr)t.ajax({url:d,data:r,type:"POST",context:t(this)}).done(function(n,e,a){o.removeClass("loading"),i&&s?i.call(s,n):t(this).parents(".ss-gridfield").entwine(".").entwine("ss").reload()});else{d=d+"&"+("records[]="+e.join("&records[]=")),window.location.href=d}}})})})}(jQuery)},function(t,n){!function(t){t.entwine("colymba",function(t){t("#bulkEditToggle").entwine({onmatch:function(){},onunmatch:function(){},onclick:function(n){var e=this.parents("form").find(".ss-toggle .ui-accordion-header"),i=this.data("state");i=i&&"close"!==i?"close":"open",e.each(function(){var n=t(this);"open"!==i||n.hasClass("ui-state-active")||n.click(),"close"===i&&n.hasClass("ui-state-active")&&n.click()}),this.data("state",i)}}),t(".bulkEditingFieldHolder").entwine({onmatch:function(){},onunmatch:function(){},onchange:function(){this.removeClass("updated"),this.hasClass("hasUpdate")||this.addClass("hasUpdate")}})})}(jQuery)},function(t,n){!function(t){t.entwine("ss",function(t){t.entwine("colymba",function(t){t(".bulkUploader").entwine({onmatch:function(){var t=this.parents("thead").find("tr"),n=this.clone();t.index(this)>1&&(n.insertAfter(t.eq(0)),this.remove())},onunmatch:function(){}}),t("ul.ss-uploadfield-files").entwine({onmatch:function(){},onunmatch:function(){},trackProgress:function(){var t=this.find("li.ss-uploadfield-item"),n=t.length,e=t.filter(".done"),i=e.length,s=t.not(e).find(".ui-state-warning-text,.ui-state-error-text"),a=s.length;this.parents(".ss-uploadfield").find(".colymba-bulkupload-buttons").refresh(n,i,a)}}),t("li.ss-uploadfield-item").entwine({onmatch:function(){this.parents("ul.ss-uploadfield-files").trackProgress()},onunmatch:function(){t("ul.ss-uploadfield-files").trackProgress()}}),t("li.ss-uploadfield-item .ui-state-warning-text,li.ss-uploadfield-item .ui-state-error-text").entwine({onmatch:function(){this.parents("ul.ss-uploadfield-files").trackProgress()},onunmatch:function(){t("ul.ss-uploadfield-files").trackProgress()}}),t(".colymba-bulkupload-buttons").entwine({onmatch:function(){},onunmatch:function(){},refresh:function(t,n,e){var i=this.find(".colymba-bulkupload-info"),s=this.find(".bulkUploadFinishButton"),a=this.find(".bulkUploadClearErrorButton");t>0?(this.css({display:"block"}),i.html(ss.i18n.sprintf(ss.i18n._t("GRIDFIELD_BULK_UPLOAD.PROGRESS_INFO"),t,n,e)),n+e<t?this.hasClass("loading")||(this.addClass("loading"),s.addClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","true").attr("disabled","disabled")):(this.removeClass("loading"),s.removeClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","false").removeAttr("disabled")),e>0?a.removeClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","false").removeAttr("disabled"):a.addClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","true").attr("disabled","true")):(this.css({display:"none"}).removeClass("loading"),s.addClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","true").attr("disabled","true"),a.addClass("ui-state-disabled ssui-button-disabled").attr("aria-disabled","true").attr("disabled","true"))}}),t(".bulkUploadClearErrorButton:not(.ui-state-disabled)").entwine({onmatch:function(){this.removeClass("action")},onunmatch:function(){},onclick:function(n){var e=this.parents(".bulkUpload"),i=e.find("li.ss-uploadfield-item .ui-state-warning-text,li.ss-uploadfield-item .ui-state-error-text").parents("li");t(i.get().reverse()).each(function(n,e){t(this).remove()})}}),t(".bulkUploadFinishButton:not(.ui-state-disabled)").entwine({onmatch:function(){this.removeClass("action")},onunmatch:function(){},onclick:function(){var n=this.parents(".bulkUpload"),e=n.find("li.ss-uploadfield-item");this.addClass("loading"),e.each(function(n,e){t(this).remove()}),t(this).parents(".ss-gridfield").entwine(".").entwine("ss").reload(),this.removeClass("loading")}})})})}(jQuery)}]);

View File

@ -1 +1 @@
.cms table.grid-field__table tr.bulkManagerOptions th.bulkmanagerheading{padding-left:40px}.cms table.grid-field__table tr.bulkManagerOptions th.bulkmanagerselect{text-align:center}.cms table.grid-field__table tr.bulkManagerOptions th.bulkmanagerselect input{margin-left:0}.cms table.grid-field__table tr.bulkManagerOptions .title{margin:0 0 2px 2px}.cms table.grid-field__table tr.bulkManagerOptions .dropdown{display:inline-block;border:none;box-shadow:none;padding:0;margin:0;color:#000;vertical-align:top}.cms table.grid-field__table tr.bulkManagerOptions .doBulkActionButton img{height:20px}.cms table.grid-field__table tbody .col-bulkSelect{width:25px;text-align:center}#bulkEditHeader{float:left;width:70%;margin:40px 0 20px;font-size:30px;font-weight:700}#bulkEditToggle{float:right;clear:right;width:25%;margin:40px 0 20px;text-decoration:underline;text-align:right;cursor:pointer}.bulkEditingFieldHolder{position:relative;float:left;width:100%}.bulkEditingFieldHolder.hasUpdate .ui-accordion-header{background-color:#f2ba11;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(0,#f2ba11),color-stop(100%,#df6e00));background-image:-webkit-linear-gradient(top,#f2ba11,#df6e00);background-image:-moz-linear-gradient(top,#f2ba11 0,#df6e00 100%);background-image:-o-linear-gradient(top,#f2ba11 0,#df6e00 100%);background-image:-ms-linear-gradient(top,#f2ba11 0,#df6e00 100%);background-image:linear-gradient(top,#f2ba11,#df6e00)}.bulkEditingFieldHolder.hasUpdate .ui-accordion-header a{color:#fff;text-shadow:none}.bulkEditingFieldHolder.updated .ui-accordion-header{background-color:#a4ca3a;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(0,#a4ca3a),color-stop(100%,#59781d));background-image:-webkit-linear-gradient(top,#a4ca3a,#59781d);background-image:-moz-linear-gradient(top,#a4ca3a 0,#59781d 100%);background-image:-o-linear-gradient(top,#a4ca3a 0,#59781d 100%);background-image:-ms-linear-gradient(top,#a4ca3a 0,#59781d 100%);background-image:linear-gradient(top,#a4ca3a,#59781d)}.bulkEditingFieldHolder.updated .ui-accordion-header a{color:#fff;text-shadow:none}.bulkUpload{padding:0!important;border-bottom:1px solid rgba(0,0,0,.1)}.bulkUpload:hover{background-color:#444546}.bulkUpload .component{padding:0!important;color:#fff;background:#98aab6;border-top:1px solid #a4b4bf;border-left:1px solid #a4b4bf;border-bottom:1px solid rgba(0,0,0,.1)}.bulkUpload .component div.ss-uploadfield{position:relative;float:left;clear:both;width:100%}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files{float:left;clear:both;width:100%}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item{position:relative;float:left;clear:both;overflow:hidden;width:98%;padding:5px 1%;border:none;border-top:1px solid rgba(0,0,0,.1);background-color:#eceff1}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item:nth-child(2n-1){background-color:#e6eaed}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-preview{width:30px;height:30px;line-height:38px}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info{height:30px;margin-left:40px;line-height:30px}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-name{position:absolute;top:0;left:50px;width:100%;height:100%;line-height:40px}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-name .name{color:#343434}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-name .size{font-weight:400}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-name .ss-uploadfield-item-status{float:left;width:auto;padding:0 0 0 5px;text-align:left;max-width:none}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-name .ss-uploadfield-item-status.ui-state-warning-text{color:#f29500}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-name .ss-uploadfield-item-status.ui-state-success-text{color:#298530}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-actions{position:absolute;top:0;left:0;width:100%;height:30px;margin:0;padding:5px 0}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-actions .ss-uploadfield-item-progress{left:50px;right:35px;margin-top:8px}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-actions button{margin:0 10px 0 0}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-actions button .ui-button-text{padding-top:4px;padding-bottom:3px}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-actions .ss-uploadfield-item-cancel{position:relative;top:7px;right:auto;float:right}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-actions .ss-uploadfield-item-cancel button{background:none}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-actions .ss-uploadfield-item-overwrite{position:relative;float:right;margin-top:2px}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile{float:left;clear:both;width:98%;padding:1%}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile.borderTop{border:none}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile .ss-uploadfield-item-preview.ss-uploadfield-dropzone{float:right;width:35%;height:43px;margin:0;line-height:43px;color:#eee;background-color:#8898a3;border:2px dashed #73818a;box-shadow:inset 0 0 10px 0 #73818a}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile .ss-uploadfield-item-preview.ss-uploadfield-dropzone.hover{color:#444546;background-color:#eee}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile .ss-uploadfield-item-info{float:left;width:60%;margin:0}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile .ss-uploadfield-item-info .ss-uploadfield-item-name{height:auto;margin-bottom:5px!important}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile .ss-uploadfield-item-info .ss-uploadfield-item-name small{font-weight:400!important}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile .ss-uploadfield-item-info .ss-ui-button .ui-button-text .ui-button-text{padding:0}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile .ss-uploadfield-item-info .ss-uploadfield-fromcomputer{margin-bottom:0}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile .ss-uploadfield-item-info .ss-uploadfield-fromfiles{margin-bottom:0;padding:.5px}.bulkUpload .component div.ss-uploadfield .colymba-bulkupload-buttons{display:none;float:left;width:98%;padding:6px 1%;background-color:#8898a3}.bulkUpload .component div.ss-uploadfield .colymba-bulkupload-buttons button{float:left;margin:0 6px 0 0}.bulkUpload .component div.ss-uploadfield .colymba-bulkupload-buttons button .ui-button-text .ui-button-text{padding:0}.bulkUpload .component div.ss-uploadfield .colymba-bulkupload-buttons button.bulkUploadClearErrorButton,.bulkUpload .component div.ss-uploadfield .colymba-bulkupload-buttons button.bulkUploadEditButton{float:right;margin:0 0 0 6px}.bulkUpload .component div.ss-uploadfield .colymba-bulkupload-buttons .colymba-bulkupload-info{float:left;margin:0 6px;line-height:28px;height:28px;color:#fff;overflow:hidden}.bulkUpload .component div.ss-uploadfield .colymba-bulkupload-buttons.loading .colymba-bulkupload-info{padding-left:20px;background-position:0 5px} .cms table.grid-field__table tr.bulkManagerOptions th.bulkmanagerheading{padding-left:40px}.cms table.grid-field__table tr.bulkManagerOptions th.bulkmanagerselect{text-align:center}.cms table.grid-field__table tr.bulkManagerOptions th.bulkmanagerselect input{margin-left:0}.cms table.grid-field__table tr.bulkManagerOptions .title{margin:0 0 2px 2px}.cms table.grid-field__table tr.bulkManagerOptions .dropdown{display:inline-block;border:none;box-shadow:none;padding:0;margin:0;color:#000;vertical-align:top}.cms table.grid-field__table tr.bulkManagerOptions .doBulkActionButton{margin-left:5px}.cms table.grid-field__table tr.bulkManagerOptions .doBulkActionButton img{height:20px}.cms table.grid-field__table tbody .col-bulkSelect{width:25px;text-align:center}#bulkEditHeader{float:left;width:70%;margin:40px 0 20px;font-size:30px;font-weight:700}#bulkEditToggle{float:right;clear:right;width:25%;margin:40px 0 20px;text-decoration:underline;text-align:right;cursor:pointer}.bulkEditingFieldHolder{position:relative;float:left;width:100%}.bulkEditingFieldHolder.hasUpdate .ui-accordion-header{background-color:#f2ba11;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(0,#f2ba11),color-stop(100%,#df6e00));background-image:-webkit-linear-gradient(top,#f2ba11,#df6e00);background-image:-moz-linear-gradient(top,#f2ba11 0,#df6e00 100%);background-image:-o-linear-gradient(top,#f2ba11 0,#df6e00 100%);background-image:-ms-linear-gradient(top,#f2ba11 0,#df6e00 100%);background-image:linear-gradient(top,#f2ba11,#df6e00)}.bulkEditingFieldHolder.hasUpdate .ui-accordion-header a{color:#fff;text-shadow:none}.bulkEditingFieldHolder.updated .ui-accordion-header{background-color:#a4ca3a;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(0,#a4ca3a),color-stop(100%,#59781d));background-image:-webkit-linear-gradient(top,#a4ca3a,#59781d);background-image:-moz-linear-gradient(top,#a4ca3a 0,#59781d 100%);background-image:-o-linear-gradient(top,#a4ca3a 0,#59781d 100%);background-image:-ms-linear-gradient(top,#a4ca3a 0,#59781d 100%);background-image:linear-gradient(top,#a4ca3a,#59781d)}.bulkEditingFieldHolder.updated .ui-accordion-header a{color:#fff;text-shadow:none}.bulkUpload{padding:0!important;border-bottom:1px solid rgba(0,0,0,.1)}.bulkUpload:hover{background-color:#444546}.bulkUpload .component{padding:0!important;color:#fff;background:#98aab6;border-top:1px solid #a4b4bf;border-left:1px solid #a4b4bf;border-bottom:1px solid rgba(0,0,0,.1)}.bulkUpload .component div.ss-uploadfield{position:relative;float:left;clear:both;width:100%}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files{float:left;clear:both;width:100%}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item{position:relative;float:left;clear:both;overflow:hidden;width:98%;padding:5px 1%;border:none;border-top:1px solid rgba(0,0,0,.1);background-color:#eceff1}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item:nth-child(2n-1){background-color:#e6eaed}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-preview{width:30px;height:30px;line-height:38px}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info{height:30px;margin-left:40px;line-height:30px}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-name{position:absolute;top:0;left:50px;width:100%;height:100%;line-height:40px}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-name .name{color:#343434}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-name .size{font-weight:400}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-name .ss-uploadfield-item-status{float:left;width:auto;padding:0 0 0 5px;text-align:left;max-width:none}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-name .ss-uploadfield-item-status.ui-state-warning-text{color:#f29500}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-name .ss-uploadfield-item-status.ui-state-success-text{color:#298530}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-actions{position:absolute;top:0;left:0;width:100%;height:30px;margin:0;padding:5px 0}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-actions .ss-uploadfield-item-progress{left:50px;right:35px;margin-top:8px}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-actions button{margin:0 10px 0 0}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-actions button .ui-button-text{padding-top:4px;padding-bottom:3px}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-actions .ss-uploadfield-item-cancel{position:relative;top:7px;right:auto;float:right}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-actions .ss-uploadfield-item-cancel button{background:none}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-files .ss-uploadfield-item .ss-uploadfield-item-info .ss-uploadfield-item-actions .ss-uploadfield-item-overwrite{position:relative;float:right;margin-top:2px}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile{float:left;clear:both;width:98%;padding:1%}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile.borderTop{border:none}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile .ss-uploadfield-item-preview.ss-uploadfield-dropzone{float:right;width:35%;height:43px;margin:0;line-height:43px;color:#eee;background-color:#8898a3;border:2px dashed #73818a;box-shadow:inset 0 0 10px 0 #73818a}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile .ss-uploadfield-item-preview.ss-uploadfield-dropzone.hover{color:#444546;background-color:#eee}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile .ss-uploadfield-item-info{float:left;width:60%;margin:0}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile .ss-uploadfield-item-info .ss-uploadfield-item-name{height:auto;margin-bottom:5px!important}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile .ss-uploadfield-item-info .ss-uploadfield-item-name small{font-weight:400!important}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile .ss-uploadfield-item-info .ss-ui-button .ui-button-text .ui-button-text{padding:0}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile .ss-uploadfield-item-info .ss-uploadfield-fromcomputer{margin-bottom:0}.bulkUpload .component div.ss-uploadfield .ss-uploadfield-addfile .ss-uploadfield-item-info .ss-uploadfield-fromfiles{margin-bottom:0;padding:.5px}.bulkUpload .component div.ss-uploadfield .colymba-bulkupload-buttons{display:none;float:left;width:98%;padding:6px 1%;background-color:#8898a3}.bulkUpload .component div.ss-uploadfield .colymba-bulkupload-buttons button{float:left;margin:0 6px 0 0}.bulkUpload .component div.ss-uploadfield .colymba-bulkupload-buttons button .ui-button-text .ui-button-text{padding:0}.bulkUpload .component div.ss-uploadfield .colymba-bulkupload-buttons button.bulkUploadClearErrorButton,.bulkUpload .component div.ss-uploadfield .colymba-bulkupload-buttons button.bulkUploadEditButton{float:right;margin:0 0 0 6px}.bulkUpload .component div.ss-uploadfield .colymba-bulkupload-buttons .colymba-bulkupload-info{float:left;margin:0 6px;line-height:28px;height:28px;color:#fff;overflow:hidden}.bulkUpload .component div.ss-uploadfield .colymba-bulkupload-buttons.loading .colymba-bulkupload-info{padding-left:20px;background-position:0 5px}

View File

@ -36,6 +36,8 @@
.doBulkActionButton .doBulkActionButton
{ {
margin-left: 5px;
img img
{ {
height: 20px; height: 20px;

View File

@ -3,14 +3,17 @@
namespace Colymba\BulkManager; namespace Colymba\BulkManager;
use ReflectionClass; use ReflectionClass;
use SilverStripe\Core\ClassInfo; use SilverStripe\Control\HTTPRequest;
use SilverStripe\Core\Config\Config; use SilverStripe\Control\RequestHandler;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Injector\Injector;
use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\GridField\GridField_HTMLProvider; use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridField_ColumnProvider; use SilverStripe\Forms\GridField\GridField_ColumnProvider;
use SilverStripe\Forms\GridField\GridField_HTMLProvider;
use SilverStripe\Forms\GridField\GridField_URLHandler; use SilverStripe\Forms\GridField\GridField_URLHandler;
use SilverStripe\ORM\DataObject;
use SilverStripe\View\ArrayData; use SilverStripe\View\ArrayData;
use SilverStripe\View\Requirements; use SilverStripe\View\Requirements;
@ -21,6 +24,8 @@ use SilverStripe\View\Requirements;
*/ */
class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, GridField_URLHandler class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, GridField_URLHandler
{ {
use Injectable;
/** /**
* component configuration. * component configuration.
* *
@ -35,7 +40,7 @@ class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, G
); );
/** /**
* GridFieldBulkManager component constructor. * BulkManager component constructor.
* *
* @param array $editableFields List of editable fields * @param array $editableFields List of editable fields
* @param bool $defaultActions Use default actions list. False to start fresh. * @param bool $defaultActions Use default actions list. False to start fresh.
@ -47,9 +52,10 @@ class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, G
} }
if ($defaultActions) { if ($defaultActions) {
$this->addBulkAction('Colymba\\BulkManager\\BulkAction\\EditHandler') $this
->addBulkAction('Colymba\\BulkManager\\BulkAction\\UnlinkHandler') ->addBulkAction(BulkAction\EditHandler::class)
->addBulkAction('Colymba\\BulkManager\\BulkAction\\DeleteHandler'); ->addBulkAction(BulkAction\UnlinkHandler::class)
->addBulkAction(BulkAction\DeleteHandler::class);
} }
} }
@ -102,26 +108,26 @@ class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, G
* Lets you add custom bulk actions to the bulk manager interface. * Lets you add custom bulk actions to the bulk manager interface.
* Exisiting handler will be replaced * Exisiting handler will be replaced
* *
* @param string $hanlderClassName RequestHandler class name for this action. * @param string $handlerClassName RequestHandler class name for this action.
* @param string $action Specific RequestHandler action to be called. * @param string $action Specific RequestHandler action to be called.
* *
* @return GridFieldBulkManager Current GridFieldBulkManager instance * @return $this Current BulkManager instance
*/ */
public function addBulkAction($hanlderClassName, $action = null) public function addBulkAction($handlerClassName, $action = null)
{ {
if (!$hanlderClassName || !ClassInfo::exists($hanlderClassName)) { if (!class_exists($handlerClassName)) {
user_error("Bulk action handler not found: $handler", E_USER_ERROR); user_error("Bulk action handler not found: $handlerClassName", E_USER_ERROR);
} }
$handler = Injector::inst()->get($hanlderClassName); $handler = Injector::inst()->get($handlerClassName);
$urlSegment = $handler->config()->get('url_segment'); $urlSegment = $handler->config()->get('url_segment');
if (!$urlSegment) if (!$urlSegment)
{ {
$rc = new ReflectionClass($hanlderClassName); $rc = new ReflectionClass($handlerClassName);
$urlSegment = $rc->getShortName(); $urlSegment = $rc->getShortName();
} }
$this->config['actions'][$urlSegment] = $hanlderClassName; $this->config['actions'][$urlSegment] = $handlerClassName;
return $this; return $this;
} }
@ -129,27 +135,37 @@ class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, G
/** /**
* Removes a bulk actions from the bulk manager interface. * Removes a bulk actions from the bulk manager interface.
* *
* @param string $hanlderClassName RequestHandler class name of the action to remove. * @param string $handlerClassName RequestHandler class name of the action to remove.
* @param string $urlSegment URL segment of the action to remove. * @param string $urlSegment URL segment of the action to remove.
* *
* @return GridFieldBulkManager Current GridFieldBulkManager instance * @return $this Current BulkManager instance
*/ */
public function removeBulkAction($hanlderClassName = null, $urlSegment = null) public function removeBulkAction($handlerClassName = null, $urlSegment = null)
{ {
if (!$hanlderClassName && !$urlSegment) { if (!$handlerClassName && !$urlSegment) {
user_error("Provide either a class name or URL segment", E_USER_ERROR); user_error("Provide either a class name or URL segment", E_USER_ERROR);
} }
foreach ($this->config['actions'] as $url => $class) foreach ($this->config['actions'] as $url => $class)
{ {
if ($hanlderClassName === $class || $urlSegment === $url) if ($handlerClassName === $class || $urlSegment === $url)
{ {
unset($this->config['actions'][$url]); unset($this->config['actions'][$url]);
return $this; return $this;
} }
} }
user_error("Bulk action '$hanlderClassName' or '$urlSegment' doesn't exists.", E_USER_ERROR); user_error("Bulk action '$handlerClassName' or '$urlSegment' doesn't exists.", E_USER_ERROR);
}
/**
* Return the list of bulk actions already provided
*
* @return RequestHandler[]
*/
public function getBulkActions()
{
return $this->config['actions'];
} }
/* ********************************************************************** /* **********************************************************************
@ -203,7 +219,7 @@ class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, G
* Set the column's HTML attributes. * Set the column's HTML attributes.
* *
* @param GridField $gridField Current GridField instance * @param GridField $gridField Current GridField instance
* @param DataObject $record Record intance for this row * @param DataObject $record Record instance for this row
* @param string $columnName Column's name for which we need attributes * @param string $columnName Column's name for which we need attributes
* *
* @return array List of HTML attributes * @return array List of HTML attributes
@ -244,14 +260,14 @@ class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, G
Requirements::add_i18n_javascript('colymba/gridfield-bulk-editing-tools:lang'); Requirements::add_i18n_javascript('colymba/gridfield-bulk-editing-tools:lang');
if (!count($this->config['actions'])) { if (!count($this->config['actions'])) {
user_error('Trying to use GridFieldBulkManager without any bulk action.', E_USER_ERROR); user_error('Trying to use BulkManager without any bulk action.', E_USER_ERROR);
} }
$actionsListSource = array(); $actionsListSource = array();
$actionsConfig = array(); $actionsConfig = array();
foreach ($this->config['actions'] as $urlSegment => $hanlderClassName) { foreach ($this->config['actions'] as $urlSegment => $handlerClassName) {
$handler = Injector::inst()->get($hanlderClassName); $handler = Injector::inst()->get($handlerClassName);
$handlerConfig = $handler->getConfig(); $handlerConfig = $handler->getConfig();
$actionsListSource[$urlSegment] = $handlerConfig['label']; $actionsListSource[$urlSegment] = $handlerConfig['label'];