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

feat: Version 2

Closes #627, closes #1047
This commit is contained in:
Maksim Eltyshev 2025-05-10 02:09:06 +02:00
parent ad7fb51cfa
commit 2ee1166747
1557 changed files with 76832 additions and 47042 deletions

View file

@ -1,3 +1,8 @@
/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
/**
* Project.js
*
@ -5,6 +10,11 @@
* @docs :: https://sailsjs.com/docs/concepts/models-and-orm/models
*/
const Types = {
PRIVATE: 'private',
SHARED: 'shared',
};
const BackgroundTypes = {
GRADIENT: 'gradient',
IMAGE: 'image',
@ -39,6 +49,7 @@ const BACKGROUND_GRADIENTS = [
];
module.exports = {
Types,
BackgroundTypes,
BACKGROUND_GRADIENTS,
@ -51,12 +62,27 @@ module.exports = {
type: 'string',
required: true,
},
background: {
type: 'json',
description: {
type: 'string',
isNotEmptyString: true,
allowNull: true,
},
backgroundImage: {
type: 'json',
columnName: 'background_image',
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',
},
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
@ -67,6 +93,14 @@ module.exports = {
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
ownerProjectManagerId: {
model: 'ProjectManager',
columnName: 'owner_project_manager_id',
},
backgroundImageId: {
model: 'BackgroundImage',
columnName: 'background_image_id',
},
managerUsers: {
collection: 'User',
via: 'projectId',
@ -77,16 +111,4 @@ module.exports = {
via: 'projectId',
},
},
customToJSON() {
const fileManager = sails.hooks['file-manager'].getInstance();
return {
..._.omit(this, ['backgroundImage']),
backgroundImage: this.backgroundImage && {
url: `${fileManager.buildUrl(`${sails.config.custom.projectBackgroundImagesPathSegment}/${this.backgroundImage.dirname}/original.${this.backgroundImage.extension}`)}`,
coverUrl: `${fileManager.buildUrl(`${sails.config.custom.projectBackgroundImagesPathSegment}/${this.backgroundImage.dirname}/cover-336.${this.backgroundImage.extension}`)}`,
},
};
},
};