From aa9bf472c672abee30c9af24337f96fa51b2714b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thierry=20Fran=C3=A7ois?= Date: Thu, 22 Feb 2018 10:15:42 +0200 Subject: [PATCH] API remove cancel and edit upload buttons API remove cancel and edit btns --- client/src/js/uploader.js | 106 ------------------- src/BulkUploader/BulkUploader.php | 36 +------ templates/Colymba/Bulkupload/BulkUploader.ss | 2 + 3 files changed, 6 insertions(+), 138 deletions(-) diff --git a/client/src/js/uploader.js b/client/src/js/uploader.js index 3bc91c6..9561c05 100644 --- a/client/src/js/uploader.js +++ b/client/src/js/uploader.js @@ -78,8 +78,6 @@ refresh: function(total, done, error) { var $info = this.find('.colymba-bulkupload-info'), - $editBtn = this.find('.bulkUploadEditButton'), - $cancelBtn = this.find('.bulkUploadCancelButton'), $finishBtn = this.find('.bulkUploadFinishButton'), $clearErrorBtn = this.find('.bulkUploadClearErrorButton') ; @@ -95,8 +93,6 @@ error )); - $cancelBtn.removeClass('ui-state-disabled ssui-button-disabled').attr('aria-disabled', 'false').removeAttr('disabled'); - //if there are still uploads going if ( (done + error) < total ) { @@ -109,15 +105,6 @@ else{ this.removeClass('loading'); $finishBtn.removeClass('ui-state-disabled ssui-button-disabled').attr('aria-disabled', 'false').removeAttr('disabled'); - } - - //if all done and OK, enable edit - if ( total === done ) - { - $editBtn.removeClass('ui-state-disabled ssui-button-disabled').attr('aria-disabled', 'false').removeAttr('disabled'); - } - else{ - $editBtn.addClass('ui-state-disabled ssui-button-disabled').attr('aria-disabled', 'true').attr('disabled', 'true'); } //toggle clear error button @@ -132,8 +119,6 @@ else{ //if not uploading, reset + hide this.css({display: 'none'}).removeClass('loading'); - $editBtn.addClass('ui-state-disabled ssui-button-disabled').attr('aria-disabled', 'true').attr('disabled', 'true'); - $cancelBtn.addClass('ui-state-disabled ssui-button-disabled').attr('aria-disabled', 'true').attr('disabled', 'true'); $finishBtn.addClass('ui-state-disabled ssui-button-disabled').attr('aria-disabled', 'true').attr('disabled', 'true'); $clearErrorBtn.addClass('ui-state-disabled ssui-button-disabled').attr('aria-disabled', 'true').attr('disabled', 'true'); } @@ -161,70 +146,6 @@ } }); - - /** - * Cancel all uploads - * Clear the ones with warnings/error and delete dataObjects from the successful ones - */ - $('.bulkUploadCancelButton:not(.ui-state-disabled)').entwine({ - onmatch: function(){ - this.removeClass('action'); - }, - onunmatch: function(){}, - onclick: function() - { - var $bulkUpload = this.parents('.bulkUpload'), - $li = $bulkUpload.find('li.ss-uploadfield-item'), - $records = $li.filter('[data-recordid]'), - $other = $li.not($records), - $doBulkActionButton = $bulkUpload.parents('.ss-gridfield-table').find('.doBulkActionButton'), - recordsID - ; - - $other.each(function(index, Element){ - // skip in progress - $(this).remove(); - }); - - if ( $doBulkActionButton.length > 0 ) - { - recordsID = $records.map(function() { - return parseInt( $(this).data('recordid') ) - }).get(); - - this.addClass('loading'); - $doBulkActionButton.doBulkAction('delete', recordsID, this.cancelCallback, this); - } - }, - cancelCallback: function(data) - { - var $bulkUpload = this.parents('.bulkUpload'), - $li = $bulkUpload.find('li.ss-uploadfield-item'), - ids - ; - - if ( data ) - { - ids = data.records; - - $li.each(function(index, Element){ - var $this = $(this), - recordID = parseInt( $this.data('recordid') ) - ; - - if ( ids.indexOf(recordID) !== -1 ) - { - $this.remove(); - } - }); - - $(this).parents('.ss-gridfield').entwine('.').entwine('ss').reload(); - } - - this.removeClass('loading'); - } - }); - /** * Clear all the warning/error/finished uploads @@ -252,33 +173,6 @@ } }); - $('.bulkUploadEditButton:not(.ui-state-disabled)').entwine({ - onmatch: function(){ - this.removeClass('action'); - }, - onunmatch: function(){}, - onclick: function() - { - var $bulkUpload = this.parents('.bulkUpload'), - $li = $bulkUpload.find('li.ss-uploadfield-item'), - $records = $li.filter('[data-recordid]'), - recordsID, - $doBulkActionButton = $bulkUpload.parents('.ss-gridfield-table').find('.doBulkActionButton') - ; - - if ( $doBulkActionButton.length > 0 ) - { - this.addClass('loading'); - - recordsID = $records.map(function() { - return parseInt( $(this).data('recordid') ) - }).get(); - - $doBulkActionButton.doBulkAction('bulkedit', recordsID); - } - } - }); - }); // colymba namespace }); // ss namespace diff --git a/src/BulkUploader/BulkUploader.php b/src/BulkUploader/BulkUploader.php index 256428c..6f2ada2 100644 --- a/src/BulkUploader/BulkUploader.php +++ b/src/BulkUploader/BulkUploader.php @@ -369,10 +369,7 @@ class BulkUploader implements GridField_HTMLProvider, GridField_URLHandler if (!singleton($gridField->getModelClass())->canEdit()) { return array(); } - - // check BulkManager exists - $bulkManager = $gridField->getConfig()->getComponentsByType('Colymba\\BulkManager\\BulkManager'); - + // upload management buttons $finishButton = FormAction::create('Finish', _t('GRIDFIELD_BULK_UPLOAD.FINISH_BTN_LABEL', 'Finish')) ->addExtraClass('bulkUploadFinishButton') @@ -384,37 +381,12 @@ class BulkUploader implements GridField_HTMLProvider, GridField_URLHandler ->setAttribute('data-icon', 'arrow-circle-double') ->setUseButtonTag(true); - if (count($bulkManager)) { - $cancelButton = FormAction::create('Cancel', _t('GRIDFIELD_BULK_UPLOAD.CANCEL_BTN_LABEL', 'Cancel')) - ->addExtraClass('bulkUploadCancelButton ss-ui-action-destructive') - ->setAttribute('data-icon', 'decline') - ->setAttribute('data-url', $gridField->Link('bulkupload/cancel')) - ->setUseButtonTag(true); - - $bulkManager_config = $bulkManager->first()->getConfig(); - $bulkManager_actions = $bulkManager_config['actions']; - if (array_key_exists('bulkedit', $bulkManager_actions)) { - $editAllButton = FormAction::create('EditAll', _t('GRIDFIELD_BULK_UPLOAD.EDIT_ALL_BTN_LABEL', 'Edit all')) - ->addExtraClass('bulkUploadEditButton') - ->setAttribute('data-icon', 'pencil') - ->setAttribute('data-url', $gridField->Link('bulkupload/edit')) - ->setUseButtonTag(true); - } else { - $editAllButton = ''; - } - } else { - $cancelButton = ''; - $editAllButton = ''; - } - - // get uploadField + inject extra buttons + // get uploadField $uploadField = $this->bulkUploadField($gridField); - $uploadField->FinishButton = $finishButton; - $uploadField->CancelButton = $cancelButton; - $uploadField->EditAllButton = $editAllButton; - $uploadField->ClearErrorButton = $clearErrorButton; $data = ArrayData::create(array( + 'Finish' => $finishButton, + 'ClearErrors' => $clearErrorButton, 'Colspan' => (count($gridField->getColumns())), 'UploadField' => $uploadField->Field() // call ->Field() to get requirements in right order )); diff --git a/templates/Colymba/Bulkupload/BulkUploader.ss b/templates/Colymba/Bulkupload/BulkUploader.ss index 67b9044..4958b9e 100644 --- a/templates/Colymba/Bulkupload/BulkUploader.ss +++ b/templates/Colymba/Bulkupload/BulkUploader.ss @@ -1,5 +1,7 @@ $UploadField + $Finish + $ClearErrors \ No newline at end of file