mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 13:19:44 +02:00
Add project backgrounds
This commit is contained in:
parent
fb9ceb5db7
commit
2f7a244807
67 changed files with 774 additions and 210 deletions
|
@ -1,3 +1,6 @@
|
|||
const path = require('path');
|
||||
const rimraf = require('rimraf');
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
record: {
|
||||
|
@ -6,6 +9,10 @@ module.exports = {
|
|||
},
|
||||
values: {
|
||||
type: 'json',
|
||||
custom: (value) =>
|
||||
_.isPlainObject(value) &&
|
||||
(_.isUndefined(value.background) || _.isNull(value.background)) &&
|
||||
(_.isUndefined(value.backgroundImage) || _.isNull(value.backgroundImage)),
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
|
@ -14,9 +21,39 @@ module.exports = {
|
|||
},
|
||||
|
||||
async fn(inputs, exits) {
|
||||
if (!_.isUndefined(inputs.values.backgroundImage)) {
|
||||
/* eslint-disable no-param-reassign */
|
||||
inputs.values.backgroundImageDirname = null;
|
||||
delete inputs.values.backgroundImage;
|
||||
/* eslint-enable no-param-reassign */
|
||||
}
|
||||
|
||||
if (inputs.values.backgroundImageDirname) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
inputs.values.background = {
|
||||
type: 'image',
|
||||
};
|
||||
}
|
||||
|
||||
const project = await Project.updateOne(inputs.record.id).set(inputs.values);
|
||||
|
||||
if (project) {
|
||||
if (
|
||||
inputs.record.backgroundImageDirname &&
|
||||
project.backgroundImageDirname !== inputs.record.backgroundImageDirname
|
||||
) {
|
||||
try {
|
||||
rimraf.sync(
|
||||
path.join(
|
||||
sails.config.custom.projectBackgroundImagesPath,
|
||||
inputs.record.backgroundImageDirname,
|
||||
),
|
||||
);
|
||||
} catch (error) {
|
||||
console.warn(error.stack); // eslint-disable-line no-console
|
||||
}
|
||||
}
|
||||
|
||||
const userIds = await sails.helpers.getMembershipUserIdsForProject(project.id);
|
||||
|
||||
userIds.forEach((userId) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue