Switch to SS webpack-config and FIX add-from-files

Now using the SilverStripe webpack-config which lets us extend the CMS front end components. Allowed to write a quick hack fixing the add-from-file for bulk uploader
This commit is contained in:
Thierry François 2018-03-06 00:03:12 +02:00
parent ea0359b76f
commit de2d3234f4
16 changed files with 196 additions and 171 deletions

View File

@ -1 +0,0 @@
!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);i<a&&(a=i)}),c>a&&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('<img src="'+c[e].icon+'" alt="" />')}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){}]);

View File

@ -1 +0,0 @@
{"version":3,"sources":["webpack:///webpack/bootstrap ceb9cfb05baa8567dac6","webpack:///./client/src/js/manager.js","webpack:///./client/src/js/managerBulkEditingForm.js","webpack:///./client/src/js/uploader.js"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;AC7DA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;;AAEX;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,OAAO;;;AAGP;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;;;AAGJ;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA,IAAI;;;AAGJ;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA,MAAM;;;AAGN;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;;AAEN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,IAAI;;;AAGJ;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA,yBAAyB;AACzB;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;;;AAGJ,GAAG;AACH,EAAE;AACF,CAAC;;;;;;;AC7QD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,W;AACA,SAAS;;AAET;AACA;AACA,KAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL,GAAG;AACH,CAAC,U;;;;;;AC7DD;AACA,c;AACA;AACA;;;AAGA,GAAG,EAAE;AACL,EAAE,EAAE;AACJ,CAAC;AACD,E","file":"js/bulkTools.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap ceb9cfb05baa8567dac6","(function($) {\n\t$.entwine('ss', function($) {\n\n\t\t$.entwine('colymba', function($) {\n\n\t\t\t/**\n * Makes sure the component is above the headers\n */\n $('.bulkManagerOptions').entwine({\n onmatch: function(){\n var $parent = this.parents('thead'),\n \t\t$tr = $parent.find('tr'),\n\n \t\ttargets = ['.filter-header', '.sortable-header'],\n \t\t$target = $parent.find(targets.join(',')),\n\n index = $tr.index(this),\n newIndex = $tr.length - 1\n ;\n\n $target.each(function(index, Element){\n \tvar idx = $tr.index(Element);\n \tif ( idx < newIndex )\n \t{\n \t\tnewIndex = idx;\n \t}\n });\n\n if ( index > newIndex )\n {\n $tr.eq(newIndex).insertAfter($(this));\n }\n },\n onunmatch: function(){}\n });\n\n\n\t\t /**\n\t\t * Bulkselect table cell behaviours\n\t\t */\n\t\t\t$('td.col-bulkSelect').entwine({\n\t\t\t\tonmatch: function(){\n\t\t\t\t},\n\t\t\t\tonunmatch: function(){\n\t\t\t\t},\n\t\t\t\tonmouseover: function(){\n\t\t\t\t\t//disable default row click behaviour -> avoid navigation to edit form when clicking the checkbox\n\t $(this).parents('.ss-gridfield-item').find('.edit-link').removeClass('edit-link').addClass('tempDisabledEditLink');\n\t\t\t\t},\n\t\t\t\tonmouseout: function(){\n\t\t\t\t\t//re-enable default row click behaviour\n\t\t\t\t\t$(this).parents('.ss-gridfield-item').find('.tempDisabledEditLink').addClass('edit-link').removeClass('tempDisabledEditLink');\n\t\t\t\t},\n\t\t\t\tonclick: function(e) {\n\t\t\t\t\t//check/uncheck checkbox when clicking cell\n\t\t\t\t\tvar cb = $(e.target).find('input');\n\t\t\t\t\tif ( !$(cb).prop('checked') ) $(cb).prop('checked', true);\n\t\t\t\t\telse $(cb).prop('checked', false);\n\t\t\t\t}\n\t\t\t});\n\n\n\t\t\t/**\n\t\t\t * Individual select checkbox behaviour\n\t\t\t */\n\t\t\t$('td.col-bulkSelect input').entwine({\n\t\t\t\tonmatch: function(){\n\t\t\t\t},\n\t\t\t\tonunmatch: function(){\n\t\t\t\t},\n\t\t\t\tonclick: function(e) {\n\t\t\t\t\t$(this).parents('.grid-field__table').find('input.bulkSelectAll').prop('checked', '');\n\t\t\t\t}\n\t\t\t});\n\n\n\t\t\t/**\n\t\t\t * Bulkselect checkbox behaviours\n\t\t\t */\n\t $('input.bulkSelectAll').entwine({\n\t onmatch: function(){\n\t\t\t\t},\n\t\t\t\tonunmatch: function(){\n\t\t\t\t},\n\t onclick: function()\n\t {\n\t var state = $(this).prop('checked');\n\t $(this).parents('.grid-field__table')\n\t \t\t\t .find('td.col-bulkSelect input')\n\t \t\t\t .prop('checked', state)\n\t \t\t\t .trigger('change');\n\t },\n\t getSelectRecordsID: function()\n\t {\n\t \treturn $(this).parents('.grid-field__table')\n\t\t\t\t\t \t\t\t\t.find('td.col-bulkSelect input:checked')\n\t\t\t\t\t \t\t\t\t.map(function() {\n\t\t\t\t\t \t\t\t\t\treturn parseInt( $(this).data('record') )\n\t\t\t\t\t \t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t\t .get();\n\t }\n\t });\n\n\n\t /**\n\t * Bulk action dropdown behaviours\n\t */\n\t\t\t$('select.bulkActionName').entwine({\n\t\t\t\tonmatch: function(){\n\t\t\t\t},\n\t\t\t\tonunmatch: function(){\n\t\t\t\t},\n\t\t\t\tonchange: function(e)\n\t\t\t\t{\n\t\t\t\t\tvar value = $(this).val(),\n\t\t\t\t\t\t$parent = $(this).parents('.bulkManagerOptions'),\n\t\t\t\t\t\t$btn = $parent.find('.doBulkActionButton'),\n\t\t\t\t\t\tconfig = $btn.data('config');\n\n\t\t\t\t\t$.each( config, function( configKey, configData )\n\t\t\t\t\t{\n\t\t\t\t\t\tif ( configKey != value )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$btn.removeClass(configData['buttonClasses']);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tif(!value)\n\t\t\t\t\t{\n\t\t\t\t\t\t$btn.addClass('disabled');\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t$btn.removeClass('disabled');\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t$btn.addClass(config[value]['buttonClasses']).addClass('btn-outline-secondary');\n\n\n\t\t\t\t\tif ( config[value]['icon'] )\n\t\t\t\t\t{\n\t\t\t\t\t\tvar $img = $btn.find('img');\n\n\t\t\t\t\t\tif ($img.length)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$img.attr('src', config[value]['icon']);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse{\n\t\t\t\t\t\t\t$btn.prepend('<img src=\"'+config[value]['icon']+'\" alt=\"\" />');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\t$btn.find('img').remove();\n\t\t\t\t\t}\n\n\n\t\t\t\t\tif ( config[value]['destructive'] )\n\t\t\t\t\t{\n\t\t\t\t\t\t$btn.addClass('btn-outline-danger');\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\t$btn.removeClass('btn-outline-danger');\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t});\n\n\n\t\t\t/**\n\t\t\t * bulk action button behaviours\n\t\t\t */\n\t\t\t$('.doBulkActionButton').entwine({\n\t\t\t\tonmatch: function(){\n\t\t\t\t},\n\t\t\t\tonunmatch: function(){\n\t\t\t\t},\n\t\t\t\tgetActionURL: function(action, url)\n\t\t\t\t{\n\t\t\t\t\tvar cacheBuster = new Date().getTime();\n\t\t\t\t\turl = url.split('?');\n\n\t\t\t\t\tif ( action )\n\t\t\t\t\t{\n\t\t\t\t\t\taction = '/' + action;\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\taction = '';\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( url[1] )\n\t\t\t\t\t{\n\t\t\t\t\t\turl = url[0] + action + '?' + url[1] + '&' + 'cacheBuster=' + cacheBuster;\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\turl = url[0] + action + '?' + 'cacheBuster=' + cacheBuster;\n\t\t\t\t\t}\n\t\t\t\t\treturn url;\n\t\t\t\t},\n\t\t\t\tonclick: function(e)\n\t\t\t\t{\n var $parent = $(this).parents('.bulkManagerOptions'),\n action = $parent.find('select.bulkActionName').val(),\n ids = $(this).parents('.bulkManagerOptions').find('input.bulkSelectAll:first').getSelectRecordsID()\n\t\t\t\t\t\t\t;\n\n\t\t\t\t\tthis.doBulkAction(action, ids);\n\t\t\t\t},\n\n\t\t\t\tdoBulkAction: function(action, ids, callbackFunction, callbackContext)\n\t\t\t\t{\n var $parent = $(this).parents('.bulkManagerOptions'),\n $btn = $parent.find('a.doBulkActionButton'),\n\n config = $btn.data('config'),\n url = this.getActionURL(action, $(this).data('url')),\n data = { records: ids }\n\t\t\t\t\t\t\t;\n\n\t\t\t\t\tif ( ids.length <= 0 )\n\t\t\t\t\t{\n\t\t\t\t\t\talert( ss.i18n._t('GRIDFIELD_BULK_MANAGER.BULKACTION_EMPTY_SELECT') );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t//if ( $btn.hasClass('ss-ui-action-destructive') )\n\t\t\t\t\tif ( config[action]['destructive'] )\n\t\t\t\t\t{\n\t\t\t\t\t\tif( !confirm(ss.i18n._t('GRIDFIELD_BULK_MANAGER.CONFIRM_DESTRUCTIVE_ACTION')) )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif ( callbackFunction && callbackContext )\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcallbackFunction.call(callbackContext, false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t$btn.addClass('loading');\n\n\t\t\t\t\tif ( config[action]['xhr'] )\n\t\t\t\t\t{\n\t\t\t\t\t\t$.ajax({\n\t\t\t\t\t\t\turl: url,\n\t\t\t\t\t\t\tdata: data,\n\t\t\t\t\t\t\ttype: \"POST\",\n\t\t\t\t\t\t\tcontext: $(this)\n\t\t\t\t\t\t}).done(function(data, textStatus, jqXHR) {\n\t $btn.removeClass('loading');\n\t if ( callbackFunction && callbackContext )\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcallbackFunction.call(callbackContext, data);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse{\n\t\t\t\t\t\t\t\t$(this).parents('.ss-gridfield').entwine('.').entwine('ss').reload();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\tvar records = 'records[]='+ids.join('&records[]=');\n\t\t\t\t\t\turl = url + '&' + records;\n\n\t\t\t\t\t\twindow.location.href = url;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\n\t\t});\n\t});\n}(jQuery));\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./client/src/js/manager.js\n// module id = 1\n// module chunks = 0","(function($) {\n $.entwine('colymba', function($) {\n\n /**\n * Toggle all accordion forms\n * open or closed\n */\n $('#bulkEditToggle') .entwine({\n onmatch: function(){},\n onunmatch: function(){},\n onclick: function(e)\n {\n var toggleFields = this.parents('form').find('.ss-toggle .ui-accordion-header'),\n state = this.data('state')\n ;\n\n if ( !state || state === 'close' )\n {\n state = 'open';\n }\n else {\n state = 'close';\n }\n\n toggleFields.each(function()\n {\n var $this = $(this);\n \n if ( state === 'open' && !$this.hasClass('ui-state-active') )\n {\n $this.click();\n }\n\n if ( state === 'close' && $this.hasClass('ui-state-active') )\n {\n $this.click();\n } \n });\n\n this.data('state', state);\n }\n });\n \n \n /**\n * Contains each rocrds editing fields,\n * tracks changes and updates...\n */\n $('.bulkEditingFieldHolder').entwine({\n onmatch: function(){},\n onunmatch: function(){},\n onchange: function(){\n this.removeClass('updated');\n if ( !this.hasClass('hasUpdate') )\n {\n this.addClass('hasUpdate');\n }\n }\n });\n \n });\n}(jQuery));\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./client/src/js/managerBulkEditingForm.js\n// module id = 2\n// module chunks = 0","/*\n(function($) {\t\n\t$.entwine('ss', function($) {\n\t\t$.entwine('colymba', function($) {\n\n\n\t\t}); // colymba namespace\n\t}); // ss namespace\n}(jQuery));\n*/\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./client/src/js/uploader.js\n// module id = 3\n// module chunks = 0"],"sourceRoot":""}

1
client/dist/js/main.js vendored Normal file
View File

@ -0,0 +1 @@
!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)}({"./client/src/js/manager.js":function(n,t,e){(function(n){!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(",")),a=e.index(this),c=e.length-1;o.each(function(n,t){var i=e.index(t);i<c&&(c=i)}),a>c&&e.eq(c).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"),a=o.data("config");if(n.each(a,function(n,t){n!=e&&o.removeClass(t.buttonClasses)}),!e)return void o.addClass("disabled");if(o.removeClass("disabled"),o.addClass(a[e].buttonClasses).addClass("btn-outline-secondary"),a[e].icon){var c=o.find("img");c.length?c.attr("src",a[e].icon):o.prepend('<img src="'+a[e].icon+'" alt="" />')}else o.find("img").remove();a[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 a=n(this).parents(".bulkManagerOptions"),c=a.find("a.doBulkActionButton"),s=c.data("config"),r=this.getActionURL(t,n(this).data("url")),l={records:e};return e.length<=0?void alert(ss.i18n._t("GRIDFIELD_BULK_MANAGER.BULKACTION_EMPTY_SELECT")):s[t].destructive&&!confirm(ss.i18n._t("GRIDFIELD_BULK_MANAGER.CONFIRM_DESTRUCTIVE_ACTION"))?(i&&o&&i.call(o,!1),!1):(c.addClass("loading"),void(s[t].xhr?n.ajax({url:r,data:l,type:"POST",context:n(this)}).done(function(t,e,a){c.removeClass("loading"),i&&o?i.call(o,t):n(this).parents(".ss-gridfield").entwine(".").entwine("ss").reload()}):(r=r+"&records[]="+e.join("&records[]="),window.location.href=r)))}})})})}(n)}).call(t,e("jquery"))},"./client/src/js/managerBulkEditingForm.js":function(n,t,e){(function(n){!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")}})})}(n)}).call(t,e("jquery"))},"./client/src/js/uploader.js":function(n,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(n){var t=e("lib/Injector"),i=function(t){var e=n("#"+t.fieldId).data("schema");n.ajax(e.data.attachFileEndpoint.url,{method:e.data.attachFileEndpoint.method,data:{fileID:t.file.id}}).done(function(n,t,e){})},o=function(n){return function(t){return function(t,e){var o=e.type,a=e.payload;switch(o){case"UPLOADFIELD_ADD_FILE":return-1!==a.fieldId.indexOf("_BU")&&a.file.id&&i(a),n(t,{type:o,payload:a});default:return n(t,{type:o,payload:a})}}}};e.n(t).a.transform("bulkUploaderCustom",function(n){n.reducer("assetAdmin",o)})}.call(t,e("jquery"))},0:function(n,t,e){e("./client/src/js/manager.js"),e("./client/src/js/managerBulkEditingForm.js"),n.exports=e("./client/src/js/uploader.js")},jquery:function(n,t){n.exports=jQuery},"lib/Injector":function(n,t){n.exports=Injector}});

View File

@ -1 +0,0 @@
{"version":3,"sources":[],"names":[],"mappings":"","file":"styles/bulkTools.css","sourceRoot":""}

View File

@ -1,94 +0,0 @@
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(1);
__webpack_require__(2);
module.exports = __webpack_require__(3);
/***/ }),
/* 1 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/* 2 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/* 3 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ })
/******/ ]);

