1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00

Add preferences tab to user settings, add subscribe to own cards option

This commit is contained in:
Maksim Eltyshev 2020-04-10 00:11:34 +05:00
parent f3e0cadca6
commit 6a82448dc7
13 changed files with 96 additions and 2 deletions

View file

@ -40,6 +40,9 @@ module.exports = {
isNotEmptyString: true,
allowNull: true,
},
subscribeToOwnCards: {
type: 'boolean',
},
},
exits: {
@ -59,6 +62,7 @@ module.exports = {
'username',
'phone',
'organization',
'subscribeToOwnCards',
]);
const user = await sails.helpers

View file

@ -32,6 +32,9 @@ module.exports = {
isNotEmptyString: true,
allowNull: true,
},
subscribeToOwnCards: {
type: 'boolean',
},
},
exits: {
@ -57,7 +60,14 @@ module.exports = {
throw Errors.USER_NOT_FOUND;
}
const values = _.pick(inputs, ['isAdmin', 'name', 'avatar', 'phone', 'organization']);
const values = _.pick(inputs, [
'isAdmin',
'name',
'avatar',
'phone',
'organization',
'subscribeToOwnCards',
]);
user = await sails.helpers.updateUser(user, values, this.req);

View file

@ -49,6 +49,17 @@ module.exports = {
boardId: inputs.list.boardId,
}).fetch();
if (inputs.user.subscribeToOwnCards) {
await CardSubscription.create({
cardId: card.id,
userId: inputs.user.id,
}).tolerate('E_UNIQUE');
card.isSubscribed = true;
} else {
card.isSubscribed = false;
}
sails.sockets.broadcast(
`board:${card.boardId}`,
'cardCreate',

View file

@ -52,6 +52,11 @@ module.exports = {
isNotEmptyString: true,
allowNull: true,
},
subscribeToOwnCards: {
type: 'boolean',
defaultsTo: false,
columnName: 'subscribe_to_own_cards',
},
deletedAt: {
type: 'ref',
columnName: 'deleted_at',

View file

@ -13,6 +13,7 @@ module.exports.up = (knex) =>
table.text('avatar');
table.text('phone');
table.text('organization');
table.boolean('subscribe_to_own_cards').notNullable();
table.timestamp('created_at', true);
table.timestamp('updated_at', true);

View file

@ -9,6 +9,7 @@ exports.seed = (knex) => {
isAdmin: true,
name: 'Demo Demo',
username: 'demo',
subscribeToOwnCards: false,
createdAt: date,
updatedAt: date,
});