Files
planka/server/api/models/List.js

164 lines
4.0 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
/**
* List.js
*
* @description :: A model definition represents a database table/collection.
* @docs :: https://sailsjs.com/docs/concepts/models-and-orm/models
*/
2025-09-08 16:20:27 +02:00
/**
* @swagger
* components:
* schemas:
* List:
* type: object
* required:
2025-09-08 23:40:36 +02:00
* - id
2025-09-08 16:20:27 +02:00
* - boardId
* - type
* properties:
* id:
* type: string
* description: Unique identifier for the list
2025-09-08 19:14:31 +02:00
* example: "1357158568008091264"
2025-09-08 16:20:27 +02:00
* boardId:
* type: string
* description: ID of the board the list belongs to
2025-09-08 19:14:31 +02:00
* example: "1357158568008091265"
2025-09-08 16:20:27 +02:00
* type:
* type: string
* enum: [active, closed, archive, trash]
* description: Type/status of the list
* example: active
* position:
* type: number
* nullable: true
* description: Position of the list within the board
* example: 65536
* name:
* type: string
* nullable: true
* description: Name/title of the list
* example: To Do
* color:
* type: string
* enum: [berry-red, pumpkin-orange, lagoon-blue, pink-tulip, light-mud, orange-peel, bright-moss, antique-blue, dark-granite, turquoise-sea]
* nullable: true
* description: Color for the list
* example: lagoon-blue
* createdAt:
* type: string
* format: date-time
* nullable: true
* description: When the list was created
* example: 2024-01-01T00:00:00.000Z
* updatedAt:
* type: string
* format: date-time
* nullable: true
* description: When the list was last updated
* example: 2024-01-01T00:00:00.000Z
*/
const Types = {
ACTIVE: 'active',
CLOSED: 'closed',
ARCHIVE: 'archive',
TRASH: 'trash',
};
2025-07-14 14:54:06 +02:00
const TypeStates = {
OPENED: 'opened',
CLOSED: 'closed',
};
const SortFieldNames = {
NAME: 'name',
DUE_DATE: 'dueDate',
CREATED_AT: 'createdAt',
};
// TODO: should not be here
const SortOrders = {
ASC: 'asc',
DESC: 'desc',
};
const FINITE_TYPES = [Types.ACTIVE, Types.CLOSED];
2025-07-14 14:54:06 +02:00
const TYPE_STATE_BY_TYPE = {
[Types.ACTIVE]: TypeStates.OPENED,
[Types.CLOSED]: Types.CLOSED,
};
const COLORS = [
'berry-red',
'pumpkin-orange',
'lagoon-blue',
'pink-tulip',
'light-mud',
'orange-peel',
'bright-moss',
'antique-blue',
'dark-granite',
'turquoise-sea',
];
2019-08-31 04:07:25 +05:00
module.exports = {
Types,
2025-07-14 14:54:06 +02:00
TypeStates,
SortFieldNames,
SortOrders,
FINITE_TYPES,
2025-07-14 14:54:06 +02:00
TYPE_STATE_BY_TYPE,
COLORS,
2019-08-31 04:07:25 +05:00
attributes: {
// ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦ ╦╔═╗╔═╗
// ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗
// ╩ ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝
type: {
type: 'string',
isIn: Object.values(Types),
required: true,
},
2019-08-31 04:07:25 +05:00
position: {
type: 'number',
allowNull: true,
2019-08-31 04:07:25 +05:00
},
name: {
type: 'string',
isNotEmptyString: true,
allowNull: true,
2019-08-31 04:07:25 +05:00
},
color: {
type: 'string',
isIn: COLORS,
allowNull: true,
},
2019-08-31 04:07:25 +05:00
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
// ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝
// ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
boardId: {
model: 'Board',
required: true,
columnName: 'board_id',
2019-08-31 04:07:25 +05:00
},
cards: {
collection: 'Card',
via: 'listId',
},
},
2019-08-31 04:07:25 +05:00
};