View File

@ -1 +0,0 @@
{"version":3,"sources":["webpack:///webpack/bootstrap 8cffac81604e6aa9f28c","webpack:///./client/src/styles/manager.scss","webpack:///./client/src/styles/managerBulkEditingForm.scss","webpack:///./client/src/styles/uploader.scss"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;AC7DA,yC;;;;;;ACAA,yC;;;;;;ACAA,yC","file":"styles/bundle.css","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 8cffac81604e6aa9f28c","// removed by extract-text-webpack-plugin\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./client/src/styles/manager.scss\n// module id = 1\n// module chunks = 0","// removed by extract-text-webpack-plugin\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./client/src/styles/managerBulkEditingForm.scss\n// module id = 2\n// module chunks = 0","// removed by extract-text-webpack-plugin\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./client/src/styles/uploader.scss\n// module id = 3\n// module chunks = 0"],"sourceRoot":""}

View File

@ -1 +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;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"}
.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:-o-linear-gradient(top,#f2ba11 0,#df6e00 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f2ba11),to(#df6e00));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:-o-linear-gradient(top,#a4ca3a 0,#59781d 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(top),color-stop(0,#a4ca3a),to(#59781d));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"}

View File

@ -1,10 +1,39 @@
/*
(function($) {
$.entwine('ss', function($) {
$.entwine('colymba', function($) {
/**
* A quick hack to catch the uploadfield add file event
* and send the file ID to the bulkUploader component
*/
import Injector from 'lib/Injector';
}); // colymba namespace
}); // ss namespace
}(jQuery));
*/
const bulkUploadFieldAttach = (payload) => {
const schema = jQuery('#'+payload.fieldId).data('schema');
jQuery.ajax(schema.data.attachFileEndpoint.url, {
method: schema.data.attachFileEndpoint.method, //doesn't seem to change anything
data: {
fileID: payload.file.id
}
}).done(function( data, textStatus, jqXHR ) {
//do something?
});
}
const bulkUploadFieldReducer = (originalReducer) => (globalState) => (state, { type, payload }) => {
switch (type) {
case 'UPLOADFIELD_ADD_FILE': {
// Needs to be a bulk upload field and have a file ID (no file ID = normal)
if (payload.fieldId.indexOf('_BU') !== -1 && payload.file.id)
{
bulkUploadFieldAttach(payload);
}
return originalReducer(state, { type, payload });
}
default: {
return originalReducer(state, { type, payload });
}
}
}
Injector.transform('bulkUploaderCustom', (updater) => {
updater.reducer('assetAdmin', bulkUploadFieldReducer);
});

