From d4726cb5fe5fc9d1a139b7ca50f67965cb842634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thierry=20Fran=C3=A7ois?= Date: Tue, 27 Feb 2018 16:48:02 +0200 Subject: [PATCH] Clean up :shower: --- .upgrade.yml | 2 +- README.md | 4 +- _config.php | 7 - client/dist/js/bulkTools.js | 436 +------------------------------ client/dist/styles/bulkTools.css | 72 +---- client/dist/styles/bundle.css | 3 +- 6 files changed, 5 insertions(+), 519 deletions(-) diff --git a/.upgrade.yml b/.upgrade.yml index 49a211d..be82823 100644 --- a/.upgrade.yml +++ b/.upgrade.yml @@ -7,4 +7,4 @@ mappings: BulkUploadField: Colymba\BulkUpload\BulkUploadField GridFieldBulkImageUpload: Colymba\BulkUpload\GridFieldBulkImageUpload GridFieldBulkUpload: Colymba\BulkUpload\BulkUploader - GridFieldBulkUpload_Request: Colymba\BulkUpload\BulkUploadRequest + GridFieldBulkUpload_Request: Colymba\BulkUpload\BulkUploadHandler diff --git a/README.md b/README.md index e6007ae..6828762 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,8 @@ Set of SilverStripe 4 GridField components to facilitate bulk file upload & reco * [Bulk Upload](#bulk-upload): Upload multiple images or files at once into DataObjects * [Bulk Manager](#bulk-manager): Delete, Unlink, Edit (and more) multiple records at once -[More screenshots here.](screenshots) - ## Requirements -* SilverStripe 4.0 (3.+) +* SilverStripe 4.0 (master / 3.+) * SilverStripe 3.1 (version 2.+ / 1.+) * Silverstripe 3.0 (version 0.5) diff --git a/_config.php b/_config.php index 332f216..b3d9bbc 100644 --- a/_config.php +++ b/_config.php @@ -1,8 +1 @@ newIndex ) - { - $tr.eq(newIndex).insertAfter($(this)); - } - }, - onunmatch: function(){} - }); - - - /** - * Bulkselect table cell behaviours - */ - $('td.col-bulkSelect').entwine({ - onmatch: function(){ - }, - onunmatch: function(){ - }, - onmouseover: function(){ - //disable default row click behaviour -> avoid navigation to edit form when clicking the checkbox - $(this).parents('.ss-gridfield-item').find('.edit-link').removeClass('edit-link').addClass('tempDisabledEditLink'); - }, - onmouseout: function(){ - //re-enable default row click behaviour - $(this).parents('.ss-gridfield-item').find('.tempDisabledEditLink').addClass('edit-link').removeClass('tempDisabledEditLink'); - }, - onclick: function(e) { - //check/uncheck checkbox when clicking cell - var cb = $(e.target).find('input'); - if ( !$(cb).prop('checked') ) $(cb).prop('checked', true); - else $(cb).prop('checked', false); - } - }); - - - /** - * Individual select checkbox behaviour - */ - $('td.col-bulkSelect input').entwine({ - onmatch: function(){ - }, - onunmatch: function(){ - }, - onclick: function(e) { - $(this).parents('.grid-field__table').find('input.bulkSelectAll').prop('checked', ''); - } - }); - - - /** - * Bulkselect checkbox behaviours - */ - $('input.bulkSelectAll').entwine({ - onmatch: function(){ - }, - onunmatch: function(){ - }, - onclick: function() - { - var state = $(this).prop('checked'); - $(this).parents('.grid-field__table') - .find('td.col-bulkSelect input') - .prop('checked', state) - .trigger('change'); - }, - getSelectRecordsID: function() - { - return $(this).parents('.grid-field__table') - .find('td.col-bulkSelect input:checked') - .map(function() { - return parseInt( $(this).data('record') ) - }) - .get(); - } - }); - - - /** - * Bulk action dropdown behaviours - */ - $('select.bulkActionName').entwine({ - onmatch: function(){ - }, - onunmatch: function(){ - }, - onchange: function(e) - { - var value = $(this).val(), - $parent = $(this).parents('.bulkManagerOptions'), - $btn = $parent.find('.doBulkActionButton'), - config = $btn.data('config'); - - $.each( config, function( configKey, configData ) - { - if ( configKey != value ) - { - $btn.removeClass(configData['buttonClasses']); - } - }); - - if(!value) - { - $btn.addClass('disabled'); - return; - } - else { - $btn.removeClass('disabled'); - } - - $btn.addClass(config[value]['buttonClasses']).addClass('btn-outline-secondary'); - - - if ( config[value]['icon'] ) - { - var $img = $btn.find('img'); - - if ($img.length) - { - $img.attr('src', config[value]['icon']); - } - else{ - $btn.prepend(''); - } - } - else{ - $btn.find('img').remove(); - } - - - if ( config[value]['destructive'] ) - { - $btn.addClass('btn-outline-danger'); - } - else{ - $btn.removeClass('btn-outline-danger'); - } - - } - }); - - - /** - * bulk action button behaviours - */ - $('.doBulkActionButton').entwine({ - onmatch: function(){ - }, - onunmatch: function(){ - }, - getActionURL: function(action, url) - { - var cacheBuster = new Date().getTime(); - url = url.split('?'); - - if ( action ) - { - action = '/' + action; - } - else{ - action = ''; - } - - if ( url[1] ) - { - url = url[0] + action + '?' + url[1] + '&' + 'cacheBuster=' + cacheBuster; - } - else{ - url = url[0] + action + '?' + 'cacheBuster=' + cacheBuster; - } - return url; - }, - onclick: function(e) - { - var $parent = $(this).parents('.bulkManagerOptions'), - action = $parent.find('select.bulkActionName').val(), - ids = $(this).parents('.bulkManagerOptions').find('input.bulkSelectAll:first').getSelectRecordsID() - ; - - this.doBulkAction(action, ids); - }, - - doBulkAction: function(action, ids, callbackFunction, callbackContext) - { - var $parent = $(this).parents('.bulkManagerOptions'), - $btn = $parent.find('a.doBulkActionButton'), - - config = $btn.data('config'), - url = this.getActionURL(action, $(this).data('url')), - data = { records: ids } - ; - - if ( ids.length <= 0 ) - { - alert( ss.i18n._t('GRIDFIELD_BULK_MANAGER.BULKACTION_EMPTY_SELECT') ); - return; - } - - //if ( $btn.hasClass('ss-ui-action-destructive') ) - if ( config[action]['destructive'] ) - { - if( !confirm(ss.i18n._t('GRIDFIELD_BULK_MANAGER.CONFIRM_DESTRUCTIVE_ACTION')) ) - { - if ( callbackFunction && callbackContext ) - { - callbackFunction.call(callbackContext, false); - } - return false; - } - } - - $btn.addClass('loading'); - - if ( config[action]['xhr'] ) - { - $.ajax({ - url: url, - data: data, - type: "POST", - context: $(this) - }).done(function(data, textStatus, jqXHR) { - $btn.removeClass('loading'); - if ( callbackFunction && callbackContext ) - { - callbackFunction.call(callbackContext, data); - } - else{ - $(this).parents('.ss-gridfield').entwine('.').entwine('ss').reload(); - } - }); - } - else{ - var records = 'records[]='+ids.join('&records[]='); - url = url + '&' + records; - - window.location.href = url; - } - } - }); - - - }); - }); -}(jQuery)); - - -/***/ }), -/* 2 */ -/***/ (function(module, exports) { - -(function($) { - $.entwine('colymba', function($) { - - /** - * Toggle all accordion forms - * open or closed - */ - $('#bulkEditToggle') .entwine({ - onmatch: function(){}, - onunmatch: function(){}, - onclick: function(e) - { - var toggleFields = this.parents('form').find('.ss-toggle .ui-accordion-header'), - state = this.data('state') - ; - - if ( !state || state === 'close' ) - { - state = 'open'; - } - else { - state = 'close'; - } - - toggleFields.each(function() - { - var $this = $(this); - - if ( state === 'open' && !$this.hasClass('ui-state-active') ) - { - $this.click(); - } - - if ( state === 'close' && $this.hasClass('ui-state-active') ) - { - $this.click(); - } - }); - - this.data('state', state); - } - }); - - - /** - * Contains each rocrds editing fields, - * tracks changes and updates... - */ - $('.bulkEditingFieldHolder').entwine({ - onmatch: function(){}, - onunmatch: function(){}, - onchange: function(){ - this.removeClass('updated'); - if ( !this.hasClass('hasUpdate') ) - { - this.addClass('hasUpdate'); - } - } - }); - - }); -}(jQuery)); - -/***/ }), -/* 3 */ -/***/ (function(module, exports) { - -/* -(function($) { - $.entwine('ss', function($) { - $.entwine('colymba', function($) { - - - }); // colymba namespace - }); // ss namespace -}(jQuery)); -*/ - -/***/ }) -/******/ ]); -//# sourceMappingURL=bulkTools.js.map \ No newline at end of file +!function(n){function t(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return n[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var e={};t.m=n,t.c=e,t.d=function(n,e,i){t.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:i})},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},t.p="",t(t.s=0)}([function(n,t,e){e(1),e(2),n.exports=e(3)},function(n,t){!function(n){n.entwine("ss",function(n){n.entwine("colymba",function(n){n(".bulkManagerOptions").entwine({onmatch:function(){var t=this.parents("thead"),e=t.find("tr"),i=[".filter-header",".sortable-header"],o=t.find(i.join(",")),c=e.index(this),a=e.length-1;o.each(function(n,t){var i=e.index(t);ia&&e.eq(a).insertAfter(n(this))},onunmatch:function(){}}),n("td.col-bulkSelect").entwine({onmatch:function(){},onunmatch:function(){},onmouseover:function(){n(this).parents(".ss-gridfield-item").find(".edit-link").removeClass("edit-link").addClass("tempDisabledEditLink")},onmouseout:function(){n(this).parents(".ss-gridfield-item").find(".tempDisabledEditLink").addClass("edit-link").removeClass("tempDisabledEditLink")},onclick:function(t){var e=n(t.target).find("input");n(e).prop("checked")?n(e).prop("checked",!1):n(e).prop("checked",!0)}}),n("td.col-bulkSelect input").entwine({onmatch:function(){},onunmatch:function(){},onclick:function(t){n(this).parents(".grid-field__table").find("input.bulkSelectAll").prop("checked","")}}),n("input.bulkSelectAll").entwine({onmatch:function(){},onunmatch:function(){},onclick:function(){var t=n(this).prop("checked");n(this).parents(".grid-field__table").find("td.col-bulkSelect input").prop("checked",t).trigger("change")},getSelectRecordsID:function(){return n(this).parents(".grid-field__table").find("td.col-bulkSelect input:checked").map(function(){return parseInt(n(this).data("record"))}).get()}}),n("select.bulkActionName").entwine({onmatch:function(){},onunmatch:function(){},onchange:function(t){var e=n(this).val(),i=n(this).parents(".bulkManagerOptions"),o=i.find(".doBulkActionButton"),c=o.data("config");if(n.each(c,function(n,t){n!=e&&o.removeClass(t.buttonClasses)}),!e)return void o.addClass("disabled");if(o.removeClass("disabled"),o.addClass(c[e].buttonClasses).addClass("btn-outline-secondary"),c[e].icon){var a=o.find("img");a.length?a.attr("src",c[e].icon):o.prepend('')}else o.find("img").remove();c[e].destructive?o.addClass("btn-outline-danger"):o.removeClass("btn-outline-danger")}}),n(".doBulkActionButton").entwine({onmatch:function(){},onunmatch:function(){},getActionURL:function(n,t){var e=(new Date).getTime();return t=t.split("?"),n=n?"/"+n:"",t=t[1]?t[0]+n+"?"+t[1]+"&cacheBuster="+e:t[0]+n+"?cacheBuster="+e},onclick:function(t){var e=n(this).parents(".bulkManagerOptions"),i=e.find("select.bulkActionName").val(),o=n(this).parents(".bulkManagerOptions").find("input.bulkSelectAll:first").getSelectRecordsID();this.doBulkAction(i,o)},doBulkAction:function(t,e,i,o){var c=n(this).parents(".bulkManagerOptions"),a=c.find("a.doBulkActionButton"),s=a.data("config"),r=this.getActionURL(t,n(this).data("url")),l={records:e};if(e.length<=0)return void alert(ss.i18n._t("GRIDFIELD_BULK_MANAGER.BULKACTION_EMPTY_SELECT"));if(s[t].destructive&&!confirm(ss.i18n._t("GRIDFIELD_BULK_MANAGER.CONFIRM_DESTRUCTIVE_ACTION")))return i&&o&&i.call(o,!1),!1;if(a.addClass("loading"),s[t].xhr)n.ajax({url:r,data:l,type:"POST",context:n(this)}).done(function(t,e,c){a.removeClass("loading"),i&&o?i.call(o,t):n(this).parents(".ss-gridfield").entwine(".").entwine("ss").reload()});else{r=r+"&"+("records[]="+e.join("&records[]=")),window.location.href=r}}})})})}(jQuery)},function(n,t){!function(n){n.entwine("colymba",function(n){n("#bulkEditToggle").entwine({onmatch:function(){},onunmatch:function(){},onclick:function(t){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 t=n(this);"open"!==i||t.hasClass("ui-state-active")||t.click(),"close"===i&&t.hasClass("ui-state-active")&&t.click()}),this.data("state",i)}}),n(".bulkEditingFieldHolder").entwine({onmatch:function(){},onunmatch:function(){},onchange:function(){this.removeClass("updated"),this.hasClass("hasUpdate")||this.addClass("hasUpdate")}})})}(jQuery)},function(n,t){}]); \ No newline at end of file diff --git a/client/dist/styles/bulkTools.css b/client/dist/styles/bulkTools.css index 07a5c46..600e692 100644 --- a/client/dist/styles/bulkTools.css +++ b/client/dist/styles/bulkTools.css @@ -1,71 +1 @@ -.cms table.grid-field__table tr.bulkManagerOptions th { - text-transform: none; } - .cms table.grid-field__table tr.bulkManagerOptions th .bulkActionName { - float: left; } - .cms table.grid-field__table tr.bulkManagerOptions th .bulkActionName .form__field-holder { - min-width: 200px; - margin-left: 0; } - .cms table.grid-field__table tr.bulkManagerOptions th .bulkActionName .chosen-container { - min-width: 120px; } - .cms table.grid-field__table tr.bulkManagerOptions th .bulkActionName .chosen-container-single .chosen-single { - border-top-right-radius: 0; - border-bottom-right-radius: 0; } - .cms table.grid-field__table tr.bulkManagerOptions th .doBulkActionButton { - border-top-left-radius: 0; - border-bottom-left-radius: 0; - height: 36px; - line-height: 26px; - margin-left: -1px; } - .cms table.grid-field__table tr.bulkManagerOptions th .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 0; - font-size: 30px; - font-weight: bold; } - -#bulkEditToggle { - float: right; - clear: right; - width: 25%; - margin: 40px 0 20px 0; - 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 0%, #df6e00 100%); - 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 0%, #df6e00 100%); } - .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 0%, #59781D 100%); - 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 0%, #59781D 100%); } - .bulkEditingFieldHolder.updated .ui-accordion-header a { - color: #fff; - text-shadow: none; } -.bulkUploader .uploadfield__droptext::before { - text-transform: none; - content: "b"; } - -/*# sourceMappingURL=bulkTools.css.map*/ \ No newline at end of file +.cms table.grid-field__table tr.bulkManagerOptions th{text-transform:none}.cms table.grid-field__table tr.bulkManagerOptions th .bulkActionName{float:left}.cms table.grid-field__table tr.bulkManagerOptions th .bulkActionName .form__field-holder{min-width:200px;margin-left:0}.cms table.grid-field__table tr.bulkManagerOptions th .bulkActionName .chosen-container{min-width:120px}.cms table.grid-field__table tr.bulkManagerOptions th .bulkActionName .chosen-container-single .chosen-single{border-top-right-radius:0;border-bottom-right-radius:0}.cms table.grid-field__table tr.bulkManagerOptions th .doBulkActionButton{border-top-left-radius:0;border-bottom-left-radius:0;height:36px;line-height:26px;margin-left:-1px}.cms table.grid-field__table tr.bulkManagerOptions th .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}.bulkUploader .uploadfield__droptext:before{text-transform:none;content:"b"} \ No newline at end of file diff --git a/client/dist/styles/bundle.css b/client/dist/styles/bundle.css index 651e4d9..e146e77 100644 --- a/client/dist/styles/bundle.css +++ b/client/dist/styles/bundle.css @@ -91,5 +91,4 @@ module.exports = __webpack_require__(3); // removed by extract-text-webpack-plugin /***/ }) -/******/ ]); -/*# sourceMappingURL=bundle.css.map*/ \ No newline at end of file +/******/ ]); \ No newline at end of file