mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 11:05:57 +02:00
Added bulk upload management buttons
This commit is contained in:
parent
198b0c05d9
commit
ade47d5e80
@ -223,6 +223,7 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
||||
->setConfig('previewMaxHeight', 20)
|
||||
->setConfig('changeDetection', false)
|
||||
|
||||
->setTemplate('GridFieldBulkUploadField')
|
||||
->setDownloadTemplateName('colymba-bulkuploaddownloadtemplate')
|
||||
|
||||
->setConfig('url', $gridField->Link('bulkupload/upload'))
|
||||
@ -264,9 +265,41 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
||||
return array();
|
||||
}
|
||||
|
||||
// upload management buttons
|
||||
$finishButton = FormAction::create('Finish', _t('GridFieldBulkTools.FINISH_BTN_LABEL', 'Finish'))
|
||||
->addExtraClass('bulkUploadFinishButton')
|
||||
->setAttribute('data-icon', 'accept')
|
||||
->setUseButtonTag(true)
|
||||
->setAttribute('src', '');//changes type to image so isn't hooked by default actions handlers
|
||||
|
||||
$cancelButton = FormAction::create('Cancel', _t('GridFieldBulkTools.CANCEL_BTN_LABEL', 'Cancel & delete all'))
|
||||
->addExtraClass('bulkUploadCancelButton ss-ui-action-destructive')
|
||||
->setAttribute('data-icon', 'decline')
|
||||
->setAttribute('data-url', $gridField->Link('bulkupload/cancel'))
|
||||
->setUseButtonTag(true)
|
||||
->setAttribute('src', '');
|
||||
|
||||
if ( $gridField->getConfig()->getComponentsByType('GridFieldBulkManager') )
|
||||
{
|
||||
$editAllButton = FormAction::create('EditAll', _t('GridFieldBulkTools.EDIT_ALL_BTN_LABEL', 'Edit all'))
|
||||
->addExtraClass('bulkUploadEditButton')
|
||||
->setAttribute('data-icon', 'pencil')
|
||||
->setAttribute('data-url', $gridField->Link('bulkupload/edit'))
|
||||
->setUseButtonTag(true)
|
||||
->setAttribute('src', '');
|
||||
}else{
|
||||
$editAllButton = '';
|
||||
}
|
||||
|
||||
// get uploadField + inject extra buttons
|
||||
$uploadField = $this->bulkUploadField($gridField);
|
||||
$uploadField->FinishButton = $finishButton;
|
||||
$uploadField->CancelButton = $cancelButton;
|
||||
$uploadField->EditAllButton = $editAllButton;
|
||||
|
||||
$data = ArrayData::create(array(
|
||||
'Colspan' => count($gridField->getColumns()),
|
||||
'UploadField' => $this->bulkUploadField($gridField)->Field() // call ->Field() to get requirements in right order
|
||||
'Colspan' => count($gridField->getColumns()),
|
||||
'UploadField' => $uploadField->Field() // call ->Field() to get requirements in right order
|
||||
));
|
||||
|
||||
Requirements::css(BULKEDITTOOLS_UPLOAD_PATH . '/css/GridFieldBulkUpload.css');
|
||||
|
78
bulkUpload/templates/GridFieldBulkUploadField.ss
Normal file
78
bulkUpload/templates/GridFieldBulkUploadField.ss
Normal file
@ -0,0 +1,78 @@
|
||||
<% if $canUpload || $canAttachExisting %>
|
||||
<div class="ss-uploadfield-item ss-uploadfield-addfile<% if $CustomisedItems %> borderTop<% end_if %>">
|
||||
<% if canUpload %>
|
||||
<div class="ss-uploadfield-item-preview ss-uploadfield-dropzone ui-corner-all">
|
||||
<% if $multiple %>
|
||||
<% _t('UploadField.DROPFILES', 'drop files') %>
|
||||
<% else %>
|
||||
<% _t('UploadField.DROPFILE', 'drop a file') %>
|
||||
<% end_if %>
|
||||
</div>
|
||||
<% end_if %>
|
||||
<div class="ss-uploadfield-item-info">
|
||||
<label class="ss-uploadfield-item-name">
|
||||
<% if $multiple %>
|
||||
<b><% _t('UploadField.ATTACHFILES', 'Attach files') %></b>
|
||||
<% else %>
|
||||
<b><% _t('UploadField.ATTACHFILE', 'Attach a file') %></b>
|
||||
<% end_if %>
|
||||
<% if $canPreviewFolder %>
|
||||
<small>(<%t UploadField.UPLOADSINTO 'saves into /{path}' path=$FolderName %>)</small>
|
||||
<% end_if %>
|
||||
</label>
|
||||
<% if $canUpload %>
|
||||
<label class="ss-uploadfield-fromcomputer ss-ui-button ui-corner-all" title="<% _t('UploadField.FROMCOMPUTERINFO', 'Upload from your computer') %>" data-icon="drive-upload">
|
||||
<% _t('UploadField.FROMCOMPUTER', 'From your computer') %>
|
||||
<input id="$id" name="{$Name}[Uploads][]" class="$extraClass ss-uploadfield-fromcomputer-fileinput" data-config="$configString" type="file"<% if $multiple %> multiple="multiple"<% end_if %> />
|
||||
</label>
|
||||
<% else %>
|
||||
<input id="$id" name="{$Name}[Uploads][]" class="$extraClass ss-uploadfield-fromcomputer-fileinput" data-config="$configString" type="hidden" />
|
||||
<% end_if %>
|
||||
|
||||
<% if $canAttachExisting %>
|
||||
<button class="ss-uploadfield-fromfiles ss-ui-button ui-corner-all" title="<% _t('UploadField.FROMCOMPUTERINFO', 'Select from files') %>" data-icon="network-cloud"><% _t('UploadField.FROMFILES', 'From files') %></button>
|
||||
<% end_if %>
|
||||
<% if $canUpload %>
|
||||
<% if not $autoUpload %>
|
||||
<button class="ss-uploadfield-startall ss-ui-button ui-corner-all" data-icon="navigation"><% _t('UploadField.STARTALL', 'Start all') %></button>
|
||||
<% end_if %>
|
||||
<% end_if %>
|
||||
<div class="clear"><!-- --></div>
|
||||
</div>
|
||||
<div class="clear"><!-- --></div>
|
||||
</div>
|
||||
|
||||
<div class="colymba-bulkupload-progress">
|
||||
$FinishButton
|
||||
$CancelButton
|
||||
$EditAllButton
|
||||
</div>
|
||||
<% end_if %>
|
||||
|
||||
<ul class="ss-uploadfield-files files">
|
||||
<% if $CustomisedItems %>
|
||||
<% loop $CustomisedItems %>
|
||||
<li class="ss-uploadfield-item template-download" data-fileid="$ID">
|
||||
<div class="ss-uploadfield-item-preview preview"><span>
|
||||
<img alt="$hasRelation" src="$UploadFieldThumbnailURL" />
|
||||
</span></div>
|
||||
<div class="ss-uploadfield-item-info">
|
||||
<input type='hidden' value='$ID' name='{$Top.Name}[Files][]' />
|
||||
<label class="ss-uploadfield-item-name">
|
||||
<span class="name">$Name.XML</span>
|
||||
<span class="size">$Size</span>
|
||||
<div class="clear"><!-- --></div>
|
||||
</label>
|
||||
<div class="ss-uploadfield-item-actions">
|
||||
<% if $Top.isActive %>
|
||||
$UploadFieldFileButtons
|
||||
<% end_if %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ss-uploadfield-item-editform includeParent">
|
||||
<iframe frameborder="0" data-src="$UploadFieldEditLink" src="about:blank"></iframe>
|
||||
</div>
|
||||
</li>
|
||||
<% end_loop %>
|
||||
<% end_if %>
|
||||
</ul>
|
Loading…
Reference in New Issue
Block a user