View File

@ -27,13 +27,10 @@
"url": "https://github.com/colymba/GridFieldBulkEditingTools/issues"
},
"homepage": "https://github.com/colymba/GridFieldBulkEditingTools",
"dependencies": {},
"dependencies": {
"webpack": "^3.10"
},
"devDependencies": {
"node-sass": "^4.7.2",
"sass-loader": "^6.0",
"css-loader": "^0.28",
"style-loader": "^0.19",
"extract-text-webpack-plugin": "^3.0",
"webpack": "^3.10.0"
"@silverstripe/webpack-config": "^0.7"
}
}

39
package.json.back Normal file
View File

@ -0,0 +1,39 @@
{
"name": "colymba-gridfield-bulk-editing-tools",
"version": "3.0.0",
"description": "Bulk upload and record editing for SilverStripe CMS",
"engines": {
"node": "^6.x"
},
"scripts": {
"build": "NODE_ENV=production webpack -p --bail --progress",
"watch": "NODE_ENV=development webpack --watch --progress",
"tx": "tx push --source && tx pull --all && node transifex.js",
"dist": "npm run tx && npm run build"
},
"repository": {
"type": "git",
"url": "git://github.com/tractorcow/silverstripe-fluent.git"
},
"keywords": [
"bulk",
"manager",
"upload",
"silverstripe"
],
"author": "Thierry Francois",
"license": "BSD-3-Clause",
"bugs": {
"url": "https://github.com/colymba/GridFieldBulkEditingTools/issues"
},
"homepage": "https://github.com/colymba/GridFieldBulkEditingTools",
"dependencies": {},
"devDependencies": {
"node-sass": "^4.7.2",
"sass-loader": "^6.0",
"css-loader": "^0.28",
"style-loader": "^0.19",
"extract-text-webpack-plugin": "^3.0",
"webpack": "^3.10.0"
}
}

