Commit d5d82d36 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou

ui: Improved project listing in resource reassign view

Do not display terminated projects, unless terminated project is
associated with the modifing resource.
parent 945ae33b
...@@ -2868,6 +2868,10 @@ ...@@ -2868,6 +2868,10 @@
if (project.id == synnefo.user.get_username()) { if (project.id == synnefo.user.get_username()) {
project.name = "System project" project.name = "System project"
} }
// missing means the project exists in a relation to a resource
// but does not appear in user projects list. Once the project
// appears in projects list set missing flag to false.
project.missing = false;
}, this); }, this);
return resp; return resp;
}, },
......
...@@ -122,6 +122,18 @@ ...@@ -122,6 +122,18 @@
this.update_disabled = _.bind(this.update_disabled, this); this.update_disabled = _.bind(this.update_disabled, this);
views.ProjectSelectView.__super__.initialize.apply(this); views.ProjectSelectView.__super__.initialize.apply(this);
}, },
do_disable_view: function(view) {
if (view._is_current) { return false }
return true;
},
post_disable_view: function(view) {
var selected = this.get_selected();
if (!selected) {
this.select_any();
}
},
get_selected: function() { get_selected: function() {
var selected = undefined; var selected = undefined;
...@@ -153,7 +165,6 @@ ...@@ -153,7 +165,6 @@
_model_bindings: {}, _model_bindings: {},
bind_custom_view_handlers: function(view, model) { bind_custom_view_handlers: function(view, model) {
var func
model.quotas.bind('change', _.bind(function() { model.quotas.bind('change', _.bind(function() {
this.update_disabled(view) this.update_disabled(view)
}, this)); }, this));
...@@ -219,6 +230,7 @@ ...@@ -219,6 +230,7 @@
init_collection_view: function(collection) { init_collection_view: function(collection) {
if (this.collection_view) { this.collection_view.destroy() } if (this.collection_view) { this.collection_view.destroy() }
this.collection_view = new views.ProjectSelectView({ this.collection_view = new views.ProjectSelectView({
__current: this.model.get('project'),
collection: collection, collection: collection,
el: this.list, el: this.list,
filter_func: _.bind(this.can_fit_func, this), filter_func: _.bind(this.can_fit_func, this),
...@@ -229,13 +241,13 @@ ...@@ -229,13 +241,13 @@
this.handle_project_change(item.model); this.handle_project_change(item.model);
}, this); }, this);
this.collection_view.show(true);
this.collection_view.model_usage = this.model_usage; this.collection_view.model_usage = this.model_usage;
this.collection_view.resource_model = this.model; this.collection_view.resource_model = this.model;
this.collection_view.show(true);
var project = this.model.get('project'); var project = this.model.get('project');
this.collection_view.set_current(project);
if (project && !(project.get('missing') && !project.get('resolved'))) { if (project && !(project.get('missing') && !project.get('resolved'))) {
this.collection_view.set_current(this.model.get('project')); this.collection_view.set_selected(project);
this.collection_view.set_selected(this.model.get('project'));
} }
this.list.append($(this.collection_view.el)); this.list.append($(this.collection_view.el));
this.handle_project_change(); this.handle_project_change();
......
...@@ -339,6 +339,15 @@ ...@@ -339,6 +339,15 @@
this.empty_el.hide(); this.empty_el.hide();
}, },
select_any: function() {
var selected = false;
_.each(this._model_views, function(v) {
if (selected) { return }
if (!v.disabled) { v.select(); selected = v }
});
return selected;
},
check_empty: function() { check_empty: function() {
if (this.collection.length == 0) { if (this.collection.length == 0) {
this.show_empty(); this.show_empty();
...@@ -404,6 +413,13 @@ ...@@ -404,6 +413,13 @@
}, this); }, this);
}, },
do_disable_view: function(view) { return true },
post_disable_view: function(view) {},
enabled_model_views: function(cb) {
return _.filter(this._model_views, function(v) {
return !v.disabled
}, this);
},
check_disabled: function(view) { check_disabled: function(view) {
var disabled = this.disabled_filter(view.model); var disabled = this.disabled_filter(view.model);
// forced models are always disabled // forced models are always disabled
...@@ -411,6 +427,8 @@ ...@@ -411,6 +427,8 @@
disabled = true; disabled = true;
} }
if (disabled) { if (disabled) {
var do_disable = this.do_disable_view(view);
if (!do_disable) { return }
view.disable && view.disable(disabled); view.disable && view.disable(disabled);
if (_.isString(disabled)) { if (_.isString(disabled)) {
var el = view.el; var el = view.el;
...@@ -421,6 +439,7 @@ ...@@ -421,6 +439,7 @@
}; };
snf.util.set_tooltip(el, disabled, tooltip); snf.util.set_tooltip(el, disabled, tooltip);
} }
this.post_disable_view(view);
} else { } else {
var el = view.el; var el = view.el;
snf.util.unset_tooltip(el); snf.util.unset_tooltip(el);
...@@ -567,15 +586,6 @@ ...@@ -567,15 +586,6 @@
return selected; return selected;
}, },
select_any: function() {
var selected = false;
_.each(this._model_views, function(v) {
if (selected) { return }
if (!v.disabled) { v.select(); selected = v }
});
return selected;
},
post_add_model_view: function(view, model) { post_add_model_view: function(view, model) {
view.bind('deselected', function(view) { view.bind('deselected', function(view) {
var selected = this.get_selected(); var selected = this.get_selected();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment