@@ -21,6 +21,11 @@ module.exports = {
|
||||
type: 'string',
|
||||
isNotEmptyString: true,
|
||||
},
|
||||
color: {
|
||||
type: 'string',
|
||||
isIn: List.COLORS,
|
||||
allowNull: true,
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
@@ -55,7 +60,7 @@ module.exports = {
|
||||
throw Errors.NOT_ENOUGH_RIGHTS;
|
||||
}
|
||||
|
||||
const values = _.pick(inputs, ['position', 'name']);
|
||||
const values = _.pick(inputs, ['position', 'name', 'color']);
|
||||
|
||||
list = await sails.helpers.lists.updateOne.with({
|
||||
values,
|
||||
|
||||
@@ -12,8 +12,22 @@ const SortTypes = {
|
||||
CREATED_AT_DESC: 'createdAt_desc',
|
||||
};
|
||||
|
||||
const COLORS = [
|
||||
'berry-red',
|
||||
'pumpkin-orange',
|
||||
'lagoon-blue',
|
||||
'pink-tulip',
|
||||
'light-mud',
|
||||
'orange-peel',
|
||||
'bright-moss',
|
||||
'antique-blue',
|
||||
'dark-granite',
|
||||
'lagune-blue',
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
SortTypes,
|
||||
COLORS,
|
||||
|
||||
attributes: {
|
||||
// ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦ ╦╔═╗╔═╗
|
||||
@@ -28,6 +42,11 @@ module.exports = {
|
||||
type: 'string',
|
||||
required: true,
|
||||
},
|
||||
color: {
|
||||
type: 'string',
|
||||
isIn: COLORS,
|
||||
allowNull: true,
|
||||
},
|
||||
|
||||
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
|
||||
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @param { import("knex").Knex } knex
|
||||
* @returns { Promise<void> }
|
||||
*/
|
||||
exports.up = (knex) =>
|
||||
knex.schema.alterTable('list', (table) => {
|
||||
table.text('color');
|
||||
});
|
||||
|
||||
/**
|
||||
* @param { import("knex").Knex } knex
|
||||
* @returns { Promise<void> }
|
||||
*/
|
||||
exports.down = (knex) =>
|
||||
knex.schema.alterTable('list', (table) => {
|
||||
table.dropColumn('color');
|
||||
});
|
||||
Reference in New Issue
Block a user