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() {
|
||||
$page = $this->currentPage();
|
||||
$document = DataObject::get_by_id('DMSDocument', (int) $_GET['documentID']);
|
||||
$document->addPage($page);
|
||||
$return = array('error' => _t('UploadField.FIELDNOTSET', 'Could not add document to page'));
|
||||
|
||||
return json_encode(array(
|
||||
'iframe_url' => $this->getEditForm()->Fields()->fieldByName('Main.From your computer.AssetUploadField')->getItemHandler($document->ID)->EditLink()
|
||||
));
|
||||
$page = $this->currentPage();
|
||||
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($) {
|
||||
"use strict";
|
||||
|
||||
$.entwine('ss', function($) {
|
||||
|
||||
$('.document-add-existing .document-autocomplete').entwine({
|
||||
onmatch: function() {
|
||||
$(this).autocomplete({
|
||||
var self = this;
|
||||
this.autocomplete({
|
||||
source: 'admin/pages/adddocument/documentautocomplete',
|
||||
select: function(event, ui) {
|
||||
if(ui.item) {
|
||||
@ -13,7 +18,19 @@
|
||||
{
|
||||
dataType: 'json',
|
||||
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));
|
@ -1,22 +1,24 @@
|
||||
<div class="document-add-existing field">
|
||||
<div class="ss-add">
|
||||
<div class="document-add-existing field">
|
||||
|
||||
<h3>
|
||||
<span class="step-label">
|
||||
<span class="flyout">1</span><span class="arrow"></span>
|
||||
<span class="title">Link a Document</span>
|
||||
</span>
|
||||
</h3>
|
||||
<h3>
|
||||
<span class="step-label">
|
||||
<span class="flyout">1</span><span class="arrow"></span>
|
||||
<span class="title">Link a Document</span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
<input class="document-autocomplete" placeholder="Search by ID or filename" />
|
||||
</div>
|
||||
<input class="document-autocomplete" placeholder="Search by ID or filename" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3>
|
||||
<span class="step-label">
|
||||
<span class="flyout">2</span><span class="arrow"></span>
|
||||
<span class="title">Edit details</span>
|
||||
</span>
|
||||
</h3>
|
||||
<div class="fileOverview">
|
||||
<ul class="files"></ul>
|
||||
<div class="ss-assetuploadfield">
|
||||
<h3>
|
||||
<span class="step-label">
|
||||
<span class="flyout">2</span><span class="arrow"></span>
|
||||
<span class="title">Edit details</span>
|
||||
</span>
|
||||
</h3>
|
||||
<div class="fileOverview">
|
||||
<ul class="files ss-uploadfield-files ss-add-files"></ul>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user