rename shoppinglist
This commit is contained in:
		@@ -67,6 +67,27 @@ async function newShoppinglist(name, description, username, color) {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//rename Shoppinglist
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async function renameShoppinglist(sl_id, newname, newdescription) {
 | 
			
		||||
    try {
 | 
			
		||||
        let shoppinglist = await query('SELECT row_to_json("Shoppinglist") AS obj FROM "Shoppinglist" WHERE sl_id = $1;', [sl_id]);
 | 
			
		||||
        
 | 
			
		||||
        if(shoppinglist.name != newname) {
 | 
			
		||||
            await nonQuery('UPDATE "Shoppinglist" SET name = $1 WHERE sl_id = $2;', [newname, sl_id]);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(shoppinglist.description != newdescription) {
 | 
			
		||||
            await nonQuery('UPDATE "Shoppinglist" SET description = $1 WHERE sl_id = $2;', [newdescription, sl_id]);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    catch (error) {
 | 
			
		||||
        console.error(error);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function generateUser() {
 | 
			
		||||
        //insert user
 | 
			
		||||
 | 
			
		||||
@@ -133,6 +154,8 @@ async function addItem(group_id, sl_id, name, count) {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Invite System
 | 
			
		||||
 | 
			
		||||
async function verifyInvite(link, user_id) {
 | 
			
		||||
@@ -160,10 +183,6 @@ async function createInvite(sl_id) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//sl_id generieren
 | 
			
		||||
function generate_sl_id() {
 | 
			
		||||
    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
 | 
			
		||||
@@ -234,5 +253,5 @@ function generateInviteLink() {
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
    getShoppinglistsAdmin, getShoppinglistsShared, newShoppinglist, displayShoppinglist, deleteShoppinglist, addGroup,
 | 
			
		||||
    addItem, verifyInvite, createInvite
 | 
			
		||||
    addItem, verifyInvite, createInvite, renameShoppinglist
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user