Merge branch 'master' of https://github.com/LukasNowy/SmartShopper
This commit is contained in:
commit
131f1c4448
@ -84,7 +84,7 @@ async function displayShoppinglist(sl_id) {
|
||||
try {
|
||||
let groups = await query('SELECT row_to_json("Group") AS obj FROM "Group" JOIN "Shoppinglist" USING (sl_id) WHERE sl_id = $1;', [sl_id]);
|
||||
let items = await query('SELECT row_to_json("Item") AS obj FROM "Item" JOIN "Group" USING (group_id) WHERE "Group".sl_id = $1;', [sl_id]);
|
||||
return items_in_groups(groups, items);
|
||||
return items_in_groups(groups, items, sl_id);
|
||||
|
||||
|
||||
}
|
||||
@ -173,13 +173,16 @@ function generate_item_id() {
|
||||
return output;
|
||||
}
|
||||
|
||||
function items_in_groups(groups, items) {
|
||||
function items_in_groups(groups, items, sl_id) {
|
||||
|
||||
let result = [];
|
||||
let result = {
|
||||
sl_id: sl_id,
|
||||
groups: []
|
||||
};
|
||||
|
||||
for(let item of groups) {
|
||||
|
||||
result.push({
|
||||
result.groups.push({
|
||||
group_id: item.group_id,
|
||||
name: item.name,
|
||||
color: item.color,
|
||||
|
Loading…
x
Reference in New Issue
Block a user