mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 14:05:56 +02:00
FEATURE: Adding existing documents now works
This commit is contained in:
parent
9e9cc995b3
commit
0e65cb2f1e
@ -160,13 +160,21 @@ class DMSDocumentAddController extends LeftAndMain {
|
|||||||
|
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach($data as $doc) {
|
foreach($data as $doc) {
|
||||||
$return[] = $doc->ID . ' - ' . $doc->Title;
|
$return[] = array(
|
||||||
|
'label' => $doc->ID . ' - ' . $doc->Title,
|
||||||
|
'value' => $doc->ID
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return json_encode($return);
|
return json_encode($return);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function linkdocument() {
|
||||||
|
$page = $this->currentPage();
|
||||||
|
$document = DataObject::get_by_id('DMSDocument', (int) $_GET['documentID']);
|
||||||
|
$document->addPage($page);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,15 @@
|
|||||||
$('.document-add-existing .document-autocomplete').entwine({
|
$('.document-add-existing .document-autocomplete').entwine({
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
$(this).autocomplete({
|
$(this).autocomplete({
|
||||||
source: 'admin/pages/adddocument/documentautocomplete'
|
source: 'admin/pages/adddocument/documentautocomplete',
|
||||||
|
select: function(event, ui) {
|
||||||
|
if(ui.item) {
|
||||||
|
var page_id = $(this).closest('form').find(':input[name=ID]').val();
|
||||||
|
var document_id = ui.item.value;
|
||||||
|
|
||||||
|
jQuery.ajax('admin/pages/adddocument/linkdocument?ID=' + page_id + '&documentID=' + document_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user