diff --git a/apps/grocery/ChangeLog b/apps/grocery/ChangeLog index cb066ef3d..38cef7076 100644 --- a/apps/grocery/ChangeLog +++ b/apps/grocery/ChangeLog @@ -2,3 +2,4 @@ 0.02: Refactor code to store grocery list in separate file 0.03: Sort selected items to bottom and enable Widgets 0.04: Add settings to edit list on device +0.05: Drop app customiser as it is redundant with download interface diff --git a/apps/grocery/app.js b/apps/grocery/app.js index a68f53010..c087f1311 100644 --- a/apps/grocery/app.js +++ b/apps/grocery/app.js @@ -1,18 +1,19 @@ -var filename = 'grocery_list.json'; -var settings = require("Storage").readJSON(filename,1)|| { products: [] }; +{ +const filename = 'grocery_list.json'; +const settings = require("Storage").readJSON(filename,1)|| { products: [] }; let menu; -function updateSettings() { +const updateSettings = function() { require("Storage").writeJSON(filename, settings); Bangle.buzz(); -} +}; -function twoChat(n){ +const twoChat = function(n) { if(n<10) return '0'+n; return ''+n; -} +}; -function sortMenu() { +const sortMenu = function() { mainMenu.sort((a,b) => { const byValue = a.value-b.value; return byValue !== 0 ? byValue : a.index-b.index; @@ -20,7 +21,7 @@ function sortMenu() { if (menu) { menu.draw(); } -} +}; const mainMenu = settings.products.map((p,i) => ({ title: twoChat(p.quantity)+' '+p.name, @@ -35,9 +36,14 @@ const mainMenu = settings.products.map((p,i) => ({ })); sortMenu(); -mainMenu[''] = { 'title': 'Grocery list' }; +mainMenu[''] = { + 'title': 'Grocery list', + remove: () => { + }, +}; mainMenu['< Back'] = ()=>{load();}; Bangle.loadWidgets(); menu = E.showMenu(mainMenu); Bangle.drawWidgets(); +} diff --git a/apps/grocery/grocery.html b/apps/grocery/grocery.html deleted file mode 100644 index e717dee2e..000000000 --- a/apps/grocery/grocery.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - -

List of products

- - - - - - - - - - - -
namequantityactions
-

-

Add a new product

-
-
-
- -
-
- -
-
- -
-
-
-

- - - - - - - diff --git a/apps/grocery/interface.html b/apps/grocery/interface.html index 58ab2a484..0c8df1e86 100644 --- a/apps/grocery/interface.html +++ b/apps/grocery/interface.html @@ -80,7 +80,7 @@ // remove window Util.hideModal(); - settings = JSON.parse(data || "{products: []}"); + settings = JSON.parse(data || '{"products": []}'); products = settings.products; renderProducts(); }); @@ -89,7 +89,6 @@ function save(){ settings.products = products; Util.showModal("Saving..."); - localStorage.setItem('grocery-product-list',JSON.stringify(products)); Util.writeStorage("grocery_list.json", JSON.stringify(settings), () => { Util.hideModal(); }); diff --git a/apps/grocery/metadata.json b/apps/grocery/metadata.json index 8cf304cc1..9262b0c5e 100644 --- a/apps/grocery/metadata.json +++ b/apps/grocery/metadata.json @@ -1,13 +1,12 @@ { "id": "grocery", "name": "Grocery", - "version": "0.04", + "version": "0.05", "description": "Simple grocery (shopping) list - Display a list of product and track if you already put them in your cart.", "icon": "grocery.png", "type": "app", "tags": "tool,shopping,list", "supports": ["BANGLEJS", "BANGLEJS2"], - "custom": "grocery.html", "interface": "interface.html", "allow_emulator": true, "dependencies": {"textinput":"type"}, diff --git a/apps/grocery/settings.js b/apps/grocery/settings.js index 5f84fd782..a39f12d8c 100644 --- a/apps/grocery/settings.js +++ b/apps/grocery/settings.js @@ -118,7 +118,7 @@ /*LANG*/"Edit List": () => editlist(), /*LANG*/"Add item": () => { settings.products.push({ - "name":/*LANG*/"New item", + "name":/*LANG*/"New", "quantity":1, "ok":false });