Skip to content

Commit

Permalink
Merge 5cf2247 into 5bea2fb
Browse files Browse the repository at this point in the history
  • Loading branch information
fspringveldt committed Jun 6, 2017
2 parents 5bea2fb + 5cf2247 commit ebd0efd
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
1 change: 1 addition & 0 deletions code/cms/DMSDocumentAdmin.php
Expand Up @@ -47,6 +47,7 @@ protected function modifyGridField(CMSForm $form, GridField $gridField)
$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;
Expand Down
28 changes: 26 additions & 2 deletions code/model/DMSDocumentSet.php
Expand Up @@ -89,7 +89,6 @@ public function getCMSFields()
);
} else {
$fields->removeByName('DocumentSetSort');

// Document listing
$gridFieldConfig = GridFieldConfig::create()
->addComponents(
Expand Down Expand Up @@ -207,6 +206,15 @@ public function addQueryFields($fields)
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 taxonomies model admin'
)
);
}
}
}
$keyValPairs = DMSJsonField::create('KeyValuePairs', $dmsDocFields->toArray());
Expand All @@ -230,7 +238,23 @@ public function addQueryFields($fields)
));

$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
)
);
$this->extend('updateQueryFields', $fields);
}

public function onBeforeWrite()
Expand Down
11 changes: 11 additions & 0 deletions 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",
});
}
9 changes: 9 additions & 0 deletions tests/DMSDocumentSetTest.php
Expand Up @@ -138,6 +138,15 @@ public function testAddQueryFields()
$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 taxonomies model admin',
$keyValuePairs->fieldByName('KeyValuePairs[Tags__ID]')->RightTitle()
);
}

/**
Expand Down

0 comments on commit ebd0efd

Please sign in to comment.