mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 12:05:56 +00:00
ENHANCEMENT: Tidy-up of DMS link existing document feature
This commit is contained in:
parent
607d3e8266
commit
043eb540c1
@ -179,23 +179,22 @@ class DMSDocumentAddController extends LeftAndMain {
|
|||||||
$document = DataObject::get_by_id('DMSDocument', (int) $_GET['documentID']);
|
$document = DataObject::get_by_id('DMSDocument', (int) $_GET['documentID']);
|
||||||
$document->addPage($page);
|
$document->addPage($page);
|
||||||
|
|
||||||
|
$buttonText = '<button class="ss-uploadfield-item-edit ss-ui-button ui-corner-all" title="Edit this document" data-icon="pencil">'.
|
||||||
|
'Edit<span class="toggle-details"><span class="toggle-details-icon"></span></span></button>';
|
||||||
|
|
||||||
// Collect all output data.
|
// Collect all output data.
|
||||||
$return = array(
|
$return = array(
|
||||||
'id' => $document->ID,
|
'id' => $document->ID,
|
||||||
'name' => $document->getTitle(),
|
'name' => $document->getTitle(),
|
||||||
'thumbnail_url' => $document->UploadFieldThumbnailURL,
|
'thumbnail_url' => $document->Icon($document->getFileExt()),
|
||||||
'edit_url' => $this->getEditForm()->Fields()->fieldByName('Main.From your computer.AssetUploadField')->getItemHandler($document->ID)->EditLink(),
|
'edit_url' => $this->getEditForm()->Fields()->fieldByName('Main.From your computer.AssetUploadField')->getItemHandler($document->ID)->EditLink(),
|
||||||
'size' => $document->getFileSizeFormatted(),
|
'size' => $document->getFileSizeFormatted(),
|
||||||
'buttons' => $document->renderWith('UploadField_FileButtons'),
|
'buttons' => $buttonText,
|
||||||
'showeditform' => true
|
'showeditform' => true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return json_encode($return);
|
return json_encode($return);
|
||||||
|
|
||||||
// array(
|
|
||||||
// 'iframe_url' => $this->getEditForm()->Fields()->fieldByName('Main.From your computer.AssetUploadField')->getItemHandler($document->ID)->EditLink()
|
|
||||||
// ));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,15 +135,11 @@ class DMSUploadField extends UploadField {
|
|||||||
// CUSTOM Attach the file to the related record.
|
// CUSTOM Attach the file to the related record.
|
||||||
$document = $this->attachFile($file);
|
$document = $this->attachFile($file);
|
||||||
|
|
||||||
// TODO: both $document->UploadFieldThumbnailURL and $document->UploadFieldFileButtons are null,
|
|
||||||
// check the code from UploadField.php where they use $file->UploadFieldThumbnailURL and $file->UploadFieldFileButtons
|
|
||||||
// and $file is_a File but in our case $document is a Document, that is why it doesn't work.
|
|
||||||
|
|
||||||
// Collect all output data.
|
// Collect all output data.
|
||||||
$return = array_merge($return, array(
|
$return = array_merge($return, array(
|
||||||
'id' => $document->ID,
|
'id' => $document->ID,
|
||||||
'name' => $document->getTitle(),
|
'name' => $document->getTitle(),
|
||||||
'thumbnail_url' => $document->UploadFieldThumbnailURL,
|
'thumbnail_url' => $document->Icon($document->getFileExt()),
|
||||||
'edit_url' => $this->getItemHandler($document->ID)->EditLink(),
|
'edit_url' => $this->getItemHandler($document->ID)->EditLink(),
|
||||||
'size' => $document->getFileSizeFormatted(),
|
'size' => $document->getFileSizeFormatted(),
|
||||||
'buttons' => $document->renderWith($this->getTemplateFileButtons()),
|
'buttons' => $document->renderWith($this->getTemplateFileButtons()),
|
||||||
@ -176,6 +172,9 @@ class DMSUploadField extends UploadField {
|
|||||||
if (!empty($useCustomTemplate)) {
|
if (!empty($useCustomTemplate)) {
|
||||||
Requirements::block(FRAMEWORK_DIR . '/javascript/UploadField_downloadtemplate.js');
|
Requirements::block(FRAMEWORK_DIR . '/javascript/UploadField_downloadtemplate.js');
|
||||||
Requirements::javascript('dms/javascript/DMSUploadField_downloadtemplate.js');
|
Requirements::javascript('dms/javascript/DMSUploadField_downloadtemplate.js');
|
||||||
|
} else {
|
||||||
|
//in the add dialog, add the addtemplate into the set of file that load
|
||||||
|
Requirements::javascript('dms/javascript/DMSUploadField_addtemplate.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
{
|
{
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(data, textstatus) {
|
success: function(data, textstatus) {
|
||||||
var fn = window.tmpl.cache['ss-uploadfield-downloadtemplate'];
|
var fn = window.tmpl.cache['ss-uploadfield-addtemplate'];
|
||||||
var fnout = fn({
|
var fnout = fn({
|
||||||
files: [data],
|
files: [data],
|
||||||
formatFileSize: function (bytes) {
|
formatFileSize: function (bytes) {
|
||||||
|
30
javascript/DMSUploadField_addtemplate.js
Normal file
30
javascript/DMSUploadField_addtemplate.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
window.tmpl.cache['ss-uploadfield-addtemplate'] = tmpl(
|
||||||
|
'{% for (var i=0, files=o.files, l=files.length, file=files[0]; i<l; file=files[++i]) { %}' +
|
||||||
|
'<li class="ss-uploadfield-item template-download{% if (file.error) { %} ui-state-error{% } %}" data-fileid="{%=file.id%}">' +
|
||||||
|
'<div class="ss-uploadfield-item-preview preview"><span>' +
|
||||||
|
'<img src="{%=file.thumbnail_url%}" alt="" />' +
|
||||||
|
'</span></div>' +
|
||||||
|
'<div class="ss-uploadfield-item-info">' +
|
||||||
|
'<label class="ss-uploadfield-item-name">' +
|
||||||
|
'<span class="name" title="{%=file.name%}">{%=file.name%}</span> ' +
|
||||||
|
'{% if (!file.error) { %}' +
|
||||||
|
'<div class="ss-uploadfield-item-status ui-state-success-text" title="'+ss.i18n._t('UploadField.AddedToPage', 'Added to Page')+'">'+ss.i18n._t('UploadField.AddedToPage', 'Added to Page')+'</div>' +
|
||||||
|
'{% } else { %}' +
|
||||||
|
'<div class="ss-uploadfield-item-status ui-state-error-text" title="{%=o.options.errorMessages[file.error] || file.error%}">{%=o.options.errorMessages[file.error] || file.error%}</div>' +
|
||||||
|
'{% } %}' +
|
||||||
|
'<div class="clear"><!-- --></div>' +
|
||||||
|
'</label>' +
|
||||||
|
'{% if (file.error) { %}' +
|
||||||
|
'<div class="ss-uploadfield-item-actions">' +
|
||||||
|
'<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>' +
|
||||||
|
'{% if (!file.error) { %}' +
|
||||||
|
'<div class="ss-uploadfield-item-editform loading"><iframe frameborder="0" src="{%=file.edit_url%}"></iframe></div>' +
|
||||||
|
'{% } %}' +
|
||||||
|
'</li>' +
|
||||||
|
'{% } %}'
|
||||||
|
);
|
@ -15,7 +15,7 @@
|
|||||||
<h3>
|
<h3>
|
||||||
<span class="step-label">
|
<span class="step-label">
|
||||||
<span class="flyout">2</span><span class="arrow"></span>
|
<span class="flyout">2</span><span class="arrow"></span>
|
||||||
<span class="title">Edit details</span>
|
<span class="title">Edit Document Details</span>
|
||||||
</span>
|
</span>
|
||||||
</h3>
|
</h3>
|
||||||
<div class="fileOverview">
|
<div class="fileOverview">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user