1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-18 19:19:36 +02:00

Apps reordering. Sorting apps while adding them

This commit is contained in:
unknown 2021-06-15 16:02:57 +02:00
parent 9a1ec76ffd
commit ce173f2c42
12 changed files with 219 additions and 53 deletions

View file

@ -36,8 +36,11 @@ exports.createApp = asyncWrapper(async (req, res, next) => {
// @route GET /api/apps
// @access Public
exports.getApps = asyncWrapper(async (req, res, next) => {
// const apps = await App.findAll({
// order: [[ Sequelize.fn('lower', Sequelize.col('name')), 'ASC' ]]
// });
const apps = await App.findAll({
order: [[ Sequelize.fn('lower', Sequelize.col('name')), 'ASC' ]]
order: [[ 'orderId', 'ASC' ]]
});
res.status(200).json({
@ -92,6 +95,22 @@ exports.deleteApp = asyncWrapper(async (req, res, next) => {
where: { id: req.params.id }
})
res.status(200).json({
success: true,
data: {}
})
})
// @desc Reorder apps
// @route PUT /api/apps/0/reorder
// @access Public
exports.reorderApps = asyncWrapper(async (req, res, next) => {
req.body.apps.forEach(async ({ id, orderId }) => {
await App.update({ orderId }, {
where: { id }
})
})
res.status(200).json({
success: true,
data: {}