Add message notification

issue3465
review14001002
This commit is contained in:
Cédric Krier committed 2015-07-03 19:35:28 +02:00
1 parent b94c5533a9
commit 56bfd4b1eb
4 files changed
+87 -15

No files matched your search

+1
View File
@@ -776,6 +776,7 @@
} else {
this.tab.attachment_count(0);
}
this.tab.record_message();
}
},
display: function() {
+45 -14
View File
@@ -16,6 +16,9 @@
});
this.title = jQuery('<h4/>').appendTo(this.el);
this.el.append(this.info_bar.el);
this.create_toolbar().appendTo(this.el);
},
set_menu: function(menu) {
@@ -221,6 +224,7 @@
this.menu_def[10][2] = null;
}
this.info_bar = new Sao.Window.InfoBar();
this.create_tabcontent();
var access = Sao.common.MODELACCESS.get(model_name);
@@ -429,8 +433,9 @@
return;
}
this.modified_save().done(function() {
this.screen.new_();
// TODO message
this.screen.new_().then(function() {
this.info_bar.message();
}.bind(this));
// TODO activate_save
}.bind(this));
},
@@ -438,8 +443,15 @@
if (!Sao.common.MODELACCESS.get(this.screen.model_name).write) {
return jQuery.when();
}
// TODO message
return this.screen.save_current();
return this.screen.save_current().then(
function() {
this.info_bar.message(
Sao.i18n.gettext('Record saved.'), 'info');
}.bind(this),
function() {
this.info_bar.message(
Sao.i18n.gettext('Invalid form.'), 'danger');
}.bind(this));
},
switch_: function() {
this.modified_save().done(function() {
@@ -458,8 +470,9 @@
this.screen.screen_container.search_entry.val());
// TODO set current_record
}
return this.screen.display();
// TODO message
return this.screen.display().then(function() {
this.info_bar.message();
}.bind(this));
// TODO activate_save
}.bind(this));
}.bind(this);
@@ -474,8 +487,12 @@
return;
}
this.modified_save().done(function() {
this.screen.copy();
// TODO message
this.screen.copy().then(function() {
this.info_bar.message(
Sao.i18n.gettext(
'Working now on the duplicated record(s).'),
'info');
}.bind(this));
}.bind(this));
},
delete_: function() {
@@ -489,21 +506,30 @@
msg = Sao.i18n.gettext('Are you sure to remove those records?');
}
Sao.common.sur.run(msg).done(function() {
this.screen.remove(true, false, true).done(function() {
// TODO message
});
this.screen.remove(true, false, true).then(
function() {
this.info_bar.message(
Sao.i18n.gettext('Records removed.'),
'info');
}.bind(this), function() {
this.info_bar.message(
Sao.i18n.gettext('Records not removed.'),
'danger');
}.bind(this));
}.bind(this));
},
previous: function() {
this.modified_save().done(function() {
this.screen.display_previous();
// TODO message and activate_save
this.info_bar.message();
// TODO activate_save
}.bind(this));
},
next: function() {
this.modified_save().done(function() {
this.screen.display_next();
// TODO message and activate_save
this.info_bar.message();
// TODO activate_save
}.bind(this));
},
search: function() {
@@ -517,7 +543,9 @@
logs: function() {
var record = this.screen.current_record;
if ((!record) || (record.id < 0)) {
// TODO message
this.info_bar.message(
Sao.i18n.gettext('You have to select one record.'),
'info');
return;
}
var fields = [
@@ -640,6 +668,9 @@
this.buttons.attach.prop('disabled',
record_id < 0 || record_id === null);
},
record_message: function() {
this.info_bar.message();
},
action: function() {
this.buttons.action.click();
},
+36
View File
@@ -5,6 +5,36 @@
Sao.Window = {};
Sao.Window.InfoBar = Sao.class_(Object, {
init: function() {
this.text = jQuery('<span/>');
this.el = jQuery('<div/>', {
'class': 'alert',
'role': 'alert'
}).append(jQuery('<button/>', {
'type': 'button',
'class': 'close',
'aria-label': Sao.i18n.gettext('Close')
}).append(jQuery('<span/>', {
'aria-hidden': true
}).append('&times;').click(function() {
this.el.hide();
}.bind(this)))).append(this.text);
this.el.hide();
},
message: function(message, type) {
if (message) {
this.el.removeClass(
'alert-success alert-info alert-warning alert-danger');
this.el.addClass('alert-' + (type || 'info'));
this.text.text(message);
this.el.show();
} else {
this.el.hide();
}
}
});
Sao.Window.Form = Sao.class_(Object, {
init: function(screen, callback, kwargs) {
kwargs = kwargs || {};
@@ -16,6 +46,7 @@
this.save_current = kwargs.save_current;
this.prev_view = screen.current_view;
this.screen.screen_container.alternate_view = true;
this.info_bar = new Sao.Window.InfoBar();
var view_type = kwargs.view_type || 'form';
var form_prm = jQuery.when();
@@ -38,6 +69,8 @@
var dialog = new Sao.Dialog('', '', 'lg');
this.el = dialog.modal;
dialog.body.append(this.info_bar.el);
var readonly = (this.screen.attributes.readonly ||
this.screen.group.get_readonly());
@@ -249,8 +282,11 @@
jQuery.when.apply(jQuery, validate_prms).then(
closing_prm.resolve, closing_prm.reject);
} else if (!validate) {
this.info_bar.message(
Sao.i18n.gettext('Invalid form.'), 'danger');
closing_prm.reject();
} else {
this.info_bar.message();
closing_prm.resolve();
}
+5 -1
View File
@@ -24,6 +24,7 @@
this.session = Sao.Session.current_session;
this.__processing = false;
this.__waiting_response = false;
this.info_bar = new Sao.Window.InfoBar();
},
run: function(attributes) {
this.action = attributes.action;
@@ -116,8 +117,11 @@
return this.screen.current_record.validate().then(function(validate) {
if ((!validate) && state != this.end_state) {
this.screen.display();
this.info_bar.message(
Sao.i18n.gettext('Invalid form.'), 'danger');
return;
}
this.info_bar.message();
this.state = state;
this.process();
}.bind(this));
@@ -206,7 +210,7 @@
this.dialog = dialog.modal;
this.content = dialog.content;
this.footer = dialog.footer;
dialog.body.append(this.widget);
dialog.body.append(this.info_bar.el).append(this.widget);
},
clean: function() {
Sao.Wizard.Dialog._super.clean.call(this);