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 @@
if (project.id == synnefo.user.get_username()) {
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);
return resp;
},
......
......@@ -123,6 +123,18 @@
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() {
var selected = undefined;
_.each(this._model_views, function(view, id){
......@@ -153,7 +165,6 @@
_model_bindings: {},
bind_custom_view_handlers: function(view, model) {
var func
model.quotas.bind('change', _.bind(function() {
this.update_disabled(view)
}, this));
......@@ -219,6 +230,7 @@
init_collection_view: function(collection) {
if (this.collection_view) { this.collection_view.destroy() }
this.collection_view = new views.ProjectSelectView({
__current: this.model.get('project'),
collection: collection,
el: this.list,
filter_func: _.bind(this.can_fit_func, this),
......@@ -229,13 +241,13 @@
this.handle_project_change(item.model);
}, this);
this.collection_view.show(true);
this.collection_view.model_usage = this.model_usage;
this.collection_view.resource_model = this.model;
this.collection_view.show(true);
var project = this.model.get('project');
this.collection_view.set_current(project);
if (project && !(project.get('missing') && !project.get('resolved'))) {
this.collection_view.set_current(this.model.get('project'));
this.collection_view.set_selected(this.model.get('project'));
this.collection_view.set_selected(project);
}
this.list.append($(this.collection_view.el));
this.handle_project_change();
......
......@@ -339,6 +339,15 @@
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() {
if (this.collection.length == 0) {
this.show_empty();
......@@ -404,6 +413,13 @@
}, 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) {
var disabled = this.disabled_filter(view.model);
// forced models are always disabled
......@@ -411,6 +427,8 @@
disabled = true;
}
if (disabled) {
var do_disable = this.do_disable_view(view);
if (!do_disable) { return }
view.disable && view.disable(disabled);
if (_.isString(disabled)) {
var el = view.el;
......@@ -421,6 +439,7 @@
};
snf.util.set_tooltip(el, disabled, tooltip);
}
this.post_disable_view(view);
} else {
var el = view.el;
snf.util.unset_tooltip(el);
......@@ -567,15 +586,6 @@
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) {
view.bind('deselected', function(view) {
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