2025-05-10 02:09:06 +02:00
|
|
|
/*!
|
|
|
|
|
* 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
|
|
|
/**
|
|
|
|
|
* Card.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:
|
|
|
|
|
* Card:
|
|
|
|
|
* type: object
|
|
|
|
|
* required:
|
|
|
|
|
* - boardId
|
|
|
|
|
* - listId
|
|
|
|
|
* - type
|
|
|
|
|
* - name
|
|
|
|
|
* properties:
|
|
|
|
|
* id:
|
|
|
|
|
* type: string
|
|
|
|
|
* description: Unique identifier for the card
|
|
|
|
|
* example: 1357158568008091264
|
|
|
|
|
* boardId:
|
|
|
|
|
* type: string
|
|
|
|
|
* description: ID of the board the card belongs to (denormalized)
|
|
|
|
|
* example: 1357158568008091265
|
|
|
|
|
* listId:
|
|
|
|
|
* type: string
|
|
|
|
|
* description: ID of the list the card belongs to
|
|
|
|
|
* example: 1357158568008091266
|
|
|
|
|
* creatorUserId:
|
|
|
|
|
* type: string
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: ID of the user who created the card
|
|
|
|
|
* example: 1357158568008091267
|
|
|
|
|
* prevListId:
|
|
|
|
|
* type: string
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: ID of the previous list the card was in (available when in archive or trash)
|
|
|
|
|
* example: 1357158568008091268
|
|
|
|
|
* coverAttachmentId:
|
|
|
|
|
* type: string
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: ID of the attachment used as cover
|
|
|
|
|
* example: 1357158568008091269
|
|
|
|
|
* type:
|
|
|
|
|
* type: string
|
|
|
|
|
* enum: [project, story]
|
|
|
|
|
* description: Type of the card
|
|
|
|
|
* example: project
|
|
|
|
|
* position:
|
|
|
|
|
* type: number
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: Position of the card within the list
|
|
|
|
|
* example: 65536
|
|
|
|
|
* name:
|
|
|
|
|
* type: string
|
|
|
|
|
* description: Name/title of the card
|
|
|
|
|
* example: Implement user authentication
|
|
|
|
|
* description:
|
|
|
|
|
* type: string
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: Detailed description of the card
|
|
|
|
|
* example: Add JWT-based authentication system...
|
|
|
|
|
* dueDate:
|
|
|
|
|
* type: string
|
|
|
|
|
* format: date-time
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: Due date for the card
|
|
|
|
|
* example: 2024-01-01T00:00:00.000Z
|
|
|
|
|
* isDueCompleted:
|
|
|
|
|
* type: boolean
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: Whether the due date is completed
|
|
|
|
|
* example: false
|
|
|
|
|
* stopwatch:
|
|
|
|
|
* type: object
|
|
|
|
|
* required:
|
|
|
|
|
* - startedAt
|
|
|
|
|
* - total
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: Stopwatch data for time tracking
|
|
|
|
|
* properties:
|
|
|
|
|
* startedAt:
|
|
|
|
|
* type: string
|
|
|
|
|
* format: date-time
|
|
|
|
|
* description: When the stopwatch was started
|
|
|
|
|
* example: 2024-01-01T00:00:00.000Z
|
|
|
|
|
* total:
|
|
|
|
|
* type: number
|
|
|
|
|
* description: Total time in seconds
|
|
|
|
|
* example: 3600
|
|
|
|
|
* commentsTotal:
|
|
|
|
|
* type: number
|
|
|
|
|
* description: Total number of comments on the card
|
|
|
|
|
* example: 100
|
|
|
|
|
* isClosed:
|
|
|
|
|
* type: boolean
|
|
|
|
|
* description: Whether the card is closed
|
|
|
|
|
* example: false
|
|
|
|
|
* listChangedAt:
|
|
|
|
|
* type: string
|
|
|
|
|
* format: date-time
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: When the card was last moved between lists
|
|
|
|
|
* example: 2024-01-01T00:00:00.000Z
|
|
|
|
|
* createdAt:
|
|
|
|
|
* type: string
|
|
|
|
|
* format: date-time
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: When the card was created
|
|
|
|
|
* example: 2024-01-01T00:00:00.000Z
|
|
|
|
|
* updatedAt:
|
|
|
|
|
* type: string
|
|
|
|
|
* format: date-time
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: When the card was last updated
|
|
|
|
|
* example: 2024-01-01T00:00:00.000Z
|
|
|
|
|
*/
|
|
|
|
|
|
2025-05-10 02:09:06 +02:00
|
|
|
const Types = {
|
|
|
|
|
PROJECT: 'project',
|
|
|
|
|
STORY: 'story',
|
|
|
|
|
};
|
|
|
|
|
|
2019-08-31 04:07:25 +05:00
|
|
|
module.exports = {
|
2025-05-10 02:09:06 +02:00
|
|
|
Types,
|
|
|
|
|
|
2019-08-31 04:07:25 +05:00
|
|
|
attributes: {
|
|
|
|
|
// ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦ ╦╔═╗╔═╗
|
|
|
|
|
// ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗
|
|
|
|
|
// ╩ ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝
|
|
|
|
|
|
2025-05-10 02:09:06 +02:00
|
|
|
type: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
isIn: Object.values(Types),
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
position: {
|
|
|
|
|
type: 'number',
|
2025-05-10 02:09:06 +02:00
|
|
|
allowNull: true,
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
|
name: {
|
|
|
|
|
type: 'string',
|
2019-11-05 18:01:42 +05:00
|
|
|
required: true,
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
|
description: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
isNotEmptyString: true,
|
2019-11-05 18:01:42 +05:00
|
|
|
allowNull: true,
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
2019-10-05 06:12:36 +05:00
|
|
|
dueDate: {
|
|
|
|
|
type: 'ref',
|
2019-11-05 18:01:42 +05:00
|
|
|
columnName: 'due_date',
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
2025-09-05 07:55:20 -04:00
|
|
|
isDueCompleted: {
|
|
|
|
|
type: 'boolean',
|
|
|
|
|
allowNull: true,
|
|
|
|
|
columnName: 'is_due_completed',
|
|
|
|
|
},
|
2023-02-27 19:09:51 +01:00
|
|
|
stopwatch: {
|
2019-11-05 18:01:42 +05:00
|
|
|
type: 'json',
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
2025-05-23 17:31:28 +02:00
|
|
|
commentsTotal: {
|
|
|
|
|
type: 'number',
|
|
|
|
|
defaultsTo: 0,
|
|
|
|
|
columnName: 'comments_total',
|
|
|
|
|
},
|
2025-07-14 14:54:06 +02:00
|
|
|
isClosed: {
|
|
|
|
|
type: 'boolean',
|
|
|
|
|
defaultsTo: false,
|
|
|
|
|
columnName: 'is_closed',
|
|
|
|
|
},
|
2025-05-10 02:09:06 +02:00
|
|
|
listChangedAt: {
|
|
|
|
|
type: 'ref',
|
|
|
|
|
columnName: 'list_changed_at',
|
|
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
|
|
|
|
|
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
|
|
|
|
|
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
|
|
|
|
|
// ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝
|
|
|
|
|
|
|
|
|
|
// ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
|
|
|
|
|
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
|
|
|
|
|
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
|
|
|
|
|
|
2025-05-10 02:09:06 +02:00
|
|
|
// Denormalization
|
2019-08-31 04:07:25 +05:00
|
|
|
boardId: {
|
|
|
|
|
model: 'Board',
|
|
|
|
|
required: true,
|
2019-11-05 18:01:42 +05:00
|
|
|
columnName: 'board_id',
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
2020-08-04 01:32:46 +05:00
|
|
|
listId: {
|
|
|
|
|
model: 'List',
|
2022-12-26 21:10:50 +01:00
|
|
|
required: true,
|
2020-08-04 01:32:46 +05:00
|
|
|
columnName: 'list_id',
|
|
|
|
|
},
|
2021-06-24 01:05:22 +05:00
|
|
|
creatorUserId: {
|
|
|
|
|
model: 'User',
|
|
|
|
|
columnName: 'creator_user_id',
|
|
|
|
|
},
|
2025-05-10 02:09:06 +02:00
|
|
|
prevListId: {
|
|
|
|
|
model: 'List',
|
|
|
|
|
columnName: 'prev_list_id',
|
|
|
|
|
},
|
2020-04-23 03:02:53 +05:00
|
|
|
coverAttachmentId: {
|
|
|
|
|
model: 'Attachment',
|
|
|
|
|
columnName: 'cover_attachment_id',
|
|
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
subscriptionUsers: {
|
|
|
|
|
collection: 'User',
|
|
|
|
|
via: 'cardId',
|
2019-11-05 18:01:42 +05:00
|
|
|
through: 'CardSubscription',
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
2021-06-24 01:05:22 +05:00
|
|
|
memberUsers: {
|
2019-08-31 04:07:25 +05:00
|
|
|
collection: 'User',
|
|
|
|
|
via: 'cardId',
|
2019-11-05 18:01:42 +05:00
|
|
|
through: 'CardMembership',
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
|
labels: {
|
|
|
|
|
collection: 'Label',
|
|
|
|
|
via: 'cardId',
|
2019-11-05 18:01:42 +05:00
|
|
|
through: 'CardLabel',
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
2025-05-10 02:09:06 +02:00
|
|
|
taskLists: {
|
|
|
|
|
collection: 'TaskList',
|
2019-11-05 18:01:42 +05:00
|
|
|
via: 'cardId',
|
|
|
|
|
},
|
2020-04-21 05:04:34 +05:00
|
|
|
attachments: {
|
|
|
|
|
collection: 'Attachment',
|
|
|
|
|
via: 'cardId',
|
|
|
|
|
},
|
2025-05-10 02:09:06 +02:00
|
|
|
comments: {
|
|
|
|
|
collection: 'Comment',
|
|
|
|
|
via: 'cardId',
|
|
|
|
|
},
|
2020-04-21 05:04:34 +05:00
|
|
|
actions: {
|
|
|
|
|
collection: 'Action',
|
|
|
|
|
via: 'cardId',
|
|
|
|
|
},
|
2019-11-05 18:01:42 +05:00
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
};
|