Skip to content

Commit

Permalink
API Make CMSMain more generic
Browse files Browse the repository at this point in the history
Remove hardcoded references to pages and SiteTree
Remove assumption that records are versioned
Remove or validate assumptions about methods on the model class
Improve general architecture of CMSMain
  • Loading branch information
GuySartorelli committed Nov 7, 2024
1 parent 9f1bc08 commit da66f41
Show file tree
Hide file tree
Showing 56 changed files with 1,287 additions and 1,620 deletions.
2 changes: 1 addition & 1 deletion _config/adminpanels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Name: cmsdefaultadmin
---
SilverStripe\Admin\AdminRootController:
default_panel: SilverStripe\CMS\Controllers\CMSPagesController
default_panel: SilverStripe\CMS\Controllers\CMSMain
8 changes: 4 additions & 4 deletions _config/cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ After:
- '#corecache'
---
SilverStripe\Core\Injector\Injector:
Psr\SimpleCache\CacheInterface.CMSMain_SiteTreeHints:
Psr\SimpleCache\CacheInterface.CMSMain_TreeHints:
factory: SilverStripe\Core\Cache\CacheFactory
constructor:
namespace: "CMSMain_SiteTreeHints"
namespace: "CMSMain_TreeHints"
Psr\SimpleCache\CacheInterface.SiteTree_CreatableChildren:
factory: SilverStripe\Core\Cache\CacheFactory
constructor:
namespace: "SiteTree_CreatableChildren"
Psr\SimpleCache\CacheInterface.SiteTree_PageIcons:
Psr\SimpleCache\CacheInterface.CMS_RecordIcons:
factory: SilverStripe\Core\Cache\CacheFactory
constructor:
namespace: "SiteTree_PageIcons"
namespace: "CMS_RecordIcons"
4 changes: 2 additions & 2 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Name: cmsextensions
---
SilverStripe\Admin\LeftAndMain:
extensions:
- SilverStripe\CMS\Controllers\LeftAndMainPageIconsExtension
- SilverStripe\CMS\Controllers\LeftAndMainRecordIconsExtension
- SilverStripe\CMS\Controllers\LeftAndMainBatchActionsExtension
---
Name: cmsmodals
Expand All @@ -16,4 +16,4 @@ Name: cmshierarchy
---
SilverStripe\ORM\Hierarchy\Hierarchy:
node_threshold_total: 50
node_threshold_leaf: 250
node_threshold_leaf: 250
1 change: 0 additions & 1 deletion _config/permissions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ SilverStripe\Core\Injector\Injector:
Services:
- '%$SilverStripe\Security\PermissionChecker.sitetree'
- '%$SilverStripe\CMS\Controllers\CMSMain'
- '%$SilverStripe\CMS\Model\SiteTree'
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions client/src/legacy/CMSMain.AddForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,16 @@ $.entwine('ss', function($){
* @param {string} defaultChildClass
*/
updateSelectionFilter: function(disallowedChildren, defaultChildClass) {
var currentSelection = this.find('#Form_AddForm_PageType div.radio.selected')[0];
var currentSelection = this.find('#Form_AddForm_RecordType div.radio.selected')[0];
var keepSelection = false;

// Limit selection
var allAllowed = null; // troolian
this.find('#Form_AddForm_PageType div.radio').each(function (i, el) {
this.find('#Form_AddForm_RecordType div.radio').each(function (i, el) {
var className = $(this).find('input').val(),
isAllowed = ($.inArray(className, disallowedChildren) === -1);

// Avoid changing the selected pagetype if still allowed
// Avoid changing the selected record type if still allowed
if (el === currentSelection && isAllowed) {
keepSelection = true;
}
Expand All @@ -153,16 +153,16 @@ $.entwine('ss', function($){
var selectedEl = $(currentSelection).parents('li:first');
} else if (defaultChildClass) {
var selectedEl = this
.find('#Form_AddForm_PageType div.radio input[value=' + defaultChildClass + ']')
.find('#Form_AddForm_RecordType div.radio input[value=' + defaultChildClass + ']')
.parents('li:first');
} else {
var selectedEl = this.find('#Form_AddForm_PageType div.radio:not(.disabled):first');
var selectedEl = this.find('#Form_AddForm_RecordType div.radio:not(.disabled):first');
}
selectedEl.setSelected(true);
selectedEl.siblings().setSelected(false);

// Disable the "Create" button if none of the pagetypes are available
if(this.find('#Form_AddForm_PageType div.radio:not(.disabled)').length) {
// Disable the "Create" button if none of the record types are available
if(this.find('#Form_AddForm_RecordType div.radio:not(.disabled)').length) {
this.find('button[name=action_doAdd]').removeAttr('disabled');
} else {
this.find('button[name=action_doAdd]').attr('disabled', 'disabled');
Expand All @@ -172,7 +172,7 @@ $.entwine('ss', function($){
}
});

$(".cms-add-form #Form_AddForm_PageType div.radio").entwine({
$(".cms-add-form #Form_AddForm_RecordType div.radio").entwine({
onclick: function(e) {
this.setSelected(true);
},
Expand Down
2 changes: 1 addition & 1 deletion client/src/legacy/CMSMain.Tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ $.entwine('ss.tree', function($) {
$.each(allowedChildren, function(index, child) {
hasAllowedChildren = true;
menuAllowedChildren["allowedchildren-" + child.ClassName] = {
'label': '<span class="jstree-pageicon ' + child.IconClass + '"></span>' + child.Title,
'label': '<span class="jstree-recordicon ' + child.IconClass + '"></span>' + child.Title,
'_class': 'class-' + child.ClassName.replace(/[^a-zA-Z0-9\-_:.]+/g, '_'),
'action': function(obj) {
$('.cms-container').entwine('.ss').loadPanel(
Expand Down
Loading

0 comments on commit da66f41

Please sign in to comment.