BUG Fix issue with old asset-admin repeating "level up" button

BUG Fix incorrectly built dist files
This commit is contained in:
Damian Mooyman 2016-08-01 17:32:56 +12:00
parent 8e9a243966
commit 7c151321b4
6 changed files with 185 additions and 180 deletions

View File

@ -42,7 +42,7 @@
}
});
$('.AssetAdmin.cms-edit-form .ss-gridfield .col-buttons .action.gridfield-button-delete, .AssetAdmin.cms-edit-form .Actions button.action.action-delete').entwine({
$('.AssetAdmin.cms-edit-form .ss-gridfield .col-buttons .action.gridfield-button-delete, .AssetAdmin.cms-edit-form .btn-toolbar button.action.action-delete').entwine({
onclick: function onclick(e) {
var msg;
if (this.closest('.ss-gridfield-item').data('class') == 'Folder') {
@ -103,11 +103,5 @@
$('.AssetAdmin.cms-edit-form .ss-gridfield').reload();
}
});
$('.AssetAdmin .grid-levelup').entwine({
onmatch: function onmatch() {
this.closest('.ui-tabs-panel').find('.cms-actions-row').prepend(this);
}
});
});
});

View File

@ -1,179 +1,193 @@
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define('ss.CMSMain.AddForm', ['jQuery'], factory);
} else if (typeof exports !== "undefined") {
factory(require('jQuery'));
} else {
var mod = {
exports: {}
};
factory(global.jQuery);
global.ssCMSMainAddForm = mod.exports;
}
if (typeof define === "function" && define.amd) {
define('ss.CMSMain.AddForm', ['jQuery'], factory);
} else if (typeof exports !== "undefined") {
factory(require('jQuery'));
} else {
var mod = {
exports: {}
};
factory(global.jQuery);
global.ssCMSMainAddForm = mod.exports;
}
})(this, function (_jQuery) {
'use strict';
'use strict';
var _jQuery2 = _interopRequireDefault(_jQuery);
var _jQuery2 = _interopRequireDefault(_jQuery);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
_jQuery2.default.entwine('ss', function ($) {
$(".cms-add-form .parent-mode :input").entwine({
onclick: function onclick(e) {
if (this.val() == 'top') {
var parentField = this.closest('form').find('#Form_AddForm_ParentID_Holder .TreeDropdownField');
parentField.setValue('');
parentField.setTitle('');
}
}
});
_jQuery2.default.entwine('ss', function ($) {
$(".cms-add-form .parent-mode :input").entwine({
onclick: function onclick(e) {
if (this.val() == 'top') {
var parentField = this.closest('form').find('#Form_AddForm_ParentID_Holder .TreeDropdownField');
parentField.setValue('');
parentField.setTitle('');
}
}
});
$(".cms-add-form").entwine({
ParentID: 0,
ParentCache: {},
onadd: function onadd() {
var self = this;
this.find('#Form_AddForm_ParentID_Holder .TreeDropdownField').bind('change', function () {
self.updateTypeList();
});
this.find(".SelectionGroup.parent-mode").bind('change', function () {
self.updateTypeList();
});
this.updateTypeList();
},
loadCachedChildren: function loadCachedChildren(parentID) {
var cache = this.getParentCache();
if (typeof cache[parentID] !== 'undefined') return cache[parentID];else return null;
},
saveCachedChildren: function saveCachedChildren(parentID, children) {
var cache = this.getParentCache();
cache[parentID] = children;
this.setParentCache(cache);
},
$(".cms-add-form").entwine({
ParentID: 0,
ParentCache: {},
onadd: function onadd() {
var self = this;
updateTypeList: function updateTypeList() {
var hints = this.data('hints'),
parentTree = this.find('#Form_AddForm_ParentID_Holder .TreeDropdownField'),
parentMode = this.find("input[name=ParentModeField]:checked").val(),
metadata = parentTree.data('metadata'),
id = metadata && parentMode === 'child' ? parentTree.getValue() || this.getParentID() : null,
newClassName = metadata ? metadata.ClassName : null,
hintKey = newClassName && parentMode === 'child' ? newClassName : 'Root',
hint = typeof hints[hintKey] !== 'undefined' ? hints[hintKey] : null,
self = this,
defaultChildClass = hint && typeof hint.defaultChild !== 'undefined' ? hint.defaultChild : null,
disallowedChildren = [];
this.find('#Form_AddForm_ParentID_Holder .TreeDropdownField').bind('change', function () {
self.updateTypeList();
});
this.find(".SelectionGroup.parent-mode").bind('change', function () {
self.updateTypeList();
});
this.updateTypeList();
},
loadCachedChildren: function loadCachedChildren(parentID) {
var cache = this.getParentCache();
if (typeof cache[parentID] !== 'undefined') return cache[parentID];else return null;
},
saveCachedChildren: function saveCachedChildren(parentID, children) {
var cache = this.getParentCache();
cache[parentID] = children;
this.setParentCache(cache);
},
if (id) {
if (this.hasClass('loading')) return;
this.addClass('loading');
updateTypeList: function updateTypeList() {
var hints = this.data('hints'),
parentTree = this.find('#Form_AddForm_ParentID_Holder .TreeDropdownField'),
parentMode = this.find("input[name=ParentModeField]:checked").val(),
metadata = parentTree.data('metadata'),
id = metadata && parentMode === 'child' ? parentTree.getValue() || this.getParentID() : null,
newClassName = metadata ? metadata.ClassName : null,
hintKey = newClassName && parentMode === 'child' ? newClassName : 'Root',
hint = typeof hints[hintKey] !== 'undefined' ? hints[hintKey] : null,
self = this,
defaultChildClass = hint && typeof hint.defaultChild !== 'undefined' ? hint.defaultChild : null,
disallowedChildren = [];
this.setParentID(id);
if (!parentTree.getValue()) parentTree.setValue(id);
if (id) {
if (this.hasClass('loading')) return;
this.addClass('loading');
disallowedChildren = this.loadCachedChildren(id);
if (disallowedChildren !== null) {
this.updateSelectionFilter(disallowedChildren, defaultChildClass);
this.removeClass('loading');
return;
}
$.ajax({
url: self.data('childfilter'),
data: { 'ParentID': id },
success: function success(data) {
self.saveCachedChildren(id, data);
self.updateSelectionFilter(data, defaultChildClass);
},
complete: function complete() {
self.removeClass('loading');
}
});
this.setParentID(id);
if (!parentTree.getValue()) parentTree.setValue(id);
return false;
} else {
disallowedChildren = hint && typeof hint.disallowedChildren !== 'undefined' ? hint.disallowedChildren : [], this.updateSelectionFilter(disallowedChildren, defaultChildClass);
}
},
disallowedChildren = this.loadCachedChildren(id);
if (disallowedChildren !== null) {
this.updateSelectionFilter(disallowedChildren, defaultChildClass);
this.removeClass('loading');
return;
}
$.ajax({
url: self.data('childfilter'),
data: { 'ParentID': id },
success: function success(data) {
self.saveCachedChildren(id, data);
self.updateSelectionFilter(data, defaultChildClass);
},
complete: function complete() {
self.removeClass('loading');
}
});
updateSelectionFilter: function updateSelectionFilter(disallowedChildren, defaultChildClass) {
var allAllowed = null;
this.find('#Form_AddForm_PageType li').each(function () {
var className = $(this).find('input').val(),
isAllowed = $.inArray(className, disallowedChildren) === -1;
return false;
} else {
disallowedChildren = hint && typeof hint.disallowedChildren !== 'undefined' ? hint.disallowedChildren : [];
this.updateSelectionFilter(disallowedChildren, defaultChildClass);
}
},
$(this).setEnabled(isAllowed);
if (!isAllowed) $(this).setSelected(false);
if (allAllowed === null) allAllowed = isAllowed;else allAllowed = allAllowed && isAllowed;
});
updateSelectionFilter: function updateSelectionFilter(disallowedChildren, defaultChildClass) {
var allAllowed = null;
this.find('#Form_AddForm_PageType div.radio').each(function () {
var className = $(this).find('input').val(),
isAllowed = $.inArray(className, disallowedChildren) === -1;
if (defaultChildClass) {
var selectedEl = this.find('#Form_AddForm_PageType li input[value=' + defaultChildClass + ']').parents('li:first');
} else {
var selectedEl = this.find('#Form_AddForm_PageType li:not(.disabled):first');
}
selectedEl.setSelected(true);
selectedEl.siblings().setSelected(false);
$(this).setEnabled(isAllowed);
if (!isAllowed) {
$(this).setSelected(false);
}
if (allAllowed === null) {
allAllowed = isAllowed;
} else {
allAllowed = allAllowed && isAllowed;
}
});
var buttonState = this.find('#Form_AddForm_PageType li:not(.disabled)').length ? 'enable' : 'disable';
this.find('button[name=action_doAdd]').button(buttonState);
if (defaultChildClass) {
var selectedEl = this.find('#Form_AddForm_PageType div.radio input[value=' + defaultChildClass + ']').parents('li:first');
} else {
var selectedEl = this.find('#Form_AddForm_PageType div.radio:not(.disabled):first');
}
selectedEl.setSelected(true);
selectedEl.siblings().setSelected(false);
this.find('.message-restricted')[allAllowed ? 'hide' : 'show']();
}
});
var buttonState = this.find('#Form_AddForm_PageType div.radio:not(.disabled)').length ? 'enable' : 'disable';
this.find('button[name=action_doAdd]').button(buttonState);
$(".cms-add-form #Form_AddForm_PageType li").entwine({
onclick: function onclick(e) {
this.setSelected(true);
},
setSelected: function setSelected(bool) {
var input = this.find('input');
if (bool && !input.is(':disabled')) {
this.siblings().setSelected(false);
this.toggleClass('selected', true);
input.prop('checked', true);
} else {
this.toggleClass('selected', false);
input.prop('checked', false);
}
},
setEnabled: function setEnabled(bool) {
$(this).toggleClass('disabled', !bool);
if (!bool) $(this).find('input').attr('disabled', 'disabled').removeAttr('checked');else $(this).find('input').removeAttr('disabled');
}
});
this.find('.message-restricted')[allAllowed ? 'hide' : 'show']();
}
});
$(".cms-page-add-button").entwine({
onclick: function onclick(e) {
var tree = $('.cms-tree'),
list = $('.cms-list'),
parentId = 0;
$(".cms-add-form #Form_AddForm_PageType div.radio").entwine({
onclick: function onclick(e) {
this.setSelected(true);
},
setSelected: function setSelected(bool) {
var input = this.find('input');
if (bool && !input.is(':disabled')) {
this.siblings().setSelected(false);
this.toggleClass('selected', true);
input.prop('checked', true);
} else {
this.toggleClass('selected', false);
input.prop('checked', false);
}
},
setEnabled: function setEnabled(bool) {
$(this).toggleClass('disabled', !bool);
if (!bool) {
$(this).find('input').attr('disabled', 'disabled').removeAttr('checked');
} else {
$(this).find('input').removeAttr('disabled');
}
}
});
if (tree.is(':visible')) {
var selected = tree.jstree('get_selected');
parentId = selected ? $(selected[0]).data('id') : null;
} else {
var state = list.find('input[name="Page[GridState]"]').val();
if (state) parentId = parseInt(JSON.parse(state).ParentID, 10);
}
$(".cms-content-addpage-button").entwine({
onclick: function onclick(e) {
var tree = $('.cms-tree'),
list = $('.cms-list'),
parentId = 0,
extraParams;
var data = { selector: this.data('targetPanel'), pjax: this.data('pjax') },
url;
if (parentId) {
extraParams = this.data('extraParams') ? this.data('extraParams') : '';
url = $.path.addSearchParams(i18n.sprintf(this.data('urlAddpage'), parentId), extraParams);
} else {
url = this.attr('href');
}
if (tree.is(':visible')) {
var selected = tree.jstree('get_selected');
parentId = selected ? $(selected[0]).data('id') : null;
} else {
var state = list.find('input[name="Page[GridState]"]').val();
if (state) {
parentId = parseInt(JSON.parse(state).ParentID, 10);
}
}
$('.cms-container').loadPanel(url, null, data);
e.preventDefault();
var data = { selector: this.data('targetPanel'), pjax: this.data('pjax') },
url;
if (parentId) {
extraParams = this.data('extraParams') ? this.data('extraParams') : '';
url = $.path.addSearchParams(i18n.sprintf(this.data('urlAddpage'), parentId), extraParams);
} else {
url = this.attr('href');
}
$('.cms-container').loadPanel(url, null, data);
e.preventDefault();
this.blur();
}
});
});
this.blur();
}
});
});
});

