mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-02 22:28:37 +02:00
BUGFIX Allowing deselection of nodes in single select mode for TreeDropdownField (fixes #4981)
This commit is contained in:
parent
2449a2b5c6
commit
bde24b3415
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
var strings = {
|
var strings = {
|
||||||
'openlink': 'Open',
|
'openlink': 'Open',
|
||||||
|
'fieldTitle': '(choose)',
|
||||||
'searchFieldTitle': '(choose or search)'
|
'searchFieldTitle': '(choose or search)'
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -42,6 +43,8 @@
|
|||||||
this[this.getPanel().is(':visible') ? 'closePanel' : 'openPanel']();
|
this[this.getPanel().is(':visible') ? 'closePanel' : 'openPanel']();
|
||||||
},
|
},
|
||||||
setTitle: function(title) {
|
setTitle: function(title) {
|
||||||
|
if(!title) title = strings.fieldTitle;
|
||||||
|
|
||||||
this.find('.title').text(title);
|
this.find('.title').text(title);
|
||||||
this.data('title', title); // separate view from storage (important for search cancellation)
|
this.data('title', title); // separate view from storage (important for search cancellation)
|
||||||
},
|
},
|
||||||
@ -70,9 +73,15 @@
|
|||||||
})
|
})
|
||||||
.jstree(self.getTreeConfig())
|
.jstree(self.getTreeConfig())
|
||||||
.bind('select_node.jstree', function(e, data) {
|
.bind('select_node.jstree', function(e, data) {
|
||||||
var node = data.rslt.obj;
|
var node = data.rslt.obj, id = $(node).data('id');
|
||||||
self.setValue($(node).data('id'));
|
if(self.getValue() == id) {
|
||||||
|
self.setValue(null);
|
||||||
|
self.setTitle(null);
|
||||||
|
} else {
|
||||||
|
self.setValue(id);
|
||||||
self.setTitle(data.inst.get_text(node));
|
self.setTitle(data.inst.get_text(node));
|
||||||
|
}
|
||||||
|
|
||||||
// Avoid auto-closing panel on first load
|
// Avoid auto-closing panel on first load
|
||||||
if(!firstLoad) self.closePanel();
|
if(!firstLoad) self.closePanel();
|
||||||
});
|
});
|
||||||
@ -144,6 +153,8 @@
|
|||||||
this.setTitle(title ? title : strings.searchFieldTitle);
|
this.setTitle(title ? title : strings.searchFieldTitle);
|
||||||
},
|
},
|
||||||
setTitle: function(title) {
|
setTitle: function(title) {
|
||||||
|
if(!title) title = strings.fieldTitle;
|
||||||
|
|
||||||
this.find('.title').val(title);
|
this.find('.title').val(title);
|
||||||
},
|
},
|
||||||
getTitle: function() {
|
getTitle: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user