From 5824c1b0eb5186a5a206e9dd37229d958b4c2e05 Mon Sep 17 00:00:00 2001 From: Franco Springveldt Date: Wed, 7 Jun 2017 09:31:08 +1200 Subject: [PATCH] NEW info notices added to QueryBuilder --- code/cms/DMSDocumentAdmin.php | 1 + code/model/DMSDocumentSet.php | 27 +++++++++++++++++++++++++-- javascript/lang/en.js | 11 +++++++++++ lang/en.yml | 2 ++ tests/DMSDocumentSetTest.php | 9 +++++++++ 5 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 javascript/lang/en.js diff --git a/code/cms/DMSDocumentAdmin.php b/code/cms/DMSDocumentAdmin.php index 7f11371..08f90fd 100644 --- a/code/cms/DMSDocumentAdmin.php +++ b/code/cms/DMSDocumentAdmin.php @@ -47,6 +47,7 @@ class DMSDocumentAdmin extends ModelAdmin $fields = $dataColumns->getDisplayFields($gridField); $fields = array('Title' => 'Title', 'Page.Title' => 'Page') + $fields; $dataColumns->setDisplayFields($fields); + Requirements::add_i18n_javascript(DMS_DIR.'/javascript/lang'); } return $form; diff --git a/code/model/DMSDocumentSet.php b/code/model/DMSDocumentSet.php index 8516cdd..2fbbaa2 100644 --- a/code/model/DMSDocumentSet.php +++ b/code/model/DMSDocumentSet.php @@ -89,7 +89,6 @@ class DMSDocumentSet extends DataObject ); } else { $fields->removeByName('DocumentSetSort'); - // Document listing $gridFieldConfig = GridFieldConfig::create() ->addComponents( @@ -207,6 +206,15 @@ class DMSDocumentSet extends DataObject if ($field instanceof ListboxField) { $map = ($field->getName() === 'Tags__ID') ? $doc->getAllTagsMap() : $membersMap; $field->setMultiple(true)->setSource($map); + + if ($field->getName() === 'Tags__ID') { + $field->setRightTitle( + _t( + 'DMSDocumentSet.TAGS_RIGHT_TITLE', + 'Tags can be set in the taxonomy area, and can be assigned when editing a document.' + ) + ); + } } } $keyValPairs = DMSJsonField::create('KeyValuePairs', $dmsDocFields->toArray()); @@ -230,7 +238,22 @@ class DMSDocumentSet extends DataObject )); $sortedBy->setTitle(_t('DMSDocumentSet.SORTED_BY', 'Sort the document set by:')); - $fields->addFieldsToTab('Root.QueryBuilder', array($keyValPairs, $sortedBy)); + $fields->addFieldsToTab( + 'Root.QueryBuilder', + array( + LiteralField::create( + 'GridFieldNotice', + '

' . _t( + 'DMSDocumentSet.QUERY_BUILDER_NOTICE', + 'The query builder provides the ability to add documents to a document set based on the ' . + 'filters below. Please note that the set will be built using this criteria when you save the ' . + 'form. This set will not be dynamically updated (see the documentation for more information).' + ) . '

' + ), + $keyValPairs, + $sortedBy + ) + ); } public function onBeforeWrite() diff --git a/javascript/lang/en.js b/javascript/lang/en.js new file mode 100644 index 0000000..5f86afa --- /dev/null +++ b/javascript/lang/en.js @@ -0,0 +1,11 @@ +// This file was generated by silverstripe/cow from javascript/lang/src/en.js. +// See https://github.com/tractorcow/cow for details +if (typeof(ss) === 'undefined' || typeof(ss.i18n) === 'undefined') { + if (typeof(console) !== 'undefined') { // eslint-disable-line no-console + console.error('Class ss.i18n not defined'); // eslint-disable-line no-console + } +} else { + ss.i18n.addDictionary('en', { + "TABLEFIELD.DELETECONFIRMMESSAGE": "Are you sure you want to delete this record? The documents will remain on the system.", +}); +} diff --git a/lang/en.yml b/lang/en.yml index db21441..36be04f 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -28,8 +28,10 @@ en: DIRECTION_DESCENDING: Descending GRIDFIELD_NOTICE: Managing documents will be available once you have created this document set. PLURALNAME: Document Sets + QUERY_BUILDER_NOTICE: The query builder provides the ability to add documents to a document set based on the filters below. Please note that the set will be built using this criteria when you save the form. This set will not be dynamically updated (see the documentation for more information). SHOWONPAGE: Show on page SINGULARNAME: Document Set + TAGS_RIGHT_TITLE: Tags can be set in the taxonomy area, and can be assigned when editing a document. DMSDocumentTaxonomyExtension: TAGS: Tags NOTAGS: No tags found diff --git a/tests/DMSDocumentSetTest.php b/tests/DMSDocumentSetTest.php index 1759c7c..0c46409 100644 --- a/tests/DMSDocumentSetTest.php +++ b/tests/DMSDocumentSetTest.php @@ -138,6 +138,15 @@ class DMSDocumentSetTest extends SapphireTest $keyValuePairs->fieldByName('KeyValuePairs[Title]'), 'addQueryFields() includes KeyValuePairs composite field' ); + + // Test that the notification field exists + $this->assertNotNull($fields->fieldByName('Root.QueryBuilder.GridFieldNotice')); + + // Test that Tags__ID field exists + $this->assertContains( + 'Tags can be set in the taxonomy area,', + $keyValuePairs->fieldByName('KeyValuePairs[Tags__ID]')->RightTitle() + ); } /**