++ Added "Projects" (step 1b)
This commit is contained in:
@@ -5,19 +5,39 @@ import globalroutines from './../../globalroutines/index'
|
||||
import { serv_constants } from '@src/store/Modules/serv_constants'
|
||||
import { tools } from '@src/store/Modules/tools'
|
||||
|
||||
export const allTables = ['todos', 'categories', 'sync_post_todos', 'sync_patch_todos', 'delete_todos', 'config', 'swmsg']
|
||||
export const OtherTables = ['categories', 'config', 'swmsg']
|
||||
export const MainTables = ['todos', 'projects']
|
||||
export const allMethod = ['sync_post_', 'sync_patch_', 'delete_']
|
||||
|
||||
export function getLinkByTableName(nametable) {
|
||||
if (nametable === 'todos') {
|
||||
return 'todos'
|
||||
} else if (nametable === 'projects') {
|
||||
return 'projects'
|
||||
}
|
||||
}
|
||||
|
||||
export const LIST_START = '0'
|
||||
|
||||
export const DB = {
|
||||
CMD_SYNC: 'sync-',
|
||||
CMD_SYNC_NEW: 'sync-new-',
|
||||
CMD_DELETE: 'sync-delete-',
|
||||
CMD_SYNC: 'sync',
|
||||
CMD_SYNC_NEW: 'sync-new',
|
||||
CMD_DELETE: 'sync-delete',
|
||||
TABLE_SYNC_POST: 'sync_post_',
|
||||
TABLE_SYNC_PATCH: 'sync_patch_',
|
||||
TABLE_DELETE: 'delete_'
|
||||
}
|
||||
|
||||
export function allTables() {
|
||||
const myarr = OtherTables
|
||||
for (const tab of MainTables) {
|
||||
for (const method of allMethod) {
|
||||
myarr.push(method + tab)
|
||||
}
|
||||
}
|
||||
return myarr
|
||||
}
|
||||
|
||||
async function dbInsertSave(call, item, method) {
|
||||
|
||||
let ret = true
|
||||
@@ -75,10 +95,10 @@ async function dbDeleteItem(call, item) {
|
||||
}
|
||||
}
|
||||
|
||||
async function Sync_Execute(cmd, table, method, item: ITodo, id, msg: String) {
|
||||
async function Sync_Execute(cmd, tablesync, nametab, method, item: ITodo, id, msg: String) {
|
||||
// Send to Server to Sync
|
||||
|
||||
// console.log('Sync_Execute', cmd, table, method, item.descr, id, msg)
|
||||
console.log('Sync_Execute', cmd, tablesync, nametab, method, item.descr, id, msg)
|
||||
|
||||
let cmdSw = cmd
|
||||
if ((cmd === DB.CMD_SYNC_NEW) || (cmd === DB.CMD_DELETE)) {
|
||||
@@ -88,18 +108,19 @@ async function Sync_Execute(cmd, table, method, item: ITodo, id, msg: String) {
|
||||
if ('serviceWorker' in navigator) {
|
||||
return await navigator.serviceWorker.ready
|
||||
.then((sw) => {
|
||||
// console.log('---------------------- navigator.serviceWorker.ready')
|
||||
console.log('---------------------- navigator.serviceWorker.ready')
|
||||
|
||||
return globalroutines(null, 'write', table, item, id)
|
||||
return globalroutines(null, 'write', tablesync, item, id)
|
||||
.then((id) => {
|
||||
// console.log('id', id)
|
||||
const sep = '|'
|
||||
|
||||
const multiparams = cmdSw + sep + table + sep + method + sep + UserStore.state.x_auth_token + sep + UserStore.state.lang
|
||||
const multiparams = cmdSw + sep + tablesync + sep + nametab + sep + method + sep + UserStore.state.x_auth_token + sep + UserStore.state.lang
|
||||
const mymsgkey = {
|
||||
_id: multiparams,
|
||||
value: multiparams
|
||||
}
|
||||
console.log('*** swmsg')
|
||||
return globalroutines(null, 'write', 'swmsg', mymsgkey, multiparams)
|
||||
.then((ris) => {
|
||||
// if ('SyncManager' in window) {
|
||||
@@ -118,19 +139,26 @@ async function Sync_Execute(cmd, table, method, item: ITodo, id, msg: String) {
|
||||
return data
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('Errore in globalroutines', table, err)
|
||||
console.error('Errore in globalroutines', tablesync, nametab, err)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async function Sync_ExecuteCmd(cmd, nametab: string, table, method, item: ITodo, id, msg: String) {
|
||||
async function Sync_ExecuteCmd(cmd, nametab: string, method, item: ITodo, id, msg: String) {
|
||||
// Send to Server to Sync
|
||||
|
||||
console.log('Sync_Execute', cmd, table, method, item.descr, id, msg)
|
||||
let tablesync = ''
|
||||
if (method === 'POST') {
|
||||
tablesync = DB.TABLE_SYNC_POST + nametab
|
||||
} else if (method === 'PATCH') {
|
||||
tablesync = DB.TABLE_SYNC_PATCH + nametab
|
||||
} else if (method === 'DELETE') {
|
||||
tablesync = DB.TABLE_DELETE + nametab
|
||||
}
|
||||
|
||||
const risdata = await Sync_Execute(cmd, table, method, item, id, msg)
|
||||
const risdata = await Sync_Execute(cmd, tablesync, nametab, method, item, id, msg)
|
||||
|
||||
if (cmd === DB.CMD_SYNC_NEW) {
|
||||
if ((method === 'POST') || (method === 'PATCH')) {
|
||||
@@ -144,19 +172,11 @@ async function Sync_ExecuteCmd(cmd, nametab: string, table, method, item: ITodo,
|
||||
}
|
||||
|
||||
export async function Sync_SaveItem(nametab: string, method, item) {
|
||||
let table = ''
|
||||
if (method === 'POST') {
|
||||
table = DB.TABLE_SYNC_POST
|
||||
}
|
||||
else if (method === 'PATCH') {
|
||||
table = DB.TABLE_SYNC_PATCH
|
||||
}
|
||||
|
||||
return await Sync_ExecuteCmd(DB.CMD_SYNC_NEW, nametab, table + nametab, method, item, 0, '')
|
||||
return await Sync_ExecuteCmd(DB.CMD_SYNC_NEW, nametab, method, item, 0, '')
|
||||
}
|
||||
|
||||
export function Sync_DeleteItem(nametab: string, item, id) {
|
||||
Sync_ExecuteCmd(DB.CMD_DELETE, nametab, DB.TABLE_DELETE + nametab, 'DELETE', item, id, '')
|
||||
Sync_ExecuteCmd(DB.CMD_DELETE, nametab, 'DELETE', item, id, '')
|
||||
}
|
||||
|
||||
export async function aftercalling(ris, checkPending: boolean, nametabindex: string) {
|
||||
@@ -268,8 +288,8 @@ async function sendSwMsgIfAvailable() {
|
||||
}
|
||||
|
||||
async function waitAndRefreshData() {
|
||||
return await Projects.actions.dbLoadProjects({ checkPending: false })
|
||||
return await Todos.actions.dbLoadTodo({ checkPending: false })
|
||||
return await Projects.actions.dbLoad({ checkPending: false })
|
||||
return await Todos.actions.dbLoad({ checkPending: false })
|
||||
}
|
||||
|
||||
export async function waitAndcheckPendingMsg() {
|
||||
@@ -372,7 +392,7 @@ export async function table_ModifyRecord(nametable, myitem, fieldtochange) {
|
||||
})
|
||||
|
||||
if (miorec.modified) {
|
||||
console.log('Todo MODIFICATO! ', miorec.descr, miorec.pos, 'SALVALO SULLA IndexedDB todos')
|
||||
console.log(nametable + ' MODIFICATO! ', miorec.descr, miorec.pos, 'SALVALO SULLA IndexedDB')
|
||||
miorec.modify_at = new Date().getDate()
|
||||
miorec.modified = false
|
||||
|
||||
@@ -392,8 +412,10 @@ export async function table_ModifyRecord(nametable, myitem, fieldtochange) {
|
||||
|
||||
export function table_DeleteRecord(nametable, myobjtrov, id) {
|
||||
|
||||
const mymodule = tools.getModulesByTable(nametable)
|
||||
|
||||
// 1) Delete from the Todos Array
|
||||
Todos.mutations.deletemyitem(myobjtrov)
|
||||
mymodule.mutations.deletemyitem(myobjtrov)
|
||||
|
||||
// 2) Delete from the IndexedDb
|
||||
globalroutines(null, 'delete', nametable, null, id)
|
||||
@@ -403,10 +425,3 @@ export function table_DeleteRecord(nametable, myobjtrov, id) {
|
||||
|
||||
}
|
||||
|
||||
export function getLinkByTableName(nametable) {
|
||||
if (nametable === 'todos') {
|
||||
return 'todos'
|
||||
} else if (nametable === 'projects') {
|
||||
return 'projects'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ namespace Actions {
|
||||
console.log('clearDataAfterLogout')
|
||||
|
||||
// Clear all data from the IndexedDB
|
||||
for (const table of ApiTables.allTables) {
|
||||
for (const table of ApiTables.allTables()) {
|
||||
await globalroutines(null, 'clearalldata', table, null)
|
||||
}
|
||||
|
||||
@@ -474,14 +474,6 @@ namespace Actions {
|
||||
|
||||
async function clearDataAfterLoginOnlyIfActiveConnection(context) {
|
||||
|
||||
// if (Getters.getters.isOnline) {
|
||||
// console.log('clearDataAfterLoginOnlyIfActiveConnection')
|
||||
// // Clear all data from the IndexedDB
|
||||
// allTablesAfterLogin.forEach(table => {
|
||||
// globalroutines(null, 'clearalldata', table, null)
|
||||
// })
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
async function loadAfterLogin(context) {
|
||||
|
||||
@@ -9,14 +9,13 @@ import globalroutines from './../../globalroutines/index'
|
||||
import objectId from '@src/js/objectId'
|
||||
import { costanti } from '@src/store/Modules/costanti'
|
||||
|
||||
const nametable = 'projs'
|
||||
const nametable = 'projects'
|
||||
|
||||
// import _ from 'lodash'
|
||||
|
||||
const state: IProjectsState = {
|
||||
showtype: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED,
|
||||
projs: {},
|
||||
categories: [],
|
||||
projects: [],
|
||||
insidePending: false,
|
||||
visuLastCompleted: 10
|
||||
}
|
||||
@@ -26,21 +25,16 @@ const fieldtochange: string [] = ['descr', 'completed', 'category', 'expiring_at
|
||||
const b = storeBuilder.module<IProjectsState>('Projects', state)
|
||||
const stateGetter = b.state()
|
||||
|
||||
function getindexbycategory(category: string) {
|
||||
return state.categories.indexOf(category)
|
||||
}
|
||||
// function getindexbycategory(category: string) {
|
||||
// return state.categories.indexOf(category)
|
||||
// }
|
||||
|
||||
function gettodosByCategory(category: string) {
|
||||
const indcat = state.categories.indexOf(category)
|
||||
if (!state.projs[indcat]) {
|
||||
function getarrByCategory(category: string) {
|
||||
// const indcat = state.categories.indexOf(category)
|
||||
if (!state.projects) {
|
||||
return []
|
||||
}
|
||||
return state.projs[indcat]
|
||||
}
|
||||
|
||||
function isValidIndex(cat, index) {
|
||||
const myarr = gettodosByCategory(cat)
|
||||
return (index >= 0 && index < myarr.length)
|
||||
return state.projects
|
||||
}
|
||||
|
||||
function initcat() {
|
||||
@@ -64,7 +58,7 @@ function initcat() {
|
||||
id_prev: '',
|
||||
pos: 0,
|
||||
modified: false,
|
||||
progress: 0
|
||||
progressCalc: 0
|
||||
}
|
||||
// return this.copy(objproj)
|
||||
return objproj
|
||||
@@ -72,23 +66,21 @@ function initcat() {
|
||||
}
|
||||
|
||||
namespace Getters {
|
||||
const projs_dacompletare = b.read((state: IProjectsState) => (cat: string): IProject[] => {
|
||||
const indcat = getindexbycategory(cat)
|
||||
if (state.projs[indcat]) {
|
||||
return state.projs[indcat].filter((proj) => !proj.completed)
|
||||
const items_dacompletare = b.read((state: IProjectsState) => (cat: string): IProject[] => {
|
||||
if (state.projects) {
|
||||
return state.projects.filter((proj) => !proj.completed)
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}, 'projs_dacompletare')
|
||||
}, 'items_dacompletare')
|
||||
|
||||
const projs_completati = b.read((state: IProjectsState) => (cat: string): IProject[] => {
|
||||
const indcat = getindexbycategory(cat)
|
||||
if (state.projs[indcat]) {
|
||||
if (state.projects) {
|
||||
if (state.showtype === costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED) {
|
||||
return state.projs[indcat].filter((proj) => proj.completed).slice(0, state.visuLastCompleted)
|
||||
return state.projects.filter((proj) => proj.completed).slice(0, state.visuLastCompleted)
|
||||
} // Show only the first N completed
|
||||
else if (state.showtype === costanti.ShowTypeTask.SHOW_ALL) {
|
||||
return state.projs[indcat].filter((proj) => proj.completed)
|
||||
return state.projects.filter((proj) => proj.completed)
|
||||
}
|
||||
else {
|
||||
return []
|
||||
@@ -102,17 +94,16 @@ namespace Getters {
|
||||
return getters.projs_completati(cat).length
|
||||
}, 'doneProjectsCount')
|
||||
const ProjectsCount = b.read((state: IProjectsState) => (cat: string): number => {
|
||||
const indcat = getindexbycategory(cat)
|
||||
if (state.projs[indcat]) {
|
||||
return state.projs[indcat].length
|
||||
if (state.projects) {
|
||||
return state.projects.length
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}, 'ProjectsCount')
|
||||
|
||||
export const getters = {
|
||||
get projs_dacompletare() {
|
||||
return projs_dacompletare()
|
||||
get items_dacompletare() {
|
||||
return items_dacompletare()
|
||||
},
|
||||
get projs_completati() {
|
||||
return projs_completati()
|
||||
@@ -128,44 +119,30 @@ namespace Getters {
|
||||
|
||||
namespace Mutations {
|
||||
|
||||
function findIndTodoById(state: IProjectsState, data: IParamTodo) {
|
||||
const indcat = state.categories.indexOf(data.categorySel)
|
||||
if (indcat >= 0) {
|
||||
return state.projs[indcat].findIndex((elem) => elem._id === data.id)
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
function createNewItem(state: IProjectsState, { objproj, atfirst, categorySel }) {
|
||||
let indcat = state.categories.indexOf(categorySel)
|
||||
if (indcat === -1) {
|
||||
state.categories.push(categorySel)
|
||||
indcat = state.categories.indexOf(categorySel)
|
||||
}
|
||||
console.log('createNewItem', objproj, 'cat=', categorySel, 'state.projs[indcat]', state.projs[indcat])
|
||||
if (state.projs[indcat] === undefined) {
|
||||
state.projs[indcat] = []
|
||||
state.projs[indcat].push(objproj)
|
||||
console.log('push state.projs[indcat]', state.projs)
|
||||
console.log('createNewItem', objproj, 'cat=', categorySel, 'state.projects', state.projects)
|
||||
if (state.projects === undefined) {
|
||||
state.projects = []
|
||||
state.projects.push(objproj)
|
||||
console.log('push state.projects', state.projects)
|
||||
return
|
||||
}
|
||||
if (atfirst) {
|
||||
state.projs[indcat].unshift(objproj)
|
||||
state.projects.unshift(objproj)
|
||||
}
|
||||
else {
|
||||
state.projs[indcat].push(objproj)
|
||||
state.projects.push(objproj)
|
||||
}
|
||||
|
||||
console.log('state.projs[indcat]', state.projs[indcat])
|
||||
console.log('state.projects', state.projects)
|
||||
|
||||
}
|
||||
|
||||
function deletemyitem(state: IProjectsState, myitem: IProject) {
|
||||
// Find record
|
||||
const indcat = state.categories.indexOf(myitem.category)
|
||||
const ind = findIndTodoById(state, { id: myitem._id, categorySel: myitem.category })
|
||||
const ind = tools.getIndexById(state.projects, myitem._id)
|
||||
|
||||
ApiTables.removeitemfromarray(state.projs[indcat], ind)
|
||||
ApiTables.removeitemfromarray(state.projects, ind)
|
||||
}
|
||||
|
||||
export const mutations = {
|
||||
@@ -177,8 +154,8 @@ namespace Mutations {
|
||||
|
||||
namespace Actions {
|
||||
|
||||
async function dbLoadProjects(context, { checkPending }) {
|
||||
console.log('dbLoadProjects', checkPending, 'userid=', UserStore.state.userId)
|
||||
async function dbLoad(context, { checkPending }) {
|
||||
console.log('dbLoad', nametable, checkPending, 'userid=', UserStore.state.userId)
|
||||
|
||||
if (UserStore.state.userId === '') {
|
||||
return false // Login not made
|
||||
@@ -186,11 +163,10 @@ namespace Actions {
|
||||
|
||||
const ris = await Api.SendReq('/projects/' + UserStore.state.userId, 'GET', null)
|
||||
.then((res) => {
|
||||
if (res.data.projs) { // console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
|
||||
state.projs = res.data.projs
|
||||
state.categories = res.data.categories
|
||||
if (res.data.projects) { // console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
|
||||
state.projects = res.data.projects
|
||||
} else {
|
||||
state.projs = [[]]
|
||||
state.projects = []
|
||||
}
|
||||
|
||||
state.showtype = parseInt(GlobalStore.getters.getConfigStringbyId({
|
||||
@@ -198,15 +174,15 @@ namespace Actions {
|
||||
default: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED
|
||||
}), 10)
|
||||
|
||||
// console.log('ARRAY TODOS = ', state.projs)
|
||||
// console.log('ARRAY TODOS = ', state.projects)
|
||||
if (process.env.DEBUG === '1') {
|
||||
console.log('dbLoadProjects', 'state.projs', state.projs, 'state.categories', state.categories)
|
||||
console.log('dbLoad', 'state.projects', state.projects)
|
||||
}
|
||||
|
||||
return res
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error dbLoadProjects', error)
|
||||
console.log('error dbLoad', error)
|
||||
UserStore.mutations.setErrorCatch(error)
|
||||
return error
|
||||
})
|
||||
@@ -217,7 +193,7 @@ namespace Actions {
|
||||
async function deleteItem(context, { cat, idobj }) {
|
||||
console.log('deleteItem: KEY = ', idobj)
|
||||
|
||||
const myarr = gettodosByCategory(cat)
|
||||
const myarr = getarrByCategory(cat)
|
||||
|
||||
const myobjtrov = tools.getElemById(myarr, idobj)
|
||||
|
||||
@@ -236,7 +212,7 @@ namespace Actions {
|
||||
}
|
||||
}
|
||||
|
||||
async function insertProject(context, { myobj, atfirst }) {
|
||||
async function dbInsert(context, { myobj, atfirst }) {
|
||||
|
||||
const objproj = initcat()
|
||||
|
||||
@@ -245,7 +221,7 @@ namespace Actions {
|
||||
|
||||
let elemtochange: IProject = null
|
||||
|
||||
const myarr = gettodosByCategory(objproj.category)
|
||||
const myarr = getarrByCategory(objproj.category)
|
||||
|
||||
if (atfirst) {
|
||||
console.log('INSERT AT THE TOP')
|
||||
@@ -329,23 +305,20 @@ namespace Actions {
|
||||
}
|
||||
|
||||
async function swapElems(context, itemdragend: IDrag) {
|
||||
console.log('swapElems', itemdragend)
|
||||
console.log('state.projs', state.projs)
|
||||
console.log('state.categories', state.categories)
|
||||
console.log('PROJECT swapElems', itemdragend, state.projects)
|
||||
|
||||
const cat = itemdragend.category
|
||||
const indcat = state.categories.indexOf(cat)
|
||||
const myarr = state.projs[indcat]
|
||||
const myarr = state.projects
|
||||
|
||||
tools.swapGeneralElem(nametable, myarr, itemdragend, fieldtochange)
|
||||
|
||||
}
|
||||
|
||||
export const actions = {
|
||||
dbLoadProjects: b.dispatch(dbLoadProjects),
|
||||
dbLoad: b.dispatch(dbLoad),
|
||||
swapElems: b.dispatch(swapElems),
|
||||
deleteItem: b.dispatch(deleteItem),
|
||||
insertProject: b.dispatch(insertProject),
|
||||
dbInsert: b.dispatch(dbInsert),
|
||||
modify: b.dispatch(modify)
|
||||
}
|
||||
|
||||
|
||||
@@ -73,14 +73,14 @@ function initcat() {
|
||||
}
|
||||
|
||||
namespace Getters {
|
||||
const todos_dacompletare = b.read((state: ITodosState) => (cat: string): ITodo[] => {
|
||||
const items_dacompletare = b.read((state: ITodosState) => (cat: string): ITodo[] => {
|
||||
const indcat = getindexbycategory(cat)
|
||||
if (state.todos[indcat]) {
|
||||
return state.todos[indcat].filter((todo) => !todo.completed)
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}, 'todos_dacompletare')
|
||||
}, 'items_dacompletare')
|
||||
|
||||
const todos_completati = b.read((state: ITodosState) => (cat: string): ITodo[] => {
|
||||
const indcat = getindexbycategory(cat)
|
||||
@@ -112,8 +112,8 @@ namespace Getters {
|
||||
}, 'TodosCount')
|
||||
|
||||
export const getters = {
|
||||
get todos_dacompletare() {
|
||||
return todos_dacompletare()
|
||||
get items_dacompletare() {
|
||||
return items_dacompletare()
|
||||
},
|
||||
get todos_completati() {
|
||||
return todos_completati()
|
||||
@@ -132,7 +132,7 @@ namespace Mutations {
|
||||
function findIndTodoById(state: ITodosState, data: IParamTodo) {
|
||||
const indcat = state.categories.indexOf(data.categorySel)
|
||||
if (indcat >= 0) {
|
||||
return state.todos[indcat].findIndex((elem) => elem._id === data.id)
|
||||
return tools.getIndexById(state.todos[indcat], data.id)
|
||||
}
|
||||
return -1
|
||||
}
|
||||
@@ -178,8 +178,8 @@ namespace Mutations {
|
||||
|
||||
namespace Actions {
|
||||
|
||||
async function dbLoadTodo(context, { checkPending }) {
|
||||
console.log('dbLoadTodo', checkPending, 'userid=', UserStore.state.userId)
|
||||
async function dbLoad(context, { checkPending }) {
|
||||
console.log('dbLoad', nametable, checkPending, 'userid=', UserStore.state.userId)
|
||||
|
||||
if (UserStore.state.userId === '') {
|
||||
return false // Login not made
|
||||
@@ -201,13 +201,13 @@ namespace Actions {
|
||||
|
||||
// console.log('ARRAY TODOS = ', state.todos)
|
||||
if (process.env.DEBUG === '1') {
|
||||
console.log('dbLoadTodo', 'state.todos', state.todos, 'state.categories', state.categories)
|
||||
console.log('dbLoad', 'state.todos', state.todos, 'state.categories', state.categories)
|
||||
}
|
||||
|
||||
return res
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error dbLoadTodo', error)
|
||||
console.log('error dbLoad', error)
|
||||
UserStore.mutations.setErrorCatch(error)
|
||||
return error
|
||||
})
|
||||
@@ -237,7 +237,7 @@ namespace Actions {
|
||||
}
|
||||
}
|
||||
|
||||
async function insertTodo(context, { myobj, atfirst }) {
|
||||
async function dbInsert(context, { myobj, atfirst }) {
|
||||
|
||||
const objtodo = initcat()
|
||||
|
||||
@@ -330,9 +330,7 @@ namespace Actions {
|
||||
}
|
||||
|
||||
async function swapElems(context, itemdragend: IDrag) {
|
||||
console.log('swapElems', itemdragend)
|
||||
console.log('state.todos', state.todos)
|
||||
console.log('state.categories', state.categories)
|
||||
console.log('TODOS swapElems', itemdragend, state.todos, state.categories)
|
||||
|
||||
const cat = itemdragend.category
|
||||
const indcat = state.categories.indexOf(cat)
|
||||
@@ -343,10 +341,10 @@ namespace Actions {
|
||||
}
|
||||
|
||||
export const actions = {
|
||||
dbLoadTodo: b.dispatch(dbLoadTodo),
|
||||
dbLoad: b.dispatch(dbLoad),
|
||||
swapElems: b.dispatch(swapElems),
|
||||
deleteItem: b.dispatch(deleteItem),
|
||||
insertTodo: b.dispatch(insertTodo),
|
||||
dbInsert: b.dispatch(dbInsert),
|
||||
modify: b.dispatch(modify)
|
||||
}
|
||||
|
||||
|
||||
@@ -502,7 +502,7 @@ namespace Actions {
|
||||
|
||||
await GlobalStore.actions.loadAfterLogin()
|
||||
.then(() => {
|
||||
Todos.actions.dbLoadTodo({ checkPending: true })
|
||||
Todos.actions.dbLoad({ checkPending: true })
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ export const tools = {
|
||||
DUPLICATE_EMAIL_ID: 11000,
|
||||
DUPLICATE_USERNAME_ID: 11100,
|
||||
|
||||
FIRST_PROJ: '__FIRSTPROJ',
|
||||
|
||||
arrLangUsed: ['enUs', 'it', 'es'],
|
||||
|
||||
SERVKEY_VERS: 'vers',
|
||||
@@ -249,6 +251,57 @@ export const tools = {
|
||||
]
|
||||
},
|
||||
|
||||
menuPopupProj: {
|
||||
it: [
|
||||
{
|
||||
id: 40,
|
||||
label: 'Imposta Scadenza',
|
||||
value: 101, // TOGGLE_EXPIRING
|
||||
icon: 'date_range',
|
||||
checked: true
|
||||
},
|
||||
{
|
||||
id: 50,
|
||||
label: 'Elimina',
|
||||
value: 100, // DELETE
|
||||
icon: 'delete',
|
||||
checked: false
|
||||
}
|
||||
],
|
||||
es: [
|
||||
{
|
||||
id: 40,
|
||||
label: 'Establecer expiración',
|
||||
value: 101, // TOGGLE_EXPIRING
|
||||
icon: 'date_range',
|
||||
checked: true
|
||||
},
|
||||
{
|
||||
id: 50,
|
||||
label: 'Borrar',
|
||||
value: 100, // DELETE
|
||||
icon: 'delete',
|
||||
checked: false
|
||||
}
|
||||
],
|
||||
enUs: [
|
||||
{
|
||||
id: 40,
|
||||
label: 'Set Expiring',
|
||||
value: 101, // TOGGLE_EXPIRING
|
||||
icon: 'date_range',
|
||||
checked: true
|
||||
},
|
||||
{
|
||||
id: 50,
|
||||
label: 'Delete',
|
||||
value: 100, // DELETE
|
||||
icon: 'trash',
|
||||
checked: false
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
menuPopupConfigTodo: {
|
||||
it: [
|
||||
{
|
||||
@@ -276,6 +329,33 @@ export const tools = {
|
||||
]
|
||||
},
|
||||
|
||||
menuPopupConfigProject: {
|
||||
it: [
|
||||
{
|
||||
id: 10,
|
||||
label: 'Mostra Task',
|
||||
value: 150, // SHOW_TASK
|
||||
icon: 'rowing'
|
||||
}
|
||||
],
|
||||
es: [
|
||||
{
|
||||
id: 10,
|
||||
label: 'Mostrar Tareas',
|
||||
value: 150,
|
||||
icon: 'rowing'
|
||||
}
|
||||
],
|
||||
enUs: [
|
||||
{
|
||||
id: 10,
|
||||
label: 'Show Task',
|
||||
value: 150,
|
||||
icon: 'rowing'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
listOptionShowTask: {
|
||||
it: [
|
||||
{
|
||||
@@ -456,6 +536,9 @@ export const tools = {
|
||||
console.log('swapElems PRIORITY', itemdragend)
|
||||
}
|
||||
|
||||
if (itemdragend.newIndex === itemdragend.oldIndex)
|
||||
return
|
||||
|
||||
if (tools.isOkIndex(myarr, itemdragend.newIndex) && tools.isOkIndex(myarr, itemdragend.oldIndex)) {
|
||||
myarr.splice(itemdragend.newIndex, 0, myarr.splice(itemdragend.oldIndex, 1)[0])
|
||||
tools.notifyarraychanged(myarr[itemdragend.newIndex])
|
||||
@@ -506,7 +589,7 @@ export const tools = {
|
||||
},
|
||||
|
||||
getIndexById(myarr, id) {
|
||||
return myarr.findIndex((elem) => elem._id === id)
|
||||
return myarr.indexOf(tools.getElemById(myarr, id))
|
||||
},
|
||||
|
||||
getElemById(myarr, id) {
|
||||
@@ -557,13 +640,17 @@ export const tools = {
|
||||
return myarr.find((elem) => elem.id_prev === ApiTables.LIST_START)
|
||||
},
|
||||
|
||||
getLastListNotCompleted(nametable, cat) {
|
||||
let arr
|
||||
getModulesByTable(nametable) {
|
||||
if (nametable === 'todos') {
|
||||
arr = Todos.getters.todos_dacompletare(cat)
|
||||
return Todos
|
||||
} else if (nametable === 'projects') {
|
||||
arr = Projects.getters.projs_dacompletare(cat)
|
||||
return Projects
|
||||
}
|
||||
},
|
||||
|
||||
getLastListNotCompleted(nametable, cat) {
|
||||
const module = tools.getModulesByTable(nametable)
|
||||
let arr = module.getters.items_dacompletare(cat)
|
||||
|
||||
return (arr.length > 0) ? arr[arr.length - 1] : null
|
||||
},
|
||||
@@ -668,7 +755,7 @@ export const tools = {
|
||||
/*
|
||||
get todos_vista() {
|
||||
let mystr = ''
|
||||
const arr = Todos.getters.todos_dacompletare(this.categoryAtt)
|
||||
const arr = Todos.getters.items_dacompletare(this.categoryAtt)
|
||||
for (const ind in arr) {
|
||||
mystr += this.getstrelem(arr[ind]) + '\n'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user