summaryrefslogtreecommitdiff
path: root/addons/note/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/note/static/src')
-rw-r--r--addons/note/static/src/js/systray_activity_menu.js149
-rw-r--r--addons/note/static/src/scss/note.scss63
-rw-r--r--addons/note/static/src/xml/systray.xml32
3 files changed, 244 insertions, 0 deletions
diff --git a/addons/note/static/src/js/systray_activity_menu.js b/addons/note/static/src/js/systray_activity_menu.js
new file mode 100644
index 00000000..ac4054c0
--- /dev/null
+++ b/addons/note/static/src/js/systray_activity_menu.js
@@ -0,0 +1,149 @@
+odoo.define('note.systray.ActivityMenu', function (require) {
+"use strict";
+
+var ActivityMenu = require('mail.systray.ActivityMenu');
+
+var core = require('web.core');
+var datepicker = require('web.datepicker');
+
+var _t = core._t;
+
+ActivityMenu.include({
+ events: _.extend({}, ActivityMenu.prototype.events, {
+ 'click .o_note_show': '_onAddNoteClick',
+ 'click .o_note_save': '_onNoteSaveClick',
+ 'click .o_note_set_datetime': '_onNoteDateTimeSetClick',
+ 'keydown input.o_note_input': '_onNoteInputKeyDown',
+ 'click .o_note': '_onNewNoteClick',
+ }),
+ //--------------------------------------------------
+ // Private
+ //--------------------------------------------------
+ /**
+ * Moving notes at first place
+ * @override
+ */
+ _getActivityData: function () {
+ var self = this;
+ return this._super.apply(this, arguments).then(function () {
+ var reminderIndex = _.findIndex(self.activities, function (val) {
+ return val.model === 'note.note';
+ });
+ if (reminderIndex > 0) {
+ self.activities.splice(0, 0, self.activities.splice(reminderIndex, 1)[0]);
+ }
+ });
+ },
+ /**
+ * Save the note to database using datepicker date and field as note
+ * By default, when no datetime is set, it uses the current datetime.
+ *
+ * @private
+ */
+ _saveNote: function () {
+ var note = this.$('.o_note_input').val().trim();
+ if (! note) {
+ return;
+ }
+ var params = {'note': note};
+ var noteDateTime = this.noteDateTimeWidget.getValue();
+ if (noteDateTime) {
+ params = _.extend(params, {'date_deadline': noteDateTime});
+ } else {
+ params = _.extend(params, {'date_deadline': moment()});
+ }
+ this.$('.o_note_show').removeClass('d-none');
+ this.$('.o_note').addClass('d-none');
+ this._rpc({
+ route: '/note/new',
+ params: params,
+ }).then(this._updateActivityPreview.bind(this));
+ },
+ //-----------------------------------------
+ // Handlers
+ //-----------------------------------------
+ /**
+ * @override
+ */
+ _onActivityFilterClick: function (ev) {
+ var $el = $(ev.currentTarget);
+ if (!$el.hasClass("o_note")) {
+ var data = _.extend({}, $el.data(), $(ev.target).data());
+ if (data.res_model === "note.note" && data.filter === "my") {
+ this.do_action({
+ type: 'ir.actions.act_window',
+ name: data.model_name,
+ res_model: data.res_model,
+ views: [[false, 'kanban'], [false, 'form'], [false, 'list']]
+ }, {
+ clear_breadcrumbs: true,
+ });
+ } else {
+ this._super.apply(this, arguments);
+ }
+ }
+ },
+ /**
+ * When add new note button clicked, toggling quick note create view inside
+ * Systray activity view
+ *
+ * @private
+ * @param {MouseEvent} ev
+ */
+ _onAddNoteClick: function (ev) {
+ var self = this;
+ ev.stopPropagation();
+ if (!this.noteDateTimeWidget){
+ this.noteDateTimeWidget = new datepicker.DateWidget(this, {useCurrent: true});
+ }
+ this.noteDateTimeWidget.appendTo(this.$('.o_note_datetime')).then(function() {
+ self.noteDateTimeWidget.$input.attr('placeholder', _t("Today"));
+ self.noteDateTimeWidget.setValue(false);
+ self.$('.o_note_show, .o_note').toggleClass('d-none');
+ self.$('.o_note_input').val('').focus();
+ });
+ },
+ /**
+ * When focusing on input for new quick note systerm tray must be open.
+ * Preventing to close
+ *
+ * @private
+ * @param {MouseEvent} ev
+ */
+ _onNewNoteClick: function (ev) {
+ ev.stopPropagation();
+ },
+ /**
+ * Opens datetime picker for note.
+ * Quick FIX due to no option for set custom icon instead of caret in datepicker.
+ *
+ * @private
+ * @param {MouseEvent} ev
+ */
+ _onNoteDateTimeSetClick: function (ev) {
+ ev.preventDefault();
+ ev.stopPropagation();
+ this.noteDateTimeWidget.$input.click();
+ },
+ /**
+ * Saving note (quick create) and updating activity preview
+ *
+ * @private
+ * @param {MouseEvent} ev
+ */
+ _onNoteSaveClick: function (ev) {
+ this._saveNote();
+ },
+ /**
+ * Handling Enter key for quick create note.
+ *
+ * @private
+ * @param {KeyboardEvent} ev
+ */
+ _onNoteInputKeyDown: function (ev) {
+ if (ev.which === $.ui.keyCode.ENTER) {
+ this._saveNote();
+ }
+ },
+});
+});
diff --git a/addons/note/static/src/scss/note.scss b/addons/note/static/src/scss/note.scss
new file mode 100644
index 00000000..2e15d5de
--- /dev/null
+++ b/addons/note/static/src/scss/note.scss
@@ -0,0 +1,63 @@
+
+.o_kanban_group .note_text_line_through {
+ text-decoration: line-through;
+}
+
+.o_note_form_view.o_form_view {
+ .o_form_statusbar {
+ margin-bottom: 0;
+ }
+ .oe_form_field.oe_memo {
+ margin: 0;
+ padding: 0;
+ min-height: 200px;
+ }
+ &.o_form_readonly {
+ .oe_memo {
+ padding: $input-btn-padding-x-lg;
+ border-bottom: 1px solid gray('300');
+ }
+ }
+}
+
+// Quick create notes from systray
+.o_note.o_mail_preview {
+ background-color: white;
+ .o_preview_info {
+ .o_preview_title {
+ .o_preview_name {
+ flex: 1 1 100%;
+ }
+ }
+ .o_note_input_box {
+ display: flex;
+ p {
+ flex: 1 1 auto;
+ margin-bottom: 0px;
+ }
+ }
+ .o_note_save {
+ font-size: 11px;
+ font-weight: bold;
+ }
+ }
+ .o_note_input {
+ border: none;
+ }
+ .o_note_datetime {
+ .o_datepicker {
+ .o_datepicker_input {
+ float: right;
+ text-align: right;
+ border: none;
+ font-size: 11px;
+ }
+ .o_datepicker_button {
+ display: none;
+ }
+ }
+ }
+ .o_note_set_datetime {
+ color: $text-muted;
+ }
+}
diff --git a/addons/note/static/src/xml/systray.xml b/addons/note/static/src/xml/systray.xml
new file mode 100644
index 00000000..8f0e953d
--- /dev/null
+++ b/addons/note/static/src/xml/systray.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates>
+ <t t-extend="mail.systray.ActivityMenu.Previews">
+ <t t-jquery="t[t-foreach*='activities'][t-as*='activity']" t-operation="after">
+ <div class="o_note_show">
+ <a role="button" class="btn btn-block text-center">Add new note</a>
+ </div>
+ <div class="o_note o_mail_preview d-none">
+ <div class="o_mail_preview_image o_mail_preview_app">
+ <img src="/note/static/description/icon.png" alt="Channel"/>
+ </div>
+ <div class="o_preview_info">
+ <div class="o_preview_title">
+ <span class="o_preview_name"><strong>Add a note</strong></span>
+ <div class="o_note_datetime"/>
+ <span class="ml4">
+ <a class="o_note_set_datetime">
+ <span class="fa fa-calendar" role="img" aria-label="Set date and time" title="Set date and time"/>
+ </a>
+ </span>
+ </div>
+ <div class="o_note_input_box">
+ <p><input class="o_note_input" type="text" placeholder="Remember..." /></p>
+ <span class="ml8 mr4">
+ <a class="o_note_save">SAVE</a>
+ </span>
+ </div>
+ </div>
+ </div>
+ </t>
+ </t>
+</templates>