1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 05:09:43 +02:00
planka/server/api/models/Project.js
Maksim Eltyshev 2ee1166747 feat: Version 2
Closes #627, closes #1047
2025-05-10 02:09:06 +02:00

114 lines
2.7 KiB
JavaScript
Executable file

/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
/**
* Project.js
*
* @description :: A model definition represents a database table/collection.
* @docs :: https://sailsjs.com/docs/concepts/models-and-orm/models
*/
const Types = {
PRIVATE: 'private',
SHARED: 'shared',
};
const BackgroundTypes = {
GRADIENT: 'gradient',
IMAGE: 'image',
};
const BACKGROUND_GRADIENTS = [
'old-lime',
'ocean-dive',
'tzepesch-style',
'jungle-mesh',
'strawberry-dust',
'purple-rose',
'sun-scream',
'warm-rust',
'sky-change',
'green-eyes',
'blue-xchange',
'blood-orange',
'sour-peel',
'green-ninja',
'algae-green',
'coral-reef',
'steel-grey',
'heat-waves',
'velvet-lounge',
'purple-rain',
'blue-steel',
'blueish-curve',
'prism-light',
'green-mist',
'red-curtain',
];
module.exports = {
Types,
BackgroundTypes,
BACKGROUND_GRADIENTS,
attributes: {
// ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦ ╦╔═╗╔═╗
// ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗
// ╩ ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝
name: {
type: 'string',
required: true,
},
description: {
type: 'string',
isNotEmptyString: true,
allowNull: true,
},
backgroundType: {
type: 'string',
isIn: Object.values(BackgroundTypes),
allowNull: true,
columnName: 'background_type',
},
backgroundGradient: {
type: 'string',
isIn: BACKGROUND_GRADIENTS,
allowNull: true,
columnName: 'background_gradient',
},
isHidden: {
type: 'boolean',
defaultsTo: false, // TODO: implement via normalizeValues?
columnName: 'is_hidden',
},
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
// ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝
// ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
ownerProjectManagerId: {
model: 'ProjectManager',
columnName: 'owner_project_manager_id',
},
backgroundImageId: {
model: 'BackgroundImage',
columnName: 'background_image_id',
},
managerUsers: {
collection: 'User',
via: 'projectId',
through: 'ProjectManager',
},
boards: {
collection: 'Board',
via: 'projectId',
},
},
};