- Load Events

- Edit Events
- When a field is updated: undate also memory list record

- Duplicate Event
This commit is contained in:
Paolo Arena
2019-10-20 22:44:18 +02:00
parent b8ec241b37
commit 9656b14cd0
11 changed files with 348 additions and 75 deletions

View File

@@ -349,7 +349,7 @@ export default class CEventsCalendar extends Vue {
}
public getEndTime(eventparam) {
let endTime = new Date(eventparam.date + ' ' + eventparam.time + ':00')
let endTime = new Date(eventparam.date)
endTime = date.addToDate(endTime, { minutes: eventparam.dur })
endTime = date.formatDate(endTime, 'HH:mm')
return endTime
@@ -421,8 +421,8 @@ export default class CEventsCalendar extends Vue {
this.resetForm()
this.contextDay = { ...eventparam }
let timestamp
if (eventparam.time) {
timestamp = eventparam.date + ' ' + eventparam.time
if (eventparam.withtime) {
timestamp = eventparam.date
const startTime = new Date(timestamp)
const endTime = date.addToDate(startTime, { minutes: eventparam.dur })
this.eventForm.dateTimeStart = this.formatDate(startTime) + ' ' + this.formatTime(startTime) // endTime.toString()
@@ -431,7 +431,7 @@ export default class CEventsCalendar extends Vue {
timestamp = eventparam.date
this.eventForm.dateTimeStart = timestamp
}
this.eventForm.allDay = !eventparam.time
this.eventForm.allDay = !eventparam.withtime
this.eventForm.bgcolor = eventparam.bgcolor
this.eventForm.icon = eventparam.icon
this.eventForm.title = eventparam.title
@@ -515,7 +515,7 @@ export default class CEventsCalendar extends Vue {
// an add
}
const data: IEvents = {
time: '',
withtime: false,
dur: 0,
dur2: 0,
title: form.title,
@@ -526,7 +526,7 @@ export default class CEventsCalendar extends Vue {
}
if (form.allDay === false) {
// get time into separate var
data.time = String(form.dateTimeStart).slice(11, 16)
// data.time = String(form.dateTimeStart).slice(11, 16)
data.dur = self.getDuration(form.dateTimeStart, form.dateTimeEnd, 'minutes')
}
if (update === true) {
@@ -685,7 +685,8 @@ export default class CEventsCalendar extends Vue {
return this.draggedEvent.date !== day.date
} else if (type === 'interval') {
stopAndPrevent(ev)
return this.draggedEvent.date !== day.date && this.draggedEvent.time !== day.time
// return this.draggedEvent.date !== day.date && this.draggedEvent.time !== day.time
return this.draggedEvent.date !== day.date
}
}
@@ -697,7 +698,7 @@ export default class CEventsCalendar extends Vue {
this.draggedEvent.side = void 0
} else if (type === 'interval') {
this.draggedEvent.date = day.date
this.draggedEvent.time = day.time
// this.draggedEvent.time = day.time
this.draggedEvent.side = void 0
}
}
@@ -724,6 +725,16 @@ export default class CEventsCalendar extends Vue {
return this.dateFormatter.format(mydate)
}
public getTeacherName(teacherusername) {
const op = CalendarStore.state.operators.find((myop) => myop.username === teacherusername)
return (op) ? `${op.name} ${op.surname}` : ''
}
public getTeacherImg(teacherusername) {
const op = CalendarStore.state.operators.find((myop) => myop.username === teacherusername)
return (op) ? op.img : 'avatar/noimage.png'
}
public badgeClasses(eventparam, type) {
const cssColor = tools.isCssColor(eventparam.bgcolor)
const isHeader = type === 'header'
@@ -743,7 +754,7 @@ export default class CEventsCalendar extends Vue {
s.color = colors.luminosity(eventparam.bgcolor) > 0.5 ? 'black' : 'white'
}
if (timeStartPos) {
s.top = timeStartPos(eventparam.time) + 'px'
s.top = timeStartPos(tools.getstrTime(eventparam.date)) + 'px'
}
if (timeDurationHeight) {
s.height = timeDurationHeight(eventparam.dur) + 'px'
@@ -786,7 +797,8 @@ export default class CEventsCalendar extends Vue {
for (let i = 0; i < CalendarStore.state.eventlist.length; ++i) {
// console.log(' ciclo i = ', i, CalendarStore.state.eventlist[i])
const dateEvent = new Date(CalendarStore.state.eventlist[i].date + ' 00:00:00')
// const dateEvent = new Date(CalendarStore.state.eventlist[i].date + ' 00:00:00')
const dateEvent = new Date(CalendarStore.state.eventlist[i].date)
if (dateEvent >= datenow) {
eventsloc.push(CalendarStore.state.eventlist[i])
@@ -802,14 +814,15 @@ export default class CEventsCalendar extends Vue {
for (let i = 0; i < CalendarStore.state.eventlist.length; ++i) {
let added = false
// console.log(' ciclo i = ', i, CalendarStore.state.eventlist[i])
if (CalendarStore.state.eventlist[i].date === dt) {
if (CalendarStore.state.eventlist[i].time) {
if (tools.getstrYYMMDDDate(CalendarStore.state.eventlist[i].date) === dt) {
// if (CalendarStore.state.eventlist[i].time) {
if (eventsloc.length > 0) {
// check for overlapping times
const startTime = new Date(CalendarStore.state.eventlist[i].date + ' ' + CalendarStore.state.eventlist[i].time)
// const startTime = new Date(CalendarStore.state.eventlist[i].date + ' ' + CalendarStore.state.eventlist[i].time)
const startTime = new Date(CalendarStore.state.eventlist[i].date)
const endTime = date.addToDate(startTime, { minutes: CalendarStore.state.eventlist[i].dur })
for (let j = 0; j < eventsloc.length; ++j) {
const startTime2 = new Date(eventsloc[j].date + ' ' + eventsloc[j].time)
const startTime2 = new Date(eventsloc[j].date)
const endTime2 = date.addToDate(startTime2, { minutes: eventsloc[j].dur2 })
if (date.isBetweenDates(startTime, startTime2, endTime2) || date.isBetweenDates(endTime, startTime2, endTime2)) {
eventsloc[j].side = 'left'
@@ -820,14 +833,15 @@ export default class CEventsCalendar extends Vue {
}
}
}
}
// }
if (!added) {
// CalendarStore.state.eventlist[i].side = void 0
eventsloc.push(CalendarStore.state.eventlist[i])
}
} else if (CalendarStore.state.eventlist[i].days) {
// check for overlapping dates
const startDate = new Date(CalendarStore.state.eventlist[i].date + ' 00:00:00')
// const startDate = new Date(CalendarStore.state.eventlist[i].date + ' 00:00:00')
const startDate = new Date(CalendarStore.state.eventlist[i].date)
const endDate = date.addToDate(startDate, { days: CalendarStore.state.eventlist[i].days })
if (date.isBetweenDates(dt, startDate, endDate)) {
eventsloc.push(CalendarStore.state.eventlist[i])
@@ -866,7 +880,8 @@ export default class CEventsCalendar extends Vue {
// check if event is in the past
const datenow = tools.addDays(tools.getDateNow(), -1)
let dateEvent = new Date(myevent.date + ' 00:00:00')
// let dateEvent = new Date(myevent.date + ' 00:00:00')
let dateEvent = new Date(myevent.date)
if (myevent.days) {
dateEvent = tools.addDays(dateEvent, myevent.days)

View File

@@ -32,16 +32,16 @@
<span class="cal__teacher-content">
<q-chip>
<q-avatar>
<img :src="`../../statics/images/avatar/` + myevent.avatar">
<img :src="`../../statics/images/` + getTeacherImg(myevent.teacher)">
</q-avatar>
<span class="cal__teacher-content">{{myevent.teacher}}</span>
<span class="cal__teacher-content">{{getTeacherName(myevent.teacher)}}</span>
</q-chip>
<span v-if="myevent.avatar2 && myevent.teacher2" class="margin_avatar2"></span>
<q-chip v-if="myevent.avatar2 && myevent.teacher2">
<span v-if="getTeacherImg(myevent.teacher2) && myevent.teacher2" class="margin_avatar2"></span>
<q-chip v-if="getTeacherImg(myevent.teacher2) && myevent.teacher2">
<q-avatar>
<img :src="`../../statics/images/avatar/` + myevent.avatar2">
<img :src="`../../statics/images/` + getTeacherImg(myevent.teacher2)">
</q-avatar>
<span class="cal__teacher-content">{{myevent.teacher2}}</span>
<span class="cal__teacher-content">{{getTeacherName(myevent.teacher2)}}</span>
</q-chip>
</span>
</div>
@@ -68,10 +68,10 @@
<span class="cal__hours-content">{{ myevent.infoextra }} </span>
</span>
<span v-else>
<span v-if="myevent.time" class="cal__hours">
<span v-if="myevent.withtime" class="cal__hours">
-
<span class="cal__hours-title">{{$t('cal.hours')}}: </span>
<span class="cal__hours-content">{{$t('cal.starttime')}} {{ myevent.time }} {{$t('cal.endtime')}}: {{
<span class="cal__hours-content">{{$t('cal.starttime')}} {{ tools.getstrTime(myevent.date) }} {{$t('cal.endtime')}}: {{
getEndTime(myevent) }}</span>
</span>
</span>
@@ -242,10 +242,10 @@
<span class="cal__hours-content">{{ myevent.infoextra }} </span>
</span>
<span v-else>
<span v-if="myevent.time" class="cal__hours">
<span v-if="myevent.withtime" class="cal__hours">
-
<span class="cal__hours-title">{{$t('cal.hours')}}: </span>
<span class="cal__hours-content"><span v-if="!tools.isMobile()">{{$t('cal.starttime')}} </span>{{ myevent.time }} <span v-if="!tools.isMobile()">{{$t('cal.endtime')}} </span><span v-else> - </span> {{
<span class="cal__hours-content"><span v-if="!tools.isMobile()">{{$t('cal.starttime')}} </span>{{ tools.getstrTime(myevent.date) }} <span v-if="!tools.isMobile()">{{$t('cal.endtime')}} </span><span v-else> - </span> {{
getEndTime(myevent) }}</span>
</span>
</span>
@@ -386,7 +386,7 @@
<div class="row justify-center">
<template v-for="(event, index) in eventsMap[date]">
<q-badge
v-if="!event.time"
v-if="!event.withtime"
:key="index"
style="width: 100%; cursor: pointer;"
class="ellipsis"
@@ -416,7 +416,7 @@
<template #day-body="{ date, timeStartPos, timeDurationHeight }">
<template v-for="(event, index) in getEvents(date)">
<q-badge
v-if="event.time"
v-if="event.withtime"
:key="index"
class="my-event justify-center ellipsis"
:class="badgeClasses(event, 'body')"
@@ -463,7 +463,7 @@
<div v-else>
<div v-if="event.date" class="listaev__date">
{{func_tools.getDateStr(event.date)}}
<span v-if="event.time" class="cal__hours-content"> - {{ event.time }} <span
<span v-if="event.withtime" class="cal__hours-content"> - {{ tools.getstrTime(event.date) }} <span
v-if="event.dur">- {{ getEndTime(event) }}</span></span>
<span v-if="event.days > 1"><br/>{{func_tools.getDateStr(tools.addDays(event.date, event.days - 1))}}</span>
</div>
@@ -506,16 +506,16 @@
<q-chip>
<q-avatar>
<img :src="`../../statics/images/avatar/` + event.avatar">
<img :src="`../../statics/images/` + getTeacherImg(event.teacher)">
</q-avatar>
<span class="cal__teacher-content">{{event.teacher}}</span>
<span class="cal__teacher-content">{{getTeacherName(event.teacher)}}</span>
</q-chip>
<span v-if="event.avatar2" class="margin_avatar2"></span>
<q-chip v-if="event.avatar2 && event.teacher2">
<span v-if="getTeacherImg(event.teacher2)" class="margin_avatar2"></span>
<q-chip v-if="getTeacherImg(event.teacher2) && event.teacher2">
<q-avatar>
<img :src="`../../statics/images/avatar/` + event.avatar2">
<img :src="`../../statics/images/` + getTeacherImg(event.teacher2)">
</q-avatar>
<span class="cal__teacher-content">{{event.teacher2}}</span>
<span class="cal__teacher-content">{{getTeacherName(event.teacher2)}}</span>
</q-chip>
<span v-if="event.where" class="">

View File

@@ -125,10 +125,10 @@ export default class CGridTableRec extends Vue {
this.colVisib = []
this.colExtra = []
this.mycolumns.forEach((elem) => {
if (elem.field !== '')
if (elem.field !== tools.NOFIELD)
this.colVisib.push(elem.field)
if (elem.visible && elem.field === '')
if (elem.visible && elem.field === tools.NOFIELD)
this.colExtra.push(elem.name)
})
@@ -298,9 +298,9 @@ export default class CGridTableRec extends Vue {
// Save on Server
GlobalStore.actions.saveFieldValue(mydata).then((esito) => {
if (esito)
if (esito) {
tools.showPositiveNotif(this.$q, this.$t('db.recupdated'))
else {
} else {
tools.showNegativeNotif(this.$q, this.$t('db.recfailed'))
this.undoVal()
}
@@ -325,10 +325,13 @@ export default class CGridTableRec extends Vue {
}
}
public ActionAfterYes(action, item) {
public ActionAfterYes(action, item, data) {
if (action === lists.MenuAction.DELETE_RECTABLE) {
if (this.serverData.length > 0)
this.serverData.splice(this.serverData.indexOf(item), 1)
} else if (action === lists.MenuAction.DUPLICATE_RECTABLE) {
// Add record duplicated
this.serverData.push(data)
}
}
@@ -345,7 +348,7 @@ export default class CGridTableRec extends Vue {
}
public visuValByType(col, val) {
if (col.isdate) {
if (col.fieldtype === 'date') {
if (val === undefined) {
return '[]'
} else {
@@ -369,7 +372,7 @@ export default class CGridTableRec extends Vue {
let mytab = null
if (this.tablesList) {
if (!this.tablesel) {
this.tablesel = this.tablesList[0].value
this.tablesel = this.tablesList[1].value
}
mytab = this.tablesList.find((rec) => rec.value === this.tablesel)

View File

@@ -1,5 +1,6 @@
<template>
<div class="q-pa-sm">
<q-table
:data="serverData"
:columns="mycolumns"
@@ -83,8 +84,8 @@
<q-tr v-if="mytable" slot="body" slot-scope="props" :props="props">
<q-td v-for="col in mycolumns" :key="col.name" :props="props" v-if="colVisib.includes(col.field)">
<div v-if="col.isdate">
<div style="max-width: 250px">
<div v-if="col.fieldtype === 'date'">
<div style="max-width: 250px; min-width: 200px">
<q-input dense v-model="props.row[col.name]">
<template v-slot:prepend>
<q-icon name="event" class="cursor-pointer">
@@ -117,6 +118,9 @@
</q-input>
</div>
</div>
<div v-if="col.fieldtype === 'boolean'">
<q-checkbox v-model="props.row[col.name])" label="" />
</div>
<div v-else>
<div :class="getclassCol(col)">
{{ visuValByType(col, props.row[col.name]) }}

View File

@@ -5,7 +5,7 @@ export interface IEvents {
short_tit?: string
title?: string
details?: string
time?: string
withtime?: boolean
dur?: number
dur2?: number
date?: string
@@ -18,8 +18,6 @@ export interface IEvents {
contribtype?: number
teacher?: string // teacherid
teacher2?: string // teacherid2
avatar?: string
avatar2?: string
infoextra?: string
linkpage?: string
linkpdf?: string
@@ -42,6 +40,21 @@ export interface IBookedEvent {
booked: boolean
}
export interface IOperators {
username: string
name: string
surname: string
email: string
cell: string
webpage?: string
img: string
skype?: string
days_working?: string
facebook?: string
disciplines?: string
offers?: string
}
export enum EState {
None, Creating, Modifying
}
@@ -56,6 +69,7 @@ export interface ICalendarState {
editable: boolean
eventlist: IEvents[]
bookedevent: IBookedEvent[]
operators: IOperators[]
// ---------------
titlebarHeight: number
locale: string,

View File

@@ -227,7 +227,7 @@ export interface IColGridTable {
icon?: string
action?: any
foredit?: boolean
isdate?: boolean
fieldtype?: string
visuonlyEditVal?: boolean
}
@@ -237,3 +237,9 @@ export interface ITableRec {
columns: IColGridTable[]
colkey: string
}
export interface IDataPass {
id: string
table: string
fieldsvalue: object
}

View File

@@ -32,7 +32,7 @@ const msgglobal = {
update: 'Aggiorna',
today: 'Oggi',
book: 'Prenota',
sendmsg: 'Invia Msg',
sendmsg: 'Invia solo un Msg',
msg: {
titledeleteTask: 'Elimina Task',
deleteTask: "Vuoi Eliminare {mytodo}?"
@@ -48,6 +48,8 @@ const msgglobal = {
deletetherecord: 'Eliminare il Record?',
deletedrecord: 'Record Cancellato',
recdelfailed: 'Errore durante la cancellazione del Record',
duplicatedrecord: 'Record Duplicato',
recdupfailed: 'Errore durante la duplicazione del Record',
},
components: {
authentication: {
@@ -221,6 +223,34 @@ const msgglobal = {
teachertitle: 'Insegnante',
peoplebooked: 'Prenotaz.',
},
event: {
_id: 'id',
typol: 'Typology',
short_tit: 'Titolo Breve',
title: 'Titolo',
details: 'Dettagli',
withtime: 'Con Tempo',
dur: 'durata (min)',
dur2: 'durata2 (min)',
date: 'Data',
bgcolor: 'Colore Sfondo',
days: 'Giorni',
icon: 'Icona',
img: 'Nomefile Immagine',
where: 'Dove',
contribtype: 'Tipo Contributo',
teacher: 'Insegnante', // teacherid
teacher2: 'Insegnante2', // teacherid2
infoextra: 'InfoExtra',
linkpage: 'WebSite',
linkpdf: 'Link ad un PDF',
nobookable: 'No Prenotabile',
news: 'Novità',
dupId: 'Id Duplicato',
canceled: 'Cancellato',
deleted: 'Eliminato',
duplicate: 'Duplica'
},
newsletter: {
title: 'Desideri ricevere la nostra Newsletter?',
name: 'Il tuo Nome',
@@ -233,7 +263,7 @@ const msgglobal = {
typesomething: 'Compilare correttamente il campo',
acceptlicense: 'Accetto la licenza e i termini',
license: 'Devi prima accettare la licenza e i termini',
submitted: 'Iscritto'
submitted: 'Iscritto',
},
privacy_policy:'Privacy Policy',
cookies: 'Usiamo i Cookie per una migliore prestazione web.'
@@ -269,7 +299,7 @@ const msgglobal = {
update: 'Actualiza',
today: 'Hoy',
book: 'Reserva',
sendmsg: 'Envia Mensaje',
sendmsg: 'Envia solo Mensaje',
msg: {
titledeleteTask: 'Borrar Tarea',
deleteTask: 'Quieres borrar {mytodo}?'
@@ -285,6 +315,8 @@ const msgglobal = {
deletetherecord: '¿Eliminar el registro?',
deletedrecord: 'Registro cancelado',
recdelfailed: 'Error durante la eliminación del registro',
duplicatedrecord: 'Registro Duplicado',
recdupfailed: 'Error durante la duplicación de registros',
},
components: {
authentication: {
@@ -452,6 +484,34 @@ const msgglobal = {
teachertitle: 'Maestro',
peoplebooked: 'Reserv.',
},
event: {
_id: 'id',
typol: 'Typology',
short_tit: 'Título Corto',
title: 'Título',
details: 'Detalles',
withtime: 'Con Tiempo',
dur: 'duración (min)',
dur2: 'duración2 (min)',
date: 'Fecha',
bgcolor: 'Color de fondo',
days: 'Días',
icon: 'Icono',
img: 'Nombre Imagen',
where: 'Dónde',
contribtype: 'Tipo de Contribución',
teacher: 'Profesor', // teacherid
teacher2: 'Profesor2', // teacherid2
infoextra: 'InfoExtra',
linkpage: 'Sitio WEb',
linkpdf: 'Enlace ad un PDF',
nobookable: 'No Reservable',
news: 'Novedad',
dupId: 'Id Duplicado',
canceled: 'Cancelado',
deleted: 'Eliminado',
duplicate: 'Duplica',
},
newsletter: {
title: '¿Desea recibir nuestro boletín informativo?',
name: 'Tu Nombre',
@@ -500,7 +560,7 @@ const msgglobal = {
cancel: 'annuler',
today: 'Aujourd\'hui',
book: 'Réserve',
sendmsg: 'Envoyer Msg',
sendmsg: 'envoyer seul un msg',
msg: {
titledeleteTask: 'Supprimer la tâche',
deleteTask: 'Voulez-vous supprimer {mytodo}?'
@@ -516,6 +576,8 @@ const msgglobal = {
deletetherecord: 'Supprimer l\'enregistrement?',
deletedrecord: 'Enregistrement annulé',
recdelfailed: 'Erreur lors de la suppression de l\'enregistrement',
duplicatedrecord: 'Enregistrement en double',
recdupfailed: 'Erreur lors de la duplication des enregistrements',
},
components: {
authentication: {
@@ -682,6 +744,34 @@ const msgglobal = {
teachertitle: 'Professeur',
peoplebooked: 'Réserv.',
},
event: {
_id: 'id',
typol: 'Typologie',
short_tit: 'Titre abrégé\'',
title: 'Titre',
details: 'Détails',
withtime: 'avec le temps',
dur: 'durée (min)',
dur2: 'durée2 (min)',
date: 'Date',
bgcolor: 'Couleur de fond',
days: 'Journées',
icon: 'Icône',
img: 'Image du nom de fichier',
where: 'Où',
contribtype: 'Type de contribution',
teacher: 'Enseignant', // teacherid
teacher2: 'Enseignant2', // teacherid2
infoextra: 'Extra Info',
linkpage: 'Site Web',
linkpdf: 'Lien vers un PDF',
nobookable: 'non réservable',
news: 'Nouvelles',
dupId: 'Id Double',
canceled: 'Annulé',
deleted: 'Supprimé',
duplicate: 'Duplique'
},
newsletter: {
title: 'Souhaitez-vous recevoir notre newsletter?',
name: 'Ton nom',
@@ -730,7 +820,7 @@ const msgglobal = {
cancel: 'Cancel',
today: 'Today',
book: 'Book',
sendmsg: 'Send Msg',
sendmsg: 'Send only a Msg',
msg: {
titledeleteTask: 'Delete Task',
deleteTask: 'Delete Task {mytodo}?'
@@ -746,6 +836,8 @@ const msgglobal = {
deletetherecord: 'Delete the Record?',
deletedrecord: 'Record Deleted',
recdelfailed: 'Error during deletion of the Record',
duplicatedrecord: 'Duplicate Record',
recdupfailed: 'Error during record duplication',
},
components: {
authentication: {
@@ -911,6 +1003,34 @@ const msgglobal = {
teachertitle: 'Teacher',
peoplebooked: 'Booked',
},
event: {
_id: 'id',
typol: 'Typology',
short_tit: 'Short Title',
title: 'Title',
details: 'Details',
withtime: 'With Time',
dur: 'Duration (min)',
dur2: 'Duration2 (min)',
date: 'Date',
bgcolor: 'Background color',
days: 'Days',
icon: 'Icon',
img: 'Nomefile Img',
where: 'Qhere',
contribtype: 'Contribute Type',
teacher: 'Teacher', // teacherid
teacher2: 'Teacher2', // teacherid2
infoextra: 'Extra Info',
linkpage: 'WebSite',
linkpdf: 'PDF Link',
nobookable: 'No Bookable',
news: 'News',
dupId: 'Id Duplicate',
canceled: 'Canceled',
deleted: 'Deleted',
duplicate: 'Duplicate'
},
newsletter: {
title: 'Would you like to receive our Newsletter?',
name: 'Your name',
@@ -959,7 +1079,7 @@ const msgglobal = {
cancel: 'Cancel',
today: 'Today',
book: 'Book',
sendmsg: 'Send Msg',
sendmsg: 'Send only a Msg',
msg: {
titledeleteTask: 'Delete Task',
deleteTask: 'Delete Task {mytodo}?'
@@ -975,6 +1095,8 @@ const msgglobal = {
deletetherecord: 'Delete the Record?',
deletedrecord: 'Record Deleted',
recdelfailed: 'Error during deletion of the Record',
duplicatedrecord: 'Duplicate Record',
recdupfailed: 'Error during record duplication',
},
components: {
authentication: {
@@ -1142,6 +1264,34 @@ const msgglobal = {
teachertitle: 'Teacher',
peoplebooked: 'Booked',
},
event: {
_id: 'id',
typol: 'Typology',
short_tit: 'Short Title',
title: 'Title',
details: 'Details',
withtime: 'With Time',
dur: 'Duration (min)',
dur2: 'Duration2 (min)',
date: 'Date',
bgcolor: 'Background color',
days: 'Days',
icon: 'Icon',
img: 'Nomefile Img',
where: 'Qhere',
contribtype: 'Contribute Type',
teacher: 'Teacher', // teacherid
teacher2: 'Teacher2', // teacherid2
infoextra: 'Extra Info',
linkpage: 'WebSite',
linkpdf: 'PDF Link',
nobookable: 'No Bookable',
news: 'News',
dupId: 'Id Duplicate',
canceled: 'Canceled',
deleted: 'Deleted',
duplicate: 'Duplicate'
},
newsletter: {
title: 'Would you like to receive our Newsletter?',
name: 'Your name',

View File

@@ -13,15 +13,16 @@ import { costanti } from '@src/store/Modules/costanti'
import { tools } from '@src/store/Modules/tools'
import { toolsext } from '@src/store/Modules/toolsext'
import * as ApiTables from '@src/store/Modules/ApiTables'
import { GlobalStore, Projects, Todos, UserStore } from '@store'
import { CalendarStore, GlobalStore, Projects, Todos, UserStore } from '@store'
import messages from '../../statics/i18n'
import globalroutines from './../../globalroutines/index'
import { cfgrouter } from '../../router/route-config'
import { static_data } from '@src/db/static_data'
import { IParamsQuery } from '@src/model/GlobalStore'
import { IDataPass, IParamsQuery } from '@src/model/GlobalStore'
import { serv_constants } from '@src/store/Modules/serv_constants'
import { IUserState } from '@src/model'
import { Calendar } from 'element-ui'
// import { static_data } from '@src/db/static_data'
let stateConnDefault = 'online'
@@ -268,6 +269,41 @@ namespace Mutations {
}
function getListByTable(table): any[] {
if (table === 'events')
return CalendarStore.state.eventlist
else if (table === 'operators')
return CalendarStore.state.operators
else if (table === 'bookings')
return CalendarStore.state.bookedevent
else if (table === 'users')
return UserStore.state.usersList
else
return null
}
function UpdateValuesInMemory(mystate: IGlobalState, mydata: IDataPass) {
const id = mydata.id
const table = mydata.table
try {
const mylist = getListByTable(table)
const myrec = mylist.find((event) => event._id === id)
// console.log('myrec', myrec)
if (myrec) {
for (const [key, value] of Object.entries(mydata.fieldsvalue)) {
console.log('key', value, myrec[key])
myrec[key] = value
}
}
} catch (e) {
console.error(e)
}
}
export const mutations = {
setConta: b.commit(setConta),
setleftDrawerOpen: b.commit(setleftDrawerOpen),
@@ -278,7 +314,8 @@ namespace Mutations {
setPaoArray: b.commit(setPaoArray),
setPaoArray_Delete: b.commit(setPaoArray_Delete),
NewArray: b.commit(NewArray),
setShowType: b.commit(setShowType)
setShowType: b.commit(setShowType),
UpdateValuesInMemory: b.commit(UpdateValuesInMemory)
}
}
@@ -533,14 +570,15 @@ namespace Actions {
})
}
async function saveFieldValue(context, mydata: object) {
async function saveFieldValue(context, mydata: IDataPass) {
console.log('saveFieldValue', mydata)
return await Api.SendReq(`/chval`, 'PATCH', { data: mydata })
.then((res) => {
if (res)
if (res) {
Mutations.mutations.UpdateValuesInMemory(mydata)
return (res.data.code === serv_constants.RIS_CODE_OK)
else
} else
return false
})
.catch((error) => {
@@ -566,6 +604,24 @@ namespace Actions {
})
}
async function DuplicateRec(context, { table, id }) {
console.log('DuplicateRec', id)
return await Api.SendReq('/duprec/' + table + '/' + id, 'POST', null)
.then((res) => {
if (res.status === 200) {
if (res.data.code === serv_constants.RIS_CODE_OK) {
return res.data.record
}
}
return null
})
.catch((error) => {
console.error(error)
return null
})
}
export const actions = {
setConta: b.dispatch(setConta),
createPushSubscription: b.dispatch(createPushSubscription),
@@ -578,7 +634,8 @@ namespace Actions {
saveFieldValue: b.dispatch(saveFieldValue),
loadTable: b.dispatch(loadTable),
saveTable: b.dispatch(saveTable),
DeleteRec: b.dispatch(DeleteRec)
DeleteRec: b.dispatch(DeleteRec),
DuplicateRec: b.dispatch(DuplicateRec)
}
}

View File

@@ -17,6 +17,7 @@ const state: ICalendarState = {
editable: false,
eventlist: [],
bookedevent: [],
operators: [],
// ---------------
titlebarHeight: 0,
locale: 'it-IT',
@@ -92,7 +93,7 @@ namespace Actions {
// console.log('CalendarStore: loadAfterLogin')
// Load local data
state.editable = db_data.userdata.calendar_editable
state.eventlist = db_data.events
// state.eventlist = db_data.events
// state.bookedevent = db_data.userdata.bookedevent
if (UserStore.getters.isUserInvalid) {
@@ -109,11 +110,10 @@ namespace Actions {
ris = await Api.SendReq('/booking/' + UserStore.state.userId + '/' + process.env.APP_ID + '/' + showall, 'GET', null)
.then((res) => {
if (res.data.bookedevent) {
state.bookedevent = res.data.bookedevent
} else {
state.bookedevent = []
}
state.bookedevent = (res.data.bookedevent) ? res.data.bookedevent : []
state.eventlist = (res.data.eventlist) ? res.data.eventlist : []
state.operators = (res.data.operators) ? res.data.operators : []
})
.catch((error) => {
console.log('error dbLoad', error)

View File

@@ -16,6 +16,7 @@ export const lists = {
THEMEBG: 211,
DELETE_RECTABLE: 300,
DUPLICATE_RECTABLE: 310,
CAN_EDIT_TABLE: 400,
SHOW_PREV_REC: 401,

View File

@@ -45,6 +45,8 @@ export const tools = {
DUPLICATE_EMAIL_ID: 11000,
DUPLICATE_USERNAME_ID: 11100,
NOFIELD: 'nofield',
TYPE_AUDIO: 1,
NUMSEC_CHECKUPDATE: 20000,
@@ -1333,11 +1335,20 @@ export const tools = {
console.log('param1', par.param1)
GlobalStore.actions.DeleteRec({ table, id: par.param1 }).then((ris) => {
if (ris) {
myself.ActionAfterYes(func, par.param2)
myself.ActionAfterYes(func, par.param2, null)
tools.showPositiveNotif(myself.$q, myself.$t('db.deletedrecord'))
} else
tools.showNegativeNotif(myself.$q, myself.$t('db.recdelfailed'))
})
} else if (func === lists.MenuAction.DUPLICATE_RECTABLE) {
console.log('param1', par.param1)
GlobalStore.actions.DuplicateRec({ table, id: par.param1 }).then((ris) => {
if (ris) {
myself.ActionAfterYes(func, par.param2, ris.data)
tools.showPositiveNotif(myself.$q, myself.$t('db.duplicatedrecord'))
} else
tools.showNegativeNotif(myself.$q, myself.$t('db.recdupfailed'))
})
}
},
@@ -1551,7 +1562,7 @@ export const tools = {
}
}
let i = 0
// let i2 = 0
while (sortedList.length < linkedList.length) {
// get the item with a previous item ID referencing the current item
const nextItem = linkedList[map.get(currentId)]
@@ -1561,7 +1572,7 @@ export const tools = {
sortedList.push(nextItem)
// tools.logelemprj('FATTO:' + i, nextItem)
currentId = String(nextItem._id)
i++
// i2++
}
if (sortedList.length < linkedList.length) {
@@ -1628,10 +1639,18 @@ export const tools = {
return ''
},
getstrTime(mytimestamp) {
// console.log('getstrDate', mytimestamp)
if (!!mytimestamp)
return date.formatDate(mytimestamp, 'HH:mm')
else
return ''
},
getstrDateTime(mytimestamp) {
// console.log('getstrDate', mytimestamp)
if (!!mytimestamp)
return date.formatDate(mytimestamp, 'DD/MM/YYYY HH:MM')
return date.formatDate(mytimestamp, 'DD/MM/YYYY HH:mm')
else
return ''
},
@@ -1683,8 +1702,11 @@ export const tools = {
return ''
}
try {
return value.substring(0, numchars) + '...'
}catch (e) {
let mycar = value.substring(0, numchars)
if (value.length > numchars)
mycar += '...'
return mycar
} catch (e) {
return value
}
},
@@ -2121,7 +2143,8 @@ export const tools = {
return msg
},
gettextevent(myevent: IEvents) {
return '"' + myevent.title + '" (' + func_tools.getDateStr(myevent.date) + ') - ' + myevent.time
// return '"' + myevent.title + '" (' + func_tools.getDateStr(myevent.date) + ') - ' + myevent.time
return '"' + myevent.title + '" (' + tools.getstrDateTime(myevent.date)
},
setLangAtt(mylang) {