mirror of
https://github.com/wekan/wekan.git
synced 2026-01-25 02:36:09 +01:00
Add Features: allowing lists to be sorted by modifiedAt when not in draggable mode.
Bug Fix #2093: the broken should be prior to file attachment feature introduced, and tested export board is working. Thanks to whowillcare ! ( xet7 merged this pull request manually from https://github.com/wekan/wekan/pull/2756 ) Closes #2093
This commit is contained in:
parent
13a2bd6380
commit
7d6d3af54a
29 changed files with 475 additions and 41 deletions
|
|
@ -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
|
||||
*/
|
||||
|
|
@ -109,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?
|
||||
|
|
@ -184,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
|
||||
|
|
@ -358,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);
|
||||
|
|
@ -368,6 +419,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 +529,21 @@ Users.mutations({
|
|||
else this.addTag(tag);
|
||||
},
|
||||
|
||||
setListSortBy(value) {
|
||||
return {
|
||||
$set: {
|
||||
'profile.listSortBy': value,
|
||||
},
|
||||
};
|
||||
},
|
||||
toggleDesktopHandles(value = false) {
|
||||
return {
|
||||
$set: {
|
||||
'profile.showDesktopDragHandles': !value,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
toggleSystem(value = false) {
|
||||
return {
|
||||
$set: {
|
||||
|
|
@ -549,6 +620,14 @@ 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());
|
||||
},
|
||||
toggleSystemMessages() {
|
||||
const user = Meteor.user();
|
||||
user.toggleSystem(user.hasHiddenSystemMessages());
|
||||
|
|
@ -776,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(
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue