++ hoursweeky_plannedtowork, endwork_estimate, totalphases , actualphase

This commit is contained in:
Paolo Arena
2019-04-07 21:24:10 +02:00
parent f60edc1c5b
commit 884d84e2df
14 changed files with 239 additions and 108 deletions

View File

@@ -10,9 +10,11 @@ import { date } from 'quasar'
export default class CDate extends Vue {
@Prop() public mydate!: Date
@Prop({ required: false }) public label: string
@Prop({ required: false, default: '' }) public label: string
@Prop({ required: false, default: '' }) public data_class!: string
@Prop({ required: false, default: false }) public readonly!: boolean
@Prop({ required: false, default: false }) public disable!: boolean
@Prop({ required: false, default: '' }) public color!: string
public mystyleicon: string = 'font-size: 1.5rem;'

View File

@@ -1,5 +1,5 @@
<template>
<q-input :class="data_class" :readonly="readonly" :disable="readonly" debounce="1000" dense :value="getdatestring" stack-label :label="label" @input="changedate">
<q-input :class="data_class" :bg-color="color" :readonly="readonly" :disable="disable" debounce="1000" dense :value="getdatestring" stack-label :label="label" @input="changedate">
<template v-slot:append>
<q-icon name="event" class="cursor-pointer" :style="mystyleicon">
<q-popup-proxy v-if="!readonly" ref="datePicker">

View File

@@ -68,14 +68,23 @@ export default class SingleProject extends Vue {
@Watch('itemproject.begin_development') public valueChangedbegin_development() {
this.watchupdate('begin_development')
}
@Watch('itemproject.hoursweeky_plannedtowork') public valueChangedhoursweeky_plannedtowork() {
this.watchupdate('hoursweeky_plannedtowork')
}
@Watch('itemproject.begin_test') public valueChangedbegin_test() {
this.watchupdate('begin_test')
}
@Watch('itemproject.actualphase') public valueChangedactualphase() {
this.watchupdate('actualphase')
}
@Watch('itemproject.totalphases') public valueChangedtotalphases() {
this.watchupdate('totalphases')
}
@Watch('itemproject.progressCalc') public valueChanged6() {
console.log('itemproject.progressCalc')
this.updateClasses()
console.log('this.percentageProgress', this.percentageProgress, 'this.itemproject.progressCalc', this.itemproject.progressCalc)
// console.log('this.percentageProgress', this.percentageProgress, 'this.itemproject.progressCalc', this.itemproject.progressCalc)
this.watchupdate('progressCalc')
}

View File

@@ -70,8 +70,7 @@ export default class SingleTodo extends Vue {
console.log('itemtodo.hoursplanned', this.itemtodo.hoursplanned)
this.watchupdate('hoursplanned')
}
// ++TODO: FIX! STATUSTODO WILL NOT UPDATE IF I DON'T PUT { immediate: true } parameter. ! WHY???
@Watch('itemtodo.statustodo', {immediate: true}) public valueChangedstatus() {
@Watch('itemtodo.statustodo') public valueChangedstatus() {
console.log('itemtodo.statustodo', this.itemtodo.statustodo)
this.watchupdate('statustodo')
}

View File

@@ -9,8 +9,6 @@ export interface IProject {
id_parent?: string
descr?: string
longdescr?: string
hoursplanned?: number
hoursworked?: number
priority?: number
statusproj?: number
created_at?: Date
@@ -22,33 +20,19 @@ export interface IProject {
modified?: boolean
pos?: number
order?: number
progressCalc?: number
live_url?: string
test_url?: string
hoursplanned?: number
hoursworked?: number
progressCalc?: number
begin_development?: Date
hoursweeky_plannedtowork?: number
endwork_estimate?: Date
begin_test?: Date
totalphases?: number
actualphase?: number
}
export interface IParamIProject {
categorySel?: string
checkPending?: boolean
id?: string
objtodo?: IProject
atfirst?: boolean
}
/*
export interface IDrag {
field?: string
idelemtochange?: string
prioritychosen?: number
oldIndex?: number
newIndex?: number
category: string
atfirst?: boolean
}
*/
export interface IProjectsState {
showtype: number
projects: IProject[]

View File

@@ -248,7 +248,11 @@ const messages = {
hoursworked: 'Ore Lavorate',
begin_development: 'Inizio Sviluppo',
begin_test: 'Inizio Test',
progresstask: 'Progressione'
progresstask: 'Progressione',
actualphase: 'Fase Attuale',
hoursweeky_plannedtowork: 'Ore settimanali previste',
endwork_estimate: 'Data fine lavori stimata',
totalphases: 'Totale Fasi'
}
},
'es': {
@@ -494,7 +498,11 @@ const messages = {
hoursworked: 'Horas Trabajadas',
begin_development: 'Comienzo desarrollo',
begin_test: 'Comienzo Prueba',
progresstask: 'Progresion'
progresstask: 'Progresion',
actualphase: 'Fase Actual',
hoursweeky_plannedtowork: 'Horarios semanales programados',
endwork_estimate: 'Fecha estimada de finalización',
totalphases: 'Fases totales'
}
},
'enUs': {
@@ -740,7 +748,11 @@ const messages = {
hoursworked: 'Worked Hours',
begin_development: 'Start Dev',
begin_test: 'Start Test',
progresstask: 'Progression'
progresstask: 'Progression',
actualphase: 'Actual Phase',
hoursweeky_plannedtowork: 'Scheduled weekly hours',
endwork_estimate: 'Estimated completion date',
totalphases: 'Total Phase'
}
},
};

View File

@@ -9,7 +9,7 @@ export { addAuthHeaders, removeAuthHeaders, API_URL } from './Instance'
import Paths from '@paths'
import { tools } from '@src/store/Modules/tools'
import { GlobalStore, UserStore } from '@modules'
import { GlobalStore, Projects, UserStore } from '@modules'
import globalroutines from './../../globalroutines/index'
import { serv_constants } from '@src/store/Modules/serv_constants'
import router from '@router'
@@ -122,6 +122,21 @@ export namespace ApiTool {
})
}
function ReceiveResponsefromServer(tablesync, nametab, method, risdata) {
// console.log('ReceiveResponsefromServer', nametab, method, risdata)
if (!!risdata) {
// Updated somw data after Server arrived data.
if (method === 'PATCH') {
if (nametab === 'projects') {
if (!!risdata.projectris) {
const copyrec = tools.jsonCopy(risdata.projectris)
Projects.mutations.updateProject({ objproj: copyrec })
}
}
}
}
}
export async function syncAlternative(mystrparam) {
// console.log('[ALTERNATIVE Background syncing', mystrparam)
@@ -155,7 +170,8 @@ export namespace ApiTool {
// Insert/Delete/Update table to the server
return SendReq(link, method, rec)
.then(() => {
.then((ris) => {
ReceiveResponsefromServer(tablesync, nametab, method, ris.data)
lettoqualcosa = true
return globalroutines(null, 'delete', tablesync, null, rec._id)
})

View File

@@ -20,7 +20,9 @@ const stateglob: IProjectsState = {
visuLastCompleted: 10
}
const listFieldsToChange: string [] = ['descr', 'longdescr', 'hoursplanned', 'hoursworked', 'id_parent', 'statusproj', 'category', 'expiring_at', 'priority', 'id_prev', 'pos', 'enableExpiring', 'progress', 'live_url', 'test_url', 'begin_development', 'begin_test']
const listFieldsToChange: string [] = ['descr', 'longdescr', 'hoursplanned', 'hoursworked', 'id_parent', 'statusproj', 'category', 'expiring_at', 'priority', 'id_prev', 'pos', 'enableExpiring', 'progressCalc', 'live_url', 'test_url', 'begin_development', 'begin_test', 'actualphase', 'totalphases', 'hoursweeky_plannedtowork', 'endwork_estimate']
const listFieldsUpdateCalculation: string [] = ['hoursplanned', 'hoursworked', 'progressCalc', 'endwork_estimate']
const b = storeBuilder.module<IProjectsState>('Projects', stateglob)
const stateGetter = b.state()
@@ -39,6 +41,12 @@ function initcat() {
return rec
}
function updateDataCalculated(projout, projin) {
listFieldsUpdateCalculation.forEach((field) => {
projout[field] = projin[field];
});
}
namespace Getters {
const getRecordEmpty = b.read((state: IProjectsState) => (): IProject => {
// const tomorrow = tools.getDateNow()
@@ -60,13 +68,17 @@ namespace Getters {
id_prev: '',
pos: 0,
modified: false,
hoursworked: 0,
hoursplanned: 0,
live_url: '',
test_url: '',
totalphases: 1,
actualphase: 1,
hoursworked: 0,
hoursplanned: 0,
progressCalc: 0,
begin_development: tools.getDateNull(),
begin_test: tools.getDateNull()
begin_test: tools.getDateNull(),
hoursweeky_plannedtowork: 0,
endwork_estimate: tools.getDateNull()
}
return obj
@@ -87,7 +99,7 @@ namespace Getters {
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})
myarr.push({ nametranslate: '', description: proj.descr, idelem: proj._id })
}
return myarr
@@ -165,9 +177,20 @@ namespace Mutations {
else {
state.projects.push(objproj)
}
}
// console.log('state.projects', state.projects)
function updateProject(state: IProjectsState, { objproj }) {
if (!!objproj) {
console.log('updateProject', objproj)
const index = tools.getIndexById(state.projects, objproj._id)
console.log('index', index)
if (index >= 0) {
updateDataCalculated(state.projects[index], objproj)
// state.projects.splice(index, 1, objproj)
// tools.notifyarraychanged(state.projects)
}
}
}
function deletemyitem(state: IProjectsState, myitem: IProject) {
@@ -179,7 +202,8 @@ namespace Mutations {
export const mutations = {
deletemyitem: b.commit(deletemyitem),
createNewItem: b.commit(createNewItem)
createNewItem: b.commit(createNewItem),
updateProject: b.commit(updateProject)
}
}
@@ -298,7 +322,7 @@ namespace Actions {
return id
}
async function modify(context, { myitem, field } ) {
async function modify(context, { myitem, field }) {
return await ApiTables.table_ModifyRecord(nametable, myitem, listFieldsToChange, field)
}

View File

@@ -6,5 +6,7 @@ export const costanti = {
},
CONFIG_ID_CFG: '1',
CONFIG_ID_STATE_CONN: '2',
CONFIG_ID_SHOW_TYPE_TODOS: '3'
CONFIG_ID_SHOW_TYPE_TODOS: '3',
MAX_PHASES: 5
}

View File

@@ -153,7 +153,7 @@ export const tools = {
icon: 'expand_less'
},
{
id: 2,
id: 3,
label: 'Completato',
value: 10, // Status.COMPLETED
icon: 'expand_less'
@@ -174,7 +174,7 @@ export const tools = {
icon: 'expand_less'
},
{
id: 2,
id: 3,
label: 'Completado',
value: 10, // Status.COMPLETED
icon: 'expand_less'
@@ -195,7 +195,7 @@ export const tools = {
icon: 'expand_less'
},
{
id: 2,
id: 3,
label: 'Completed',
value: 10, // Status.COMPLETED
icon: 'expand_less'
@@ -691,10 +691,7 @@ export const tools = {
}
,
logga_arrproj(myarr
:
IProject[]
) {
logga_arrproj(myarr: IProject[]) {
let mystr = '\n'
myarr.forEach((item) => {
mystr += tools.getelemprojstr(item) + ' '
@@ -795,18 +792,18 @@ export const tools = {
console.log('swapElems PRIORITY', itemdragend)
}
console.log('swapGeneralElem', 'new =', itemdragend.newIndex, 'Old =', itemdragend.oldIndex, itemdragend)
if (itemdragend.newIndex === itemdragend.oldIndex) {
return
}
console.log('swapGeneralElem', 'new =', itemdragend.newIndex, 'Old =', itemdragend.oldIndex, itemdragend)
if (tools.isOkIndex(myarr, itemdragend.newIndex) && tools.isOkIndex(myarr, itemdragend.oldIndex)) {
console.log('SPLICE!')
console.log(' PRIMA!', tools.logga_arrproj(myarr))
// console.log(' PRIMA!', tools.logga_arrproj(myarr))
myarr.splice(itemdragend.newIndex, 0, myarr.splice(itemdragend.oldIndex, 1)[0])
console.log(' DOPO!', tools.logga_arrproj(myarr))
// console.log(' DOPO!', tools.logga_arrproj(myarr))
// Ora inverti gli indici
const indold = itemdragend.oldIndex
@@ -874,7 +871,7 @@ export const tools = {
,
getElemById(myarr, id) {
console.log('getElemById', myarr, id)
// console.log('getElemById', myarr, id)
return myarr.find((elem) => elem._id === id)
}
,
@@ -1271,6 +1268,7 @@ export const tools = {
,
getTimestampsNow() {
return new Date().valueOf()
}
},
}

View File

@@ -182,3 +182,7 @@ $heightBtn: 100%;
text-align: center;
//line-height: $heightitem;
}
.endwork_estimate {
color: blue;
}

View File

@@ -13,7 +13,7 @@ import { UserStore } from '@store'
import { Getter } from 'vuex-class'
import { Screen } from 'quasar'
import { date, Screen } from 'quasar'
import { CProgress } from '../../../components/CProgress'
import { CDate } from '../../../components/CDate'
@@ -45,7 +45,7 @@ export default class ProjList extends Vue {
public splitterModel = 50 // start at 50%
public itemproj: IProject = null
public idsel: string = ''
public itemsel: IProject = Projects.getters.getRecordEmpty()
public itemselproj: IProject = Projects.getters.getRecordEmpty()
public itemtodosel: ITodo = Todos.getters.getRecordEmpty()
public whatisSel: number = 0
public colProgress: string = 'blue'
@@ -59,13 +59,35 @@ export default class ProjList extends Vue {
ctodo: CTodo
}
@Getter('items_dacompletare', { namespace })
public items_dacompletare: (state: IProjectsState, id_parent: string) => IProject[]
@Watch('items_dacompletare')
public changeitems() {
this.idProjParentAtt = Projects.getters.getParentById(this.idProjAtt)
}
@Watch('$route.params.idProj')
public changeparent() {
this.idProjAtt = this.$route.params.idProj
this.idProjParentAtt = Projects.getters.getParentById(this.idProjAtt)
this.selproj()
}
@Watch('itemselproj.progressCalc')
public changeprogress() {
this.updateclasses()
}
get getidProjParentAtt() {
return this.idProjParentAtt
}
public watchupdatetodo(field = '') {
console.log('watchupdatetodo', field)
this.$emit('eventupdate', {myitem: this.itemtodosel, field } )
// I use this because the statustodo will disappear from the UI, so it won't call the status changed...
// in this case I need to call manually the modify.
public modifyfieldtodo(field) {
console.log('modifyfieldtodo', field)
Todos.actions.modify({ myitem: this.itemtodosel, field })
}
get getrouteup() {
@@ -103,26 +125,6 @@ export default class ProjList extends Vue {
return Projects.getters.getDescrById(this.idProjAtt)
}
@Getter('items_dacompletare', { namespace })
public items_dacompletare: (state: IProjectsState, id_parent: string) => IProject[]
@Watch('items_dacompletare')
public changeitems() {
this.idProjParentAtt = Projects.getters.getParentById(this.idProjAtt)
}
@Watch('$route.params.idProj')
public changeparent() {
this.idProjAtt = this.$route.params.idProj
this.idProjParentAtt = Projects.getters.getParentById(this.idProjAtt)
this.selproj()
}
@Watch('itemsel.progressCalc')
public changeprogress() {
this.updateclasses()
}
public showTask(field_value) {
return field_value === tools.MenuAction.SHOW_TASK
}
@@ -257,7 +259,7 @@ export default class ProjList extends Vue {
public setidsel(id: string) {
this.idsel = id
this.whatisSel = tools.WHAT_PROJECT
this.itemsel = Projects.getters.getRecordById(this.idsel)
this.itemselproj = Projects.getters.getRecordById(this.idsel)
}
public setitemsel(item: ITodo) {
this.whatisSel = tools.WHAT_TODO
@@ -331,13 +333,61 @@ export default class ProjList extends Vue {
}
public updateclasses() {
this.colProgress = tools.getProgressColor(this.itemsel.progressCalc)
this.colProgress = tools.getProgressColor(this.itemselproj.progressCalc)
}
public checkUpdate() {
ApiTables.waitAndcheckPendingMsg()
}
get getCalcHoursWorked() {
if (this.itemselproj.hoursplanned <= 0) {
return 0
}
return Math.round(this.itemselproj.hoursworked / this.itemselproj.hoursplanned * 100)
}
get calcprogressWeekly() {
if (this.itemselproj.hoursplanned <= 0) {
return 0
}
return Math.round(this.itemselproj.hoursworked / this.itemselproj.hoursplanned * 100)
}
get calcEndWork_Estimate() {
if (date.isValid(this.itemselproj.begin_development) && (this.itemselproj.hoursweeky_plannedtowork > 0)) {
const hoursw = this.itemselproj.hoursweeky_plannedtowork
try {
let orerimaste = this.itemselproj.hoursplanned - this.itemselproj.hoursworked
if (orerimaste < 0) {
orerimaste = 0
}
const weeks = orerimaste / hoursw
const days = Math.round(weeks * 7)
const mydate = this.itemselproj.begin_development
this.itemselproj.endwork_estimate = date.addToDate(mydate, { days })
console.log(' days', days, 'weeks', weeks, 'orerimaste', orerimaste, 'dateestimated', this.itemselproj.endwork_estimate)
return this.itemselproj.endwork_estimate
}catch (e) {
this.itemselproj.endwork_estimate = tools.getDateNull()
}
return tools.getDateNull()
} else {
return tools.getDateNull()
}
}
private getElementIndex(el: any) {
return [].slice.call(el.parentElement.children).indexOf(el)
}
@@ -346,16 +396,6 @@ export default class ProjList extends Vue {
return parseInt(el.attributes.index.value, 10)
}
get getCalcHoursWorked() {
if (this.itemsel.hoursplanned <= 0) {
return 0
}
const myperc = Math.round(this.itemsel.hoursworked / this.itemsel.hoursplanned * 100)
return myperc
}
get getCalcTodoHoursWorked() {
if (this.itemtodosel.hoursplanned <= 0) {
return 0

View File

@@ -105,12 +105,12 @@
</div>
</template>
<template v-if="(whatisSel === tools.WHAT_PROJECT) && (!!itemsel.descr)" v-slot:after>
<template v-if="(whatisSel === tools.WHAT_PROJECT) && (!!itemselproj.descr)" v-slot:after>
<div class="q-pa-xs clMain">
<div class="flex-container clMain">
<q-icon class="flex-item flex-icon" name="format_align_center"/>
<div class="flex-item projecttitle shadow-4">
{{itemsel.descr}}
{{itemselproj.descr}}
</div>
</div>
<div class="flex-container clMain">
@@ -118,10 +118,10 @@
<div class="flex-item itemdescr">
<q-input
ref="input"
v-model="itemsel.longdescr"
v-model="itemselproj.longdescr"
:label="$t('proj.longdescr')"
outlined
debounce="500"
debounce="1000"
autogrow
/>
@@ -133,7 +133,7 @@
<q-input
ref="input2"
readonly
v-model="itemsel.hoursworked"
v-model="itemselproj.hoursworked"
type="number"
rounded outlined
:label="$t('proj.hoursworked')"
@@ -146,31 +146,71 @@
ref="input3"
type="number"
readonly
v-model="itemsel.hoursplanned"
v-model="itemselproj.hoursplanned"
rounded outlined
:label="$t('proj.hoursplanned')"
debounce="500">
</q-input>
<CProgress :descr="$t('proj.progresstask')"
:progressval="itemsel.progressCalc"></CProgress>
:progressval="itemselproj.progressCalc"></CProgress>
</div>
</div>
<div class="flex-container clMain">
<q-icon class="flex-item flex-icon" name="developer_mode"/>
<div class="flex-item itemdata">
<CDate :mydate="itemsel.begin_development" @input="itemsel.begin_development = new Date(arguments[0])"
<CDate :mydate="itemselproj.begin_development"
@input="itemselproj.begin_development = new Date(arguments[0])"
:label="$t('proj.begin_development')">
</CDate>
</div>
<div style="margin: 10px;"></div>
<div class="flex-item itemdata">
<CDate :mydate="itemsel.begin_test" @input="itemsel.begin_test = new Date(arguments[0])"
<CDate :mydate="itemselproj.begin_test" @input="itemselproj.begin_test = new Date(arguments[0])"
:label="$t('proj.begin_test')">
</CDate>
</div>
</div>
<div class="flex-container clMain">
<q-icon class="flex-item flex-icon" name="outlined_flag"/>
<div class="flex-item itemstatus">
<q-select rounded outlined v-model="itemselproj.actualphase" :options="selectPhase"
:label="$t('proj.actualphase')" emit-value map-options>
</q-select>
</div>
<q-icon class="flex-item flex-icon" name="outlined_flag"/>
<div class="flex-item itemstatus">
<q-select rounded outlined v-model="itemselproj.totalphases" :options="selectPhase"
:label="$t('proj.totalphases')" emit-value map-options>
</q-select>
</div>
</div>
<div class="flex-container clMain">
<q-icon class="flex-item flex-icon" name="watch_later"/>
<div class="flex-item itemdata content-center">
<q-input
ref="input3"
type="number"
v-model="itemselproj.hoursweeky_plannedtowork"
rounded outlined
maxlength="2"
:label="$t('proj.hoursweeky_plannedtowork')"
debounce="500">
</q-input>
<CProgress :progressval="calcprogressWeekly"></CProgress>
</div>
<q-icon class="flex-item flex-icon" name="developer_mode"/>
<div class="flex-item itemdata">
<CDate color="green-2" :mydate="calcEndWork_Estimate" :readonly="true"
:label="$t('proj.endwork_estimate')">
</CDate>
</div>
</div>
</div>
</template>
<template v-else-if="(whatisSel === tools.WHAT_TODO) && (!!itemtodosel.descr)" v-slot:after>
<div class="q-pa-xs clMain">
@@ -194,14 +234,13 @@
<div class="flex-item itemstatus">
<q-select rounded outlined v-model="itemtodosel.statustodo" :options="selectStatus"
:label="$t('todo.status')" emit-value map-options
@input="watchupdatetodo('statustodo')">
@input="modifyfieldtodo('statustodo')">
</q-select>
</div>
<q-icon class="flex-item flex-icon" name="outlined_flag"/>
<div class="flex-item itemstatus">
<q-select rounded outlined v-model="itemtodosel.phase" :options="selectPhase"
:label="$t('todo.phase')" emit-value map-options
@input="watchupdatetodo('phase')">
:label="$t('todo.phase')" emit-value map-options>
</q-select>
</div>
</div>
@@ -233,13 +272,14 @@
<CProgress :descr="$t('proj.progresstask')"
:progressval="itemtodosel.progress"
:slider="true" @input="itemtodosel.progress = arguments[0]"></CProgress>
:slider="true" @input="itemtodosel.progress = arguments[0]"></CProgress>
</div>
</div>
<div class="flex-container clMain">
<q-icon class="flex-item flex-icon" name="developer_mode"/>
<div class="flex-item itemdata">
<CDate :mydate="itemtodosel.start_date" @input="itemtodosel.start_date = new Date(arguments[0])"
<CDate :mydate="itemtodosel.start_date"
@input="itemtodosel.start_date = new Date(arguments[0])"
:label="$t('todo.start_date')">
</CDate>
@@ -248,7 +288,8 @@
<q-icon class="flex-item flex-icon" name="event"/>
<div class="flex-item itemdata">
<CDate :readonly="itemtodosel.statustodo !== tools.Status.COMPLETED"
:mydate="itemtodosel.completed_at" @input="itemtodosel.completed_at = new Date(arguments[0])"
:mydate="itemtodosel.completed_at"
@input="itemtodosel.completed_at = new Date(arguments[0])"
:label="$t('todo.completed_at')">
</CDate>
</div>

View File

@@ -67,5 +67,5 @@
"dist",
"node_modules"
],
"compileOnSave": true
"compileOnSave": false
}