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
|
|
|
|
|
*/
|
2024-06-14 16:38:06 +02:00
|
|
|
|
2025-09-08 16:20:27 +02:00
|
|
|
/**
|
|
|
|
|
* @swagger
|
2025-09-08 18:25:26 +02:00
|
|
|
* /projects:
|
2025-09-08 16:20:27 +02:00
|
|
|
* post:
|
|
|
|
|
* summary: Create project
|
|
|
|
|
* description: Creates a project. The current user automatically becomes a project manager.
|
|
|
|
|
* tags:
|
|
|
|
|
* - Projects
|
2025-09-12 12:17:01 +02:00
|
|
|
* operationId: createProject
|
2025-09-08 16:20:27 +02:00
|
|
|
* requestBody:
|
|
|
|
|
* required: true
|
|
|
|
|
* content:
|
|
|
|
|
* application/json:
|
|
|
|
|
* schema:
|
|
|
|
|
* type: object
|
|
|
|
|
* required:
|
|
|
|
|
* - type
|
|
|
|
|
* - name
|
|
|
|
|
* properties:
|
|
|
|
|
* type:
|
|
|
|
|
* type: string
|
|
|
|
|
* enum: [public, private]
|
|
|
|
|
* description: Type of the project
|
|
|
|
|
* example: private
|
|
|
|
|
* name:
|
|
|
|
|
* type: string
|
|
|
|
|
* maxLength: 128
|
|
|
|
|
* description: Name/title of the project
|
|
|
|
|
* example: Development Project
|
|
|
|
|
* description:
|
|
|
|
|
* type: string
|
|
|
|
|
* maxLength: 1024
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: Detailed description of the project
|
|
|
|
|
* example: A project for developing new features...
|
|
|
|
|
* responses:
|
|
|
|
|
* 200:
|
|
|
|
|
* description: Project created successfully
|
|
|
|
|
* content:
|
|
|
|
|
* application/json:
|
|
|
|
|
* schema:
|
|
|
|
|
* type: object
|
|
|
|
|
* required:
|
|
|
|
|
* - item
|
|
|
|
|
* - included
|
|
|
|
|
* properties:
|
|
|
|
|
* item:
|
|
|
|
|
* $ref: '#/components/schemas/Project'
|
|
|
|
|
* included:
|
|
|
|
|
* type: object
|
|
|
|
|
* required:
|
|
|
|
|
* - projectManagers
|
|
|
|
|
* properties:
|
|
|
|
|
* projectManagers:
|
|
|
|
|
* type: array
|
|
|
|
|
* description: Related project managers
|
|
|
|
|
* items:
|
|
|
|
|
* $ref: '#/components/schemas/ProjectManager'
|
|
|
|
|
* 400:
|
|
|
|
|
* $ref: '#/components/responses/ValidationError'
|
|
|
|
|
* 401:
|
|
|
|
|
* $ref: '#/components/responses/Unauthorized'
|
|
|
|
|
*/
|
|
|
|
|
|
2019-08-31 04:07:25 +05:00
|
|
|
module.exports = {
|
|
|
|
|
inputs: {
|
2025-05-10 02:09:06 +02:00
|
|
|
type: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
isIn: Object.values(Project.Types),
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
name: {
|
|
|
|
|
type: 'string',
|
2025-05-10 02:09:06 +02:00
|
|
|
maxLength: 128,
|
2019-11-05 18:01:42 +05:00
|
|
|
required: true,
|
|
|
|
|
},
|
2025-05-10 02:09:06 +02:00
|
|
|
description: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
isNotEmptyString: true,
|
|
|
|
|
maxLength: 1024,
|
|
|
|
|
allowNull: true,
|
2024-06-14 16:38:06 +02:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
2021-06-24 01:05:22 +05:00
|
|
|
async fn(inputs) {
|
2019-08-31 04:07:25 +05:00
|
|
|
const { currentUser } = this.req;
|
|
|
|
|
|
2025-05-10 02:09:06 +02:00
|
|
|
const values = _.pick(inputs, ['type', 'name', 'description']);
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2022-12-26 21:10:50 +01:00
|
|
|
const { project, projectManager } = await sails.helpers.projects.createOne.with({
|
2020-08-04 01:32:46 +05:00
|
|
|
values,
|
2024-06-12 00:51:36 +02:00
|
|
|
actorUser: currentUser,
|
2022-12-26 21:10:50 +01:00
|
|
|
request: this.req,
|
|
|
|
|
});
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2021-06-24 01:05:22 +05:00
|
|
|
return {
|
2019-08-31 04:07:25 +05:00
|
|
|
item: project,
|
|
|
|
|
included: {
|
2021-06-24 01:05:22 +05:00
|
|
|
projectManagers: [projectManager],
|
2019-11-05 18:01:42 +05:00
|
|
|
},
|
2021-06-24 01:05:22 +05:00
|
|
|
};
|
2019-11-05 18:01:42 +05:00
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
};
|