From 010d75133796b3bc9ab8a6df5b9a7a18287225c9 Mon Sep 17 00:00:00 2001 From: Franco Springveldt Date: Fri, 22 Sep 2017 12:20:41 +1200 Subject: [PATCH] FIX Blog user settings help links displayed incorrectly --- css/cms.css | 6 ++- js/cms.js | 7 ++-- src/Model/Blog.php | 101 +++++++++++++++++++++++++-------------------- 3 files changed, 63 insertions(+), 51 deletions(-) diff --git a/css/cms.css b/css/cms.css index 7aa1caf..9473644 100755 --- a/css/cms.css +++ b/css/cms.css @@ -74,16 +74,18 @@ background: url("../images/information.png") no-repeat center center; width: 20px; height: 20px; - margin-left: 4px; } + margin-left: 4px; + cursor:pointer; } .middleColumn.toggle-description-correct-middle { margin-left: 0; float: left; width: 416px; } -label.right.toggle-description-correct-right { +.tab-content .field p.toggle-description-correct-right { display: inline-block; margin-left: 0; + padding-left: 0; clear: none; float: left; } diff --git a/js/cms.js b/js/cms.js index 926c78b..d73f70c 100644 --- a/js/cms.js +++ b/js/cms.js @@ -38,19 +38,18 @@ * Toggle next description when button is clicked. */ var shown = false; + var $helpInfo = $this.closest('.field').find('.form-text'); $this.on('click', function () { - $this.parent().next('.description')[shown ? 'hide' : 'show'](); - + $helpInfo[shown ? 'hide' : 'show'](); $this.toggleClass('toggle-description-shown'); - shown = !shown; }); /** * Hide next description by default. */ - $this.parent().next('.description').hide(); + $helpInfo.hide(); /** * Add classes to correct inherited layout issues in a small context. diff --git a/src/Model/Blog.php b/src/Model/Blog.php index ac6db91..565ce41 100644 --- a/src/Model/Blog.php +++ b/src/Model/Blog.php @@ -3,26 +3,18 @@ namespace SilverStripe\Blog\Model; use Page; -use PageController; use SilverStripe\Blog\Admin\GridFieldCategorisationConfig; use SilverStripe\Blog\Forms\GridField\GridFieldConfig_BlogPost; -use SilverStripe\Blog\Model\BlogCategory; -use SilverStripe\Blog\Model\BlogFilter; -use SilverStripe\Blog\Model\BlogPost; -use SilverStripe\Blog\Model\BlogTag; use SilverStripe\CMS\Controllers\RootURLController; use SilverStripe\Control\Controller; -use SilverStripe\Control\RSS\RSSFeed; use SilverStripe\Core\Convert; use SilverStripe\Core\Manifest\ModuleLoader; use SilverStripe\Forms\GridField\GridField; use SilverStripe\Forms\ListboxField; +use SilverStripe\Forms\LiteralField; use SilverStripe\Forms\NumericField; -use SilverStripe\ORM\ArrayList; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DB; -use SilverStripe\ORM\FieldType\DBDatetime; -use SilverStripe\ORM\PaginatedList; use SilverStripe\ORM\UnsavedRelationList; use SilverStripe\Security\Group; use SilverStripe\Security\Member; @@ -142,9 +134,7 @@ class Blog extends Page implements PermissionProvider */ public function getCMSFields() { - $module = ModuleLoader::getModule('silverstripe/blog'); - Requirements::css($module->getRelativeResourcePath('css/cms.css')); - Requirements::javascript($module->getRelativeResourcePath('js/cms.js')); + $this->addCMSRequirements(); $this->beforeUpdateCMSFields(function ($fields) { if (!$this->canEdit()) { @@ -194,6 +184,15 @@ class Blog extends Page implements PermissionProvider return parent::getCMSFields(); } + /** + * Adds CMS related css and js overrides + */ + protected function addCMSRequirements() + { + $module = ModuleLoader::getModule('silverstripe/blog'); + Requirements::css($module->getRelativeResourcePath('css/cms.css')); + Requirements::javascript($module->getRelativeResourcePath('js/cms.js')); + } /** * {@inheritdoc} */ @@ -347,6 +346,7 @@ class Blog extends Page implements PermissionProvider */ public function getSettingsFields() { + $this->addCMSRequirements(); $fields = parent::getSettingsFields(); $fields->addFieldToTab( @@ -355,37 +355,43 @@ class Blog extends Page implements PermissionProvider ); $members = $this->getCandidateUsers()->map()->toArray(); + $toggleButton = LiteralField::create('ToggleButton', ''); $editorField = ListboxField::create('Editors', 'Editors', $members) - // ->setMultiple(true) - ->setRightTitle('help') - ->setDescription(' - An editor has control over specific Blogs, and all posts included within it. Short of being able to assign other editors to a blog, they are able to handle most changes to their assigned blog.
-
- Editors have these permissions:
-
- Update or publish any BlogPost in their Blog
- Update or publish their Blog
- Assign/unassign writers to their Blog
- Assign/unassign contributors to their Blog
- Assign/unassign any member as an author of a particular BlogPost - '); - + ->setRightTitle($toggleButton) + ->setDescription( + _t( + __CLASS__ . '.UsersEditorsFieldDescription', + 'An editor has control over specific Blogs, and all posts included within it. + Short of being able to assign other editors to a blog, they are able to handle most changes to + their assigned blog.

+ Editors have these permissions:
+
+ Update or publish any BlogPost in their Blog
+ Update or publish their Blog
+ Assign/unassign writers to their Blog
+ Assign/unassign contributors to their Blog
+ Assign/unassign any member as an author of a particular BlogPost' + ) + ); if (!$this->canEditEditors()) { $editorField = $editorField->performDisabledTransformation(); } - $writerField = ListboxField::create('Writers', 'Writers', $members) - // ->setMultiple(true) - ->setRightTitle('help') - ->setDescription(' - A writer has full control over creating, editing and publishing BlogPosts they have authored or have been assigned to. Writers are unable to edit BlogPosts to which they are not assigned.
-
- Writers have these permissions:
-
- Update or publish any BlogPost they have authored or have been assigned to
- Assign/unassign any member as an author of a particular BlogPost they have authored or have been assigned to - '); + ->setRightTitle($toggleButton) + ->setDescription( + _t( + __CLASS__ . '.UsersWritersFieldDescription', + 'A writer has full control over creating, editing and publishing BlogPosts they have authored + or have been assigned to. Writers are unable to edit BlogPosts to which they are not assigned. +

+ Writers have these permissions:
+
+ Update or publish any BlogPost they have authored or have been assigned to
+ Assign/unassign any member as an author of a particular BlogPost they have authored or have been + assigned to' + ) + ); if (!$this->canEditWriters()) { $writerField = $writerField->performDisabledTransformation(); @@ -393,14 +399,19 @@ class Blog extends Page implements PermissionProvider $contributorField = ListboxField::create('Contributors', 'Contributors', $members) // ->setMultiple(true) - ->setRightTitle('help') - ->setDescription(' - Contributors have the ability to create or edit BlogPosts, but are unable to publish without authorisation of an editor. They are also unable to assign other contributing authors to any of their BlogPosts.
-
- Contributors have these permissions:
-
- Update any BlogPost they have authored or have been assigned to - '); + ->setRightTitle($toggleButton) + ->setDescription( + _t( + __CLASS__ . '.UsersContributorsFieldDescription', + 'Contributors have the ability to create or edit BlogPosts, but are unable to publish without + authorisation of an editor. They are also unable to assign other contributing authors to any of + their BlogPosts.
+
+ Contributors have these permissions:
+
+ Update any BlogPost they have authored or have been assigned to' + ) + ); if (!$this->canEditContributors()) { $contributorField = $contributorField->performDisabledTransformation();