mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 09:05:53 +00:00
BUGFIX Updated various CMS javascript functions to new jstree library
This commit is contained in:
parent
885597a754
commit
ea0f8b0e65
@ -208,8 +208,9 @@
|
||||
|
||||
// integrate with sitetree selection changes
|
||||
// TODO Only trigger when report is visible
|
||||
jQuery('#sitetree').bind('selectionchanged', function(e, data) {
|
||||
self.find(':input[name=ID]').val(data.node.getIdx());
|
||||
jQuery('#sitetree_ul').bind('select_node.jstree', function(e, data) {
|
||||
var node = data.rslt.obj;
|
||||
self.find(':input[name=ID]').val(node ? $(node).data('id') : null);
|
||||
self.trigger('submit');
|
||||
});
|
||||
|
||||
@ -329,8 +330,9 @@
|
||||
});
|
||||
|
||||
// integrate with sitetree selection changes
|
||||
jQuery('#sitetree').bind('selectionchanged', function(e, data) {
|
||||
self.find(':input[name=ID]').val(data.node.getIdx());
|
||||
jQuery('#sitetree_ul').bind('select_node.jstree', function(e, data) {
|
||||
var node = data.rslt.obj;
|
||||
self.find(':input[name=ID]').val(node ? $(node).data('id') : null);
|
||||
if(self.is(':visible')) self.trigger('submit');
|
||||
});
|
||||
|
||||
|
@ -40,11 +40,11 @@
|
||||
|
||||
Observable.applyTo(this[0]);
|
||||
|
||||
var tree = jQuery('#sitetree')[0];
|
||||
var tree = $('#sitetree_ul');
|
||||
this.setTree(tree);
|
||||
|
||||
// Event bindings
|
||||
jQuery(tree).bind('selectionchanged', function(e, data) {self.refresh(data.node);});
|
||||
$(tree).bind('select_node.jstree', function(e, data) {self.refresh(data.rslt.obj);});
|
||||
typeDropdown.bind('change', function(e) {self.refresh();});
|
||||
// TODO Bind on tree initialization to set dropdown for selected node
|
||||
|
||||
@ -66,16 +66,15 @@
|
||||
* (Event) e
|
||||
*/
|
||||
onsubmit: function(e) {
|
||||
var newPages = this.getNewPages();
|
||||
var tree = this.getTree();
|
||||
var parentID = (tree.firstSelected()) ? tree.getIdxOf(tree.firstSelected()) : 0;
|
||||
var newPages = this.getNewPages(), tree = this.getTree(), node = $(tree).jstree('get_selected');
|
||||
var parentID = (node.length) ? node.data('id') : 0;
|
||||
|
||||
// TODO: Remove 'new-' code http://open.silverstripe.com/ticket/875
|
||||
if(parentID && parentID.substr(0,3) == 'new') {
|
||||
alert(ss.i18n._t('CMSMAIN.WARNINGSAVEPAGESBEFOREADDING'));
|
||||
}
|
||||
// if(parentID && parentID.substr(0,3) == 'new') {
|
||||
// alert(ss.i18n._t('CMSMAIN.WARNINGSAVEPAGESBEFOREADDING'));
|
||||
// }
|
||||
|
||||
if(tree.firstSelected() && jQuery(tree.firstSelected()).hasClass("nochildren")) {
|
||||
if(node && node.hasClass("nochildren")) {
|
||||
alert(ss.i18n._t('CMSMAIN.CANTADDCHILDREN') );
|
||||
}
|
||||
|
||||
@ -83,17 +82,19 @@
|
||||
if(!newPages[parentID] ) newPages[parentID] = 1;
|
||||
|
||||
// default to first button
|
||||
var button = jQuery(this).find(':submit:first');
|
||||
var button = this.find(':submit:first');
|
||||
button.addClass('loading');
|
||||
|
||||
// collect data and submit the form
|
||||
var data = jQuery(this).serializeArray();
|
||||
var data = this.serializeArray();
|
||||
data.push({name:'Suffix',value:newPages[parentID]++});
|
||||
data.push({name:button.attr('name'),value:button.val()});
|
||||
|
||||
// TODO Should be set by hiddenfield already
|
||||
jQuery('#Form_EditForm').entwine('ss').loadForm(
|
||||
jQuery(this).attr('action'),
|
||||
this.attr('action'),
|
||||
function() {
|
||||
// Tree updates are triggered by Form_EditForm load events
|
||||
button.removeClass('loading');
|
||||
},
|
||||
{type: 'POST', data: data}
|
||||
@ -113,9 +114,9 @@
|
||||
refresh: function(selectedNode) {
|
||||
// Note: Uses siteTreeHints global
|
||||
var tree = this.getTree(),
|
||||
selectedNode = selectedNode || $(tree).jstree('get_selected')
|
||||
origOptions = this.getOrigOptions(),
|
||||
dropdown = this.find('select[name=PageType]');
|
||||
if(!selectedNode) selectedNode = tree.firstSelected();
|
||||
|
||||
// Clear all existing <option> elements
|
||||
// (IE doesn't allow setting display:none on these elements)
|
||||
@ -155,8 +156,7 @@
|
||||
}
|
||||
|
||||
// Set parent node (fallback to root)
|
||||
var parentID = tree.getIdxOf(selectedNode);
|
||||
this.find(':input[name=ParentID]').val(parentID ? parentID : 0);
|
||||
this.find(':input[name=ParentID]').val(selectedNode ? selectedNode.data('id') : 0);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -40,8 +40,8 @@
|
||||
|
||||
this.setTree($('#sitetree')[0]);
|
||||
|
||||
$(this.getTree()).bind('selectionchanged', function(e, data) {
|
||||
self._treeSelectionChanged(data.node);
|
||||
$(this.getTree()).bind('select_node.jstree', function(e, data) {
|
||||
self._treeSelectionChanged(data.rslt.obj);
|
||||
});
|
||||
|
||||
// if tab which contains this form is shown, make the tree selectable
|
||||
|
Loading…
x
Reference in New Issue
Block a user