++ Added "Projects" (step 1b)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Todos, UserStore } from '@store'
|
||||
import { Projects, Todos, UserStore } from '@store'
|
||||
import _ from 'lodash'
|
||||
import { GlobalStore } from '../store/Modules'
|
||||
|
||||
@@ -24,44 +24,49 @@ function writeConfigIndexDb(context, data) {
|
||||
storage.setdata('config', data)
|
||||
}
|
||||
|
||||
async function readfromIndexDbToStateTodos(context, table) {
|
||||
console.log('*** readfromIndexDbToStateTodos ***')
|
||||
async function readfromIndexDbToState(context, table) {
|
||||
console.log('*** readfromIndexDbToState ***')
|
||||
|
||||
return await storage.getalldata(table)
|
||||
.then((reccat) => {
|
||||
// console.log('&&&&&&& readfromIndexDbToStateTodos OK: Num RECORD: ', records.length)
|
||||
// console.log('&&&&&&& readfromIndexDbToState OK: Num RECORD: ', records.length)
|
||||
if (table === 'categories') {
|
||||
console.log('reccat', reccat)
|
||||
Todos.state.categories = []
|
||||
for (const indcat in reccat) {
|
||||
Todos.state.categories.push(reccat[indcat].valore)
|
||||
for (const elem of reccat) {
|
||||
Todos.state.categories.push(elem.valore)
|
||||
}
|
||||
|
||||
console.log('ARRAY Categories', Todos.state.categories)
|
||||
table = 'todos'
|
||||
|
||||
return storage.getalldata('todos')
|
||||
return storage.getalldata(table)
|
||||
.then((records) => {
|
||||
console.log('todos records', records)
|
||||
// console.log('&&&&&&& readfromIndexDbToStateTodos OK: Num RECORD: ', records.length)
|
||||
console.log(table + ' records', records)
|
||||
// console.log('&&&&&&& readfromIndexDbToState OK: Num RECORD: ', records.length)
|
||||
|
||||
/*
|
||||
for (const myrec in records) {
|
||||
const cat = myrec.category
|
||||
const indcat = state.categories.indexOf(cat)
|
||||
for (const mytodo of records) {
|
||||
const cat = mytodo.category
|
||||
const indcat = Todos.state.categories.indexOf(cat)
|
||||
if (Todos.state.todos[indcat] === undefined) {
|
||||
Todos.state.todos[indcat] = {}
|
||||
}
|
||||
|
||||
// add to the right array
|
||||
Todos.state.todos[indcat].push(myrec)
|
||||
|
||||
Todos.state.todos[indcat].push(mytodo)
|
||||
}
|
||||
*/
|
||||
|
||||
console.log('************ ARRAYS SALVATI IN MEMORIA Todos.state.todos ', Todos.state.todos)
|
||||
console.log('************ ARRAYS SALVATI IN MEMORIA ', records)
|
||||
})
|
||||
|
||||
} else if (table === 'projects') {
|
||||
Projects.state.projects = []
|
||||
for (const elem of reccat) {
|
||||
Projects.state.projects.push(elem.valore)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}).catch((error) => {
|
||||
console.log('err: ', error)
|
||||
})
|
||||
@@ -91,7 +96,7 @@ export default async (context, cmd, table, datakey = null, id = '') => {
|
||||
}
|
||||
return await storage.setdata(table, datakey)
|
||||
} else if (cmd === 'updatefromIndexedDbToStateTodo') {
|
||||
return await readfromIndexDbToStateTodos(context, table)
|
||||
return await readfromIndexDbToState(context, table)
|
||||
} else if (cmd === 'readall') {
|
||||
if (GlobalStore) {
|
||||
GlobalStore.state.connData.downloading_indexeddb = 1
|
||||
|
||||
Reference in New Issue
Block a user