Return null for empty MultiSelection key of Dict widget

This is more consistent with the other widgets.
This commit is contained in:
Cédric Krier
2024-06-30 01:57:44 +02:00
parent df1fdfaf0d
commit e047988aff
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -5437,7 +5437,11 @@ function eval_pyson(value){
},
get_value: function() {
var value = this.input.val();
return value.map(function(e) { return JSON.parse(e); });
if (value && value.length) {
return value.map(function(e) { return JSON.parse(e); });
} else {
return null;
}
},
set_value: function(value) {
if (value) {
@@ -233,7 +233,7 @@ class DictMultiSelectionEntry(DictEntry):
def get_value(self):
model, paths = self.tree.get_selection().get_selected_rows()
return [model[path][0] for path in paths]
return [model[path][0] for path in paths] or None
def set_value(self, value):
value2path = {v: idx for idx, (v, _) in enumerate(self.selection)}