mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 14:05:56 +02:00
ENHANCEMENT: re-adding modified downloadtemplate, but only in specific case when access it through a grid field
This commit is contained in:
parent
7cfefdb953
commit
66422c0a31
@ -16,6 +16,14 @@ class DMSUploadField extends UploadField {
|
||||
|
||||
protected $folderName = 'DMSTemporaryUploads';
|
||||
|
||||
public function __construct($name, $title = null, SS_List $items = null) {
|
||||
parent::__construct($name, $title, $items);
|
||||
|
||||
//set default DMS replace template to false
|
||||
$this->setConfig('useDMSReplaceTemplate', 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Override the default behaviour of the UploadField and take the uploaded file (uploaded to assets) and
|
||||
* add it into the DMS storage, deleting the old/uploaded file.
|
||||
@ -163,8 +171,9 @@ class DMSUploadField extends UploadField {
|
||||
public function Field($properties = array()) {
|
||||
$fields = parent::Field($properties);
|
||||
|
||||
//replace the download template with a new one
|
||||
if (!empty($this->getConfig('useDMSReplaceTemplate'))) {
|
||||
//replace the download template with a new one only when access the upload field through a GridField
|
||||
$useCustomTemplate = $this->getConfig('useDMSReplaceTemplate');
|
||||
if (!empty($useCustomTemplate)) {
|
||||
Requirements::block(FRAMEWORK_DIR . '/javascript/UploadField_downloadtemplate.js');
|
||||
Requirements::javascript('dms/javascript/DMSUploadField_downloadtemplate.js');
|
||||
}
|
||||
|
@ -19,12 +19,9 @@ window.tmpl.cache['ss-uploadfield-downloadtemplate'] = tmpl(
|
||||
'<div class="ss-uploadfield-item-cancel ss-uploadfield-item-cancelfailed"><button class="icon icon-16">' + ss.i18n._t('UploadField.CANCEL', 'Cancel') + '</button></div>' +
|
||||
'</div>' +
|
||||
'{% } else { %}' +
|
||||
'<div class="ss-uploadfield-item-actions">{% print(file.buttons, true); %}</div>' +
|
||||
'<div class="ss-uploadfield-item-actions">(please refresh the page to display new file information)</div>' +
|
||||
'{% } %}' +
|
||||
'</div>' +
|
||||
'{% if (!file.error) { %}' +
|
||||
'<div class="ss-uploadfield-item-editform loading"><iframe frameborder="0" src="{%=file.edit_url%}"></iframe></div>' +
|
||||
'{% } %}' +
|
||||
'</li>' +
|
||||
'{% } %}'
|
||||
);
|
Loading…
Reference in New Issue
Block a user