diff --git a/docs/docs.txt b/docs/docs.txt index a795997..4f522d8 100644 --- a/docs/docs.txt +++ b/docs/docs.txt @@ -4,3 +4,31 @@ md 992px Medium-sized window lg 1200px Large sized window xl Infinite Extra large sized window + +-------------------------------------------------------- +https://alligator.io/vuejs/progressive-image-rendering/ +--- lOADING LAZY IMAGES: +-------------------------------------------------------- + + + + - - - - + + + + diff --git a/src/model/GlobalStore.ts b/src/model/GlobalStore.ts index d5adf31..6504e23 100644 --- a/src/model/GlobalStore.ts +++ b/src/model/GlobalStore.ts @@ -11,6 +11,7 @@ export interface IConnData { export interface ICfgServer { chiave: string + userId: string valore: string } @@ -21,6 +22,12 @@ export interface ITestp1 { export type StateConnection = 'online' | 'offline' +export interface IConfig { + _id: string, + key?: string, + value: string +} + export interface IGlobalState { conta: number wasAlreadySubOnDb: boolean @@ -38,6 +45,7 @@ export interface IGlobalState { connData: IConnData posts: IPost[] listatodo: ITodoList[] + arrConfig: IConfig[] } diff --git a/src/model/Todos.ts b/src/model/Todos.ts index 85ce990..3ea0da1 100644 --- a/src/model/Todos.ts +++ b/src/model/Todos.ts @@ -35,10 +35,9 @@ export interface IDrag { atfirst?: boolean } - export interface ITodosState { - visuOnlyUncompleted: boolean - todos: [ ITodo[] ] + showtype: number + todos: [ITodo[]] categories: string[] // todos_changed: number reload_fromServer: number diff --git a/src/store/Api/index.ts b/src/store/Api/index.ts index b302377..f51b0ae 100644 --- a/src/store/Api/index.ts +++ b/src/store/Api/index.ts @@ -13,7 +13,8 @@ import { GlobalStore, UserStore } from '@modules' import globalroutines from './../../globalroutines/index' import { serv_constants } from '@src/store/Modules/serv_constants' import router from '@router' -import * as Types from "@src/store/Api/ApiTypes" +import * as Types from '@src/store/Api/ApiTypes' +import { costanti } from '@src/store/Modules/costanti' // const algoliaApi = new AlgoliaSearch() @@ -188,7 +189,8 @@ export namespace ApiTool { // console.log('¨¨¨¨¨¨¨¨¨¨¨¨¨¨ errorfromserver:', errorfromserver) const mystate = errorfromserver ? 'offline' : 'online' GlobalStore.mutations.setStateConnection(mystate) - return globalroutines(null, 'write', 'config', { _id: 2, stateconn: mystate }) + GlobalStore.mutations.saveConfig( { _id: costanti.CONFIG_ID_STATE_CONN, value: mystate }) + }) // console.log(' [Alternative] A2) ?????????????????????????? ESCO DAL LOOP !!!!!!!!!') diff --git a/src/store/Modules/GlobalStore.ts b/src/store/Modules/GlobalStore.ts index cafebf0..5945692 100644 --- a/src/store/Modules/GlobalStore.ts +++ b/src/store/Modules/GlobalStore.ts @@ -1,4 +1,4 @@ -import { ICfgServer, IGlobalState, StateConnection } from 'model' +import { ICfgServer, IConfig, IGlobalState, StateConnection } from 'model' import { storeBuilder } from './Store/Store' import Vue from 'vue' @@ -12,18 +12,12 @@ import { GlobalStore, Todos, UserStore } from '@store' import globalroutines from './../../globalroutines/index' import Api from '@api' import { tools } from '@src/store/Modules/tools' +import { costanti } from '@src/store/Modules/costanti' +import * as Types from '@src/store/Api/ApiTypes' const allTables = ['todos', 'categories', 'sync_todos', 'sync_todos_patch', 'delete_todos', 'config', 'swmsg'] const allTablesAfterLogin = ['todos', 'categories', 'sync_todos', 'sync_todos_patch', 'delete_todos', 'config', 'swmsg'] -async function getstateConnSaved() { - const config = await globalroutines(null, 'readall', 'config', null) - if (config.length > 1) { - return config[1].stateconn - } else { - return 'online' - } -} let stateConnDefault = 'online' @@ -57,6 +51,22 @@ const state: IGlobalState = { uploading_indexeddb: 0, downloading_server: 0, downloading_indexeddb: 0 + }, + arrConfig: [] +} + +async function getConfig(id) { + return await globalroutines(null, 'read', 'config', null, id) +} + +async function getstateConnSaved() { + const config = await getConfig(costanti.CONFIG_ID_CFG) + console.log('config', config) + if (config.length > 1) { + const cfgstateconn = config[1] + return cfgstateconn.stateconn + } else { + return 'online' } } @@ -71,7 +81,27 @@ namespace Getters { const category = b.read(state => state.category, 'category') const testpao1_getter_contatore = b.read(state => param1 => state.testp1.contatore + 100 + param1, 'testpao1_getter_contatore') - const testpao1_getter_array = b.read(state => param1 => state.testp1.mioarray.filter(item => item).map(item => item.valore) , 'testpao1_getter_array') + const testpao1_getter_array = b.read(state => param1 => state.testp1.mioarray.filter(item => item).map(item => item.valore), 'testpao1_getter_array') + + const getConfigbyId = b.read(state => id => state.arrConfig.find(item => item._id === id), 'getConfigbyId') + const getConfigStringbyId = b.read(state => id => { + const config = state.arrConfig.find(item => item._id === id) + if (config) { + return config.value + } else { + return '' + } + }, 'getConfigStringbyId') + + const showtype = b.read(state => { + // const config = state.arrConfig.find(item => item._id === cat + costanti.CONFIG_ID_SHOW_TYPE_TODOS) + const config = state.arrConfig.find(item => item._id === costanti.CONFIG_ID_SHOW_TYPE_TODOS) + if (config) + return config.value + else + return '' + + }, 'showtype') export const getters = { @@ -93,6 +123,18 @@ namespace Getters { return category() }, + get getConfigbyId() { + return getConfigbyId() + }, + + get getConfigStringbyId() { + return getConfigStringbyId() + }, + + get showtype() { + return showtype() + }, + get isOnline() { console.log('*********************** isOnline') return state.stateConnection === 'online' @@ -118,9 +160,11 @@ namespace Mutations { tools.notifyarraychanged(state.testp1.mioarray) console.log('last elem = ', state.testp1.mioarray[state.testp1.mioarray.length - 1]) } + function NewArray(state: IGlobalState, newarr: ICfgServer[]) { state.testp1.mioarray = newarr } + function setPaoArray_Delete(state: IGlobalState) { state.testp1.mioarray.pop() } @@ -144,19 +188,39 @@ namespace Mutations { } } + function saveConfig(state: IGlobalState, data: IConfig) { + let dataout + // this.$set(dataout, data.value, {'value': 'default value'}) + return globalroutines(null, 'write', 'config', { _id: data._id, value: data.value }) + } + function SetwasAlreadySubOnDb(state: IGlobalState, subscrib: boolean) { state.wasAlreadySubOnDb = subscrib } + function setShowType(state: IGlobalState, showtype: number) { + // console.log('setShowType', showtype) + const config = Getters.getters.getConfigbyId(costanti.CONFIG_ID_SHOW_TYPE_TODOS) + // console.log('config', config) + if (config) { + config.value = String(showtype) + Todos.state.showtype = parseInt(config.value) + // console.log('Todos.state.showtype', Todos.state.showtype) + GlobalStore.mutations.saveConfig({ _id: costanti.CONFIG_ID_SHOW_TYPE_TODOS, value: String(showtype) }) + } + } + export const mutations = { setConta: b.commit(setConta), setleftDrawerOpen: b.commit(setleftDrawerOpen), setCategorySel: b.commit(setCategorySel), setStateConnection: b.commit(setStateConnection), SetwasAlreadySubOnDb: b.commit(SetwasAlreadySubOnDb), + saveConfig: b.commit(saveConfig), setPaoArray: b.commit(setPaoArray), setPaoArray_Delete: b.commit(setPaoArray_Delete), - NewArray: b.commit(NewArray) + NewArray: b.commit(NewArray), + setShowType: b.commit(setShowType) } } @@ -339,7 +403,10 @@ namespace Actions { async function loadAfterLogin(context) { + console.log('loadAfterLogin') actions.clearDataAfterLoginOnlyIfActiveConnection() + + state.arrConfig = await globalroutines(null, 'readall', 'config', null) } async function saveCfgServerKey(context, dataval: ICfgServer) { diff --git a/src/store/Modules/Todos.ts b/src/store/Modules/Todos.ts index d2c6e3e..1bdda15 100644 --- a/src/store/Modules/Todos.ts +++ b/src/store/Modules/Todos.ts @@ -1,4 +1,4 @@ -import { IGlobalState, ITodo, ITodosState, IParamTodo, IUserState, IDrag } from 'model' +import { ITodo, ITodosState, IParamTodo, IDrag } from 'model' import { storeBuilder } from './Store/Store' import Api from '@api' @@ -9,11 +9,12 @@ import { Mutation } from 'vuex-module-decorators' import { serv_constants } from '@src/store/Modules/serv_constants' import { GetterTree } from 'vuex' import objectId from '@src/js/objectId' +import { costanti } from '@src/store/Modules/costanti' // import _ from 'lodash' const state: ITodosState = { - visuOnlyUncompleted: false, + showtype: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED, todos: [[]], categories: [], // todos_changed: 1, @@ -228,7 +229,12 @@ namespace Getters { const todos_completati = b.read((state: ITodosState) => (cat: string): ITodo[] => { const indcat = getindexbycategory(cat) if (state.todos[indcat]) { - return state.todos[indcat].filter(todo => todo.completed).slice(0, state.visuLastCompleted) // Show only the first N completed + if (state.showtype === costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED) + return state.todos[indcat].filter(todo => todo.completed).slice(0, state.visuLastCompleted) // Show only the first N completed + else if (state.showtype === costanti.ShowTypeTask.SHOW_ALL) + return state.todos[indcat].filter(todo => todo.completed) + else + return [] } else return [] }, 'todos_completati') @@ -409,10 +415,14 @@ namespace Actions { return await dbLoadTodo(context, { checkPending: false }) } + async function readConfig(id) { + return await globalroutines(null, 'read', 'config', null, String(id)) + } + async function checkPendingMsg(context) { // console.log('checkPendingMsg') - const config = await globalroutines(null, 'readall', 'config', null) + const config = await globalroutines(null, 'read', 'config', null, '1') // console.log('config', config) try { @@ -466,6 +476,12 @@ namespace Actions { state.todos = [[]] } + // console.log('PRIMA showtype = ', state.showtype) + + state.showtype = parseInt(GlobalStore.getters.getConfigStringbyId(costanti.CONFIG_ID_SHOW_TYPE_TODOS)) + + // console.log('showtype = ', state.showtype) + // console.log('ARRAY TODOS = ', state.todos) console.log('dbLoadTodo', 'state.todos', state.todos, 'state.categories', state.categories) @@ -681,28 +697,32 @@ namespace Actions { if (atfirst) { // Check the second item, if it's different priority, then move to the first position of the priority const secondindelem = indelem + 1 - const secondelem = getElemByIndex(objtodo.category, secondindelem) - if (secondelem.priority !== objtodo.priority) { - itemdragend = { - field: 'priority', - idelemtochange: objtodo._id, - prioritychosen: objtodo.priority, - category: objtodo.category, - atfirst + if (isValidIndex(objtodo.category, secondindelem)) { + const secondelem = getElemByIndex(objtodo.category, secondindelem) + if (secondelem.priority !== objtodo.priority) { + itemdragend = { + field: 'priority', + idelemtochange: objtodo._id, + prioritychosen: objtodo.priority, + category: objtodo.category, + atfirst + } } } } else { // get previous of the last const prevlastindelem = indelem - 1 - const prevlastelem = getElemByIndex(objtodo.category, prevlastindelem) - if (prevlastelem.priority !== objtodo.priority) { - itemdragend = { - field: 'priority', - idelemtochange: objtodo._id, - prioritychosen: objtodo.priority, - category: objtodo.category, - atfirst + if (isValidIndex(objtodo.category, prevlastindelem)) { + const prevlastelem = getElemByIndex(objtodo.category, prevlastindelem) + if (prevlastelem.priority !== objtodo.priority) { + itemdragend = { + field: 'priority', + idelemtochange: objtodo._id, + prioritychosen: objtodo.priority, + category: objtodo.category, + atfirst + } } } } diff --git a/src/store/Modules/costanti.ts b/src/store/Modules/costanti.ts new file mode 100644 index 0000000..5746789 --- /dev/null +++ b/src/store/Modules/costanti.ts @@ -0,0 +1,10 @@ +export const costanti = { + ShowTypeTask: { + SHOW_LAST_N_COMPLETED: 200, + SHOW_ONLY_TOCOMPLETE: 201, + SHOW_ALL: 202 + }, + CONFIG_ID_CFG: '1', + CONFIG_ID_STATE_CONN: '2', + CONFIG_ID_SHOW_TYPE_TODOS: '3' +} diff --git a/src/store/Modules/tools.ts b/src/store/Modules/tools.ts index c08f938..0946e19 100644 --- a/src/store/Modules/tools.ts +++ b/src/store/Modules/tools.ts @@ -1,4 +1,5 @@ import { ITodo } from '@src/model' +import { costanti } from './costanti' import globalroutines from './../../globalroutines/index' import { Todos, UserStore } from '@store' import Api from '@api' @@ -51,7 +52,8 @@ export const tools = { TOGGLE_EXPIRING: 101, COMPLETED: 110, PROGRESS_BAR: 120, - PRIORITY: 130 + PRIORITY: 130, + SHOW_TASK: 150, }, @@ -252,6 +254,105 @@ export const tools = { ] }, + menuPopupConfigTodo: { + 'it': [ + { + id: 10, + label: 'Mostra Task', + value: 150, // SHOW_TASK + icon: 'rowing', + }, + ], + 'esEs': [ + { + id: 10, + label: 'Mostrar Tareas', + value: 150, + icon: 'rowing', + }, + ], + 'enUs': [ + { + id: 10, + label: 'Show Task', + value: 150, + icon: 'rowing', + }, + ] + }, + + listOptionShowTask: { + 'it': [ + { + id: 10, + label: 'Mostra gli ultimi N completati', + value: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED, + icon: 'rowing', + checked: true + }, + { + id: 20, + label: 'Compiti da Completare', + value: costanti.ShowTypeTask.SHOW_ONLY_TOCOMPLETE, + icon: 'rowing', + checked: false + }, + { + id: 30, + label: 'Tutti i compiti', + value: costanti.ShowTypeTask.SHOW_ALL, + icon: 'check_circle', + checked: true + } + ], + 'esEs': [ + { + id: 10, + label: 'Mostrar los ultimos N completados', + value: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED, + icon: 'rowing', + checked: true + }, + { + id: 20, + label: 'Tareas para completar', + value: costanti.ShowTypeTask.SHOW_ONLY_TOCOMPLETE, + icon: 'rowing', + checked: false + }, + { + id: 30, + label: 'Todos las Tareas', + value: costanti.ShowTypeTask.SHOW_ALL, + icon: 'check_circle', + checked: true + } + ], + 'enUs': [ + { + id: 10, + label: 'Show last N Completed', + value: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED, + icon: 'rowing', + checked: true + }, + { + id: 20, + label: 'Task to complete', + value: costanti.ShowTypeTask.SHOW_ONLY_TOCOMPLETE, + icon: 'rowing', + checked: false + }, + { + id: 30, + label: 'All Tasks', + value: costanti.ShowTypeTask.SHOW_ALL, + icon: 'check_circle', + checked: true + } + ] + }, + jsonCopy(src) { return JSON.parse(JSON.stringify(src)) },