add listWidths to user profile

This commit is contained in:
mark 2023-06-12 22:14:06 -05:00
parent f33ea5baf0
commit f2e4a280d7
6 changed files with 114 additions and 15 deletions

View file

@ -422,6 +422,24 @@ Users.attachSchema(
type: String,
defaultValue: '',
},
'profile.listWidths': {
/**
* User-specified width of each list (or nothing if default).
* profile[boardId][listId] = width;
*/
type: Object,
defaultValue: {},
blackbox: true,
},
'profile.swimlaneHeights': {
/**
* User-specified heights of each swimlane (or nothing if default).
* profile[boardId][swimlaneId] = height;
*/
type: Object,
defaultValue: {},
blackbox: true,
},
services: {
/**
* services field of the user
@ -760,6 +778,19 @@ Users.helpers({
return this._getListSortBy()[1];
},
getListWidths() {
const { listWidths = {} } = this.profile || {};
return listWidths;
},
getListWidth(boardId, listId) {
const listWidths = this.getListWidths();
if (listWidths[boardId] && listWidths[boardId][listId]) {
return listWidths[boardId][listId];
} else {
return 270; //TODO(mark-i-m): default?
}
},
/** returns all confirmed move and copy dialog field values
* <li> the board, swimlane and list id is stored for each board
*/
@ -1137,6 +1168,19 @@ Users.mutations({
},
};
},
setListWidth(boardId, listId, width) {
let currentWidths = this.getListWidths();
if (!currentWidths[boardId]) {
currentWidths[boardId] = {};
}
currentWidths[boardId][listId] = width;
return {
$set: {
'profile.listWidths': currentWidths,
},
};
},
});
Meteor.methods({
@ -1180,6 +1224,13 @@ Meteor.methods({
check(startDay, Number);
Meteor.user().setStartDayOfWeek(startDay);
},
applyListWidth(boardId, listId, width) {
check(boardId, String);
check(listId, String);
check(width, Number);
const user = Meteor.user();
user.setListWidth(boardId, listId, width);
},
});
if (Meteor.isServer) {