1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 21:29:43 +02:00
planka/server/api/models/BoardMembership.js

81 lines
1.9 KiB
JavaScript
Raw Normal View History

/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
2019-08-31 04:07:25 +05:00
/**
* BoardMembership.js
2019-08-31 04:07:25 +05:00
*
* @description :: A model definition represents a database table/collection.
* @docs :: https://sailsjs.com/docs/concepts/models-and-orm/models
*/
const Roles = {
EDITOR: 'editor',
VIEWER: 'viewer',
};
const SHARED_RULES = {
role: {},
canComment: { setTo: null },
};
const RULES_BY_ROLE = {
[Roles.EDITOR]: {
canComment: { setTo: null },
},
[Roles.VIEWER]: {
canComment: { defaultTo: false },
},
};
2019-08-31 04:07:25 +05:00
module.exports = {
Roles,
SHARED_RULES,
RULES_BY_ROLE,
2019-08-31 04:07:25 +05:00
attributes: {
// ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦ ╦╔═╗╔═╗
// ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗
// ╩ ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝
role: {
type: 'string',
isIn: Object.values(Roles),
required: true,
},
canComment: {
type: 'boolean',
allowNull: true,
columnName: 'can_comment',
},
2019-08-31 04:07:25 +05:00
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
// ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝
// ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
// Denormalization
projectId: {
model: 'Project',
required: true,
columnName: 'project_id',
},
boardId: {
model: 'Board',
2019-08-31 04:07:25 +05:00
required: true,
columnName: 'board_id',
2019-08-31 04:07:25 +05:00
},
userId: {
model: 'User',
required: true,
columnName: 'user_id',
},
2019-08-31 04:07:25 +05:00
},
tableName: 'board_membership',
2019-08-31 04:07:25 +05:00
};