diff --git a/code/cms/DMSDocumentAddController.php b/code/cms/DMSDocumentAddController.php index bfccb9e..64ec7e3 100644 --- a/code/cms/DMSDocumentAddController.php +++ b/code/cms/DMSDocumentAddController.php @@ -18,7 +18,8 @@ class DMSDocumentAddController extends LeftAndMain { private static $allowed_actions = array ( 'getEditForm', 'documentautocomplete', - 'linkdocument' + 'linkdocument', + 'documentlist' ); /** @@ -212,24 +213,30 @@ class DMSDocumentAddController extends LeftAndMain { } public function documentlist() { - $page = DataObject::get_by_id('SiteTree', (int) $_GET['pageID']); - if($page && $page->Documents()) { + if(!isset($_GET['pageID'])) { + return $this->httpError(400); + } + + $page = SiteTree::get()->byId($_GET['pageID']); + + if($page && $page->Documents()->count() > 0) { $list = '
There are no documents attached to the selected page.
'; } + + return sprintf('%s
', + _t('DMSDocumentAddController.NODOCUMENTS', 'There are no documents attached to the selected page.') + ); } } - - -?> diff --git a/css/DMSMainCMS.css b/css/DMSMainCMS.css index 1b305f3..d17b162 100644 --- a/css/DMSMainCMS.css +++ b/css/DMSMainCMS.css @@ -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-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 .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 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; } diff --git a/javascript/DMSDocumentAddExistingField.js b/javascript/DMSDocumentAddExistingField.js index 22457b8..a6adc98 100644 --- a/javascript/DMSDocumentAddExistingField.js +++ b/javascript/DMSDocumentAddExistingField.js @@ -81,7 +81,7 @@ $('.document-add-existing input[name=PageSelector]').entwine({ onchange: function(event) { var doclist = $(this).closest('.document-add-existing').find('.document-list'); - doclist.html('Loading...'); + doclist.html('Loading...
'); doclist.show(); doclist.load( 'admin/pages/adddocument/documentlist?pageID=' + $(this).val() diff --git a/scss/DMSMainCMS.scss b/scss/DMSMainCMS.scss index 28fb91c..8d084ca 100644 --- a/scss/DMSMainCMS.scss +++ b/scss/DMSMainCMS.scss @@ -104,14 +104,14 @@ $gf_colour_zebra: #F0F4F7; .treedropdownfield-title { width: auto; } + .treedropdownfield-toggle-panel-link a { display: inline-block; top: 4px; position: relative; } + .document-list { - position: absolute; - z-index: 9999; width: 510px; border: 1px solid #DDD; border-top:none; @@ -122,16 +122,24 @@ $gf_colour_zebra: #F0F4F7; border-radius: 6px; background-clip: padding-box; overflow:scroll; - ul{ + + p { + padding: 10px 10px 0; + } + + ul { padding: 4px 0; - li{ + + li { line-height:18px; - a{ + + a { display: block; padding: 4px 8px; border: 1px solid #FFF; color: black; - &:hover{ + + &:hover { border: 1px solid #CCC; border-radius: 4px; background: rgba(203, 203, 203, 0.4);