##// END OF EJS Templates
Fixed buggy behavior
Jonathan Frederic -
Show More
@@ -321,18 +321,20 function(WidgetManager, _, Backbone){
321 var view_ids = this.child_model_views[child_model.id];
321 var view_ids = this.child_model_views[child_model.id];
322 if (view_ids !== undefined) {
322 if (view_ids !== undefined) {
323
323
324 // Remove every view associate with the model id.
324 // Only delete the first view in the list.
325 for (var i =0; i < view_ids.length; i++) {
325 var view_id = view_ids[0];
326 var view_id = view_ids[i];
326 var view = this.child_views[view_id];
327 var view = this.child_views[view_id];
327 delete this.child_views[view_id];
328 views.remove();
328 delete view_ids[0];
329 delete this.child_views[view_id];
329 child_model.views.pop(view);
330 child_model.views.pop(view);
330
331 // Remove the view list specific to this model if it is empty.
332 if (view_ids.length === 0) {
333 delete this.child_model_views[child_model.id];
331 }
334 }
332
335 return view;
333 // Remove the view list specific to this model.
334 delete this.child_model_views[child_model.id];
335 }
336 }
337 return null;
336 },
338 },
337
339
338 do_diff: function(old_list, new_list, removed_callback, added_callback) {
340 do_diff: function(old_list, new_list, removed_callback, added_callback) {
@@ -22,9 +22,9 define(["widgets/js/widget"], function(WidgetManager) {
22 this.$el.addClass('widget-container')
22 this.$el.addClass('widget-container')
23 .addClass('vbox');
23 .addClass('vbox');
24 this.children={};
24 this.children={};
25 this.update_children([], this.model.get('_children'));
25 this.update_children([], this.model.get('children'));
26 this.model.on('change:_children', function(model, value, options) {
26 this.model.on('change:children', function(model, value, options) {
27 this.update_children(model.previous('_children'), value);
27 this.update_children(model.previous('children'), value);
28 }, this);
28 }, this);
29 this.update();
29 this.update();
30
30
@@ -51,8 +51,7 define(["widgets/js/widget"], function(WidgetManager) {
51
51
52 remove_child_model: function(model) {
52 remove_child_model: function(model) {
53 // Called when a model is removed from the children list.
53 // Called when a model is removed from the children list.
54 this.child_views[model.id].remove();
54 this.delete_child_view(model).remove();
55 this.delete_child_view(model);
56 },
55 },
57
56
58 add_child_model: function(model) {
57 add_child_model: function(model) {
@@ -187,9 +186,9 define(["widgets/js/widget"], function(WidgetManager) {
187 this._shown_once = false;
186 this._shown_once = false;
188 this.popped_out = true;
187 this.popped_out = true;
189
188
190 this.update_children([], this.model.get('_children'));
189 this.update_children([], this.model.get('children'));
191 this.model.on('change:_children', function(model, value, options) {
190 this.model.on('change:children', function(model, value, options) {
192 this.update_children(model.previous('_children'), value);
191 this.update_children(model.previous('children'), value);
193 }, this);
192 }, this);
194 this.update();
193 this.update();
195
194
@@ -257,8 +256,7 define(["widgets/js/widget"], function(WidgetManager) {
257
256
258 remove_child_model: function(model) {
257 remove_child_model: function(model) {
259 // Called when a child is removed from children list.
258 // Called when a child is removed from children list.
260 this.child_views[model.id].remove();
259 this.delete_child_view(model).remove();
261 this.delete_child_view(model);
262 },
260 },
263
261
264 add_child_model: function(model) {
262 add_child_model: function(model) {
@@ -25,9 +25,9 define(["widgets/js/widget"], function(WidgetManager){
25 .addClass('panel-group');
25 .addClass('panel-group');
26 this.containers = [];
26 this.containers = [];
27 this.model_containers = {};
27 this.model_containers = {};
28 this.update_children([], this.model.get('_children'));
28 this.update_children([], this.model.get('children'));
29 this.model.on('change:_children', function(model, value, options) {
29 this.model.on('change:children', function(model, value, options) {
30 this.update_children(model.previous('_children'), value);
30 this.update_children(model.previous('children'), value);
31 }, this);
31 }, this);
32 this.model.on('change:selected_index', function(model, value, options) {
32 this.model.on('change:selected_index', function(model, value, options) {
33 this.update_selected_index(model.previous('selected_index'), value, options);
33 this.update_selected_index(model.previous('selected_index'), value, options);
@@ -163,9 +163,9 define(["widgets/js/widget"], function(WidgetManager){
163 .addClass('tab-content')
163 .addClass('tab-content')
164 .appendTo(this.$el);
164 .appendTo(this.$el);
165 this.containers = [];
165 this.containers = [];
166 this.update_children([], this.model.get('_children'));
166 this.update_children([], this.model.get('children'));
167 this.model.on('change:_children', function(model, value, options) {
167 this.model.on('change:children', function(model, value, options) {
168 this.update_children(model.previous('_children'), value);
168 this.update_children(model.previous('children'), value);
169 }, this);
169 }, this);
170
170
171 // Trigger model displayed events for any models that are child to
171 // Trigger model displayed events for any models that are child to
@@ -190,12 +190,11 define(["widgets/js/widget"], function(WidgetManager){
190
190
191 remove_child_model: function(model) {
191 remove_child_model: function(model) {
192 // Called when a child is removed from children list.
192 // Called when a child is removed from children list.
193 var view = this.child_views[model.id];
193 var view = this.delete_child_view(model);
194 this.containers.splice(view.parent_tab.tab_text_index, 1);
194 this.containers.splice(view.parent_tab.tab_text_index, 1);
195 view.parent_tab.remove();
195 view.parent_tab.remove();
196 view.parent_container.remove();
196 view.parent_container.remove();
197 view.remove();
197 view.remove();
198 this.delete_child_view(model);
199 },
198 },
200
199
201 add_child_model: function(model) {
200 add_child_model: function(model) {
@@ -15,16 +15,14 class ContainerWidget(DOMWidget):
15 # Child widgets in the container.
15 # Child widgets in the container.
16 # Using a tuple here to force reassignment to update the list.
16 # Using a tuple here to force reassignment to update the list.
17 # When a proper notifying-list trait exists, that is what should be used here.
17 # When a proper notifying-list trait exists, that is what should be used here.
18 children = Tuple()
18 children = Tuple(sync=True)
19 _children = Tuple(sync=True)
20
21
19
22 def __init__(self, **kwargs):
20 def __init__(self, **kwargs):
23 super(ContainerWidget, self).__init__(**kwargs)
21 super(ContainerWidget, self).__init__(**kwargs)
24 self.on_displayed(ContainerWidget._fire_children_displayed)
22 self.on_displayed(ContainerWidget._fire_children_displayed)
25
23
26 def _fire_children_displayed(self):
24 def _fire_children_displayed(self):
27 for child in self._children:
25 for child in self.children:
28 child._handle_displayed()
26 child._handle_displayed()
29
27
30
28
General Comments 0
You need to be logged in to leave comments. Login now