Updated Project calculation for hours and progress.
This commit is contained in:
@@ -383,9 +383,7 @@ export async function table_ModifyRecord(nametable, myitem, listFieldsToChange,
|
||||
console.log('--> table_ModifyRecord', nametable, myitem.descr)
|
||||
|
||||
if ((field === 'status') && (nametable === 'todos') && (myitem.status === tools.Status.COMPLETED)) {
|
||||
console.log('AAAAAAAAAAAAAAAAAAAAAAAA ', myitem.completed_at)
|
||||
myitem.completed_at = tools.getDateNow()
|
||||
console.log(' DOPO ', myitem.completed_at)
|
||||
}
|
||||
|
||||
const myobjsaved = tools.jsonCopy(myitem)
|
||||
@@ -397,44 +395,28 @@ export async function table_ModifyRecord(nametable, myitem, listFieldsToChange,
|
||||
return
|
||||
}
|
||||
|
||||
console.log(' 0-> ')
|
||||
|
||||
console.log('myobjsaved.completed_at', myobjsaved.completed_at)
|
||||
console.log('miorec.completed_at', miorec.completed_at)
|
||||
|
||||
console.log('miorec', miorec.descr, miorec.id_prev, nametable)
|
||||
console.log('status', miorec.status, myobjsaved.status)
|
||||
|
||||
console.log(' 3-> ')
|
||||
|
||||
listFieldsToChange.forEach((myfield) => {
|
||||
setmodifiedIfchanged(miorec, myobjsaved, myfield)
|
||||
})
|
||||
|
||||
if (miorec.modified) {
|
||||
console.log(' ' + nametable + ' MODIFICATO! ', miorec.descr, miorec.pos, 'SALVALO SULLA IndexedDB')
|
||||
// console.log(' ' + nametable + ' MODIFICATO! ', miorec.descr, miorec.pos, 'SALVALO SULLA IndexedDB')
|
||||
miorec.modify_at = tools.getDateNow()
|
||||
miorec.modified = false
|
||||
|
||||
console.log(' 0) ARR MIOREC PRIMA ', miorec.completed_at, miorec)
|
||||
|
||||
// 1) Permit to Update the Views
|
||||
tools.notifyarraychanged(miorec)
|
||||
|
||||
console.log(' 1) MIOREC CALL WRITE: ', miorec.completed_at, miorec)
|
||||
|
||||
// 2) Modify on IndexedDb
|
||||
return globalroutines(null, 'write', nametable, miorec)
|
||||
.then((ris) => {
|
||||
|
||||
console.log(' 2) MIOREC !: ', miorec.completed_at)
|
||||
|
||||
// 3) Modify on the Server (call)
|
||||
return Sync_SaveItem(nametable, 'PATCH', miorec)
|
||||
|
||||
})
|
||||
} else {
|
||||
console.log(' ', miorec.descr, 'NON MODIF!')
|
||||
// } else {
|
||||
// console.log(' ', miorec.descr, 'NON MODIF!')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,6 +432,5 @@ export function table_DeleteRecord(nametable, myobjtrov, id) {
|
||||
|
||||
// 3) Delete from the Server (call)
|
||||
Sync_DeleteItem(nametable, myobjtrov, id)
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace Getters {
|
||||
level_child: 0.5
|
||||
})
|
||||
|
||||
addRoute(arrroutes,{ route: '/projects/' + tools.FIRST_PROJ, faIcon: 'fa fa-list-alt', materialIcon: 'next_week', name: 'pages.Projects',
|
||||
addRoute(arrroutes,{ route: '/projects/' + process.env.PROJECT_ID_MAIN, faIcon: 'fa fa-list-alt', materialIcon: 'next_week', name: 'pages.Projects',
|
||||
routes2: listaprojects,
|
||||
level_parent: 0,
|
||||
level_child: 0.5
|
||||
|
||||
@@ -13,7 +13,7 @@ const nametable = 'projects'
|
||||
|
||||
// import _ from 'lodash'
|
||||
|
||||
const state: IProjectsState = {
|
||||
const stateglob: IProjectsState = {
|
||||
showtype: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED,
|
||||
projects: [],
|
||||
insidePending: false,
|
||||
@@ -22,19 +22,14 @@ const state: IProjectsState = {
|
||||
|
||||
const listFieldsToChange: string [] = ['descr', 'longdescr', 'hoursplanned', 'hoursworked', 'id_parent', 'status', 'category', 'expiring_at', 'priority', 'id_prev', 'pos', 'enableExpiring', 'progress', 'live_url', 'test_url', 'begin_development', 'begin_test']
|
||||
|
||||
const b = storeBuilder.module<IProjectsState>('Projects', state)
|
||||
const b = storeBuilder.module<IProjectsState>('Projects', stateglob)
|
||||
const stateGetter = b.state()
|
||||
|
||||
// function getindexbycategory(category: string) {
|
||||
// return state.categories.indexOf(category)
|
||||
// }
|
||||
|
||||
function getarrByCategory(category: string) {
|
||||
// const indcat = state.categories.indexOf(category)
|
||||
if (!state.projects) {
|
||||
if (!stateglob.projects) {
|
||||
return []
|
||||
}
|
||||
return state.projects
|
||||
return stateglob.projects
|
||||
}
|
||||
|
||||
function initcat() {
|
||||
@@ -89,7 +84,7 @@ namespace Getters {
|
||||
const listaprojects = b.read((state: IProjectsState) => (): IMenuList[] => {
|
||||
if (state.projects) {
|
||||
// console.log('state.projects', state.projects)
|
||||
const listaproj = tools.mapSort(state.projects.filter((proj) => proj.id_parent === tools.FIRST_PROJ))
|
||||
const listaproj = tools.mapSort(state.projects.filter((proj) => proj.id_parent === process.env.PROJECT_ID_MAIN))
|
||||
const myarr: IMenuList[] = []
|
||||
for (const proj of listaproj) {
|
||||
myarr.push({nametranslate: '', description: proj.descr, idelem: proj._id})
|
||||
@@ -102,12 +97,12 @@ namespace Getters {
|
||||
}, 'listaprojects')
|
||||
|
||||
const getDescrById = b.read((state: IProjectsState) => (id: string): string => {
|
||||
if (id === tools.FIRST_PROJ)
|
||||
if (id === process.env.PROJECT_ID_MAIN)
|
||||
return 'Projects'
|
||||
if (state.projects) {
|
||||
const item = state.projects.find((item) => item._id === id)
|
||||
if (!!item)
|
||||
return item.descr
|
||||
const itemtrov = state.projects.find((item) => item._id === id)
|
||||
if (!!itemtrov)
|
||||
return itemtrov.descr
|
||||
}
|
||||
|
||||
return ''
|
||||
@@ -115,9 +110,10 @@ namespace Getters {
|
||||
|
||||
const getParentById = b.read((state: IProjectsState) => (id: string): string => {
|
||||
if (state.projects) {
|
||||
const item = state.projects.find((item) => item._id === id)
|
||||
if (!!item)
|
||||
return item.id_parent
|
||||
const itemfound = state.projects.find((item) => item._id === id)
|
||||
if (!!itemfound) {
|
||||
return itemfound.id_parent
|
||||
}
|
||||
}
|
||||
|
||||
return ''
|
||||
@@ -193,7 +189,7 @@ namespace Actions {
|
||||
async function dbLoad(context, { checkPending, onlyiffirsttime }) {
|
||||
|
||||
if (onlyiffirsttime) {
|
||||
if (state.projects.length > 0) {
|
||||
if (stateglob.projects.length > 0) {
|
||||
// if already set, then exit.
|
||||
return false
|
||||
}
|
||||
@@ -208,18 +204,18 @@ namespace Actions {
|
||||
const ris = await Api.SendReq('/projects/' + UserStore.state.userId, 'GET', null)
|
||||
.then((res) => {
|
||||
if (res.data.projects) { // console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
|
||||
state.projects = res.data.projects
|
||||
stateglob.projects = res.data.projects
|
||||
} else {
|
||||
state.projects = []
|
||||
stateglob.projects = []
|
||||
}
|
||||
|
||||
state.showtype = parseInt(GlobalStore.getters.getConfigStringbyId({
|
||||
stateglob.showtype = parseInt(GlobalStore.getters.getConfigStringbyId({
|
||||
id: costanti.CONFIG_ID_SHOW_TYPE_TODOS,
|
||||
default: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED
|
||||
}), 10)
|
||||
|
||||
if (process.env.DEBUG === '1') {
|
||||
console.log('dbLoad', 'state.projects', state.projects)
|
||||
console.log('dbLoad', 'state.projects', stateglob.projects)
|
||||
}
|
||||
|
||||
return res
|
||||
@@ -307,7 +303,7 @@ namespace Actions {
|
||||
}
|
||||
|
||||
async function swapElems(context, itemdragend: IDrag) {
|
||||
console.log('PROJECT swapElems', itemdragend, state.projects)
|
||||
console.log('PROJECT swapElems', itemdragend, stateglob.projects)
|
||||
|
||||
const myarr = Getters.getters.items_dacompletare(itemdragend.id_proj)
|
||||
|
||||
|
||||
@@ -251,19 +251,21 @@ namespace Actions {
|
||||
const myarr = gettodosByCategory(cat)
|
||||
|
||||
const myobjtrov = tools.getElemById(myarr, idobj)
|
||||
|
||||
console.log('myobjtrov', myobjtrov.descr)
|
||||
|
||||
if (!!myobjtrov) {
|
||||
const myobjnext = tools.getElemPrevById(myarr, myobjtrov._id)
|
||||
|
||||
if (!!myobjnext) {
|
||||
myobjnext.id_prev = myobjtrov.id_prev
|
||||
myobjnext.modified = true
|
||||
await modify(context, { myitem: myobjnext, field: 'id_prev' })
|
||||
console.log('myobjtrov', myobjtrov.descr)
|
||||
|
||||
if (!!myobjtrov) {
|
||||
const myobjnext = tools.getElemPrevById(myarr, myobjtrov._id)
|
||||
|
||||
if (!!myobjnext) {
|
||||
myobjnext.id_prev = myobjtrov.id_prev
|
||||
myobjnext.modified = true
|
||||
await modify(context, { myitem: myobjnext, field: 'id_prev' })
|
||||
}
|
||||
|
||||
ApiTables.table_DeleteRecord(nametable, myobjtrov, idobj)
|
||||
}
|
||||
|
||||
ApiTables.table_DeleteRecord(nametable, myobjtrov, idobj)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ export const tools = {
|
||||
|
||||
NUMSEC_CHECKUPDATE: 20000,
|
||||
|
||||
FIRST_PROJ: '__PROJECTS',
|
||||
FIRST_PROJ: '5ca8f17fcd40dc5012f53346',
|
||||
|
||||
WHAT_TODO: 1,
|
||||
WHAT_PROJECT: 2,
|
||||
@@ -1258,7 +1258,6 @@ export const tools = {
|
||||
|
||||
getDateNow() {
|
||||
const mydate = new Date()
|
||||
console.log('mydate', mydate)
|
||||
return mydate
|
||||
}
|
||||
,
|
||||
|
||||
Reference in New Issue
Block a user