Added CDate component !
This commit is contained in:
@@ -400,8 +400,9 @@ export async function table_ModifyRecord(nametable, myitem, fieldtochange) {
|
||||
console.log('miorec', miorec.descr, miorec.id_prev)
|
||||
|
||||
if (nametable === 'todos') {
|
||||
if (setmodifiedIfchanged(miorec, myobjsaved, 'status')) {
|
||||
miorec.completed_at = new Date().getDate()
|
||||
if (setmodifiedIfchanged(miorec, myobjsaved, 'status') && (miorec.status === tools.Status.COMPLETED)) {
|
||||
miorec.completed_at = tools.getDateNow()
|
||||
console.log('miorec.completed_at', miorec.completed_at)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,7 +412,7 @@ export async function table_ModifyRecord(nametable, myitem, fieldtochange) {
|
||||
|
||||
if (miorec.modified) {
|
||||
console.log(' ' + nametable + ' MODIFICATO! ', miorec.descr, miorec.pos, 'SALVALO SULLA IndexedDB')
|
||||
miorec.modify_at = new Date().getDate()
|
||||
miorec.modify_at = tools.getDateNow()
|
||||
miorec.modified = false
|
||||
|
||||
// 1) Permit to Update the Views
|
||||
|
||||
@@ -46,7 +46,7 @@ function initcat() {
|
||||
|
||||
namespace Getters {
|
||||
const getRecordEmpty = b.read((state: IProjectsState) => (): IProject => {
|
||||
// const tomorrow = new Date()
|
||||
// const tomorrow = tools.getDateNow()
|
||||
// tomorrow.setDate(tomorrow.getDate() + 1)
|
||||
|
||||
const obj: IProject = {
|
||||
@@ -56,11 +56,9 @@ namespace Getters {
|
||||
id_parent: '',
|
||||
priority: tools.Priority.PRIORITY_NORMAL,
|
||||
status: tools.Status.OPENED,
|
||||
created_at: new Date(),
|
||||
modify_at: new Date(),
|
||||
completed_at: new Date(),
|
||||
begin_development: new Date(0),
|
||||
begin_test: new Date(0),
|
||||
created_at: tools.getDateNow(),
|
||||
modify_at: tools.getDateNow(),
|
||||
completed_at: tools.getDateNull(),
|
||||
category: '',
|
||||
// expiring_at: tomorrow,
|
||||
enableExpiring: false,
|
||||
@@ -71,8 +69,9 @@ namespace Getters {
|
||||
hoursplanned: 0,
|
||||
live_url: '',
|
||||
test_url: '',
|
||||
progressCalc: 0
|
||||
|
||||
progressCalc: 0,
|
||||
begin_development: tools.getDateNull(),
|
||||
begin_test: tools.getDateNull()
|
||||
}
|
||||
|
||||
return obj
|
||||
|
||||
@@ -27,7 +27,7 @@ const state: ITodosState = {
|
||||
visuLastCompleted: 10
|
||||
}
|
||||
|
||||
const fieldtochange: string [] = ['descr', 'status', 'category', 'expiring_at', 'priority', 'id_prev', 'pos', 'enableExpiring', 'progress']
|
||||
const fieldtochange: string [] = ['descr', 'status', 'category', 'expiring_at', 'priority', 'id_prev', 'pos', 'enableExpiring', 'progress', 'phase', 'assigned_to_userId', 'hoursplanned', 'hoursworked', 'start_date', 'completed_at']
|
||||
|
||||
const b = storeBuilder.module<ITodosState>('Todos', state)
|
||||
const stateGetter = b.state()
|
||||
@@ -56,26 +56,32 @@ function initcat() {
|
||||
namespace Getters {
|
||||
const getRecordEmpty = b.read((state: ITodosState) => (): ITodo => {
|
||||
|
||||
const tomorrow = new Date()
|
||||
const tomorrow = tools.getDateNow()
|
||||
tomorrow.setDate(tomorrow.getDate() + 1)
|
||||
|
||||
const objtodo: ITodo = {
|
||||
// _id: new Date().toISOString(), // Create NEW
|
||||
// _id: tools.getDateNow().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(),
|
||||
created_at: tools.getDateNow(),
|
||||
modify_at: tools.getDateNow(),
|
||||
completed_at: tools.getDateNull(),
|
||||
category: '',
|
||||
expiring_at: tomorrow,
|
||||
enableExpiring: false,
|
||||
id_prev: '',
|
||||
pos: 0,
|
||||
modified: false,
|
||||
progress: 0
|
||||
progress: 0,
|
||||
progressCalc: 0,
|
||||
phase: 0,
|
||||
assigned_to_userId: '',
|
||||
hoursplanned: 0,
|
||||
hoursworked: 0,
|
||||
start_date: tools.getDateNull(),
|
||||
}
|
||||
// return this.copy(objtodo)
|
||||
return objtodo
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Mutations {
|
||||
} // ??
|
||||
|
||||
resetArrToken(state.tokens)
|
||||
state.tokens.push({ access: 'auth', token: state.x_auth_token, data_login: new Date() })
|
||||
state.tokens.push({ access: 'auth', token: state.x_auth_token, data_login: tools.getDateNow() })
|
||||
|
||||
// ++Todo: Settings Users Admin
|
||||
if (state.username === 'paoloar77') {
|
||||
@@ -127,7 +127,7 @@ namespace Mutations {
|
||||
if (!state.tokens) {
|
||||
state.tokens = []
|
||||
}
|
||||
state.tokens.push({ access: 'auth', token: x_auth_token, data_login: new Date() })
|
||||
state.tokens.push({ access: 'auth', token: x_auth_token, data_login: tools.getDateNow() })
|
||||
}
|
||||
|
||||
function setServerCode(state: IUserState, num: number) {
|
||||
@@ -328,7 +328,7 @@ namespace Actions {
|
||||
verified_email: false
|
||||
})
|
||||
|
||||
const now = new Date()
|
||||
const now = tools.getDateNow()
|
||||
// const expirationDate = new Date(now.getTime() + myres.data.expiresIn * 1000);
|
||||
const expirationDate = new Date(now.getTime() * 1000)
|
||||
localStorage.setItem(tools.localStorage.lang, state.lang)
|
||||
@@ -427,7 +427,7 @@ namespace Actions {
|
||||
verified_email
|
||||
})
|
||||
|
||||
const now = new Date()
|
||||
const now = tools.getDateNow()
|
||||
// const expirationDate = new Date(now.getTime() + myres.data.expiresIn * 1000);
|
||||
const expirationDate = new Date(now.getTime() * 1000)
|
||||
localStorage.setItem(tools.localStorage.lang, state.lang)
|
||||
@@ -520,7 +520,7 @@ namespace Actions {
|
||||
}
|
||||
const expirationDateStr = localStorage.getItem(tools.localStorage.expirationDate)
|
||||
const expirationDate = new Date(String(expirationDateStr))
|
||||
const now = new Date()
|
||||
const now = tools.getDateNow()
|
||||
if (now >= expirationDate) {
|
||||
console.log('!!! Login Expired')
|
||||
return false
|
||||
|
||||
@@ -67,7 +67,69 @@ export const tools = {
|
||||
EDIT: 160,
|
||||
ADD_PROJECT: 200
|
||||
},
|
||||
selectStatus: {
|
||||
it: [
|
||||
{
|
||||
id: 1,
|
||||
label: 'Nessuno',
|
||||
value: 0, // Status.NONE
|
||||
icon: 'expand_less'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
label: 'Aperto',
|
||||
value: 1, // Status.OPENED
|
||||
icon: 'expand_less'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
label: 'Completato',
|
||||
value: 10, // Status.COMPLETED
|
||||
icon: 'expand_less'
|
||||
}
|
||||
],
|
||||
es: [
|
||||
{
|
||||
id: 1,
|
||||
label: 'Ninguno',
|
||||
value: 0, // Status.NONE
|
||||
icon: 'expand_less'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
label: 'Abierto',
|
||||
value: 1, // Status.OPENED
|
||||
icon: 'expand_less'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
label: 'Completado',
|
||||
value: 10, // Status.COMPLETED
|
||||
icon: 'expand_less'
|
||||
}
|
||||
],
|
||||
enUs: [
|
||||
{
|
||||
id: 1,
|
||||
label: 'None',
|
||||
value: 0, // Status.NONE
|
||||
icon: 'expand_less'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
label: 'Opened',
|
||||
value: 1, // Status.OPENED
|
||||
icon: 'expand_less'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
label: 'Completed',
|
||||
value: 10, // Status.COMPLETED
|
||||
icon: 'expand_less'
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
selectPriority: {
|
||||
it: [
|
||||
{
|
||||
@@ -493,6 +555,20 @@ export const tools = {
|
||||
return cl + ' titlePriority'
|
||||
},
|
||||
|
||||
getStatusListByInd(index) {
|
||||
try {
|
||||
const arr = tools.selectStatus[UserStore.state.lang]
|
||||
for (const rec of arr) {
|
||||
if (rec.value === index) {
|
||||
return rec.label
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Error: ', e)
|
||||
}
|
||||
return ''
|
||||
},
|
||||
|
||||
getPriorityByInd(index) {
|
||||
// console.log('LANG in PRIOR', UserStore.state.lang)
|
||||
try {
|
||||
@@ -985,7 +1061,32 @@ export const tools = {
|
||||
},
|
||||
|
||||
getstrDate(mytimestamp) {
|
||||
return date.formatDate(mytimestamp, 'DD-MM-YY')
|
||||
console.log('getstrDate', mytimestamp)
|
||||
if (!!mytimestamp)
|
||||
return date.formatDate(mytimestamp, 'DD/MM/YYYY')
|
||||
else
|
||||
return ''
|
||||
},
|
||||
getstrYYMMDDDate(mytimestamp) {
|
||||
return date.formatDate(mytimestamp, 'YYYY-MM-DD')
|
||||
},
|
||||
|
||||
// mystrdate "26.04.2013"
|
||||
convertstrtoDate(mystrdate: string) {
|
||||
if (mystrdate.length < 10) {
|
||||
return null
|
||||
}
|
||||
|
||||
const pattern = /(\d{2})\/(\d{2})\/(\d{4})/
|
||||
const strdate = mystrdate.replace(pattern, '$3-$2-$1')
|
||||
let mydate = null
|
||||
if (date.isValid(strdate)) {
|
||||
mydate = new Date(strdate)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
console.log('mystrdate', mystrdate, strdate, mydate)
|
||||
return mydate
|
||||
},
|
||||
|
||||
capitalize(value) {
|
||||
@@ -994,6 +1095,22 @@ export const tools = {
|
||||
}
|
||||
value = value.toString()
|
||||
return value.charAt(0).toUpperCase() + value.slice(1)
|
||||
},
|
||||
|
||||
getDateNow() {
|
||||
const mydate = new Date()
|
||||
console.log('mydate', mydate, mydate.getDate(), mydate.getUTCDate())
|
||||
return mydate
|
||||
},
|
||||
getDateNull() {
|
||||
const mydate = new Date(0)
|
||||
return mydate
|
||||
},
|
||||
getTimeNow() {
|
||||
return new Date().getTime()
|
||||
},
|
||||
getTimestampsNow() {
|
||||
return new Date().valueOf()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user