View File

@ -179,7 +179,7 @@
}
});
$('.cms-edit-form .Actions #Form_EditForm_action_print').entwine({
$('.cms-edit-form .btn-toolbar #Form_EditForm_action_print').entwine({
onclick: function onclick(e) {
var printURL = $(this[0].form).attr('action').replace(/\?.*$/, '') + '/printable/' + $(':input[name=ID]', this[0].form).val();
if (printURL.substr(0, 7) != 'http://') printURL = $('base').attr('href') + printURL;
@ -190,7 +190,7 @@
}
});
$('.cms-edit-form .Actions #Form_EditForm_action_rollback').entwine({
$('.cms-edit-form .btn-toolbar #Form_EditForm_action_rollback').entwine({
onclick: function onclick(e) {
var form = this.parents('form:first'),
version = form.find(':input[name=Version]').val(),
@ -208,7 +208,7 @@
}
});
$('.cms-edit-form .Actions #Form_EditForm_action_archive').entwine({
$('.cms-edit-form .btn-toolbar #Form_EditForm_action_archive').entwine({
onclick: function onclick(e) {
var form = this.parents('form:first'),
version = form.find(':input[name=Version]').val(),
@ -222,7 +222,7 @@
}
});
$('.cms-edit-form .Actions #Form_EditForm_action_restore').entwine({
$('.cms-edit-form .btn-toolbar #Form_EditForm_action_restore').entwine({
onclick: function onclick(e) {
var form = this.parents('form:first'),
version = form.find(':input[name=Version]').val(),
@ -237,7 +237,7 @@
}
});
$('.cms-edit-form .Actions #Form_EditForm_action_delete').entwine({
$('.cms-edit-form .btn-toolbar #Form_EditForm_action_delete').entwine({
onclick: function onclick(e) {
var form = this.parents('form:first'),
version = form.find(':input[name=Version]').val(),
@ -251,7 +251,7 @@
}
});
$('.cms-edit-form .Actions #Form_EditForm_action_unpublish').entwine({
$('.cms-edit-form .btn-toolbar #Form_EditForm_action_unpublish').entwine({
onclick: function onclick(e) {
var form = this.parents('form:first'),
version = form.find(':input[name=Version]').val(),
@ -280,7 +280,7 @@
}
});
$('.cms-edit-form .Actions button[name=action_publish]').entwine({
$('.cms-edit-form .btn-toolbar button[name=action_publish]').entwine({
onbuttonafterrefreshalternate: function onbuttonafterrefreshalternate() {
if (this.button('option', 'showingAlternate')) {
this.addClass('ss-ui-action-constructive');
@ -290,7 +290,7 @@
}
});
$('.cms-edit-form .Actions button[name=action_save]').entwine({
$('.cms-edit-form .btn-toolbar button[name=action_save]').entwine({
onbuttonafterrefreshalternate: function onbuttonafterrefreshalternate() {
if (this.button('option', 'showingAlternate')) {
this.addClass('ss-ui-action-constructive');

View File

@ -133,10 +133,4 @@ $.entwine('ss', function($){
$('.AssetAdmin.cms-edit-form .ss-gridfield').reload();
}
});
$('.AssetAdmin .grid-levelup').entwine({
onmatch: function () {
this.closest('.ui-tabs-panel').find('.cms-actions-row').prepend(this);
}
})
});

View File

@ -166,7 +166,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
new GridFieldEditButton(),
new GridFieldDeleteAction(),
new GridFieldDetailForm(),
GridFieldLevelup::create($folder->ID)->setLinkSpec('admin/assets/show/%d')
GridFieldLevelup::create($folder->ID)->setLinkSpec($this->Link('show') . '/%d')
);
$gridField = GridField::create('File', $title, $this->getList(), $gridFieldConfig);

View File

@ -101,12 +101,15 @@ gulp.task('bundle-legacy', function bundleLeftAndMain() {
});
gulp.task('umd-cms', () => { // eslint-disable-line
return transformToUmd(glob.sync(`${PATHS.CMS_JS_SRC}/*.js`), PATHS.CMS_JS_DIST);
return transformToUmd(glob.sync(
`${PATHS.CMS_JS_SRC}/**/*.js`,
{ ignore: `${PATHS.CMS_JS_SRC}/bundles/*` }
), PATHS.CMS_JS_DIST);
});
gulp.task('umd-watch', () => { // eslint-disable-line
if (isDev) {
gulp.watch(`${PATHS.CMS_JS_SRC}/*.js`, ['umd-cms']);
gulp.watch(`${PATHS.CMS_JS_SRC}/**/*.js`, ['umd-cms']);
}
});