Merge pull request #162 from silverstripe/issue/157

NEW info notices added to QueryBuilder
This commit is contained in:
sachajudd 2017-06-07 11:00:36 +12:00 committed by GitHub
commit 0368293e74
5 changed files with 48 additions and 2 deletions

View File

@ -47,6 +47,7 @@ class DMSDocumentAdmin extends ModelAdmin
$fields = $dataColumns->getDisplayFields($gridField); $fields = $dataColumns->getDisplayFields($gridField);
$fields = array('Title' => 'Title', 'Page.Title' => 'Page') + $fields; $fields = array('Title' => 'Title', 'Page.Title' => 'Page') + $fields;
$dataColumns->setDisplayFields($fields); $dataColumns->setDisplayFields($fields);
Requirements::add_i18n_javascript(DMS_DIR.'/javascript/lang');
} }
return $form; return $form;

View File

@ -89,7 +89,6 @@ class DMSDocumentSet extends DataObject
); );
} else { } else {
$fields->removeByName('DocumentSetSort'); $fields->removeByName('DocumentSetSort');
// Document listing // Document listing
$gridFieldConfig = GridFieldConfig::create() $gridFieldConfig = GridFieldConfig::create()
->addComponents( ->addComponents(
@ -207,6 +206,15 @@ class DMSDocumentSet extends DataObject
if ($field instanceof ListboxField) { if ($field instanceof ListboxField) {
$map = ($field->getName() === 'Tags__ID') ? $doc->getAllTagsMap() : $membersMap; $map = ($field->getName() === 'Tags__ID') ? $doc->getAllTagsMap() : $membersMap;
$field->setMultiple(true)->setSource($map); $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()); $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:')); $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',
'<p class="message warning">' . _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).'
) . '</p>'
),
$keyValPairs,
$sortedBy
)
);
} }
public function onBeforeWrite() public function onBeforeWrite()

11
javascript/lang/en.js Normal file
View File

@ -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.",
});
}

View File

@ -28,8 +28,10 @@ en:
DIRECTION_DESCENDING: Descending DIRECTION_DESCENDING: Descending
GRIDFIELD_NOTICE: Managing documents will be available once you have created this document set. GRIDFIELD_NOTICE: Managing documents will be available once you have created this document set.
PLURALNAME: Document Sets 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 SHOWONPAGE: Show on page
SINGULARNAME: Document Set SINGULARNAME: Document Set
TAGS_RIGHT_TITLE: Tags can be set in the taxonomy area, and can be assigned when editing a document.
DMSDocumentTaxonomyExtension: DMSDocumentTaxonomyExtension:
TAGS: Tags TAGS: Tags
NOTAGS: No tags found NOTAGS: No tags found

View File

@ -138,6 +138,15 @@ class DMSDocumentSetTest extends SapphireTest
$keyValuePairs->fieldByName('KeyValuePairs[Title]'), $keyValuePairs->fieldByName('KeyValuePairs[Title]'),
'addQueryFields() includes KeyValuePairs composite field' '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()
);
} }
/** /**