summaryrefslogtreecommitdiff
path: root/addons/mail/static/src
diff options
context:
space:
mode:
authorDharmang Soni <dpr@openerp.com>2018-04-04 15:34:43 +0530
committerThibault Delavallée <tde@odoo.com>2018-04-09 14:35:06 +0200
commit807c4c3f5e729d8b2f463d93e73b0dbbc008492b (patch)
treedc6774487c50efbd6c09b5ae642744582b3fe260 /addons/mail/static/src
parentc56491b11bc399247a595a2e08bbc940d2be3746 (diff)
[REF] mail, note: move reminder feature from mail to note
This commit refactors f488dc58c37fdc7fd49df759165de641e213444b that added reminder feature in activities. After merging it was suggested specifications were not correct and it has been decided to move the whole reminder feature in note. Reminders are now notes instead of activities. Now when having note appµ systray proposes to create a note / reminder. A note.note record is created with info given by the user. If a date is given in the systray quick create then an activity is scheduled on this note. This means user can create records in activity systray that are not activities but notes used as reminders. Those will use the first availableµ note column for the user. As reminders are now notes the support of activities not linked to any document is removed, as well as archiving activities and tests linked to that behavior. This commit has been not carefully tested nor in-depth reviewied. It is considered as too important for the upcoming freeze. This closes task ID 1833628. Closes #24129 . Many thanks to @dpr-odoo for its quick development and good work on this task.
Diffstat (limited to 'addons/mail/static/src')
-rw-r--r--addons/mail/static/src/img/reminder.pngbin4953 -> 0 bytes
-rw-r--r--addons/mail/static/src/js/systray.js129
-rw-r--r--addons/mail/static/src/less/discuss.less23
-rw-r--r--addons/mail/static/src/less/mail_activity.less9
-rw-r--r--addons/mail/static/src/xml/systray.xml23
5 files changed, 13 insertions, 171 deletions
diff --git a/addons/mail/static/src/img/reminder.png b/addons/mail/static/src/img/reminder.png
deleted file mode 100644
index a585b8d6e09..00000000000
--- a/addons/mail/static/src/img/reminder.png
+++ /dev/null
Binary files differ
diff --git a/addons/mail/static/src/js/systray.js b/addons/mail/static/src/js/systray.js
index d382745df29..5a4c8ea4675 100644
--- a/addons/mail/static/src/js/systray.js
+++ b/addons/mail/static/src/js/systray.js
@@ -3,13 +3,11 @@ odoo.define('mail.systray', function (require) {
var config = require('web.config');
var core = require('web.core');
-var datepicker = require('web.datepicker');
var session = require('web.session');
var SystrayMenu = require('web.SystrayMenu');
var Widget = require('web.Widget');
var QWeb = core.qweb;
-var _t = core._t;
/**
* Menu item appended in the systray part of the navbar
@@ -159,13 +157,8 @@ var MessagingMenu = Widget.extend({
var ActivityMenu = Widget.extend({
template:'mail.chat.ActivityMenu',
events: {
- 'click': '_onActivityMenuClick',
- 'click .o_mail_channel_preview:not(.o_reminder)': '_onActivityFilterClick',
- 'click .o_reminder_show': '_onAddReminderClick',
- 'click .o_reminder_save': '_onReminderSaveClick',
- 'click .o_reminder_set_datetime': '_onReminderDateTimeSetClick',
- 'keydown input.o_reminder_input': '_onReminderInputKeyDown',
- 'click .o_reminder': '_onNewReminderClick',
+ "click": "_onActivityMenuClick",
+ "click .o_mail_channel_preview": "_onActivityFilterClick",
},
start: function () {
this.$activities_preview = this.$('.o_mail_navbar_dropdown_channels');
@@ -191,21 +184,8 @@ var ActivityMenu = Widget.extend({
context: session.user_context,
},
}).then(function (data) {
- // We required reminder to be first always. Moving its position from n-th to zero if not at zero
- var reminderIndex = _.findIndex(data, function (val) { return val.model == null; });
- if (reminderIndex > 0) {
- data.splice(0, 0, data.splice(reminderIndex, 1)[0]);
- }
self.activities = data;
-
- //we want to add count in reminders title
- var reminders = _.findWhere(data, {'model': null});
- if (reminders) {
- var totalReminders = reminders.overdue_count + reminders.planned_count + reminders.today_count;
- //manualy count total reminders since reminders.total_count only sum today and overdue
- reminders.name = _.str.sprintf(_t('Reminders (%s)'), totalReminders);
- }
- self.activityCounter = _.reduce(self.activities, function (total_count, p_data) { return total_count + p_data.total_count; }, 0);
+ self.activityCounter = _.reduce(data, function (total_count, p_data) { return total_count + p_data.total_count; }, 0);
self.$('.o_notification_counter').text(self.activityCounter);
self.$el.toggleClass('o_no_notification', !self.activityCounter);
});
@@ -261,27 +241,6 @@ var ActivityMenu = Widget.extend({
this.$el.toggleClass('o_no_notification', !this.activityCounter);
}
},
- /**
- * Save the reminder to database using datepicker date and field as note
- * @private
- */
- _saveReminder: function () {
- var note = this.$('.o_reminder_input').val().trim();
- if (! note) {
- return;
- }
- var params = {'note': note};
- var reminderDateTime = this.reminderDateTimeWidget.getValue();
- if (reminderDateTime) {
- params = _.extend(params, {'date_deadline': reminderDateTime});
- }
- this.$('.o_reminder_show').removeClass('hidden');
- this.$('.o_reminder').addClass('hidden');
- this._rpc({
- route: '/mail/activity/new',
- params: params,
- }).then(this._updateActivityPreview.bind(this));
- },
//------------------------------------------------------------
// Handlers
//-----------------------------------------------------------
@@ -300,20 +259,15 @@ var ActivityMenu = Widget.extend({
} else {
context['search_default_activities_' + data.filter] = 1;
}
- if (data.res_model == null) {
- // Opening Reminder custom kanban view with action.
- this.do_action('mail.mail_activity_action_reminders', {additional_context: context});
- } else {
- this.do_action({
- type: 'ir.actions.act_window',
- name: data.model_name,
- res_model: data.res_model,
- views: [[false, 'kanban'], [false, 'form']],
- search_view_id: [false],
- domain: [['activity_user_id', '=', session.uid]],
- context:context,
- });
- }
+ this.do_action({
+ type: 'ir.actions.act_window',
+ name: data.model_name,
+ res_model: data.res_model,
+ views: [[false, 'kanban'], [false, 'form']],
+ search_view_id: [false],
+ domain: [['activity_user_id', '=', session.uid]],
+ context:context,
+ });
},
/**
* When menu clicked update activity preview if counter updated
@@ -325,65 +279,6 @@ var ActivityMenu = Widget.extend({
this._updateActivityPreview();
}
},
- /**
- * When add new reminder button clicked, toggling quick reminder create view inside
- * Systray activity view
- *
- * @private
- * @param {MouseEvent} event
- */
- _onAddReminderClick: function (event) {
- event.stopPropagation();
- if (!this.reminderDateTimeWidget){
- this.reminderDateTimeWidget = new datepicker.DateWidget(this, {useCurrent: true});
- }
- this.reminderDateTimeWidget.appendTo(this.$('.o_reminder_datetime'));
- this.$('.o_reminder_show, .o_reminder').toggleClass('hidden');
- this.$('.o_reminder_input').val('').focus();
-
- },
- /**
- * When focusing on input for new quick reminder systerm tray must be open.
- * Preventing to close
- *
- * @private
- * @param {MouseEvent} event
- */
- _onNewReminderClick: function (event) {
- event.stopPropagation();
- },
- /**
- * Opens datetime picker for reminder.
- * Quick FIX due to no option for set custom icon instead of caret in datepicker.
- *
- * @private
- * @param {MouseEvent} event
- */
- _onReminderDateTimeSetClick: function (event) {
- event.preventDefault();
- event.stopPropagation();
- this.reminderDateTimeWidget.$input.click();
- },
- /**
- * Saving reminder (quick create) and updating activity preview
- *
- * @private
- * @param {MouseEvent} event
- */
- _onReminderSaveClick: function (event) {
- this._saveReminder();
- },
- /**
- * Handling Enter key for quick create reminder.
- *
- * @private
- * @param {KeyboardEvent} event
- */
- _onReminderInputKeyDown: function (event) {
- if (event.which === $.ui.keyCode.ENTER) {
- this._saveReminder();
- }
- },
});
SystrayMenu.Items.push(MessagingMenu);
diff --git a/addons/mail/static/src/less/discuss.less b/addons/mail/static/src/less/discuss.less
index b2bfc6236c8..4e0ae26dccc 100644
--- a/addons/mail/static/src/less/discuss.less
+++ b/addons/mail/static/src/less/discuss.less
@@ -391,7 +391,7 @@
.o_channel_title {
.o-flex-display();
.o_channel_name {
- .o-flex(1, 1, auto);
+ .o-flex(0, 1, auto);
.o-text-overflow();
}
.o_channel_counter {
@@ -428,27 +428,6 @@
}
}
-.o_reminder.o_mail_channel_preview {
- background-color: white;
- .o_reminder_input {
- border: none;
- }
- .o_reminder_datetime {
- .o_datepicker {
- .o_datepicker_input {
- float: right;
- text-align: right;
- border: none;
- font-size: 11px;
- width: 50%;
- }
- .o_datepicker_button {
- display: none;
- }
- }
- }
-}
-
@media (max-width: @screen-xs-max) {
@o-mail-chatter-mobile-gap: 2%;
diff --git a/addons/mail/static/src/less/mail_activity.less b/addons/mail/static/src/less/mail_activity.less
index f98e0974b7b..5f1320ce402 100644
--- a/addons/mail/static/src/less/mail_activity.less
+++ b/addons/mail/static/src/less/mail_activity.less
@@ -132,15 +132,6 @@
.o_kanban_inline_block {
display: inline-block;
}
- .o_text_line_through {
- text-decoration: line-through;
- }
- .o_reminder_title {
- text-overflow: ellipsis;
- white-space: nowrap;
- overflow: hidden;
- padding-bottom: 10px;
- }
.o_mail_activity {
.o_activity_btn {
span.fa {
diff --git a/addons/mail/static/src/xml/systray.xml b/addons/mail/static/src/xml/systray.xml
index e70d36ed4c1..dd61c486b9b 100644
--- a/addons/mail/static/src/xml/systray.xml
+++ b/addons/mail/static/src/xml/systray.xml
@@ -80,29 +80,6 @@
</div>
</div>
</t>
- <div class="o_reminder_show">
- <a class="btn btn-block text-center">Add new reminder</a>
- </div>
- <div class="o_reminder o_mail_channel_preview hidden">
- <div class="o_mail_channel_image o_mail_channel_app">
- <img src="/mail/static/src/img/reminder.png"/>
- </div>
- <div class="o_channel_info">
- <div class="o_channel_title">
- <span class="o_channel_name"><strong>Set a reminder</strong></span>
- <div class="o_reminder_datetime"/>
- <span class="ml4">
- <a class="o_reminder_set_datetime text-muted">
- <span class="fa fa-clock-o"/>
- </a>
- </span>
- <span class="ml8 mr4">
- <a class="o_reminder_save">SAVE</a>
- </span>
- </div>
- <p><input class="o_reminder_input" type="text" placeholder="Remember..." /></p>
- </div>
- </div>
</t>
<t t-name="mail.chat.ActivityMenu">