From b9099a8b7ea6f63c79bdcbb871cb993b2cb7e325 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Tue, 24 Mar 2020 20:39:49 +0200 Subject: 1) Fix Pasting text into a card is adding a line before and after (and multiplies by pasting more) by changing paste "p" to "br". 2) Fixes to summernote and markdown comment editors, related to keeping them open when adding comments, having @member mention not close card, and disabling clicking of @member mention. Thanks to xet7 ! Closes #2890 --- client/lib/popup.js | 204 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 204 insertions(+) (limited to 'client/lib') diff --git a/client/lib/popup.js b/client/lib/popup.js index 8095fbd2..8a55c2df 100644 --- a/client/lib/popup.js +++ b/client/lib/popup.js @@ -206,3 +206,207 @@ escapeActions.forEach(actionName => { }, ); }); + +// Prevent @member mentions on Add Comment input field +// from closing card, part 5. +// This duplicate below of above popup function is needed, because at +// wekan/components/main/editor.js at bottom is popping up visible +// @member mention, and it seems to trigger closing also card popup, +// so in below closing popup is disabled. +window.PopupNoClose = new (class { + constructor() { + // The template we use to render popups + this.template = Template.popup; + + // We only want to display one popup at a time and we keep the view object + // in this `Popup.current` variable. If there is no popup currently opened + // the value is `null`. + this.current = null; + + // It's possible to open a sub-popup B from a popup A. In that case we keep + // the data of popup A so we can return back to it. Every time we open a new + // popup the stack grows, every time we go back the stack decrease, and if + // we close the popup the stack is reseted to the empty stack []. + this._stack = []; + + // We invalidate this internal dependency every time the top of the stack + // has changed and we want to re-render a popup with the new top-stack data. + this._dep = new Tracker.Dependency(); + } + + /// This function returns a callback that can be used in an event map: + /// Template.tplName.events({ + /// 'click .elementClass': Popup.open("popupName"), + /// }); + /// The popup inherit the data context of its parent. + open(name) { + const self = this; + const popupName = `${name}Popup`; + function clickFromPopup(evt) { + return $(evt.target).closest('.js-pop-over').length !== 0; + } + return function(evt) { + // If a popup is already opened, clicking again on the opener element + // should close it -- and interrupt the current `open` function. + /* + if (self.isOpen()) { + const previousOpenerElement = self._getTopStack().openerElement; + if (previousOpenerElement === evt.currentTarget) { + self.close(); + return; + } else { + $(previousOpenerElement).removeClass('is-active'); + } + } + */ + // We determine the `openerElement` (the DOM element that is being clicked + // and the one we take in reference to position the popup) from the event + // if the popup has no parent, or from the parent `openerElement` if it + // has one. This allows us to position a sub-popup exactly at the same + // position than its parent. + let openerElement; + if (clickFromPopup(evt)) { + openerElement = self._getTopStack().openerElement; + } else { + self._stack = []; + openerElement = evt.currentTarget; + } + $(openerElement).addClass('is-active'); + evt.preventDefault(); + + // We push our popup data to the stack. The top of the stack is always + // used as the data source for our current popup. + self._stack.push({ + popupName, + openerElement, + hasPopupParent: clickFromPopup(evt), + title: self._getTitle(popupName), + depth: self._stack.length, + offset: self._getOffset(openerElement), + dataContext: (this && this.currentData && this.currentData()) || this, + }); + + // If there are no popup currently opened we use the Blaze API to render + // one into the DOM. We use a reactive function as the data parameter that + // return the complete along with its top element and depends on our + // internal dependency that is being invalidated every time the top + // element of the stack has changed and we want to update the popup. + // + // Otherwise if there is already a popup open we just need to invalidate + // our internal dependency, and since we just changed the top element of + // our internal stack, the popup will be updated with the new data. + if (!self.isOpen()) { + self.current = Blaze.renderWithData( + self.template, + () => { + self._dep.depend(); + return { ...self._getTopStack(), stack: self._stack }; + }, + document.body, + ); + } else { + self._dep.changed(); + } + }; + } + + /// This function returns a callback that can be used in an event map: + /// Template.tplName.events({ + /// 'click .elementClass': Popup.afterConfirm("popupName", function() { + /// // What to do after the user has confirmed the action + /// }), + /// }); + afterConfirm(name, action) { + const self = this; + + return function(evt, tpl) { + const context = (this.currentData && this.currentData()) || this; + context.__afterConfirmAction = action; + self.open(name).call(context, evt, tpl); + }; + } + + /// The public reactive state of the popup. + isOpen() { + this._dep.changed(); + return Boolean(this.current); + } + + /// In case the popup was opened from a parent popup we can get back to it + /// with this `Popup.back()` function. You can go back several steps at once + /// by providing a number to this function, e.g. `Popup.back(2)`. In this case + /// intermediate popup won't even be rendered on the DOM. If the number of + /// steps back is greater than the popup stack size, the popup will be closed. + back(n = 1) { + if (this._stack.length > n) { + _.times(n, () => this._stack.pop()); + this._dep.changed(); + } + // else { + // this.close(); + //} + } + + /// Close the current opened popup. + /* + close() { + if (this.isOpen()) { + Blaze.remove(this.current); + this.current = null; + + const openerElement = this._getTopStack().openerElement; + $(openerElement).removeClass('is-active'); + + this._stack = []; + } + } + */ + + getOpenerComponent() { + const { openerElement } = Template.parentData(4); + return BlazeComponent.getComponentForElement(openerElement); + } + + // An utility fonction that returns the top element of the internal stack + _getTopStack() { + return this._stack[this._stack.length - 1]; + } + + // We automatically calculate the popup offset from the reference element + // position and dimensions. We also reactively use the window dimensions to + // ensure that the popup is always visible on the screen. + _getOffset(element) { + const $element = $(element); + return () => { + Utils.windowResizeDep.depend(); + + if (Utils.isMiniScreen()) return { left: 0, top: 0 }; + + const offset = $element.offset(); + const popupWidth = 300 + 15; + return { + left: Math.min(offset.left, $(window).width() - popupWidth), + top: offset.top + $element.outerHeight(), + }; + }; + } + + // We get the title from the translation files. Instead of returning the + // result, we return a function that compute the result and since `TAPi18n.__` + // is a reactive data source, the title will be changed reactively. + _getTitle(popupName) { + return () => { + const translationKey = `${popupName}-title`; + + // XXX There is no public API to check if there is an available + // translation for a given key. So we try to translate the key and if the + // translation output equals the key input we deduce that no translation + // was available and returns `false`. There is a (small) risk a false + // positives. + const title = TAPi18n.__(translationKey); + // when popup showed as full of small screen, we need a default header to clearly see [X] button + const defaultTitle = Utils.isMiniScreen() ? '' : false; + return title !== translationKey ? title : defaultTitle; + }; + } +})(); -- cgit v1.2.3-1-g7c22 From 3546d7aa02bc65cf1183cb493adeb543ba51945d Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Tue, 31 Mar 2020 16:56:32 +0300 Subject: Fix Browser always reload the whole page when I change one of the card color. Fixed by making label colors and text again editable. Regression from [Wekan v3.86 2)](https://github.com/wekan/wekan/commit/b9099a8b7ea6f63c79bdcbb871cb993b2cb7e325). Thanks to javen9881 and xet7 ! Closes #2971 --- client/lib/popup.js | 204 ---------------------------------------------------- 1 file changed, 204 deletions(-) (limited to 'client/lib') diff --git a/client/lib/popup.js b/client/lib/popup.js index 8a55c2df..8095fbd2 100644 --- a/client/lib/popup.js +++ b/client/lib/popup.js @@ -206,207 +206,3 @@ escapeActions.forEach(actionName => { }, ); }); - -// Prevent @member mentions on Add Comment input field -// from closing card, part 5. -// This duplicate below of above popup function is needed, because at -// wekan/components/main/editor.js at bottom is popping up visible -// @member mention, and it seems to trigger closing also card popup, -// so in below closing popup is disabled. -window.PopupNoClose = new (class { - constructor() { - // The template we use to render popups - this.template = Template.popup; - - // We only want to display one popup at a time and we keep the view object - // in this `Popup.current` variable. If there is no popup currently opened - // the value is `null`. - this.current = null; - - // It's possible to open a sub-popup B from a popup A. In that case we keep - // the data of popup A so we can return back to it. Every time we open a new - // popup the stack grows, every time we go back the stack decrease, and if - // we close the popup the stack is reseted to the empty stack []. - this._stack = []; - - // We invalidate this internal dependency every time the top of the stack - // has changed and we want to re-render a popup with the new top-stack data. - this._dep = new Tracker.Dependency(); - } - - /// This function returns a callback that can be used in an event map: - /// Template.tplName.events({ - /// 'click .elementClass': Popup.open("popupName"), - /// }); - /// The popup inherit the data context of its parent. - open(name) { - const self = this; - const popupName = `${name}Popup`; - function clickFromPopup(evt) { - return $(evt.target).closest('.js-pop-over').length !== 0; - } - return function(evt) { - // If a popup is already opened, clicking again on the opener element - // should close it -- and interrupt the current `open` function. - /* - if (self.isOpen()) { - const previousOpenerElement = self._getTopStack().openerElement; - if (previousOpenerElement === evt.currentTarget) { - self.close(); - return; - } else { - $(previousOpenerElement).removeClass('is-active'); - } - } - */ - // We determine the `openerElement` (the DOM element that is being clicked - // and the one we take in reference to position the popup) from the event - // if the popup has no parent, or from the parent `openerElement` if it - // has one. This allows us to position a sub-popup exactly at the same - // position than its parent. - let openerElement; - if (clickFromPopup(evt)) { - openerElement = self._getTopStack().openerElement; - } else { - self._stack = []; - openerElement = evt.currentTarget; - } - $(openerElement).addClass('is-active'); - evt.preventDefault(); - - // We push our popup data to the stack. The top of the stack is always - // used as the data source for our current popup. - self._stack.push({ - popupName, - openerElement, - hasPopupParent: clickFromPopup(evt), - title: self._getTitle(popupName), - depth: self._stack.length, - offset: self._getOffset(openerElement), - dataContext: (this && this.currentData && this.currentData()) || this, - }); - - // If there are no popup currently opened we use the Blaze API to render - // one into the DOM. We use a reactive function as the data parameter that - // return the complete along with its top element and depends on our - // internal dependency that is being invalidated every time the top - // element of the stack has changed and we want to update the popup. - // - // Otherwise if there is already a popup open we just need to invalidate - // our internal dependency, and since we just changed the top element of - // our internal stack, the popup will be updated with the new data. - if (!self.isOpen()) { - self.current = Blaze.renderWithData( - self.template, - () => { - self._dep.depend(); - return { ...self._getTopStack(), stack: self._stack }; - }, - document.body, - ); - } else { - self._dep.changed(); - } - }; - } - - /// This function returns a callback that can be used in an event map: - /// Template.tplName.events({ - /// 'click .elementClass': Popup.afterConfirm("popupName", function() { - /// // What to do after the user has confirmed the action - /// }), - /// }); - afterConfirm(name, action) { - const self = this; - - return function(evt, tpl) { - const context = (this.currentData && this.currentData()) || this; - context.__afterConfirmAction = action; - self.open(name).call(context, evt, tpl); - }; - } - - /// The public reactive state of the popup. - isOpen() { - this._dep.changed(); - return Boolean(this.current); - } - - /// In case the popup was opened from a parent popup we can get back to it - /// with this `Popup.back()` function. You can go back several steps at once - /// by providing a number to this function, e.g. `Popup.back(2)`. In this case - /// intermediate popup won't even be rendered on the DOM. If the number of - /// steps back is greater than the popup stack size, the popup will be closed. - back(n = 1) { - if (this._stack.length > n) { - _.times(n, () => this._stack.pop()); - this._dep.changed(); - } - // else { - // this.close(); - //} - } - - /// Close the current opened popup. - /* - close() { - if (this.isOpen()) { - Blaze.remove(this.current); - this.current = null; - - const openerElement = this._getTopStack().openerElement; - $(openerElement).removeClass('is-active'); - - this._stack = []; - } - } - */ - - getOpenerComponent() { - const { openerElement } = Template.parentData(4); - return BlazeComponent.getComponentForElement(openerElement); - } - - // An utility fonction that returns the top element of the internal stack - _getTopStack() { - return this._stack[this._stack.length - 1]; - } - - // We automatically calculate the popup offset from the reference element - // position and dimensions. We also reactively use the window dimensions to - // ensure that the popup is always visible on the screen. - _getOffset(element) { - const $element = $(element); - return () => { - Utils.windowResizeDep.depend(); - - if (Utils.isMiniScreen()) return { left: 0, top: 0 }; - - const offset = $element.offset(); - const popupWidth = 300 + 15; - return { - left: Math.min(offset.left, $(window).width() - popupWidth), - top: offset.top + $element.outerHeight(), - }; - }; - } - - // We get the title from the translation files. Instead of returning the - // result, we return a function that compute the result and since `TAPi18n.__` - // is a reactive data source, the title will be changed reactively. - _getTitle(popupName) { - return () => { - const translationKey = `${popupName}-title`; - - // XXX There is no public API to check if there is an available - // translation for a given key. So we try to translate the key and if the - // translation output equals the key input we deduce that no translation - // was available and returns `false`. There is a (small) risk a false - // positives. - const title = TAPi18n.__(translationKey); - // when popup showed as full of small screen, we need a default header to clearly see [X] button - const defaultTitle = Utils.isMiniScreen() ? '' : false; - return title !== translationKey ? title : defaultTitle; - }; - } -})(); -- cgit v1.2.3-1-g7c22 From fe285c62e12486a8848376531c89d7a4b11b7fa7 Mon Sep 17 00:00:00 2001 From: Daniel Eder Date: Wed, 8 Apr 2020 16:54:11 +0300 Subject: Add filter option for assignee Works exactly like member --- client/lib/filter.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'client/lib') diff --git a/client/lib/filter.js b/client/lib/filter.js index 592eb4ab..24ca320b 100644 --- a/client/lib/filter.js +++ b/client/lib/filter.js @@ -459,13 +459,21 @@ Filter = { // before changing the schema. labelIds: new SetFilter(), members: new SetFilter(), + assignees: new SetFilter(), archive: new SetFilter(), hideEmpty: new SetFilter(), customFields: new SetFilter('_id'), advanced: new AdvancedFilter(), lists: new AdvancedFilter(), // we need the ability to filter list by name as well - _fields: ['labelIds', 'members', 'archive', 'hideEmpty', 'customFields'], + _fields: [ + 'labelIds', + 'members', + 'assignees', + 'archive', + 'hideEmpty', + 'customFields', + ], // We don't filter cards that have been added after the last filter change. To // implement this we keep the id of these cards in this `_exceptions` fields -- cgit v1.2.3-1-g7c22 From 3ac5dba243a9896adc5db6fdc586c8b1768f2df9 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Wed, 22 Apr 2020 14:41:27 +0200 Subject: Set first day of the week to Monday --- client/lib/datepicker.js | 1 + 1 file changed, 1 insertion(+) (limited to 'client/lib') diff --git a/client/lib/datepicker.js b/client/lib/datepicker.js index 8ad66c5f..1c02c2ff 100644 --- a/client/lib/datepicker.js +++ b/client/lib/datepicker.js @@ -16,6 +16,7 @@ DatePicker = BlazeComponent.extendComponent({ todayHighlight: true, todayBtn: 'linked', language: TAPi18n.getLanguage(), + weekStart: 1, }) .on( 'changeDate', -- cgit v1.2.3-1-g7c22 From 8e14459cff4da1391f536dfbc6441abb21e9c215 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Wed, 22 Apr 2020 14:44:08 +0200 Subject: Implement option to change the first day of week in user settings Implements #2535. --- client/lib/datepicker.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'client/lib') diff --git a/client/lib/datepicker.js b/client/lib/datepicker.js index 1c02c2ff..aa05310c 100644 --- a/client/lib/datepicker.js +++ b/client/lib/datepicker.js @@ -10,13 +10,22 @@ DatePicker = BlazeComponent.extendComponent({ this.defaultTime = defaultTime; }, + startDayOfWeek() { + const currentUser = Meteor.user(); + if (currentUser) { + return currentUser.getStartDayOfWeek(); + } else { + return 1; + } + }, + onRendered() { const $picker = this.$('.js-datepicker') .datepicker({ todayHighlight: true, todayBtn: 'linked', language: TAPi18n.getLanguage(), - weekStart: 1, + weekStart: this.startDayOfWeek(), }) .on( 'changeDate', -- cgit v1.2.3-1-g7c22 From 1c488cb8a7f8a226f1f38575fa32822fedab1067 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Wed, 29 Apr 2020 15:06:27 +0200 Subject: Fix shortcuts mapping in the shortcuts list Shorcuts are case-sensitive therefore let's fix the keys in the shortcuts list. --- client/lib/keyboard.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'client/lib') diff --git a/client/lib/keyboard.js b/client/lib/keyboard.js index da33f806..055eec18 100755 --- a/client/lib/keyboard.js +++ b/client/lib/keyboard.js @@ -97,19 +97,19 @@ Mousetrap.bind('c', evt => { Template.keyboardShortcuts.helpers({ mapping: [ { - keys: ['W'], + keys: ['w'], action: 'shortcut-toggle-sidebar', }, { - keys: ['Q'], + keys: ['q'], action: 'shortcut-filter-my-cards', }, { - keys: ['F'], + keys: ['f'], action: 'shortcut-toggle-filterbar', }, { - keys: ['X'], + keys: ['x'], action: 'shortcut-clear-filters', }, { @@ -129,7 +129,7 @@ Template.keyboardShortcuts.helpers({ action: 'shortcut-assign-self', }, { - keys: ['C'], + keys: ['c'], action: 'archive-card', }, ], -- cgit v1.2.3-1-g7c22 From 301d96f3924d1b59912cfc85cb8e84a8c3f28d1e Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Wed, 29 Apr 2020 15:07:08 +0200 Subject: Support card shortcuts when hovering a card --- client/lib/keyboard.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'client/lib') diff --git a/client/lib/keyboard.js b/client/lib/keyboard.js index 055eec18..e861e416 100755 --- a/client/lib/keyboard.js +++ b/client/lib/keyboard.js @@ -1,6 +1,16 @@ // XXX There is no reason to define these shortcuts globally, they should be // attached to a template (most of them will go in the `board` template). +function getHoveredCardId() { + const card = $('.js-minicard:hover').get(0); + if (!card) return null; + return Blaze.getData(card)._id; +} + +function getSelectedCardId() { + return Session.get('selectedCard') || getHoveredCardId(); +} + Mousetrap.bind('?', () => { FlowRouter.go('shortcuts'); }); @@ -50,9 +60,9 @@ Mousetrap.bind(['down', 'up'], (evt, key) => { } }); -// XXX This shortcut should also work when hovering over a card in board view Mousetrap.bind('space', evt => { - if (!Session.get('currentCard')) { + const cardId = getSelectedCardId(); + if (!cardId) { return; } @@ -62,7 +72,7 @@ Mousetrap.bind('space', evt => { } if (Meteor.user().isBoardMember()) { - const card = Cards.findOne(Session.get('currentCard')); + const card = Cards.findOne(cardId); card.toggleMember(currentUserId); // We should prevent scrolling in card when spacebar is clicked // This should do it according to Mousetrap docs, but it doesn't @@ -70,9 +80,9 @@ Mousetrap.bind('space', evt => { } }); -// XXX This shortcut should also work when hovering over a card in board view Mousetrap.bind('c', evt => { - if (!Session.get('currentCard')) { + const cardId = getSelectedCardId(); + if (!cardId) { return; } @@ -86,7 +96,7 @@ Mousetrap.bind('c', evt => { !Meteor.user().isCommentOnly() && !Meteor.user().isWorker() ) { - const card = Cards.findOne(Session.get('currentCard')); + const card = Cards.findOne(cardId); card.archive(); // We should prevent scrolling in card when spacebar is clicked // This should do it according to Mousetrap docs, but it doesn't -- cgit v1.2.3-1-g7c22