Added and linked todo list to the project list

This commit is contained in:
Paolo Arena
2019-04-03 02:48:05 +02:00
parent 7cacf5c6ea
commit fe600f40a6
34 changed files with 493 additions and 153 deletions

View File

@@ -111,9 +111,10 @@ namespace Getters {
}, 'showtype')
const getmenu = b.read((state) => {
console.log('getmenu')
const arrlista = GlobalStore.state.listatodo
const listatodo = []
const lista = []
arrlista.forEach((elem: IMenuList) => {
const item = {
@@ -122,7 +123,7 @@ namespace Getters {
name: 'pages.' + elem.description,
route: '/todo/' + elem.nametranslate
}
listatodo.push(item)
lista.push(item)
})
@@ -145,7 +146,7 @@ namespace Getters {
if (!process.env.PROD) {
addRoute(arrroutes, { route: '/todo', faIcon: 'fa fa-list-alt', materialIcon: 'format_list_numbered', name: 'pages.Todo',
routes2: listatodo,
routes2: lista,
level_parent: 0.5,
level_child: 0.5
})
@@ -173,6 +174,8 @@ namespace Getters {
return state.menulinks
console.log('state.menulinks', state.menulinks)
}, 'getmenu')
export const getters = {

View File

@@ -38,13 +38,10 @@ function getarrByCategory(category: string) {
}
function initcat() {
// return this.copy(objproj)
let rec = Getters.getters.getRecordEmpty()
const rec = Getters.getters.getRecordEmpty()
rec.userId = UserStore.state.userId
return rec
}
namespace Getters {

View File

@@ -36,7 +36,7 @@ function getindexbycategory(category: string) {
return state.categories.indexOf(category)
}
function gettodosByCategory(category: string) {
function gettodosByCategory(category: string): [] {
const indcat = state.categories.indexOf(category)
if (!state.todos[indcat]) {
return []
@@ -46,33 +46,40 @@ function gettodosByCategory(category: string) {
function initcat() {
const tomorrow = new Date()
tomorrow.setDate(tomorrow.getDate() + 1)
let rec = Getters.getters.getRecordEmpty()
rec.userId = UserStore.state.userId
const objtodo: ITodo = {
// _id: new Date().toISOString(), // Create NEW
_id: objectId(),
userId: UserStore.state.userId,
descr: '',
priority: tools.Priority.PRIORITY_NORMAL,
status: tools.Status.OPENED,
created_at: new Date(),
modify_at: new Date(),
completed_at: new Date(),
category: '',
expiring_at: tomorrow,
enableExpiring: false,
id_prev: '',
pos: 0,
modified: false,
progress: 0
}
// return this.copy(objtodo)
return objtodo
return rec
}
namespace Getters {
const getRecordEmpty = b.read((state: ITodosState) => (): ITodo => {
const tomorrow = new Date()
tomorrow.setDate(tomorrow.getDate() + 1)
const objtodo: ITodo = {
// _id: new Date().toISOString(), // Create NEW
_id: objectId(),
userId: UserStore.state.userId,
descr: '',
priority: tools.Priority.PRIORITY_NORMAL,
status: tools.Status.OPENED,
created_at: new Date(),
modify_at: new Date(),
completed_at: new Date(),
category: '',
expiring_at: tomorrow,
enableExpiring: false,
id_prev: '',
pos: 0,
modified: false,
progress: 0
}
// return this.copy(objtodo)
return objtodo
}, 'getRecordEmpty')
const items_dacompletare = b.read((state: ITodosState) => (cat: string): ITodo[] => {
const indcat = getindexbycategory(cat)
if (state.todos[indcat]) {
@@ -85,11 +92,14 @@ namespace Getters {
const todos_completati = b.read((state: ITodosState) => (cat: string): ITodo[] => {
const indcat = getindexbycategory(cat)
if (state.todos[indcat]) {
if (state.showtype === costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED) {
if (state.showtype === costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED) { // Show only the first N completed
return state.todos[indcat].filter((todo) => todo.status === tools.Status.COMPLETED).slice(0, state.visuLastCompleted)
} // Show only the first N completed
}
else if (state.showtype === costanti.ShowTypeTask.SHOW_ONLY_TOCOMPLETE) {
return []
}
else if (state.showtype === costanti.ShowTypeTask.SHOW_ALL) {
return state.todos[indcat].filter((todo) => todo.completed === tools.Status.COMPLETED)
return state.todos[indcat].filter((todo) => todo.status === tools.Status.COMPLETED)
}
else {
return []
@@ -120,6 +130,9 @@ namespace Getters {
}, 'getRecordById')
export const getters = {
get getRecordEmpty() {
return getRecordEmpty()
},
get items_dacompletare() {
return items_dacompletare()
},

View File

@@ -25,6 +25,9 @@ export const tools = {
FIRST_PROJ: '__PROJECTS',
WHAT_TODO: 1,
WHAT_PROJECT: 2,
arrLangUsed: ['enUs', 'it', 'es'],
SERVKEY_VERS: 'vers',
@@ -595,8 +598,8 @@ export const tools = {
if (itemdragend.field === 'priority') {
// get last elem priority
console.log('get last elem priority')
itemdragend.newIndex = tools.getLastFirstElemPriority(itemdragend.category, itemdragend.prioritychosen, itemdragend.atfirst, itemdragend.idelemtochange)
itemdragend.oldIndex = tools.getIndexById(itemdragend.category, itemdragend.idelemtochange)
itemdragend.newIndex = tools.getLastFirstElemPriority(myarr, itemdragend.prioritychosen, itemdragend.atfirst, itemdragend.idelemtochange)
itemdragend.oldIndex = tools.getIndexById(myarr, itemdragend.idelemtochange)
console.log('swapElems PRIORITY', itemdragend)
}
@@ -675,6 +678,7 @@ export const tools = {
},
getElemById(myarr, id) {
console.log('getElemById', myarr, id)
return myarr.find((elem) => elem._id === id)
},
@@ -984,5 +988,12 @@ export const tools = {
return date.formatDate(mytimestamp, 'DD-MM-YY')
},
capitalize(value) {
if (!value) {
return ''
}
value = value.toString()
return value.charAt(0).toUpperCase() + value.slice(1)
}
}