View File

@ -367,8 +367,8 @@ class EditHandler extends Handler
$form->addExtraClass('center cms-content');
$form->setAttribute('data-pjax-fragment', 'CurrentForm Content');
Requirements::javascript('colymba/gridfield-bulk-editing-tools:client/dist/js/bulkTools.js');
Requirements::css('colymba/gridfield-bulk-editing-tools:client/dist/styles/bulkTools.css');
Requirements::javascript('colymba/gridfield-bulk-editing-tools:client/dist/js/main.js');
Requirements::css('colymba/gridfield-bulk-editing-tools:client/dist/styles/main.css');
Requirements::add_i18n_javascript('colymba/gridfield-bulk-editing-tools:lang');
if ($this->request->isAjax()) {

View File

@ -262,8 +262,8 @@ class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, G
*/
public function getHTMLFragments($gridField)
{
Requirements::javascript('colymba/gridfield-bulk-editing-tools:client/dist/js/bulkTools.js');
Requirements::css('colymba/gridfield-bulk-editing-tools:client/dist/styles/bulkTools.css');
Requirements::javascript('colymba/gridfield-bulk-editing-tools:client/dist/js/main.js');
Requirements::css('colymba/gridfield-bulk-editing-tools:client/dist/styles/main.css');
Requirements::add_i18n_javascript('colymba/gridfield-bulk-editing-tools:client/lang');
if (!count($this->config['actions'])) {

View File

@ -258,7 +258,7 @@ class BulkUploadHandler extends RequestHandler
}
/**
* Retrieve Files to be attached
* Retrieve File to be attached
* and generated DataObjects for each one.
*
* @param HTTPRequest $request
@ -267,25 +267,13 @@ class BulkUploadHandler extends RequestHandler
*/
public function attach(HTTPRequest $request)
{
$uploadField = $this->getUploadField();
$attachResponses = $uploadField->attach($request);
$attachResponses = json_decode($attachResponses->getBody(), true);
$fileID = $request->requestVar('fileID'); //why is this not POST?
$dataObject = $this->createDataObject($fileID);
$return = array();
foreach ($attachResponses as $attachResponse)
{
$record = $this->createDataObject($attachResponse['id']);
// JS Template Data
$responseData = $this->newRecordJSTemplateData($record, $attachResponse);
// add to returned dataset
array_push($return, $responseData);
}
$response = new HTTPResponse(Convert::raw2json($return));
$this->contentTypeNegotiation($response);
$response = new HTTPResponse(Convert::raw2json(array(
'done' => $dataObject->ID
)));
$response->addHeader('Content-Type', 'text/json');
return $response;
}

View File

@ -370,12 +370,17 @@ class BulkUploader implements GridField_HTMLProvider, GridField_URLHandler
$uploadLink = $gridField->Link('bulkupload/upload');
$schema['data']['createFileEndpoint'] = [
'url' => $uploadLink,
'url' => $gridField->Link('bulkupload/upload'),
'method' => 'post',
'payloadFormat' => 'urlencoded',
];
$schema['data']['attachFileEndpoint'] = [
'url' => $gridField->Link('bulkupload/attach'),
'method' => 'post'
];
$uploadField->setSchemaData($schema);
return $uploadField;
@ -407,8 +412,8 @@ class BulkUploader implements GridField_HTMLProvider, GridField_URLHandler
'UploadField' => $uploadField->Field() // call ->Field() to get requirements in right order
));
Requirements::javascript('colymba/gridfield-bulk-editing-tools:client/dist/js/bulkTools.js');
Requirements::css('colymba/gridfield-bulk-editing-tools:client/dist/styles/bulkTools.css');
Requirements::javascript('colymba/gridfield-bulk-editing-tools:client/dist/js/main.js');
Requirements::css('colymba/gridfield-bulk-editing-tools:client/dist/styles/main.css');
Requirements::add_i18n_javascript('colymba/gridfield-bulk-editing-tools:client/lang');
return array(

View File

@ -1,17 +1,30 @@
const path = require('path');
const PATHS = {
ROOT: path.resolve(),
SRC: path.resolve('client/src'),
DIST: path.resolve('client/dist'),
};
const Path = require('path');
const webpack = require('webpack');
// Import the core config
const webpackConfig = require('@silverstripe/webpack-config');
const {
resolveJS,
externalJS,
moduleJS,
pluginJS,
moduleCSS,
pluginCSS,
} = webpackConfig;
const ENV = process.env.NODE_ENV;
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const extractSASS = new ExtractTextPlugin({ filename: 'styles/bulkTools.css' });
const PATHS = {
// the root path, where your webpack.config.js is located.
ROOT: Path.resolve(),
// your node_modules folder name, or full path
MODULES: 'node_modules',
// relative path from your css files to your other files, such as images and fonts
FILES_PATH: '../',
// thirdparty folder containing copies of packages which wouldn't be available on NPM
THIRDPARTY: 'thirdparty',
// the root path to your javascript source files
SRC: Path.resolve('client/src'),
DIST: Path.resolve('client/dist'),
};
const config = [
{
@ -23,11 +36,16 @@ const config = [
],
output: {
path: PATHS.DIST,
filename: 'js/bulkTools.js'
filename: 'js/[name].js',
},
devtool: (ENV !== 'production') ? 'source-map' : ''
},{
name: 'scss',
devtool: (ENV !== 'production') ? 'source-map' : '',
resolve: resolveJS(ENV, PATHS),
externals: externalJS(ENV, PATHS),
module: moduleJS(ENV, PATHS),
plugins: pluginJS(ENV, PATHS),
},
{
name: 'css',
entry: [
`${PATHS.SRC}/styles/manager.scss`,
`${PATHS.SRC}/styles/managerBulkEditingForm.scss`,
@ -35,22 +53,12 @@ const config = [
],
output: {
path: PATHS.DIST,
filename: 'styles/bundle.css'
filename: 'styles/[name].css'
},
devtool: (ENV !== 'production') ? 'source-map' : '',
module: {
rules: [{
test: /\.scss$/,
use: extractSASS.extract({
fallback: 'style-loader',
use: [ 'css-loader', 'sass-loader' ]
})
}]
},
plugins: [
extractSASS
]
}
module: moduleCSS(ENV, PATHS),
plugins: pluginCSS(ENV, PATHS),
},
];
module.exports = config;

56
webpack.config.js.back Normal file
View File

@ -0,0 +1,56 @@
const path = require('path');
const PATHS = {
ROOT: path.resolve(),
SRC: path.resolve('client/src'),
DIST: path.resolve('client/dist'),
};
const ENV = process.env.NODE_ENV;
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const extractSASS = new ExtractTextPlugin({ filename: 'styles/bulkTools.css' });
const config = [
{
name: 'js',
entry: [
`${PATHS.SRC}/js/manager.js`,
`${PATHS.SRC}/js/managerBulkEditingForm.js`,
`${PATHS.SRC}/js/uploader.js`
],
output: {
path: PATHS.DIST,
filename: 'js/bulkTools.js'
},
devtool: (ENV !== 'production') ? 'source-map' : ''
},{
name: 'scss',
entry: [
`${PATHS.SRC}/styles/manager.scss`,
`${PATHS.SRC}/styles/managerBulkEditingForm.scss`,
`${PATHS.SRC}/styles/uploader.scss`
],
output: {
path: PATHS.DIST,
filename: 'styles/bundle.css'
},
devtool: (ENV !== 'production') ? 'source-map' : '',
module: {
rules: [{
test: /\.scss$/,
use: extractSASS.extract({
fallback: 'style-loader',
use: [ 'css-loader', 'sass-loader' ]
})
}]
},
plugins: [
extractSASS
]
}
];
module.exports = config;