Popupmenu Todo:
- Show Task Completed
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
src/store/Modules/costanti.ts
Normal file
10
src/store/Modules/costanti.ts
Normal file
@@ -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'
|
||||
}
|
||||
@@ -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))
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user