From 3b9f2ca7c2fffa230bb0c6d4254a88deb9fbb023 Mon Sep 17 00:00:00 2001 From: Justin Reynolds Date: Thu, 5 Sep 2019 12:29:45 -0500 Subject: Fixes #2596 incorrect date types for created & updated --- models/users.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'models/users.js') diff --git a/models/users.js b/models/users.js index 55d85e07..ee53c7ab 100644 --- a/models/users.js +++ b/models/users.js @@ -54,6 +54,8 @@ Users.attachSchema( autoValue() { if (this.isInsert) { return new Date(); + } else if (this.isUpsert) { + return { $setOnInsert: new Date() }; } else { this.unset(); } -- cgit v1.2.3-1-g7c22 From 03d7fc02ecc90690e1282d417f35b7e4561af066 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Tue, 17 Sep 2019 01:39:10 +0300 Subject: Drag handles. In Progress. --- models/users.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'models/users.js') diff --git a/models/users.js b/models/users.js index ee53c7ab..ded864e5 100644 --- a/models/users.js +++ b/models/users.js @@ -109,6 +109,13 @@ Users.attachSchema( type: String, optional: true, }, + 'profile.showDesktopDragHandles': { + /** + * does the user want to hide system messages? + */ + type: Boolean, + optional: true, + }, 'profile.hiddenSystemMessages': { /** * does the user want to hide system messages? @@ -368,6 +375,11 @@ Users.helpers({ return _.contains(notifications, activityId); }, + hasShowDesktopDragHandles() { + const profile = this.profile || {}; + return profile.showDesktopDragHandles || false; + }, + hasHiddenSystemMessages() { const profile = this.profile || {}; return profile.hiddenSystemMessages || false; @@ -473,6 +485,14 @@ Users.mutations({ else this.addTag(tag); }, + toggleDesktopHandles(value = false) { + return { + $set: { + 'profile.showDesktopDragHandles': !value, + }, + }; + }, + toggleSystem(value = false) { return { $set: { @@ -548,6 +568,10 @@ Meteor.methods({ Users.update(userId, { $set: { username } }); } }, + toggleDesktopDragHandles() { + const user = Meteor.user(); + user.toggleDesktopHandles(user.hasShowDesktopDragHandles()); + }, toggleSystemMessages() { const user = Meteor.user(); user.toggleSystem(user.hasHiddenSystemMessages()); -- cgit v1.2.3-1-g7c22 From a37723f8a48277a152e4ef1fa2a42e6bb986b3a9 Mon Sep 17 00:00:00 2001 From: "Sam X. Chen" Date: Sat, 21 Sep 2019 15:32:21 -0400 Subject: Fixing method in users.js didn't have check userId --- models/users.js | 1 + 1 file changed, 1 insertion(+) (limited to 'models/users.js') diff --git a/models/users.js b/models/users.js index ee53c7ab..9147322c 100644 --- a/models/users.js +++ b/models/users.js @@ -541,6 +541,7 @@ Users.mutations({ Meteor.methods({ setUsername(username, userId) { check(username, String); + check(userId, String); const nUsersWithUsername = Users.find({ username }).count(); if (nUsersWithUsername > 0) { throw new Meteor.Error('username-already-taken'); -- cgit v1.2.3-1-g7c22 From bc2a20f04e32607f8488a9cecd815647fb43e40e Mon Sep 17 00:00:00 2001 From: "Sam X. Chen" Date: Fri, 18 Oct 2019 16:44:09 -0400 Subject: Add Feature: allow user to sort Lists in Board by his own preference, boardadmin can star list --- models/users.js | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'models/users.js') diff --git a/models/users.js b/models/users.js index 93fb409e..83a224ba 100644 --- a/models/users.js +++ b/models/users.js @@ -4,6 +4,16 @@ const isSandstorm = Meteor.settings && Meteor.settings.public && Meteor.settings.public.sandstorm; Users = Meteor.users; +const allowedSortValues = [ + '-modifiedAt', + 'modifiedAt', + '-title', + 'title', + '-sort', + 'sort', +]; +const defaultSortBy = allowedSortValues[0]; + /** * A User in wekan */ @@ -191,6 +201,15 @@ Users.attachSchema( 'board-view-cal', ], }, + 'profile.listSortBy': { + /** + * default sort list for user + */ + type: String, + optional: true, + defaultValue: defaultSortBy, + allowedValues: allowedSortValues, + }, 'profile.templatesBoardId': { /** * Reference to the templates board @@ -365,6 +384,31 @@ Users.helpers({ return _.contains(invitedBoards, boardId); }, + _getListSortBy() { + const profile = this.profile || {}; + const sortBy = profile.listSortBy || defaultSortBy; + const keyPattern = /^(-{0,1})(.*$)/; + const ret = []; + if (keyPattern.exec(sortBy)) { + ret[0] = RegExp.$2; + ret[1] = RegExp.$1 ? -1 : 1; + } + return ret; + }, + hasSortBy() { + // if use doesn't have dragHandle, then we can let user to choose sort list by different order + return !this.hasShowDesktopDragHandles(); + }, + getListSortBy() { + return this._getListSortBy()[0]; + }, + getListSortTypes() { + return allowedSortValues; + }, + getListSortByDirection() { + return this._getListSortBy()[1]; + }, + hasTag(tag) { const { tags = [] } = this.profile || {}; return _.contains(tags, tag); @@ -485,6 +529,13 @@ Users.mutations({ else this.addTag(tag); }, + setListSortBy(value) { + return { + $set: { + 'profile.listSortBy': value, + }, + }; + }, toggleDesktopHandles(value = false) { return { $set: { @@ -569,6 +620,10 @@ Meteor.methods({ Users.update(userId, { $set: { username } }); } }, + setListSortBy(value) { + check(value, String); + Meteor.user().setListSortBy(value); + }, toggleDesktopDragHandles() { const user = Meteor.user(); user.toggleDesktopHandles(user.hasShowDesktopDragHandles()); @@ -800,6 +855,9 @@ if (Meteor.isServer) { if (Meteor.isServer) { // Let mongoDB ensure username unicity Meteor.startup(() => { + allowedSortValues.forEach(value => { + Lists._collection._ensureIndex(value); + }); Users._collection._ensureIndex({ modifiedAt: -1 }); Users._collection._ensureIndex( { -- cgit v1.2.3-1-g7c22 From bbc3ab3f994c5a61a4414bc64b05f5a03d259e46 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Thu, 14 Nov 2019 00:55:11 +0200 Subject: Change sorting to work on desktop drag handle page instead, where it seems to work better. Thanks to xet7 ! --- models/users.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'models/users.js') diff --git a/models/users.js b/models/users.js index 83a224ba..3e3a7bbb 100644 --- a/models/users.js +++ b/models/users.js @@ -396,8 +396,8 @@ Users.helpers({ return ret; }, hasSortBy() { - // if use doesn't have dragHandle, then we can let user to choose sort list by different order - return !this.hasShowDesktopDragHandles(); + // if user has dragHandle, then we can let user to choose sort list by different order + return this.hasShowDesktopDragHandles(); }, getListSortBy() { return this._getListSortBy()[0]; -- cgit v1.2.3-1-g7c22 From ab2a721a1443b903cdbbbe275f41ffd3269012c6 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Thu, 14 Nov 2019 21:31:38 +0200 Subject: Revert list sorting change of Wekan v3.51 because it reversed alphabetical sorting of lists. Thanks to Dalisay and xet7 ! --- models/users.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'models/users.js') diff --git a/models/users.js b/models/users.js index 3e3a7bbb..83a224ba 100644 --- a/models/users.js +++ b/models/users.js @@ -396,8 +396,8 @@ Users.helpers({ return ret; }, hasSortBy() { - // if user has dragHandle, then we can let user to choose sort list by different order - return this.hasShowDesktopDragHandles(); + // if use doesn't have dragHandle, then we can let user to choose sort list by different order + return !this.hasShowDesktopDragHandles(); }, getListSortBy() { return this._getListSortBy()[0]; -- cgit v1.2.3-1-g7c22 From 96abe3c6914ce37d9fb44da8fda375e40ad65c9e Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Mon, 18 Nov 2019 22:23:49 +0200 Subject: New feature: Now there is popup selection of Lists/Swimlanes/Calendar/Roles. New feature, not set visible yet, because switching to it does not work properly yet: Collapsible Swimlanes #2804 Fix: Public board now loads correctly. When you select one of Lists/Swimlanes/Calendar view and reload webbrowser page, it can change view. Closes #2311 Fix: List sorting commented out. Closes #2800 Fix: Errors hasHiddenMinicardText, hasShowDragHandles, showSort, hasSortBy, profile, FirefoxAndroid/IE11/Vivaldi/Chromium browsers not working by using cookies instead of database. More details at https://github.com/wekan/wekan/issues/2643#issuecomment-554907955 Note: Cookie changes are not always immediate, if there is no effect, you may need to reload webbrowser page. Closes #2643 . Thanks to xet7 ! --- models/users.js | 71 +++++++++++++++------------------------------------------ 1 file changed, 18 insertions(+), 53 deletions(-) (limited to 'models/users.js') diff --git a/models/users.js b/models/users.js index 83a224ba..08b10eb5 100644 --- a/models/users.js +++ b/models/users.js @@ -119,13 +119,6 @@ Users.attachSchema( type: String, optional: true, }, - 'profile.showDesktopDragHandles': { - /** - * does the user want to hide system messages? - */ - type: Boolean, - optional: true, - }, 'profile.hiddenSystemMessages': { /** * does the user want to hide system messages? @@ -133,13 +126,6 @@ Users.attachSchema( type: Boolean, optional: true, }, - 'profile.hiddenMinicardLabelText': { - /** - * does the user want to hide minicard label texts? - */ - type: Boolean, - optional: true, - }, 'profile.initials': { /** * initials of the user @@ -198,6 +184,7 @@ Users.attachSchema( allowedValues: [ 'board-view-lists', 'board-view-swimlanes', + 'board-view-collapse', 'board-view-cal', ], }, @@ -395,10 +382,18 @@ Users.helpers({ } return ret; }, - hasSortBy() { - // if use doesn't have dragHandle, then we can let user to choose sort list by different order - return !this.hasShowDesktopDragHandles(); - }, + //hasSortBy() { + // if use doesn't have dragHandle, then we can let user to choose sort list by different order + //return this.hasShowDesktopDragHandles(); + // return false; + /* + if (typeof currentUser === 'undefined' || typeof currentUser === 'null') { + return false; + } else { + return this.hasShowDesktopDragHandles(); + } + */ + //}, getListSortBy() { return this._getListSortBy()[0]; }, @@ -419,21 +414,11 @@ Users.helpers({ return _.contains(notifications, activityId); }, - hasShowDesktopDragHandles() { - const profile = this.profile || {}; - return profile.showDesktopDragHandles || false; - }, - hasHiddenSystemMessages() { const profile = this.profile || {}; return profile.hiddenSystemMessages || false; }, - hasHiddenMinicardLabelText() { - const profile = this.profile || {}; - return profile.hiddenMinicardLabelText || false; - }, - getEmailBuffer() { const { emailBuffer = [] } = this.profile || {}; return emailBuffer; @@ -455,8 +440,11 @@ Users.helpers({ }, getLimitToShowCardsCount() { - const profile = this.profile || {}; - return profile.showCardsCountAt; + currentUser = Meteor.user(); + if (currentUser) { + const profile = this.profile || {}; + return profile.showCardsCountAt; + } }, getName() { @@ -536,13 +524,6 @@ Users.mutations({ }, }; }, - toggleDesktopHandles(value = false) { - return { - $set: { - 'profile.showDesktopDragHandles': !value, - }, - }; - }, toggleSystem(value = false) { return { @@ -552,14 +533,6 @@ Users.mutations({ }; }, - toggleLabelText(value = false) { - return { - $set: { - 'profile.hiddenMinicardLabelText': !value, - }, - }; - }, - addNotification(activityId) { return { $addToSet: { @@ -624,18 +597,10 @@ Meteor.methods({ check(value, String); Meteor.user().setListSortBy(value); }, - toggleDesktopDragHandles() { - const user = Meteor.user(); - user.toggleDesktopHandles(user.hasShowDesktopDragHandles()); - }, toggleSystemMessages() { const user = Meteor.user(); user.toggleSystem(user.hasHiddenSystemMessages()); }, - toggleMinicardLabelText() { - const user = Meteor.user(); - user.toggleLabelText(user.hasHiddenMinicardLabelText()); - }, changeLimitToShowCardsCount(limit) { check(limit, Number); Meteor.user().setShowCardsCountAt(limit); -- cgit v1.2.3-1-g7c22 From 351d4767d7e93c90ac798769d6071da8730d834f Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Tue, 19 Nov 2019 14:09:36 +0200 Subject: When logged in, use database for setting, so that changes are immediate. Only on public board use cookies. Comment out Collapse CSS that is not in use. Thanks to xet7 ! --- models/users.js | 71 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 18 deletions(-) (limited to 'models/users.js') diff --git a/models/users.js b/models/users.js index 08b10eb5..83a224ba 100644 --- a/models/users.js +++ b/models/users.js @@ -119,6 +119,13 @@ Users.attachSchema( type: String, optional: true, }, + 'profile.showDesktopDragHandles': { + /** + * does the user want to hide system messages? + */ + type: Boolean, + optional: true, + }, 'profile.hiddenSystemMessages': { /** * does the user want to hide system messages? @@ -126,6 +133,13 @@ Users.attachSchema( type: Boolean, optional: true, }, + 'profile.hiddenMinicardLabelText': { + /** + * does the user want to hide minicard label texts? + */ + type: Boolean, + optional: true, + }, 'profile.initials': { /** * initials of the user @@ -184,7 +198,6 @@ Users.attachSchema( allowedValues: [ 'board-view-lists', 'board-view-swimlanes', - 'board-view-collapse', 'board-view-cal', ], }, @@ -382,18 +395,10 @@ Users.helpers({ } return ret; }, - //hasSortBy() { - // if use doesn't have dragHandle, then we can let user to choose sort list by different order - //return this.hasShowDesktopDragHandles(); - // return false; - /* - if (typeof currentUser === 'undefined' || typeof currentUser === 'null') { - return false; - } else { - return this.hasShowDesktopDragHandles(); - } - */ - //}, + hasSortBy() { + // if use doesn't have dragHandle, then we can let user to choose sort list by different order + return !this.hasShowDesktopDragHandles(); + }, getListSortBy() { return this._getListSortBy()[0]; }, @@ -414,11 +419,21 @@ Users.helpers({ return _.contains(notifications, activityId); }, + hasShowDesktopDragHandles() { + const profile = this.profile || {}; + return profile.showDesktopDragHandles || false; + }, + hasHiddenSystemMessages() { const profile = this.profile || {}; return profile.hiddenSystemMessages || false; }, + hasHiddenMinicardLabelText() { + const profile = this.profile || {}; + return profile.hiddenMinicardLabelText || false; + }, + getEmailBuffer() { const { emailBuffer = [] } = this.profile || {}; return emailBuffer; @@ -440,11 +455,8 @@ Users.helpers({ }, getLimitToShowCardsCount() { - currentUser = Meteor.user(); - if (currentUser) { - const profile = this.profile || {}; - return profile.showCardsCountAt; - } + const profile = this.profile || {}; + return profile.showCardsCountAt; }, getName() { @@ -524,6 +536,13 @@ Users.mutations({ }, }; }, + toggleDesktopHandles(value = false) { + return { + $set: { + 'profile.showDesktopDragHandles': !value, + }, + }; + }, toggleSystem(value = false) { return { @@ -533,6 +552,14 @@ Users.mutations({ }; }, + toggleLabelText(value = false) { + return { + $set: { + 'profile.hiddenMinicardLabelText': !value, + }, + }; + }, + addNotification(activityId) { return { $addToSet: { @@ -597,10 +624,18 @@ Meteor.methods({ check(value, String); Meteor.user().setListSortBy(value); }, + toggleDesktopDragHandles() { + const user = Meteor.user(); + user.toggleDesktopHandles(user.hasShowDesktopDragHandles()); + }, toggleSystemMessages() { const user = Meteor.user(); user.toggleSystem(user.hasHiddenSystemMessages()); }, + toggleMinicardLabelText() { + const user = Meteor.user(); + user.toggleLabelText(user.hasHiddenMinicardLabelText()); + }, changeLimitToShowCardsCount(limit) { check(limit, Number); Meteor.user().setShowCardsCountAt(limit); -- cgit v1.2.3-1-g7c22