FIX: Resolve issues with find by page documentlist

This commit is contained in:
Will Rossiter 2014-01-29 10:26:34 +13:00
parent e2edeb5bf7
commit d73b13afd5
4 changed files with 35 additions and 19 deletions

View File

@ -18,7 +18,8 @@ class DMSDocumentAddController extends LeftAndMain {
private static $allowed_actions = array ( private static $allowed_actions = array (
'getEditForm', 'getEditForm',
'documentautocomplete', 'documentautocomplete',
'linkdocument' 'linkdocument',
'documentlist'
); );
/** /**
@ -212,24 +213,30 @@ class DMSDocumentAddController extends LeftAndMain {
} }
public function documentlist() { public function documentlist() {
$page = DataObject::get_by_id('SiteTree', (int) $_GET['pageID']); if(!isset($_GET['pageID'])) {
if($page && $page->Documents()) { return $this->httpError(400);
}
$page = SiteTree::get()->byId($_GET['pageID']);
if($page && $page->Documents()->count() > 0) {
$list = '<ul>'; $list = '<ul>';
foreach($page->Documents() as $document) { foreach($page->Documents() as $document) {
$list .= '<li><a class="add-document" data-document-id="' . $document->ID . '">'; $list .= sprintf(
$list .= $document->ID . ' - ' . Convert::raw2xml($document->Title); '<li><a class="add-document" data-document-id="%s">%s</a></li>',
$list .= '</a></li>'; $document->ID,
$document->ID . ' - '. Convert::raw2xml($document->Title)
);
} }
$list .= '</ul>'; $list .= '</ul>';
return $list; return $list;
} else {
return '<p>There are no documents attached to the selected page.</p>';
}
}
} }
return sprintf('<p>%s</p>',
?> _t('DMSDocumentAddController.NODOCUMENTS', 'There are no documents attached to the selected page.')
);
}
}

View File

@ -18,7 +18,8 @@
.ss-add .document-add-existing .treedropdownfield-toggle-panel-link.treedropdownfield-open-tree { background: #fff; border: 1px solid #B3B3B3; border-bottom: none; border-bottom-right-radius: 0; } .ss-add .document-add-existing .treedropdownfield-toggle-panel-link.treedropdownfield-open-tree { background: #fff; border: 1px solid #B3B3B3; border-bottom: none; border-bottom-right-radius: 0; }
.ss-add .document-add-existing .treedropdownfield-title { width: auto; } .ss-add .document-add-existing .treedropdownfield-title { width: auto; }
.ss-add .document-add-existing .treedropdownfield-toggle-panel-link a { display: inline-block; top: 4px; position: relative; } .ss-add .document-add-existing .treedropdownfield-toggle-panel-link a { display: inline-block; top: 4px; position: relative; }
.ss-add .document-add-existing .document-list { position: absolute; z-index: 9999; width: 510px; border: 1px solid #DDD; border-top: none; background: #ffffff; display: none; box-shadow: 0 2px 4px 1px #DDD; max-height: 300px; border-radius: 6px; background-clip: padding-box; overflow: scroll; } .ss-add .document-add-existing .document-list { width: 510px; border: 1px solid #DDD; border-top: none; background: #ffffff; display: none; box-shadow: 0 2px 4px 1px #DDD; max-height: 300px; border-radius: 6px; background-clip: padding-box; overflow: scroll; }
.ss-add .document-add-existing .document-list p { padding: 10px 10px 0; }
.ss-add .document-add-existing .document-list ul { padding: 4px 0; } .ss-add .document-add-existing .document-list ul { padding: 4px 0; }
.ss-add .document-add-existing .document-list ul li { line-height: 18px; } .ss-add .document-add-existing .document-list ul li { line-height: 18px; }
.ss-add .document-add-existing .document-list ul li a { display: block; padding: 4px 8px; border: 1px solid #FFF; color: black; } .ss-add .document-add-existing .document-list ul li a { display: block; padding: 4px 8px; border: 1px solid #FFF; color: black; }

View File

@ -81,7 +81,7 @@
$('.document-add-existing input[name=PageSelector]').entwine({ $('.document-add-existing input[name=PageSelector]').entwine({
onchange: function(event) { onchange: function(event) {
var doclist = $(this).closest('.document-add-existing').find('.document-list'); var doclist = $(this).closest('.document-add-existing').find('.document-list');
doclist.html('<span>Loading...</span>'); doclist.html('<p>Loading...</p>');
doclist.show(); doclist.show();
doclist.load( doclist.load(
'admin/pages/adddocument/documentlist?pageID=' + $(this).val() 'admin/pages/adddocument/documentlist?pageID=' + $(this).val()

View File

@ -104,14 +104,14 @@ $gf_colour_zebra: #F0F4F7;
.treedropdownfield-title { .treedropdownfield-title {
width: auto; width: auto;
} }
.treedropdownfield-toggle-panel-link a { .treedropdownfield-toggle-panel-link a {
display: inline-block; display: inline-block;
top: 4px; top: 4px;
position: relative; position: relative;
} }
.document-list { .document-list {
position: absolute;
z-index: 9999;
width: 510px; width: 510px;
border: 1px solid #DDD; border: 1px solid #DDD;
border-top:none; border-top:none;
@ -122,15 +122,23 @@ $gf_colour_zebra: #F0F4F7;
border-radius: 6px; border-radius: 6px;
background-clip: padding-box; background-clip: padding-box;
overflow:scroll; overflow:scroll;
p {
padding: 10px 10px 0;
}
ul { ul {
padding: 4px 0; padding: 4px 0;
li { li {
line-height:18px; line-height:18px;
a { a {
display: block; display: block;
padding: 4px 8px; padding: 4px 8px;
border: 1px solid #FFF; border: 1px solid #FFF;
color: black; color: black;
&:hover { &:hover {
border: 1px solid #CCC; border: 1px solid #CCC;
border-radius: 4px; border-radius: 4px;