Updated to SS5 and reverted original namespacing
This commit is contained in:
parent
a208bee685
commit
4fbab0d232
18
.upgrade.yml
18
.upgrade.yml
|
@ -1,10 +1,10 @@
|
|||
mappings:
|
||||
GridFieldBulkActionDeleteHandler: Violet88\BulkManager\BulkAction\DeleteHandler
|
||||
GridFieldBulkActionEditHandler: Violet88\BulkManager\BulkAction\EditHandler
|
||||
GridFieldBulkActionHandler: Violet88\BulkManager\BulkAction\Handler
|
||||
GridFieldBulkActionUnlinkHandler: Violet88\BulkManager\BulkAction\UnlinkHandler
|
||||
GridFieldBulkManager: Violet88\BulkManager\BulkManager
|
||||
BulkUploadField: Violet88\BulkUpload\BulkUploadField
|
||||
GridFieldBulkImageUpload: Violet88\BulkUpload\GridFieldBulkImageUpload
|
||||
GridFieldBulkUpload: Violet88\BulkUpload\BulkUploader
|
||||
GridFieldBulkUpload_Request: Violet88\BulkUpload\BulkUploadHandler
|
||||
GridFieldBulkActionDeleteHandler: Colymba\BulkManager\BulkAction\DeleteHandler
|
||||
GridFieldBulkActionEditHandler: Colymba\BulkManager\BulkAction\EditHandler
|
||||
GridFieldBulkActionHandler: Colymba\BulkManager\BulkAction\Handler
|
||||
GridFieldBulkActionUnlinkHandler: Colymba\BulkManager\BulkAction\UnlinkHandler
|
||||
GridFieldBulkManager: Colymba\BulkManager\BulkManager
|
||||
BulkUploadField: Colymba\BulkUpload\BulkUploadField
|
||||
GridFieldBulkImageUpload: Colymba\BulkUpload\GridFieldBulkImageUpload
|
||||
GridFieldBulkUpload: Colymba\BulkUpload\BulkUploader
|
||||
GridFieldBulkUpload_Request: Colymba\BulkUpload\BulkUploadHandler
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
SilverStripe\Admin\LeftAndMain:
|
||||
extra_requirements_javascript:
|
||||
- 'violet88/gridfield-bulk-editing-tools: client/dist/js/main.js'
|
||||
- "colymba/gridfield-bulk-editing-tools: client/dist/js/main.js"
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* global window, alert, confirm */
|
||||
import jQuery from 'jquery';
|
||||
import i18n from 'i18n';
|
||||
import jQuery from "jquery";
|
||||
import i18n from "i18n";
|
||||
|
||||
jQuery.entwine('violet88', ($) => {
|
||||
jQuery.entwine("colymba", ($) => {
|
||||
/**
|
||||
* Makes sure the component is above the headers
|
||||
*/
|
||||
$('.bulkManagerOptions').entwine({
|
||||
$(".bulkManagerOptions").entwine({
|
||||
onmatch() {
|
||||
const $parent = this.parents('thead');
|
||||
const $tr = $parent.find('tr');
|
||||
const $parent = this.parents("thead");
|
||||
const $tr = $parent.find("tr");
|
||||
|
||||
const targets = ['.filter-header', '.sortable-header'];
|
||||
const $target = $parent.find(targets.join(','));
|
||||
const targets = [".filter-header", ".sortable-header"];
|
||||
const $target = $parent.find(targets.join(","));
|
||||
|
||||
const index = $tr.index(this);
|
||||
let newIndex = $tr.length - 1;
|
||||
|
@ -30,77 +30,84 @@ jQuery.entwine('violet88', ($) => {
|
|||
},
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Bulkselect table cell behaviours
|
||||
*/
|
||||
$('td.col-bulkSelect').entwine({
|
||||
$("td.col-bulkSelect").entwine({
|
||||
onmouseover() {
|
||||
// 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');
|
||||
$(this)
|
||||
.parents(".ss-gridfield-item")
|
||||
.find(".edit-link")
|
||||
.removeClass("edit-link")
|
||||
.addClass("tempDisabledEditLink");
|
||||
},
|
||||
onmouseout() {
|
||||
// re-enable default row click behaviour
|
||||
$(this).parents('.ss-gridfield-item').find('.tempDisabledEditLink').addClass('edit-link')
|
||||
.removeClass('tempDisabledEditLink');
|
||||
$(this)
|
||||
.parents(".ss-gridfield-item")
|
||||
.find(".tempDisabledEditLink")
|
||||
.addClass("edit-link")
|
||||
.removeClass("tempDisabledEditLink");
|
||||
},
|
||||
onclick(e) {
|
||||
// check/uncheck checkbox when clicking cell
|
||||
const cb = $(e.target).find('input');
|
||||
if (!$(cb).prop('checked')) {
|
||||
$(cb).prop('checked', true);
|
||||
const cb = $(e.target).find("input");
|
||||
if (!$(cb).prop("checked")) {
|
||||
$(cb).prop("checked", true);
|
||||
} else {
|
||||
$(cb).prop('checked', false);
|
||||
$(cb).prop("checked", false);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Individual select checkbox behaviour
|
||||
*/
|
||||
$('td.col-bulkSelect input').entwine({
|
||||
onmatch() {
|
||||
},
|
||||
onunmatch() {
|
||||
},
|
||||
$("td.col-bulkSelect input").entwine({
|
||||
onmatch() {},
|
||||
onunmatch() {},
|
||||
onclick() {
|
||||
$(this).parents('.grid-field__table').find('input.bulkSelectAll').prop('checked', '');
|
||||
}
|
||||
$(this)
|
||||
.parents(".grid-field__table")
|
||||
.find("input.bulkSelectAll")
|
||||
.prop("checked", "");
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Bulkselect checkbox behaviours
|
||||
*/
|
||||
$('input.bulkSelectAll').entwine({
|
||||
$("input.bulkSelectAll").entwine({
|
||||
onclick() {
|
||||
const state = $(this).prop('checked');
|
||||
$(this).parents('.grid-field__table')
|
||||
.find('td.col-bulkSelect input')
|
||||
.prop('checked', state)
|
||||
.trigger('change');
|
||||
const state = $(this).prop("checked");
|
||||
$(this)
|
||||
.parents(".grid-field__table")
|
||||
.find("td.col-bulkSelect input")
|
||||
.prop("checked", state)
|
||||
.trigger("change");
|
||||
},
|
||||
getSelectRecordsID() {
|
||||
return $(this).parents('.grid-field__table')
|
||||
.find('td.col-bulkSelect input:checked')
|
||||
return $(this)
|
||||
.parents(".grid-field__table")
|
||||
.find("td.col-bulkSelect input:checked")
|
||||
.map(function () {
|
||||
return parseInt($(this).data('record'), 10);
|
||||
return parseInt($(this).data("record"), 10);
|
||||
})
|
||||
.get();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Bulk action dropdown behaviours
|
||||
*/
|
||||
$('select.bulkActionName').entwine({
|
||||
$("select.bulkActionName").entwine({
|
||||
onchange() {
|
||||
const value = $(this).val();
|
||||
const $parent = $(this).parents('.bulkManagerOptions');
|
||||
const $btn = $parent.find('.doBulkActionButton');
|
||||
const config = $btn.data('config');
|
||||
const $parent = $(this).parents(".bulkManagerOptions");
|
||||
const $btn = $parent.find(".doBulkActionButton");
|
||||
const config = $btn.data("config");
|
||||
|
||||
$.each(config, (configKey, configData) => {
|
||||
if (configKey !== value) {
|
||||
|
@ -109,45 +116,45 @@ jQuery.entwine('violet88', ($) => {
|
|||
});
|
||||
|
||||
if (!value) {
|
||||
$btn.addClass('disabled');
|
||||
$btn.addClass("disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
$btn.removeClass('disabled');
|
||||
$btn.removeClass("disabled");
|
||||
|
||||
$btn.addClass(config[value].buttonClasses).addClass('btn-outline-secondary');
|
||||
$btn
|
||||
.addClass(config[value].buttonClasses)
|
||||
.addClass("btn-outline-secondary");
|
||||
|
||||
if (config[value].icon) {
|
||||
const $img = $btn.find('img');
|
||||
const $img = $btn.find("img");
|
||||
|
||||
if ($img.length) {
|
||||
$img.attr('src', config[value].icon);
|
||||
$img.attr("src", config[value].icon);
|
||||
} else {
|
||||
$btn.prepend(`<img src="${config[value].icon}" alt="" />`);
|
||||
}
|
||||
} else {
|
||||
$btn.find('img').remove();
|
||||
$btn.find("img").remove();
|
||||
}
|
||||
|
||||
|
||||
if (config[value].destructive) {
|
||||
$btn.addClass('btn-outline-danger');
|
||||
$btn.addClass("btn-outline-danger");
|
||||
} else {
|
||||
$btn.removeClass('btn-outline-danger');
|
||||
$btn.removeClass("btn-outline-danger");
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* bulk action button behaviours
|
||||
*/
|
||||
$('.doBulkActionButton').entwine({
|
||||
$(".doBulkActionButton").entwine({
|
||||
getActionURL(action, url) {
|
||||
const cacheBuster = new Date().getTime();
|
||||
let newUrl = url.split('?');
|
||||
let newUrl = url.split("?");
|
||||
|
||||
let newAction = '';
|
||||
let newAction = "";
|
||||
if (action) {
|
||||
newAction = `/${action}`;
|
||||
}
|
||||
|
@ -160,9 +167,12 @@ jQuery.entwine('violet88', ($) => {
|
|||
return newUrl;
|
||||
},
|
||||
onclick() {
|
||||
const $parent = $(this).parents('.bulkManagerOptions');
|
||||
const action = $parent.find('select.bulkActionName').val();
|
||||
const ids = $(this).parents('.bulkManagerOptions').find('input.bulkSelectAll:first').getSelectRecordsID();
|
||||
const $parent = $(this).parents(".bulkManagerOptions");
|
||||
const action = $parent.find("select.bulkActionName").val();
|
||||
const ids = $(this)
|
||||
.parents(".bulkManagerOptions")
|
||||
.find("input.bulkSelectAll:first")
|
||||
.getSelectRecordsID();
|
||||
|
||||
this.doBulkAction(action, ids);
|
||||
},
|
||||
|
@ -170,38 +180,40 @@ jQuery.entwine('violet88', ($) => {
|
|||
doBulkAction(action, ids) {
|
||||
const { bulkTools } = window;
|
||||
|
||||
const $parent = $(this).parents('.bulkManagerOptions');
|
||||
const $btn = $parent.find('a.doBulkActionButton');
|
||||
const $msg = $parent.find('.message');
|
||||
const $parent = $(this).parents(".bulkManagerOptions");
|
||||
const $btn = $parent.find("a.doBulkActionButton");
|
||||
const $msg = $parent.find(".message");
|
||||
|
||||
const config = $btn.data('config');
|
||||
let url = this.getActionURL(action, $(this).data('url'));
|
||||
const config = $btn.data("config");
|
||||
let url = this.getActionURL(action, $(this).data("url"));
|
||||
const inputData = { records: ids };
|
||||
|
||||
if (ids.length <= 0) {
|
||||
alert(i18n._t('GRIDFIELD_BULK_MANAGER.BULKACTION_EMPTY_SELECT'));
|
||||
alert(i18n._t("GRIDFIELD_BULK_MANAGER.BULKACTION_EMPTY_SELECT"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// if ( $btn.hasClass('ss-ui-action-destructive') )
|
||||
if (config[action].destructive) {
|
||||
if (!confirm(i18n._t('GRIDFIELD_BULK_MANAGER.CONFIRM_DESTRUCTIVE_ACTION'))) {
|
||||
if (
|
||||
!confirm(i18n._t("GRIDFIELD_BULK_MANAGER.CONFIRM_DESTRUCTIVE_ACTION"))
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$btn.addClass('loading');
|
||||
$msg.removeClass('static show error warning');
|
||||
$btn.addClass("loading");
|
||||
$msg.removeClass("static show error warning");
|
||||
|
||||
if (config[action].xhr) {
|
||||
$.ajax({
|
||||
url,
|
||||
data: inputData,
|
||||
type: 'POST',
|
||||
context: $(this)
|
||||
type: "POST",
|
||||
context: $(this),
|
||||
}).always(function (data) {
|
||||
let returnData = data;
|
||||
$btn.removeClass('loading');
|
||||
$btn.removeClass("loading");
|
||||
|
||||
// if request fail, return a +4xx status code, extract json response
|
||||
if (data.responseText) {
|
||||
|
@ -211,23 +223,26 @@ jQuery.entwine('violet88', ($) => {
|
|||
$msg.html(returnData.message);
|
||||
|
||||
if (returnData.isError) {
|
||||
$msg.addClass('static error');
|
||||
$msg.addClass("static error");
|
||||
} else if (returnData.isWarning) {
|
||||
$msg.addClass('show warning');
|
||||
$msg.addClass("show warning");
|
||||
} else {
|
||||
$msg.addClass('show');
|
||||
$msg.addClass("show");
|
||||
}
|
||||
|
||||
bulkTools.gridfieldRefresh($(this).parents('.ss-gridfield'), returnData);
|
||||
bulkTools.gridfieldRefresh(
|
||||
$(this).parents(".ss-gridfield"),
|
||||
returnData,
|
||||
);
|
||||
});
|
||||
} else {
|
||||
const records = `records[]=${ids.join('&records[]=')}`;
|
||||
const records = `records[]=${ids.join("&records[]=")}`;
|
||||
url = `${url}&${records}`;
|
||||
|
||||
window.location.href = url;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,49 +1,50 @@
|
|||
/* global window */
|
||||
import jQuery from 'jquery';
|
||||
import jQuery from "jquery";
|
||||
|
||||
jQuery.entwine('violet88', ($) => {
|
||||
jQuery.entwine("colymba", ($) => {
|
||||
/**
|
||||
* Toggle all accordion forms
|
||||
* open or closed
|
||||
*/
|
||||
$('#bulkEditToggle').entwine({
|
||||
$("#bulkEditToggle").entwine({
|
||||
onclick() {
|
||||
const toggleFields = this.parents('form').find('.ss-toggle .ui-accordion-header');
|
||||
let state = this.data('state');
|
||||
const toggleFields = this.parents("form").find(
|
||||
".ss-toggle .ui-accordion-header",
|
||||
);
|
||||
let state = this.data("state");
|
||||
|
||||
if (!state || state === 'close') {
|
||||
state = 'open';
|
||||
if (!state || state === "close") {
|
||||
state = "open";
|
||||
} else {
|
||||
state = 'close';
|
||||
state = "close";
|
||||
}
|
||||
|
||||
toggleFields.each(function () {
|
||||
const $this = $(this);
|
||||
|
||||
if (state === 'open' && !$this.hasClass('ui-state-active')) {
|
||||
if (state === "open" && !$this.hasClass("ui-state-active")) {
|
||||
$this.click();
|
||||
}
|
||||
|
||||
if (state === 'close' && $this.hasClass('ui-state-active')) {
|
||||
if (state === "close" && $this.hasClass("ui-state-active")) {
|
||||
$this.click();
|
||||
}
|
||||
});
|
||||
|
||||
this.data('state', state);
|
||||
}
|
||||
this.data("state", state);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Contains each rocrds editing fields,
|
||||
* tracks changes and updates...
|
||||
*/
|
||||
$('.bulkEditingFieldHolder').entwine({
|
||||
$(".bulkEditingFieldHolder").entwine({
|
||||
onchange() {
|
||||
this.removeClass('updated');
|
||||
if (!this.hasClass('hasUpdate')) {
|
||||
this.addClass('hasUpdate');
|
||||
this.removeClass("updated");
|
||||
if (!this.hasClass("hasUpdate")) {
|
||||
this.addClass("hasUpdate");
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "violet88/gridfield-bulk-editing-tools",
|
||||
"name": "colymba/gridfield-bulk-editing-tools",
|
||||
"type": "silverstripe-vendormodule",
|
||||
"description": "SilverStripe GridField component to upload images/files and edit records in bulk",
|
||||
"homepage": "https://github.com/colymba/GridFieldBulkEditingTools",
|
||||
|
@ -35,9 +35,9 @@
|
|||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Violet88\\BulkTools\\": "src/BulkTools/",
|
||||
"Violet88\\BulkManager\\": "src/BulkManager/",
|
||||
"Violet88\\BulkUpload\\": "src/BulkUploader/"
|
||||
"Colymba\\BulkTools\\": "src/BulkTools/",
|
||||
"Colymba\\BulkManager\\": "src/BulkManager/",
|
||||
"Colymba\\BulkUpload\\": "src/BulkUploader/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
# Bulk Manager
|
||||
Perform actions on multiple records straight from the GridField. Comes with *unlink*, *delete* and bulk *editing*. You can also easily create/add your own.
|
||||
|
||||
Perform actions on multiple records straight from the GridField. Comes with _unlink_, _delete_ and bulk _editing_. You can also easily create/add your own.
|
||||
|
||||
## Usage
|
||||
|
||||
Simply add component to your `GridFieldConfig`
|
||||
|
||||
```php
|
||||
|
@ -9,32 +11,39 @@ $config->addComponent(new \Colymba\BulkManager\BulkManager());
|
|||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
The component's options can be configurated individually or in bulk through the 'config' functions like this:
|
||||
|
||||
```php
|
||||
$config->getComponentByType('Violet88\\BulkManager\\BulkManager')->setConfig($reference, $value);
|
||||
$config->getComponentByType('Colymba\\BulkManager\\BulkManager')->setConfig($reference, $value);
|
||||
```
|
||||
|
||||
### $config overview
|
||||
|
||||
The available configuration options are:
|
||||
* 'editableFields' : array of string referencing specific CMS fields available for editing
|
||||
|
||||
- 'editableFields' : array of string referencing specific CMS fields available for editing
|
||||
|
||||
## Custom actions
|
||||
|
||||
You can remove or add individual action or replace them all via `addBulkAction()` and `removeBulkAction()`
|
||||
|
||||
### Adding a custom action
|
||||
|
||||
To add a custom bulk action to the list use:
|
||||
|
||||
```php
|
||||
$config
|
||||
->getComponentByType('Violet88\\BulkManager\\BulkManager')
|
||||
->getComponentByType('Colymba\\BulkManager\\BulkManager')
|
||||
->addBulkAction('Namespace\\ClassName')
|
||||
```
|
||||
|
||||
#### Custom action handler
|
||||
When creating your own bulk action `RequestHandler`, you should extend `Violet88\BulkManager\BulkAction\Handler` which will expose 2 useful functions `getRecordIDList()` and `getRecords()` returning either an array with the selected records IDs or a `DataList` of the selected records.
|
||||
|
||||
When creating your own bulk action `RequestHandler`, you should extend `Colymba\BulkManager\BulkAction\Handler` which will expose 2 useful functions `getRecordIDList()` and `getRecords()` returning either an array with the selected records IDs or a `DataList` of the selected records.
|
||||
|
||||
Make sure to define the handler's `$url_segment`, from which the handler will be called and its relating `$allowed_actions` and `$url_handlers`. See `Handler`, `DeleteHandler` and `UnlinkHandler` for examples.
|
||||
|
||||
#### Front-end config
|
||||
|
||||
Bulk action handler's front-end configuration is set via class properties `label`, `icon`, `buttonClasses`, `xhr` and `destructive`. See `Handler`, `DeleteHandler` and `UnlinkHandler` for reference and examples.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Violet88\BulkManager\BulkAction;
|
||||
namespace Colymba\BulkManager\BulkAction;
|
||||
|
||||
use Violet88\BulkManager\BulkAction\Handler;
|
||||
use Violet88\BulkTools\HTTPBulkToolsResponse;
|
||||
use Colymba\BulkManager\BulkAction\Handler;
|
||||
use Colymba\BulkTools\HTTPBulkToolsResponse;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
|
@ -100,13 +100,11 @@ class ArchiveHandler extends Handler
|
|||
$response = new HTTPBulkToolsResponse(true, $this->gridField);
|
||||
|
||||
try {
|
||||
foreach ($records as $record)
|
||||
{
|
||||
foreach ($records as $record) {
|
||||
$done = $record->doArchive();
|
||||
if ($done)
|
||||
{
|
||||
if ($done) {
|
||||
$response->addSuccessRecord($record);
|
||||
}else{
|
||||
} else {
|
||||
$response->addFailedRecord($record, $done);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Violet88\BulkManager\BulkAction;
|
||||
namespace Colymba\BulkManager\BulkAction;
|
||||
|
||||
use Violet88\BulkManager\BulkAction\Handler;
|
||||
use Violet88\BulkTools\HTTPBulkToolsResponse;
|
||||
use Colymba\BulkManager\BulkAction\Handler;
|
||||
use Colymba\BulkTools\HTTPBulkToolsResponse;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Convert;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Violet88\BulkManager\BulkAction;
|
||||
namespace Colymba\BulkManager\BulkAction;
|
||||
|
||||
use Violet88\BulkManager\BulkAction\Handler;
|
||||
use Colymba\BulkManager\BulkAction\Handler;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
|
@ -141,7 +141,7 @@ class EditHandler extends Handler
|
|||
->setAttribute('data-icon', 'decline')
|
||||
->setAttribute('href', $one_level_up->Link)
|
||||
->setUseButtonTag(true)
|
||||
->setAttribute('src', '')//changes type to image so isn't hooked by default actions handlers
|
||||
->setAttribute('src', '') //changes type to image so isn't hooked by default actions handlers
|
||||
);
|
||||
|
||||
$recordList = $this->getRecordIDList();
|
||||
|
@ -164,7 +164,7 @@ class EditHandler extends Handler
|
|||
);
|
||||
$header = LiteralField::create(
|
||||
'bulkEditHeader',
|
||||
'<h1 id="bulkEditHeader">'.$headerText.'</h1>'
|
||||
'<h1 id="bulkEditHeader">' . $headerText . '</h1>'
|
||||
);
|
||||
$recordsFieldList->push($header);
|
||||
|
||||
|
@ -184,9 +184,9 @@ class EditHandler extends Handler
|
|||
$record->getTitle(),
|
||||
$recordEditingFields
|
||||
)
|
||||
->setHeadingLevel(4)
|
||||
->setAttribute('data-id', $id)
|
||||
->addExtraClass('bulkEditingFieldHolder');
|
||||
->setHeadingLevel(4)
|
||||
->setAttribute('data-id', $id)
|
||||
->addExtraClass('bulkEditingFieldHolder');
|
||||
|
||||
$recordsFieldList->push($toggleField);
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ class EditHandler extends Handler
|
|||
//and add record ids GET var
|
||||
$bulkEditForm->setAttribute(
|
||||
'action',
|
||||
$this->Link('bulkEditForm?records[]='.implode('&', $recordList))
|
||||
$this->Link('bulkEditForm?records[]=' . implode('&', $recordList))
|
||||
);
|
||||
|
||||
return $bulkEditForm;
|
||||
|
@ -368,9 +368,9 @@ class EditHandler extends Handler
|
|||
$form->addExtraClass('center cms-content');
|
||||
$form->setAttribute('data-pjax-fragment', 'CurrentForm Content');
|
||||
|
||||
Requirements::javascript('violet88/gridfield-bulk-editing-tools:client/dist/js/main.js');
|
||||
Requirements::css('violet88/gridfield-bulk-editing-tools:client/dist/styles/main.css');
|
||||
Requirements::add_i18n_javascript('violet88/gridfield-bulk-editing-tools:lang');
|
||||
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()) {
|
||||
$response = new HTTPResponse(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Violet88\BulkManager\BulkAction;
|
||||
namespace Colymba\BulkManager\BulkAction;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\RequestHandler;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Violet88\BulkManager\BulkAction;
|
||||
namespace Colymba\BulkManager\BulkAction;
|
||||
|
||||
use Violet88\BulkManager\BulkAction\Handler;
|
||||
use Violet88\BulkTools\HTTPBulkToolsResponse;
|
||||
use Colymba\BulkManager\BulkAction\Handler;
|
||||
use Colymba\BulkTools\HTTPBulkToolsResponse;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
|
@ -100,13 +100,11 @@ class PublishHandler extends Handler
|
|||
$response = new HTTPBulkToolsResponse(false, $this->gridField);
|
||||
|
||||
try {
|
||||
foreach ($records as $record)
|
||||
{
|
||||
foreach ($records as $record) {
|
||||
$done = $record->publishRecursive();
|
||||
if ($done)
|
||||
{
|
||||
if ($done) {
|
||||
$response->addSuccessRecord($record);
|
||||
}else{
|
||||
} else {
|
||||
$response->addFailedRecord($record, $done);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Violet88\BulkManager\BulkAction;
|
||||
namespace Colymba\BulkManager\BulkAction;
|
||||
|
||||
use Violet88\BulkManager\BulkAction\Handler;
|
||||
use Violet88\BulkTools\HTTPBulkToolsResponse;
|
||||
use Colymba\BulkManager\BulkAction\Handler;
|
||||
use Colymba\BulkTools\HTTPBulkToolsResponse;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
|
@ -100,13 +100,11 @@ class UnPublishHandler extends Handler
|
|||
$response = new HTTPBulkToolsResponse(false, $this->gridField);
|
||||
|
||||
try {
|
||||
foreach ($records as $record)
|
||||
{
|
||||
foreach ($records as $record) {
|
||||
$done = $record->doUnpublish();
|
||||
if ($done)
|
||||
{
|
||||
if ($done) {
|
||||
$response->addSuccessRecord($record);
|
||||
}else{
|
||||
} else {
|
||||
$response->addFailedRecord($record, $done);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Violet88\BulkManager\BulkAction;
|
||||
namespace Colymba\BulkManager\BulkAction;
|
||||
|
||||
use Violet88\BulkManager\BulkAction\Handler;
|
||||
use Violet88\BulkTools\HTTPBulkToolsResponse;
|
||||
use Colymba\BulkManager\BulkAction\Handler;
|
||||
use Colymba\BulkTools\HTTPBulkToolsResponse;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Violet88\BulkManager;
|
||||
namespace Colymba\BulkManager;
|
||||
|
||||
use ReflectionClass;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
|
@ -129,8 +129,7 @@ class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, G
|
|||
|
||||
$handler = Injector::inst()->get($handlerClassName);
|
||||
$urlSegment = $handler->config()->get('url_segment');
|
||||
if (!$urlSegment)
|
||||
{
|
||||
if (!$urlSegment) {
|
||||
$rc = new ReflectionClass($handlerClassName);
|
||||
$urlSegment = $rc->getShortName();
|
||||
}
|
||||
|
@ -154,10 +153,8 @@ class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, G
|
|||
user_error("Provide either a class name or URL segment", E_USER_ERROR);
|
||||
}
|
||||
|
||||
foreach ($this->config['actions'] as $url => $class)
|
||||
{
|
||||
if ($handlerClassName === $class || $urlSegment === $url)
|
||||
{
|
||||
foreach ($this->config['actions'] as $url => $class) {
|
||||
if ($handlerClassName === $class || $urlSegment === $url) {
|
||||
unset($this->config['actions'][$url]);
|
||||
return $this;
|
||||
}
|
||||
|
@ -263,9 +260,9 @@ class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, G
|
|||
*/
|
||||
public function getHTMLFragments($gridField)
|
||||
{
|
||||
Requirements::javascript('violet88/gridfield-bulk-editing-tools:client/dist/js/main.js');
|
||||
Requirements::css('violet88/gridfield-bulk-editing-tools:client/dist/styles/main.css');
|
||||
Requirements::add_i18n_javascript('violet88/gridfield-bulk-editing-tools:client/lang');
|
||||
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'] ?? [])) {
|
||||
user_error('Trying to use BulkManager without any bulk action.', E_USER_ERROR);
|
||||
|
@ -308,7 +305,7 @@ class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, G
|
|||
$templateData = new ArrayData($templateData);
|
||||
|
||||
return array(
|
||||
'header' => $templateData->renderWith('Violet88\\BulkManager\\BulkManagerButtons'),
|
||||
'header' => $templateData->renderWith('Colymba\\BulkManager\\BulkManagerButtons'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Violet88\BulkTools;
|
||||
namespace Colymba\BulkTools;
|
||||
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Forms\GridField\GridField;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Violet88\BulkUpload;
|
||||
namespace Colymba\BulkUpload;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
//use SilverStripe\Forms\UploadField;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Violet88\BulkUpload;
|
||||
namespace Colymba\BulkUpload;
|
||||
|
||||
use Violet88\BulkTools\HTTPBulkToolsResponse;
|
||||
use Colymba\BulkTools\HTTPBulkToolsResponse;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\RequestHandler;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
|
@ -112,8 +112,7 @@ class BulkUploadHandler extends RequestHandler
|
|||
$assetAdmin = AssetAdmin::singleton();
|
||||
$uploadResponse = $assetAdmin->apiCreateFile($request);
|
||||
|
||||
if ($uploadResponse->getStatusCode() == 200)
|
||||
{
|
||||
if ($uploadResponse->getStatusCode() == 200) {
|
||||
$responseData = Convert::json2array($uploadResponse->getBody());
|
||||
$responseData = array_shift($responseData);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Violet88\BulkUpload;
|
||||
namespace Colymba\BulkUpload;
|
||||
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\View\ArrayData;
|
||||
|
@ -183,7 +183,8 @@ class BulkUploader implements GridField_HTMLProvider, GridField_URLHandler
|
|||
|
||||
$imageField = null;
|
||||
foreach ($hasOneFields as $field => $type) {
|
||||
if ($type === 'SilverStripe\\Assets\\Image'
|
||||
if (
|
||||
$type === 'SilverStripe\\Assets\\Image'
|
||||
|| $type === 'SilverStripe\\Assets\\File'
|
||||
|| is_subclass_of($type, 'SilverStripe\\Assets\\File')
|
||||
) {
|
||||
|
@ -245,7 +246,7 @@ class BulkUploader implements GridField_HTMLProvider, GridField_URLHandler
|
|||
$uploadField = BulkUploadField::create($gridField, $fieldName, '')
|
||||
->setForm($gridField->getForm())
|
||||
->setRecord(DataObject::create()) // avoid UploadField to get auto-config from the Page (e.g fix allowedMaxFileNumber)
|
||||
;
|
||||
;
|
||||
|
||||
//UploadField setup
|
||||
foreach ($this->ufSetup as $fn => $param) {
|
||||
|
@ -294,12 +295,12 @@ class BulkUploader implements GridField_HTMLProvider, GridField_URLHandler
|
|||
'UploadField' => $uploadField->Field() // call ->Field() to get requirements in right order
|
||||
));
|
||||
//This one is no longer needed since the javascript is now loaded at the top of the cms
|
||||
//Requirements::javascript('violet88/gridfield-bulk-editing-tools:client/dist/js/main.js');
|
||||
Requirements::css('violet88/gridfield-bulk-editing-tools:client/dist/styles/main.css');
|
||||
Requirements::add_i18n_javascript('violet88/gridfield-bulk-editing-tools:client/lang');
|
||||
//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(
|
||||
'before' => $data->renderWith('Violet88\\BulkUpload\\BulkUploader'),
|
||||
'before' => $data->renderWith('Colymba\\BulkUpload\\BulkUploader'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue