summaryrefslogtreecommitdiffstats
path: root/server/api/groups.js
diff options
context:
space:
mode:
authorUdo Walter2018-08-01 23:41:24 +0200
committerUdo Walter2018-08-01 23:41:24 +0200
commitbf83c4680d2b63aad7852da5a34d50529fc148db (patch)
tree325d42f8cbb138aa8fa5ca97b62582416e1e4bd5 /server/api/groups.js
parent[groups] add edit functionality to group infos (diff)
downloadbas-bf83c4680d2b63aad7852da5a34d50529fc148db.tar.gz
bas-bf83c4680d2b63aad7852da5a34d50529fc148db.tar.xz
bas-bf83c4680d2b63aad7852da5a34d50529fc148db.zip
[groups] add client edit functionality
Diffstat (limited to 'server/api/groups.js')
-rw-r--r--server/api/groups.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/server/api/groups.js b/server/api/groups.js
index 5916585..6debc4d 100644
--- a/server/api/groups.js
+++ b/server/api/groups.js
@@ -6,7 +6,7 @@ var db = require(path.join(__appdir, 'lib', 'sequelize'))
module.exports.get = {
// get a list containing id and name of all groups
getList: function (req, res) {
- db.group.findAll({ attributes: ['id', 'name'] }).then(list => {
+ db.group.findAll({ attributes: ['id', 'name'], order: [['name', 'ASC']] }).then(list => {
res.send(list)
})
},
@@ -33,10 +33,10 @@ module.exports.post = {
const id = req.body.id > 0 ? req.body.id : null
if (id) {
db.group.findOne({ where: { id: id } }).then(group => {
- Promise.all([
- group.update({ name: req.body.name, description: req.body.description }),
- group.setParents(req.body.parentIds)
- ]).then(() => { res.send({id}) })
+ var promises = []
+ if (req.body.info) promises.push([group.update(req.body.info)])
+ if (req.body.parentIds) promises.push(group.setParents(req.body.parentIds))
+ Promise.all(promises).then(() => { res.send({id}) })
})
} else {
res.end()