NEW info notices added to QueryBuilder

This commit is contained in:
Franco Springveldt 2017-06-07 09:31:08 +12:00
parent 5bea2fb5f1
commit 5824c1b0eb
5 changed files with 48 additions and 2 deletions

View File

@ -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;

View File

@ -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',
'<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()

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
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

View File

@ -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()
);
}
/**