mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 14:05:56 +02:00
ENHANCEMENT: Editing document defaults after adding
This commit is contained in:
parent
7de79e20be
commit
607d3e8266
@ -172,13 +172,30 @@ class DMSDocumentAddController extends LeftAndMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function linkdocument() {
|
public function linkdocument() {
|
||||||
$page = $this->currentPage();
|
$return = array('error' => _t('UploadField.FIELDNOTSET', 'Could not add document to page'));
|
||||||
$document = DataObject::get_by_id('DMSDocument', (int) $_GET['documentID']);
|
|
||||||
$document->addPage($page);
|
|
||||||
|
|
||||||
return json_encode(array(
|
$page = $this->currentPage();
|
||||||
'iframe_url' => $this->getEditForm()->Fields()->fieldByName('Main.From your computer.AssetUploadField')->getItemHandler($document->ID)->EditLink()
|
if (!empty($page)) {
|
||||||
));
|
$document = DataObject::get_by_id('DMSDocument', (int) $_GET['documentID']);
|
||||||
|
$document->addPage($page);
|
||||||
|
|
||||||
|
// Collect all output data.
|
||||||
|
$return = array(
|
||||||
|
'id' => $document->ID,
|
||||||
|
'name' => $document->getTitle(),
|
||||||
|
'thumbnail_url' => $document->UploadFieldThumbnailURL,
|
||||||
|
'edit_url' => $this->getEditForm()->Fields()->fieldByName('Main.From your computer.AssetUploadField')->getItemHandler($document->ID)->EditLink(),
|
||||||
|
'size' => $document->getFileSizeFormatted(),
|
||||||
|
'buttons' => $document->renderWith('UploadField_FileButtons'),
|
||||||
|
'showeditform' => true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return json_encode($return);
|
||||||
|
|
||||||
|
// array(
|
||||||
|
// 'iframe_url' => $this->getEditForm()->Fields()->fieldByName('Main.From your computer.AssetUploadField')->getItemHandler($document->ID)->EditLink()
|
||||||
|
// ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
(function($) {
|
(function($) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
$.entwine('ss', function($) {
|
||||||
|
|
||||||
$('.document-add-existing .document-autocomplete').entwine({
|
$('.document-add-existing .document-autocomplete').entwine({
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
$(this).autocomplete({
|
var self = this;
|
||||||
|
this.autocomplete({
|
||||||
source: 'admin/pages/adddocument/documentautocomplete',
|
source: 'admin/pages/adddocument/documentautocomplete',
|
||||||
select: function(event, ui) {
|
select: function(event, ui) {
|
||||||
if(ui.item) {
|
if(ui.item) {
|
||||||
@ -13,7 +18,19 @@
|
|||||||
{
|
{
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(data, textstatus) {
|
success: function(data, textstatus) {
|
||||||
alert(data.iframe_url);
|
var fn = window.tmpl.cache['ss-uploadfield-downloadtemplate'];
|
||||||
|
var fnout = fn({
|
||||||
|
files: [data],
|
||||||
|
formatFileSize: function (bytes) {
|
||||||
|
if (typeof bytes !== 'number') return '';
|
||||||
|
if (bytes >= 1000000000) return (bytes / 1000000000).toFixed(2) + ' GB';
|
||||||
|
if (bytes >= 1000000) return (bytes / 1000000).toFixed(2) + ' MB';
|
||||||
|
return (bytes / 1000).toFixed(2) + ' KB';
|
||||||
|
},
|
||||||
|
options: self.fileupload('option')
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.ss-add-files').append(fnout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -22,4 +39,6 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
}(jQuery));
|
}(jQuery));
|
@ -1,22 +1,24 @@
|
|||||||
<div class="document-add-existing field">
|
<div class="ss-add">
|
||||||
|
<div class="document-add-existing field">
|
||||||
|
|
||||||
<h3>
|
<h3>
|
||||||
<span class="step-label">
|
<span class="step-label">
|
||||||
<span class="flyout">1</span><span class="arrow"></span>
|
<span class="flyout">1</span><span class="arrow"></span>
|
||||||
<span class="title">Link a Document</span>
|
<span class="title">Link a Document</span>
|
||||||
</span>
|
</span>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<input class="document-autocomplete" placeholder="Search by ID or filename" />
|
<input class="document-autocomplete" placeholder="Search by ID or filename" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div class="ss-assetuploadfield">
|
||||||
<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 details</span>
|
||||||
</span>
|
</span>
|
||||||
</h3>
|
</h3>
|
||||||
<div class="fileOverview">
|
<div class="fileOverview">
|
||||||
<ul class="files"></ul>
|
<ul class="files ss-uploadfield-files ss-add-files"></ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
Loading…
Reference in New Issue
Block a user