[IMP] *: update notifications to optional title

closes odoo/odoo#52826

Related: odoo/enterprise#11084
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Julien Mougenot
2020-06-12 09:01:50 +00:00
parent d093fd4236
commit c4786fccfd
43 changed files with 81 additions and 80 deletions
@@ -60,8 +60,7 @@ FormController.include({
*/
_barcodeAddX2MQuantity: function (barcode, activeBarcode) {
if (this.mode === 'readonly') {
this.do_warn(_t('Error: Document not editable'),
_t('To modify this document, please enable edit mode.'));
this.do_warn(false, _t('Enable edit mode to modify this document'));
return Promise.reject();
}
@@ -134,7 +133,7 @@ FormController.include({
const state = this.model.get(this.handle, { raw: true });
const pagingInfo = this._getPagingInfo(state);
if (!pagingInfo) {
return this.do_warn(_t('Error: Pager not available'));
return this.do_warn(false, _t('Pager unavailable'));
}
const currentMinimum = updater(pagingInfo.currentMinimum, state);
const limit = pagingInfo.limit;
@@ -331,7 +330,7 @@ FormController.include({
}
}
if (prefixed && !hasCommand) {
self.do_warn(_t('Error: Barcode command is undefined'), barcode);
self.do_warn(_t('Undefined barcode command'), barcode);
}
return self.alive(Promise.all(defs)).then(function () {
if (!prefixed) {
@@ -367,8 +366,7 @@ FormController.include({
}
if (!_.compact(_.pluck(barcodeInfos, 'candidate')).length) {
return this.do_warn(_t('Error: No last scanned barcode'),
_t('To set the quantity please scan a barcode first.'));
return this.do_warn(false, _t('Scan a barcode to set the quantity'));
}
for (var k in this.activeBarcode) {
@@ -738,7 +738,10 @@ var DataImport = AbstractAction.extend({
return prom;
},
onimported: function (event, from, to, results) {
this.do_notify(_t("Import completed"), _.str.sprintf(_t("%d records were successfully imported"), results.ids.length));
this.do_notify(false, _.str.sprintf(
_t("%d records successfully imported"),
results.ids.length
));
this.exit();
},
exit: function () {
@@ -79,7 +79,10 @@ odoo.define('base_setup.ResConfigInviteUsers', function (require) {
// filter out invalid email addresses
var invalidEmails = _.reject(emails, this._validateEmail);
if (invalidEmails.length) {
this.do_warn(_.str.sprintf(_t('The following email addresses are invalid: %s.'), invalidEmails.join(', ')));
this.do_warn(false, _.str.sprintf(
_t('Invalid email addresses: %s.'),
invalidEmails.join(', ')
));
}
emails = _.difference(emails, invalidEmails);
@@ -90,7 +93,10 @@ odoo.define('base_setup.ResConfigInviteUsers', function (require) {
});
var existingEmails = _.intersection(emails, this.emails.concat(pendingEmails));
if (existingEmails.length) {
this.do_warn(_.str.sprintf(_t('The following email addresses already exist: %s.'), existingEmails.join(', ')));
this.do_warn(false, _.str.sprintf(
_t('Email addresses already existing: %s.'),
existingEmails.join(', ')
));
}
emails = _.difference(emails, existingEmails);
}
@@ -43,8 +43,7 @@ odoo.define('hr.Many2OneAvatarEmployee', function (require) {
// this is not ourself, so if we get here it means that the
// employee is not associated with any user
this.displayNotification({
title: _t('No user to chat with'),
message: _t('You can only chat with employees that have a dedicated user.'),
message: _t('You can only chat with employees that have a dedicated user'),
type: 'info',
});
} else {
@@ -156,7 +156,7 @@ QUnit.module('hr', {}, function () {
throw new Error('should not call mail_service');
}
if (ev.data.service === 'notification') {
assert.step(`display notification "${ev.data.args[0].title}"`);
assert.step(`display notification "${ev.data.args[0].message}"`);
}
}, true);
@@ -167,7 +167,7 @@ QUnit.module('hr', {}, function () {
assert.verifySteps([
'read foo 1',
'read hr.employee 11',
'display notification "No user to chat with"',
'display notification "You can only chat with employees that have a dedicated user"',
]);
form.destroy();
@@ -198,7 +198,7 @@ QUnit.module('hr', {}, function () {
throw new Error('should not call mail_service');
}
if (ev.data.service === 'notification') {
assert.step(`display notification "${ev.data.args[0].title}"`);
assert.step(`display notification "${ev.data.args[0].message}"`);
}
}, true);
@@ -209,7 +209,7 @@ QUnit.module('hr', {}, function () {
assert.verifySteps([
'read foo 1',
'read hr.employee 11',
'display notification "Cannot chat with yourself"',
'display notification "You cannot chat with yourself"',
]);
form.destroy();
@@ -42,7 +42,7 @@ var DocumentUploadMixin = {
return filtered;
}, []);
if (!attachent_ids.length) {
return self.do_notify(_t("Error"), _t("An error occurred during the upload"));
return self.do_notify(false, _t("An error occurred during the upload"));
}
var myContext = this.initialState.context
myContext['isMobile'] = config.device.isMobile
@@ -240,8 +240,7 @@ var LivechatButton = Widget.extend({
def.then(function (livechatData) {
if (!livechatData || !livechatData.operator_pid) {
self.displayNotification({
title: _t("Collaborators offline"),
message: _t("None of our collaborators seem to be available, please try again later."),
message: _t("No available collaborator, please try again later."),
sticky: true
});
} else {
@@ -335,8 +334,7 @@ var LivechatButton = Widget.extend({
.then(function (messageId) {
if (!messageId) {
self.displayNotification({
title: _t("Session Expired"),
message: _t("You took to long to send a message. Please refresh the page and try again."),
message: _t("Session expired... Please refresh and try again."),
sticky: true
});
self._closeChat();
+1 -1
View File
@@ -129,7 +129,7 @@ var AttachmentBox = Widget.extend({
*/
_onUploaded: function(ev, response) {
if (response.error) {
this.do_warn(_t("Error"), _t("You are not allowed to upload an attachment here."));
this.do_warn(false, _t("Attachment upload not authorized here"));
} else {
this.trigger_up('reload_attachment_box');
}
@@ -265,7 +265,7 @@ var BasicComposer = Widget.extend({
*/
_doCheckAttachmentUpload: function () {
if (_.find(this.get('attachment_ids'), function (file) { return file.upload; })) {
this.do_warn(_t("Uploading error"), _t("Please, wait while the file is uploading."));
this.do_warn(false, _t("Please wait while the file is uploading..."));
return false;
}
return true;
+2 -2
View File
@@ -96,10 +96,10 @@ var PartnerInviteDialog = Dialog.extend({
var names = _.escape(_.pluck(data, 'text').join(', '));
var notification =
_.str.sprintf(
_t("You added <b>%s</b> to the conversation."),
_t("You added <b>%s</b> to the conversation"),
names
);
self.do_notify(_t("New people"), notification);
self.do_notify(false, notification);
// Update list of members with the invited user, so that
// we can mention this user in this channel right away.
var channel = self.call('mail_service', 'getChannel', self._channelID);
@@ -63,8 +63,7 @@ odoo.define('mail.Many2OneAvatarUser', function (require) {
*/
_displayWarning() {
this.displayNotification({
title: _t('Cannot chat with yourself'),
message: _t('Click on the avatar of other users to chat with them.'),
message: _t('You cannot chat with yourself'),
type: 'info',
});
},
@@ -250,7 +250,7 @@ MailManager.include({
channelData.info !== 'creation'
) {
this.do_notify(
_t("Invitation"),
false,
_t("You have been invited to: ") + channelData.name);
}
}
@@ -530,7 +530,7 @@ MailManager.include({
}
this._removeChannel(channel);
this._mailBus.trigger('unsubscribe_from_channel', data.id);
this.do_notify(_t("Unsubscribed"), message);
this.do_notify(false, message);
}
},
/**
+1 -1
View File
@@ -95,7 +95,7 @@ var ThreadField = AbstractField.extend({
self.trigger_up('reload_mail_fields', { followers: true });
}
}).guardedCatch(function () {
self.do_notify(_t("Sending Error"), _t("Your message has not been sent."));
self.do_notify(false, _t("Message not sent"));
return Promise.reject();
});
},
@@ -136,7 +136,7 @@ QUnit.module('mail', {}, function () {
throw new Error('should not call mail_service');
}
if (ev.data.service === 'notification') {
assert.step(`display notification "${ev.data.args[0].title}"`);
assert.step(`display notification "${ev.data.args[0].message}"`);
}
}, true);
@@ -146,7 +146,7 @@ QUnit.module('mail', {}, function () {
assert.verifySteps([
'read foo 4',
'display notification "Cannot chat with yourself"',
'display notification "You cannot chat with yourself"',
]);
form.destroy();
@@ -51,7 +51,7 @@ odoo.define('systray.systray_odoo_referral', function (require) {
var message = _t('A popup window has been blocked. You ' +
'may need to change your browser settings to allow ' +
'popup windows for this page.');
self.do_warn(_t('Warning'), message, true);
self.do_warn(false, message, true);
}
});
},
@@ -124,7 +124,7 @@ var PortalComposer = publicWidget.Widget.extend({
resolve();
}).guardedCatch(function (error) {
self.displayNotification({
message: _.str.sprintf(_t("The file <strong>%s</strong> could not be saved."),
message: _.str.sprintf(_t("Could not save file <strong>%s</strong>"),
_.escape(file.name)),
type: 'warning',
sticky: true,
@@ -35,7 +35,10 @@ var QtyTagWidget = Widget.extend({
*/
_onClickAddQty: function () {
if (this.quantities.length >= this.MAX_QTY) {
this.do_notify(_t("Quantity cannot be displayed"), _.str.sprintf(_t("Maximum %d quantities can be displayed simultaneously. Remove a selected quantity to add others."), this.MAX_QTY));
this.do_notify(false, _.str.sprintf(
_t("At most %d quantities can be displayed simultaneously. Remove a selected quantity to add others."),
this.MAX_QTY
));
return;
}
const qty = parseInt(this.$('.o_product_qty').val());
@@ -48,12 +51,12 @@ var QtyTagWidget = Widget.extend({
this.renderElement();
} else {
this.displayNotification({
title: _.str.sprintf(_t("Quantity already present (%d)."), qty),
message: _.str.sprintf(_t("Quantity already present (%d)."), qty),
type: 'info'
});
}
} else {
this.do_notify(_t("Please enter a positive whole number."));
this.do_notify(false, _t("Please enter a positive whole number"));
}
},
/**
@@ -94,7 +94,7 @@ QUnit.module('Product Pricelist', {
// existing quantity can not be added.
await testUtils.dom.click(actionManager.$('.o_add_qty'));
let notificationElement = document.body.querySelector('.o_notification_manager .o_notification.bg-info');
assert.strictEqual(notificationElement.querySelector('.o_notification_title').textContent,
assert.strictEqual(notificationElement.querySelector('.o_notification_content').textContent,
"Quantity already present (1).", "Existing Quantity can not be added");
// adding few more quantities to check.
@@ -111,7 +111,7 @@ QUnit.module('Product Pricelist', {
notificationElement = document.body.querySelector('.o_notification_manager .o_notification.bg-warning');
assert.strictEqual(notificationElement.querySelector('.o_notification_content').textContent,
"Maximum 5 quantities can be displayed simultaneously. Remove a selected quantity to add others.",
"At most 5 quantities can be displayed simultaneously. Remove a selected quantity to add others.",
"Can not add more then 5 quantities");
// removing all the quantities should work
@@ -143,4 +143,4 @@ QUnit.module('Product Pricelist', {
}
);
});
});
+1 -1
View File
@@ -45,7 +45,7 @@ KanbanRecord.include({
var self = this;
var value = Number(this.$target_input.val());
if (isNaN(value)) {
this.do_warn(_t("Wrong value entered!"), _t("Only Integer Value should be valid."));
this.do_warn(false, _t("Please enter an integer value"));
} else {
this.trigger_up('kanban_record_update', {
invoiced_target: value,
@@ -69,7 +69,7 @@ var InventoryValidationController = ListController.extend({
}
// ... but in any other cases, we go back on the inventory form.
self.do_notify(
_t("Success"),
false,
_t("The inventory has been validated"));
self.trigger_up('history_back');
};
@@ -536,7 +536,7 @@ var ActionManager = Widget.extend({
var message = _t('A popup window has been blocked. You ' +
'may need to change your browser settings to allow ' +
'popup windows for this page.');
this.do_warn(_t('Warning'), message, true);
this.do_warn(false, message, true);
}
}
@@ -60,7 +60,6 @@ odoo.define('web.CustomFavoriteItem', function (require) {
_saveFavorite() {
if (!this.state.description.length) {
this.env.services.notification.notify({
title: this.env._t("Error"),
message: this.env._t("A name for your favorite filter is required."),
type: 'danger',
});
@@ -69,7 +68,6 @@ odoo.define('web.CustomFavoriteItem', function (require) {
const favorites = this.model.getFiltersOfType('favorite');
if (favorites.some(f => f.description === this.state.description)) {
this.env.services.notification.notify({
title: this.env._t("Error"),
message: this.env._t("Filter with same name already exists."),
type: 'danger',
});
@@ -1680,7 +1680,7 @@ var AbstractFieldBinary = AbstractField.extend({
},
on_file_uploaded: function (size, name) {
if (size === false) {
this.do_warn(_t("File Upload"), _t("There was a problem while uploading your file"));
this.do_warn(false, _t("There was a problem while uploading your file"));
// TODO: use crashmanager
console.warn("Error while uploading file : ", name);
} else {
@@ -1823,7 +1823,7 @@ var FieldBinaryImage = AbstractFieldBinary.extend({
$img.one('error', function () {
$img.attr('src', self.placeholder);
self.do_warn(_t("Image"), _t("Could not display the selected image."));
self.do_warn(false, _t("Could not display the selected image"));
});
return this._super.apply(this, arguments);
@@ -1963,7 +1963,7 @@ var FieldBinaryFile = AbstractFieldBinary.extend({
},
on_save_as: function (ev) {
if (!this.value) {
this.do_warn(_t("Save As..."), _t("The field is empty, there's nothing to save !"));
this.do_warn(false, _t("The field is empty, there's nothing to save."));
ev.stopPropagation();
} else if (this.res_id) {
framework.blockUI();
@@ -2643,7 +2643,7 @@ var FieldProgressBar = AbstractField.extend({
// Cover all numbers with parseFloat
parsedValue = field_utils.parse.float($input.val());
} catch (error) {
this.do_warn(_t("Wrong value entered!"), _t("Only Integer or Float Value should be valid."));
this.do_warn(false, _t("Please enter a numerical value"));
}
if (parsedValue !== undefined) {
@@ -1793,7 +1793,7 @@ var One2ManyKanbanRecord = KanbanRecord.extend({
if ($button.attr('warn')) {
$button.on('click', function (e) {
e.stopPropagation();
self.do_warn(_t('Warning'), _t('Please click on the "save" button first.'));
self.do_warn(false, _t('Please click on the "save" button first'));
});
} else {
$button.attr('disabled', 'disabled');
+1 -1
View File
@@ -110,7 +110,7 @@ var FieldBinarySignature = AbstractFieldBinary.extend({
$img.on('error', function () {
self._clearFile();
$img.attr('src', self.placeholder);
self.do_warn(_t("Image"), _t("Could not display the selected image."));
self.do_warn(false, _t("Could not display the selected image"));
});
},
@@ -526,7 +526,7 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
});
warnings.unshift('<ul>');
warnings.push('</ul>');
this.do_warn(_t("The following fields are invalid:"), warnings.join(''));
this.do_warn(_t("Invalid fields:"), warnings.join(''));
},
/**
* Hook method, called when record(s) has been deleted.
@@ -80,7 +80,7 @@ var QuickCreate = Dialog.extend({
if (!val) {
this.$('label, input').addClass('o_field_invalid');
var warnings = _.str.sprintf('<ul><li>%s</li></ul>', _t("Summary"));
this.do_warn(_t("The following field is invalid:"), warnings);
this.do_warn(_t("Invalid fields:"), warnings);
}
dataCalendar.title = val;
return (val)? this.trigger_up('quickCreate', {data: dataCalendar, options: this.options}) : false;
@@ -31,7 +31,7 @@ const ProgressBar = Widget.extend({
* @return {Promise}
*/
start() {
this.xhr.onabort = () => this.do_notify(_t("Upload canceled"));
this.xhr.onabort = () => this.do_notify(false, _t("Upload cancelled"));
return this._super(...arguments);
},
@@ -706,7 +706,7 @@ var KanbanRecord = Widget.extend({
}
break;
default:
this.do_warn("Kanban: no action for type : " + type);
this.do_warn(false, _t("Kanban: no action for type: ") + type);
}
},
/**
@@ -287,10 +287,10 @@ var ListController = BasicController.extend({
});
if (resIds.length === session.active_ids_limit) {
const msg = _.str.sprintf(
_t("Of the %d records selected, only the first %d have been deleted."),
state.count, resIds.length
_t("Only the first %d records have been deleted (out of %d selected)"),
resIds.length, state.count
);
this.do_notify(_t('Warning'), msg);
this.do_notify(false, msg);
}
this.reload();
};
@@ -586,7 +586,7 @@ var ListRenderer = BasicRenderer.extend({
if (node.attrs.options.warn) {
$button.on("click", function (e) {
e.stopPropagation();
self.do_warn(_t("Warning"), _t('Please click on the "save" button first.'));
self.do_warn(false, _t('Please click on the "save" button first'));
});
} else {
$button.prop('disabled', true);
@@ -62,7 +62,7 @@ var AttachDocument = Widget.extend({
});
warnings.unshift('<ul>');
warnings.push('</ul>');
this.do_warn(_t("The following fields are invalid:"), warnings.join(''));
this.do_warn(_t("Invalid fields:"), warnings.join(''));
},
//--------------------------------------------------------------------------
@@ -87,7 +87,7 @@ var AttachDocument = Widget.extend({
// but due to this security restriction give warning to save record first.
// https://stackoverflow.com/questions/29728705/trigger-click-on-input-file-on-asynchronous-ajax-done/29873845#29873845
if (!this.res_id) {
return this.do_warn(_t('Warning : You have to save first before attaching a file.'));
return this.do_warn(false, _t('Please save before attaching a file'));
}
this.$('input.o_input_file').trigger('click');
},
@@ -535,10 +535,7 @@ var DomainSelector = DomainTree.extend({
// Warn the user if the domain is not valid after rendering
if (!this._isValid) {
this.do_warn(
_t("Domain error"),
_t("The domain you entered is not properly formed")
);
this.do_warn(false, _t("Domain not supported"));
}
},
/**
@@ -583,7 +580,7 @@ var DomainSelector = DomainTree.extend({
try {
domain = Domain.prototype.stringToArray($(e.currentTarget).val());
} catch (err) { // If there is a syntax error, just ignore the change
this.do_warn(_t("Syntax error"), _t("The domain you entered is not properly formed"));
this.do_warn(_t("Syntax error"), _t("Domain not properly formed"));
return;
}
this._redraw(domain).then((function () {
@@ -433,8 +433,8 @@ var ModelFieldSelector = Widget.extend({
if (!this.valid) {
this.do_warn(
_t("Invalid field chain"),
_t("The field chain is not valid. Did you maybe use a non-existing field name or followed a non-relational field?")
false,
_t("Invalid field chain. You may have used a non-existing field name or followed a non-relational field.")
);
}
},
@@ -495,7 +495,10 @@ var ModelFieldSelector = Widget.extend({
var userChainStr = this.$input.val();
var userChain = userChainStr.split(".");
if (!this.options.followRelations && userChain.length > 1) {
this.do_warn(_t("Relation not allowed"), _t("You cannot follow relations for this field chain construction"));
this.do_warn(
_t("Relation not allowed"),
_t("You cannot follow relations for this field chain construction")
);
userChain = [userChain[0]];
}
this.setChain(userChain).then((function () {
@@ -453,7 +453,6 @@ odoo.define('web.favorite_menu_tests', function (require) {
notification: {
notify: function (params) {
assert.deepEqual(params, {
title: "Error",
message: "Filter with same name already exists.",
type: "danger"
});
@@ -578,4 +577,4 @@ odoo.define('web.favorite_menu_tests', function (require) {
form.destroy();
});
});
});
});
@@ -7236,7 +7236,10 @@ QUnit.module('basic_fields', {
call_service: function (ev) {
if (ev.data.service === 'notification') {
assert.strictEqual(ev.data.method, 'notify');
assert.strictEqual(ev.data.args[0].title, 'Wrong value entered!');
assert.strictEqual(
ev.data.args[0].message,
"Please enter a numerical value"
);
}
}
},
+1 -1
View File
@@ -3095,7 +3095,7 @@ QUnit.module('Views', {
if (params.type !== 'danger') {
return;
}
assert.strictEqual(params.title, 'The following fields are invalid:',
assert.strictEqual(params.title, 'Invalid fields:',
"should have a warning with correct title");
assert.strictEqual(params.message, '<ul><li>Foo</li></ul>',
"should have a warning with correct message");
@@ -2037,8 +2037,7 @@ var SnippetsMenu = Widget.extend({
reason.event.preventDefault();
this.close();
self.displayNotification({
title: _t("Something went wrong."),
message: _.str.sprintf(_t("The module <strong>%s</strong> could not be installed."), name),
message: _.str.sprintf(_t("Could not install module <strong>%s</strong>"), name),
type: 'danger',
sticky: true,
});
@@ -151,7 +151,7 @@ QUnit.module('web_editor', {}, function () {
"className": undefined,
"message": "<ul><li>Header</li></ul>",
"sticky": undefined,
"title": "The following fields are invalid:",
"title": "Invalid fields:",
"type": "danger"
});
}
@@ -219,7 +219,6 @@ var WebsiteRoot = publicRootData.PublicRoot.extend(KeyboardNavigationMixin, {
if (result) {
self.displayNotification({
type: 'success',
title: _t("Congratulations"),
message: $data.data('description') ?
_.str.sprintf(_t("You've published your %s."), $data.data('description')) :
_t("Published with success."),
@@ -1625,8 +1625,7 @@ options.registry.anchor = options.Class.extend({
const anchor = decodeURIComponent(this._getAnchorLink());
this.displayNotification({
type: 'success',
title: _t("Copied !"),
message: _.str.sprintf(_t("The anchor has been copied to your clipboard.<br>Link: %s"), anchor),
message: _.str.sprintf(_t("Anchor copied to clipboard<br>Link: %s"), anchor),
buttons: [{text: _t("Edit"), click: () => this.openAnchorDialog(), primary: true}],
});
});
@@ -127,7 +127,6 @@ odoo.define('website_slides.quiz', function (require) {
this.displayNotification({
type: 'warning',
title: _t('Quiz validation error'),
message: message,
sticky: true
});
@@ -177,7 +177,6 @@ var QuestionFormWidget = publicWidget.Widget.extend({
} else {
this.displayNotification({
type: 'warning',
title: _t('Unable to create question'),
message: _t('Please fill up the question'),
sticky: true
});