From c39f0d84862856646bfee5dd2b8ac8a12f291a91 Mon Sep 17 00:00:00 2001 From: Paolo Arena Date: Wed, 23 Oct 2019 23:47:12 +0200 Subject: [PATCH] - Enable Edit Event into dialog form ... (and save to the db) - Event: enabled drag and drop (date) - Q-Select components in every table field external: Where, Operators, etc... - CMyEditor: Add HTML Editor to the details field ! - Added button Color for change font color to the text. - Complete insert Events Site --- .../CEventsCalendar/CEventsCalendar.scss | 56 ++- .../CEventsCalendar/CEventsCalendar.ts | 343 ++++++++++++------ .../CEventsCalendar/CEventsCalendar.vue | 260 +++++++++---- src/components/index.ts | 2 + src/model/Calendar.ts | 7 + src/statics/i18n.js | 39 +- src/store/Modules/GlobalStore.ts | 33 ++ .../Modules/Store/calendar/CalendarStore.ts | 62 ++-- src/store/Modules/UserStore.ts | 2 - src/store/Modules/tools.ts | 56 ++- src/store/Modules/toolsext.ts | 19 +- 11 files changed, 608 insertions(+), 271 deletions(-) diff --git a/src/components/CEventsCalendar/CEventsCalendar.scss b/src/components/CEventsCalendar/CEventsCalendar.scss index 800ef92..d3f47d1 100644 --- a/src/components/CEventsCalendar/CEventsCalendar.scss +++ b/src/components/CEventsCalendar/CEventsCalendar.scss @@ -34,7 +34,7 @@ $graytext: #555; letter-spacing: 0.03333em; &__title { - color: red; + color: white; font-weight: 700; font-size: 1rem; padding-bottom: 10px; @@ -55,7 +55,7 @@ $graytext: #555; } &__where { - margin-top: 10px; + margin-top: 5px; color: blue; &-title { @@ -67,7 +67,7 @@ $graytext: #555; } &__when { - margin-top: 10px; + margin-top: 5px; color: blue; &-title { @@ -79,7 +79,7 @@ $graytext: #555; } &__teacher { - margin-top: 10px; + margin-top: 5px; &-title { color: $graytext; } @@ -88,6 +88,16 @@ $graytext: #555; } } + &__quota { + margin-top: 5px; + &-title { + color: $graytext; + } + &-content { + + } + } + &__img { width: 100px; height: 100px; @@ -141,6 +151,18 @@ $graytext: #555; @media (max-width: 718px) { text-align: center; display: flex; + flex-direction: column; + align-items: center; + } + } + + &__align_chips { + text-align: left; + @media (max-width: 718px) { + text-align: center; + display: flex; + flex-direction: column-reverse; + align-items: center; } } @@ -201,10 +223,21 @@ $graytext: #555; position: absolute; left: 40px; @media (max-width: 400px) { + left: initial; position: initial; } } +.chipnews { + + position: absolute; + right: 0; + @media (max-width: 400px) { + position: initial; + right: initial; + } +} + .windowcol { background-color: #ffffff; // background: radial-gradient(circle, #ffffff 0%, #94dbfb 100%) @@ -213,3 +246,18 @@ $graytext: #555; .mysel{ color: white; } + +.calendar_comp{ + max-width: 170px; + @media (max-width: 400px) { + max-width: 400px; + } +} + +.myflex{ + display: flex; + flex: 1; + @media (max-width: 400px) { + flex-flow: column; + } +} diff --git a/src/components/CEventsCalendar/CEventsCalendar.ts b/src/components/CEventsCalendar/CEventsCalendar.ts index 265bd25..fee862c 100644 --- a/src/components/CEventsCalendar/CEventsCalendar.ts +++ b/src/components/CEventsCalendar/CEventsCalendar.ts @@ -13,6 +13,8 @@ import { colors, Screen, Platform, date } from 'quasar' import { CTitle } from '../../components/CTitle/index' import { CImgText } from '../../components/CImgText/index' +import { CMySelect } from '../../components/CMySelect/index' +import { CMyEditor } from '../../components/CMyEditor/index' import { stop, prevent, stopAndPrevent } from 'quasar/src/utils/event' import QDateScroller from '@quasar/quasar-app-extension-qscroller/src/component/QDateScroller' @@ -30,9 +32,90 @@ import { GlobalStore } from '../../store/Modules' @Component({ name: 'CEventsCalendar', - components: { Logo, Footer, CTitle, CImgText, QDateTimeScroller, QDateScroller } + components: { Logo, Footer, CTitle, CImgText, QDateTimeScroller, QDateScroller, CMySelect, CMyEditor } }) export default class CEventsCalendar extends Vue { + public $q + public $t: any + public calendarView = 'month' + public selectedDate = '2019-04-01' + public formDefault: IEvents = { + title: '', + details: '', + dateTimeStart: tools.getstrYYMMDDDateTime(tools.getDateNow()), + dateTimeEnd: tools.getstrYYMMDDDateTime(tools.getDateNow()), + icon: '', + bgcolor: '#839ff2' + } + + public formbookEventDefault: IBookedEvent = { + userId: '', + msgbooking: '', + infoevent: '', + numpeople: 1, + datebooked: tools.getDateNow(), + booked: false, + modified: false + } + + public mioalert = false + + public dateFormatter: any = '' + public titleFormatter: any = null + + public keyValue = 0 + public direction = 'forward' + public weekdays = [1, 2, 3, 4, 5, 6, 0] + public viewOptions = [ + { label: 'Day', value: 'day' }, + { label: '5 Day', value: '5day' }, + { label: 'Week', value: 'week' }, + { label: 'Month', value: 'month' } + ] + public addEvent = false + public bookEventpage: IBookedEventPage = { + show: false, + bookedevent: null, + state: EState.None + } + + public contextDay = null + public eventForm: IEvents = { ...this.formDefault } + public bookEventForm = { ...this.formbookEventDefault } + public displayEvent = false + public myevent = null + // public events = [] + public gmt = '' + public dragging = false + public draggedEvent = null + public ignoreNextSwipe = false + public showDateScrollerAllDay = false + public showDateTimeScrollerStart = false + public showDateTimeScrollerEnd = false + + public resources = [ + { + label: 'John' + }, + { + label: 'Mary' + }, + { + label: 'Susan' + }, + { + label: 'Olivia' + }, + { + label: 'Board Room' + }, + { + label: 'Room-1' + }, + { + label: 'Room-2' + } + ] // public eventdata = // [ @@ -189,7 +272,7 @@ export default class CEventsCalendar extends Vue { get eventsMap() { // console.log('eventsMap') const map = {} - CalendarStore.state.eventlist.forEach((myevent) => (map[myevent.dateTimeStart.toDateString()] = map[myevent.dateTimeStart.toDateString()] || []).push(myevent)) + CalendarStore.state.eventlist.forEach((myevent) => (map[tools.getstrDateTime(myevent.dateTimeStart)] = map[tools.getstrDateTime(myevent.dateTimeStart)] || []).push(myevent)) return map } @@ -271,85 +354,7 @@ export default class CEventsCalendar extends Vue { get mythis() { return this } - public $t: any - public $q - public calendarView = 'month' - public selectedDate = '2019-04-01' - public formDefault: IEvents = { - title: '', - details: '', - icon: '', - bgcolor: '#0000FF' - } - public formbookEventDefault: IBookedEvent = { - userId: '', - msgbooking: '', - infoevent: '', - numpeople: 1, - datebooked: tools.getDateNow(), - booked: false, - modified: false - } - - public mioalert = false - - public dateFormatter: any = '' - public titleFormatter: any = null - - public keyValue = 0 - public direction = 'forward' - public weekdays = [1, 2, 3, 4, 5, 6, 0] - public viewOptions = [ - { label: 'Day', value: 'day' }, - { label: '5 Day', value: '5day' }, - { label: 'Week', value: 'week' }, - { label: 'Month', value: 'month' } - ] - public addEvent = false - public bookEventpage: IBookedEventPage = { - show: false, - bookedevent: null, - state: EState.None - } - - public contextDay = null - public eventForm = { ...this.formDefault } - public bookEventForm = { ...this.formbookEventDefault } - public displayEvent = false - public myevent = null - // public events = [] - public gmt = '' - public dragging = false - public draggedEvent = null - public ignoreNextSwipe = false - public showDateScrollerAllDay = false - public showDateTimeScrollerStart = false - public showDateTimeScrollerEnd = false - - public resources = [ - { - label: 'John' - }, - { - label: 'Mary' - }, - { - label: 'Susan' - }, - { - label: 'Olivia' - }, - { - label: 'Board Room' - }, - { - label: 'Room-1' - }, - { - label: 'Room-2' - } - ] public $refs: { calendar: any @@ -367,6 +372,7 @@ export default class CEventsCalendar extends Vue { this.$root.$on('calendar:today', this.calendarToday) // CalendarStore.state.eventlist = events this.updateFormatters() + } public beforeMount() { @@ -411,6 +417,9 @@ export default class CEventsCalendar extends Vue { this.resetForm() this.contextDay = { ...day } + this.eventForm.dateTimeStart = tools.getstrYYMMDDDateTime(day.date + ' 21:00:00') + this.eventForm.dateTimeEnd = tools.getstrYYMMDDDateTime(day.date + ' 22:00:00') + this.addEvent = true // show dialog } @@ -423,7 +432,6 @@ export default class CEventsCalendar extends Vue { console.log('addBookEventMenu') this.resetForm() this.myevent = eventparam - // this.bookEventForm.msgbooking = translate('cal.bookingtextdefault') + ' ' + tools.gettextevent(this.myevent) this.bookEventForm.msgbooking = '' this.bookEventForm.numpeople = 1 this.bookEventpage.state = EState.Creating @@ -440,9 +448,10 @@ export default class CEventsCalendar extends Vue { public editEvent(eventparam) { console.log('editEvent - INIZIO') this.resetForm() + this.contextDay = { ...eventparam } - this.eventForm = {... eventparam } + this.eventForm = { ...eventparam } this.eventForm.dateTimeStart = tools.getstrYYMMDDDateTime(eventparam.dateTimeStart) this.eventForm.dateTimeEnd = tools.getstrYYMMDDDateTime(eventparam.dateTimeEnd) @@ -459,11 +468,13 @@ export default class CEventsCalendar extends Vue { public findEventIndex(eventparam) { for (let i = 0; i < CalendarStore.state.eventlist.length; ++i) { - if (eventparam.title === CalendarStore.state.eventlist[i].title && - eventparam.details === CalendarStore.state.eventlist[i].details && - eventparam.dateTimeStart === CalendarStore.state.eventlist[i].dateTimeStart && - eventparam.dateTimeEnd === CalendarStore.state.eventlist[i].dateTimeEnd) { - return i + if (eventparam) { + if (eventparam.title === CalendarStore.state.eventlist[i].title && + eventparam.details === CalendarStore.state.eventlist[i].details && + eventparam.dateTimeStart === CalendarStore.state.eventlist[i].dateTimeStart && + eventparam.dateTimeEnd === CalendarStore.state.eventlist[i].dateTimeEnd) { + return i + } } } } @@ -498,6 +509,33 @@ export default class CEventsCalendar extends Vue { return diff } + public UpdateDbByFields(myrec, undo?) { + const self = this + + const mydatatosave = { + id: myrec._id, + table: 'myevents', + fieldsvalue: myrec + } + + GlobalStore.actions.saveFieldValue(mydatatosave).then((esito) => { + if (esito) { + tools.showPositiveNotif(this.$q, this.$t('db.recupdated')) + } else { + tools.showNegativeNotif(this.$q, this.$t('db.recfailed')) + // Undo... + if (undo) { + const index = self.findEventIndex(self.contextDay) + if (index >= 0) { + // @ts-ignore + CalendarStore.state.eventlist.splice(index, 1, { ...self.contextDay }) + } + } + } + }) + + } + public saveEvent() { const self = this @@ -508,7 +546,7 @@ export default class CEventsCalendar extends Vue { self.addEvent = false const form = { ...self.eventForm } let update = false - if (self.contextDay.bgcolor) { + if (self.contextDay._id) { // an update update = true } else { @@ -516,18 +554,6 @@ export default class CEventsCalendar extends Vue { } const data = { ...form } - if (update === true) { - const index = self.findEventIndex(self.contextDay) - if (index >= 0) { - // @ts-ignore - CalendarStore.state.eventlist.splice(index, 1, { ...data }) - } - } else { - // add to events array - // @ts-ignore - CalendarStore.state.eventlist.push(data) - } - // ++Save into the Database const mydatatosave = { id: data._id, @@ -535,19 +561,42 @@ export default class CEventsCalendar extends Vue { fieldsvalue: data } - GlobalStore.actions.saveFieldValue(mydatatosave).then((esito) => { - if (esito) { - tools.showPositiveNotif(this.$q, this.$t('db.recupdated')) - } else { - tools.showNegativeNotif(this.$q, this.$t('db.recfailed')) - // Undo... - const index = self.findEventIndex(self.contextDay) - if (index >= 0) { - // @ts-ignore - CalendarStore.state.eventlist.splice(index, 1, { ...self.contextDay }) - } + if (update === true) { + this.UpdateDbByFields(data, true) + } else { + const mydataadd = { + table: 'myevents', + data } - }) + + GlobalStore.actions.saveTable(mydataadd).then((record) => { + if (record) { + tools.showPositiveNotif(this.$q, this.$t('db.recupdated')) + + if (update === true) { + const index = self.findEventIndex(self.contextDay) + if (index >= 0) { + // @ts-ignore + CalendarStore.state.eventlist.splice(index, 1, { ...data }) + } + } else { + data._id = record._id + // add to events array + // @ts-ignore + CalendarStore.state.eventlist.push(data) + } + + } else { + tools.showNegativeNotif(this.$q, this.$t('db.recfailed')) + // Undo... + const index = self.findEventIndex(self.contextDay) + if (index >= 0) { + // @ts-ignore + CalendarStore.state.eventlist.splice(index, 1, { ...self.contextDay }) + } + } + }) + } self.contextDay = null } @@ -592,7 +641,7 @@ export default class CEventsCalendar extends Vue { userId: UserStore.state.userId, id_bookedevent: myevent._id, numpeople: self.bookEventForm.numpeople, - infoevent: tools.gettextevent(myevent), + infoevent: tools.gettextevent(self, myevent), msgbooking: self.bookEventForm.msgbooking, booked: self.bookEventForm.booked, datebooked: tools.getDateNow(), @@ -686,14 +735,29 @@ export default class CEventsCalendar extends Vue { public onDrop(ev, day, type) { ev.preventDefault() ev.stopPropagation() + console.log('day.dateTimeStart', day.dateTimeStart, day.date, 'day.time', day.time) if (type === 'day') { - this.draggedEvent.dateTimeStart = day.dateTimeStart + this.draggedEvent.dateTimeStart = day.date + ' ' + tools.getstrTime(this.draggedEvent.dateTimeStart) + this.draggedEvent.dateTimeEnd = day.date + ' ' + tools.getstrTime(this.draggedEvent.dateTimeEnd) this.draggedEvent.side = void 0 } else if (type === 'interval') { - this.draggedEvent.dateTimeStart = day.dateTimeStart + const mins = date.getDateDiff(this.draggedEvent.dateTimeEnd, this.draggedEvent.dateTimeStart, 'minutes') + this.draggedEvent.dateTimeStart = day.date + ' ' + day.time + const mystart = new Date(this.draggedEvent.dateTimeStart) + this.draggedEvent.dateTimeEnd = tools.addMinutes(mystart, mins) + // this.draggedEvent.dateTimeEnd = day.dateTimeEnd // this.draggedEvent.time = day.time this.draggedEvent.side = void 0 } + // console.log('Start', this.draggedEvent.dateTimeStart, 'End', this.draggedEvent.dateTimeEnd) + + // Save Date + this.UpdateDbByFields({ + _id: this.draggedEvent._id, + dateTimeStart: this.draggedEvent.dateTimeStart, + dateTimeEnd: this.draggedEvent.dateTimeEnd + }, true) + } public resetDrag() { @@ -712,12 +776,58 @@ export default class CEventsCalendar extends Vue { return CalendarStore.getters.findEventBooked(eventparam, true) } + public getImgEvent(event: IEvents) { + if (!!event.img) + return '../../statics/' + event.img + else + return '../../statics/images/noimg.png' + } + + get getContribTypeArr() { + return CalendarStore.state.contribtype + } + + get getTeachersArr() { + return CalendarStore.state.operators + } + + get getWhereArr() { + return CalendarStore.state.wheres + } + + public isShowPrice(event: IEvents) { + const rec = CalendarStore.getters.getContribtypeRec(event.contribtype) + return (rec) ? rec.showprice : true + } + + public getContribtypeById(id) { + return CalendarStore.getters.getContribtypeById(id) + } + + public createContribType(value) { + console.log('createContribType', value) + tools.createNewRecord(this, 'contribtype', { label: value }).then((myrec) => { + console.log('myrec') + CalendarStore.state.contribtype.push(myrec) + }) + } + public getEventDate(eventparam) { const parts = eventparam.dateTimeStart.split('-') const mydate = new Date(parts[0], parts[1] - 1, parts[2]) return this.dateFormatter.format(mydate) } + public getPrice(event: IEvents) { + let myprice = (event.price > 0) ? event.price + ' €' : '' + myprice = (event.price === -1) ? this.$t('event.askinfo') : myprice + + if (event.infoafterprice) + myprice += ' ' + event.infoafterprice + + return myprice + } + public getTeacherName(teacherusername) { return CalendarStore.getters.getTeacherName(teacherusername) } @@ -726,6 +836,7 @@ export default class CEventsCalendar extends Vue { const whererec = CalendarStore.getters.getWhereRec(where) return (whererec) ? whererec.whereicon : '' } + public getWhereName(where) { const whererec = CalendarStore.getters.getWhereRec(where) return (whererec) ? whererec.placename : '' @@ -835,7 +946,7 @@ export default class CEventsCalendar extends Vue { // CalendarStore.state.eventlist[i].side = void 0 eventsloc.push(CalendarStore.state.eventlist[i]) } - } else if (func_tools.hasManyDays(CalendarStore.state.eventlist[i].dateTimeStart, CalendarStore.state.eventlist[i].dateTimeEnd)) { + } else if (tools.hasManyDays(CalendarStore.state.eventlist[i].dateTimeStart, CalendarStore.state.eventlist[i].dateTimeEnd)) { // check for overlapping dates if (date.isBetweenDates(dt, CalendarStore.state.eventlist[i].dateTimeStart, CalendarStore.state.eventlist[i].dateTimeEnd)) { eventsloc.push(CalendarStore.state.eventlist[i]) diff --git a/src/components/CEventsCalendar/CEventsCalendar.vue b/src/components/CEventsCalendar/CEventsCalendar.vue index 0809b26..463ee3b 100644 --- a/src/components/CEventsCalendar/CEventsCalendar.vue +++ b/src/components/CEventsCalendar/CEventsCalendar.vue @@ -4,8 +4,9 @@ - + + + {{ $t('cal.event') }} @@ -16,49 +17,61 @@ -
-
{{myevent.title}}
+ + + {{myevent.title}} +
{{$t('cal.teacher')}}: - - - - - {{getTeacherName(myevent.teacher)}} - - - - - - - {{getTeacherName(myevent.teacher2)}} - - + + + + + {{getTeacherName(myevent.teacher)}} + + + + + + + {{getTeacherName(myevent.teacher2)}} + +
-
+ {{$t('cal.where')}}: - - - - - - - {{getWhereName(myevent.wherecode)}} - - + + + + + + + {{getWhereName(myevent.wherecode)}} + + +
+
+ {{$t('event.price')}}: + + {{getPrice(myevent)}} +
{{$t('cal.when')}}: @@ -69,7 +82,7 @@ {{ myevent.infoextra }} - - {{$t('cal.hours')}}: @@ -109,16 +122,22 @@ - + - + + + + + -
+
+ :label="$t('cal.eventstartdatetime')" mask="####-##-## ##:##" + class="calendar_comp"> + :label="$t('cal.enterEndDateTime')" mask="####-##-## ##:##" + class="calendar_comp"> +
- - +
- + + + + +
- - - - +
+ + + + + +
- - - - - - +
- - - - - +
+
+ + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + +
+
+ +
+ + +
@@ -221,23 +294,28 @@ -
-
{{myevent.title}}
+ + {{myevent.title}} +
{{$t('cal.when')}}: {{func_tools.getDateStr(myevent.dateTimeStart)}} - - {{func_tools.getDateStr(myevent.dateTimeEnd)}}
+ - {{func_tools.getDateStr(myevent.dateTimeEnd)}}
{{$t('cal.hours')}}: {{ myevent.infoextra }} - - {{$t('cal.hours')}}: @@ -262,7 +340,7 @@ :label="$t('cal.bookingtextdefault')" color="green"> -
-

- + - {{$t('cal.booked')}} + icon="event_available">{{$t('cal.booked')}} + + + {{$t('event.news')}} + +

@@ -476,11 +560,11 @@
-
+
-
+
-
{{event.title}}
- {{event.title}} @@ -537,6 +623,22 @@
+
+ {{$t('event.price')}}: + + + {{getContribtypeById(event.contribtype)}} + + + + + {{getPrice(event)}} + +
+ +

{ + CalendarStore.state.bookedevent = (res.data.bookedevent) ? res.data.bookedevent : [] + CalendarStore.state.eventlist = (res.data.eventlist) ? res.data.eventlist : [] + CalendarStore.state.operators = (res.data.operators) ? res.data.operators : [] + CalendarStore.state.wheres = (res.data.wheres) ? res.data.wheres : [] + CalendarStore.state.contribtype = (res.data.contribtype) ? res.data.contribtype : [] + + }) + .catch((error) => { + console.log('error dbLoad', error) + // UserStore.mutations.setErrorCatch(error) + return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, tools.ERR_GENERICO, error) + }) + + return ris + + } + export const actions = { setConta: b.dispatch(setConta), createPushSubscription: b.dispatch(createPushSubscription), loadAfterLogin: b.dispatch(loadAfterLogin), + loadSite: b.dispatch(loadSite), clearDataAfterLogout: b.dispatch(clearDataAfterLogout), clearDataAfterLoginOnlyIfActiveConnection: b.dispatch(clearDataAfterLoginOnlyIfActiveConnection), prova: b.dispatch(prova), diff --git a/src/store/Modules/Store/calendar/CalendarStore.ts b/src/store/Modules/Store/calendar/CalendarStore.ts index 1834d81..e66bcde 100644 --- a/src/store/Modules/Store/calendar/CalendarStore.ts +++ b/src/store/Modules/Store/calendar/CalendarStore.ts @@ -19,6 +19,7 @@ const state: ICalendarState = { bookedevent: [], operators: [], wheres: [], + contribtype: [], // --------------- titlebarHeight: 0, locale: 'it-IT', @@ -82,6 +83,23 @@ namespace Getters { }, 'getWhereRec') + const getContribtypeRec = b.read((mystate: ICalendarState) => (id) => { + const ctrec = mystate.contribtype.find((mycontr) => mycontr._id === id) + return (ctrec) + + }, 'getContribtypeRec') + + const getContribtypeById = b.read((mystate: ICalendarState) => (id) => { + const ctrec = mystate.contribtype.find((mycontr) => mycontr._id === id) + return (ctrec) ? ctrec.label : '' + + }, 'getContribtypeById') + const getContribtypeRecByLabel = b.read((mystate: ICalendarState) => (label) => { + const ctrec = mystate.contribtype.find((mycontr) => mycontr.label === label) + return (ctrec) + + }, 'getContribtypeRecByLabel') + export const getters = { get findEventBooked() { return findEventBooked() @@ -98,6 +116,15 @@ namespace Getters { get getWhereRec() { return getWhereRec() }, + get getContribtypeRec() { + return getContribtypeRec() + }, + get getContribtypeById() { + return getContribtypeById() + }, + get getContribtypeRecByLabel() { + return getContribtypeRecByLabel() + }, get getTeacherName() { return getTeacherName() } @@ -117,40 +144,6 @@ namespace Mutations { } namespace Actions { - async function loadAfterLogin(context) { - // console.log('CalendarStore: loadAfterLogin') - // Load local data - state.editable = UserStore.state.isAdmin || UserStore.state.isManager - - if (UserStore.getters.isUserInvalid) { - state.bookedevent = [] - return false - } - - // Load local data - // console.log('CALENDAR loadAfterLogin', 'userid=', UserStore.state.userId) - - let ris = null - - const showall = UserStore.state.isAdmin || UserStore.state.isManager ? '1' : '0' - - ris = await Api.SendReq('/booking/' + UserStore.state.userId + '/' + process.env.APP_ID + '/' + showall, 'GET', null) - .then((res) => { - state.bookedevent = (res.data.bookedevent) ? res.data.bookedevent : [] - state.eventlist = (res.data.eventlist) ? res.data.eventlist : [] - state.operators = (res.data.operators) ? res.data.operators : [] - state.wheres = (res.data.wheres) ? res.data.wheres : [] - - }) - .catch((error) => { - console.log('error dbLoad', error) - // UserStore.mutations.setErrorCatch(error) - return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, tools.ERR_GENERICO, error) - }) - - return ris - - } function getparambyevent(bookevent) { return { @@ -222,7 +215,6 @@ namespace Actions { } export const actions = { - loadAfterLogin: b.dispatch(loadAfterLogin), BookEvent: b.dispatch(BookEvent), CancelBookingEvent: b.dispatch(CancelBookingEvent) } diff --git a/src/store/Modules/UserStore.ts b/src/store/Modules/UserStore.ts index a0ff41d..e0a4d68 100644 --- a/src/store/Modules/UserStore.ts +++ b/src/store/Modules/UserStore.ts @@ -621,8 +621,6 @@ namespace Actions { GlobalStore.actions.checkUpdates() } - const p2 = await CalendarStore.actions.loadAfterLogin() - const p3 = await GlobalStore.actions.loadAfterLogin() if (static_data.functionality.ENABLE_TODOS_LOADING) diff --git a/src/store/Modules/tools.ts b/src/store/Modules/tools.ts index 6247bf4..f89ddfd 100644 --- a/src/store/Modules/tools.ts +++ b/src/store/Modules/tools.ts @@ -1628,8 +1628,17 @@ export const tools = { } else { return 'red' } - } - , + }, + hasManyDays(mydatestart, mydateend) { + if (mydateend) + return tools.getstrDate(mydatestart) !== tools.getstrDate(mydateend) + else + return false + }, + + isManager() { + return UserStore.state.isManager + }, getstrDate(mytimestamp) { // console.log('getstrDate', mytimestamp) @@ -1654,6 +1663,14 @@ export const tools = { else return '' }, + + getstrDateEmailTime(mythis, mytimestamp) { + // console.log('getstrDate', mytimestamp) + if (!!mytimestamp) + return date.formatDate(mytimestamp, 'DD/MM/YYYY') + ' ' + mythis.$t('starttime') + ' ' + date.formatDate(mytimestamp, 'HH:mm') + else + return '' + }, getstrMMMDate(mytimestamp) { // console.log('getstrDate', mytimestamp) if (!!mytimestamp) @@ -1927,7 +1944,7 @@ export const tools = { myheight_dialog() { if (Screen.width < 400) { - return '350' + return '337' } else if (Screen.width < 600) { return '400' } else { @@ -2033,6 +2050,10 @@ export const tools = { return date.addToDate(mydate, { days }) }, + addMinutes(mydate, minutes) { + return date.addToDate(mydate, { minutes }) + }, + gettitlemain(datamain: ITimeLineMain) { if (datamain.titlemain[toolsext.getLocale()]) return datamain.titlemain[toolsext.getLocale()] @@ -2144,9 +2165,9 @@ export const tools = { return msg }, - gettextevent(myevent: IEvents) { + gettextevent(mythis, myevent: IEvents) { // return '"' + myevent.title + '" (' + func_tools.getDateStr(myevent.date) + ') - ' + myevent.time - return '"' + myevent.title + '" (' + tools.getstrDateTime(myevent.dateTimeStart) + return '"' + myevent.title + '" (' + tools.getstrDateEmailTime(mythis, myevent.dateTimeStart) + ')' }, setLangAtt(mylang) { @@ -2282,21 +2303,21 @@ export const tools = { }, displayClasses(eventparam) { return { - [`bg-${eventparam.bgcolor}`]: !tools.isCssColor(eventparam.bgcolor), + // [`bg-${eventparam.bgcolor}`]: !tools.isCssColor(eventparam.bgcolor), 'text-white': !tools.isCssColor(eventparam.bgcolor) } }, displayStyles(eventparam) { const s = { color: '' } if (tools.isCssColor(eventparam.bgcolor)) { - s['background-color'] = eventparam.bgcolor + // s['background-color'] = eventparam.bgcolor s.color = colors.luminosity(eventparam.bgcolor) > 0.5 ? 'black' : 'white' } return s }, CancelBookingEvent(mythis, eventparam: IEvents, bookeventid: string, notify: boolean) { console.log('CancelBookingEvent ', eventparam) - tools.askConfirm(mythis.$q, translate('cal.titlebooking'), translate('cal.cancelbooking') + ' ' + tools.gettextevent(eventparam) + '?', translate('dialog.yes'), translate('dialog.no'), mythis, '', lists.MenuAction.DELETE, 0, { + tools.askConfirm(mythis.$q, translate('cal.titlebooking'), translate('cal.cancelbooking') + ' ' + tools.gettextevent(mythis, eventparam) + '?', translate('dialog.yes'), translate('dialog.no'), mythis, '', lists.MenuAction.DELETE, 0, { param1: bookeventid, param2: notify }) @@ -2308,6 +2329,25 @@ export const tools = { param2: item }) }, + + async createNewRecord(mythis, table, data) { + + const mydata = { + table, + data + } + + return await GlobalStore.actions.saveTable(mydata) + .then((record) => { + if (record) { + tools.showPositiveNotif(mythis.$q, mythis.$t('db.recupdated')) + } else { + tools.showNegativeNotif(mythis.$q, mythis.$t('db.recfailed')) + } + return record + }) + }, + isBitActive(bit, whattofind) { return ((bit & whattofind) === whattofind) } diff --git a/src/store/Modules/toolsext.ts b/src/store/Modules/toolsext.ts index 12a9dac..b29121b 100644 --- a/src/store/Modules/toolsext.ts +++ b/src/store/Modules/toolsext.ts @@ -34,18 +34,17 @@ export const func_tools = { year: 'numeric' // timeZone: 'UTC' }) - if (DateFormatter) { - const date1 = new Date(mydate) - return DateFormatter.format(date1) + try { + console.log('mydate', mydate, DateFormatter) + if (DateFormatter) { + const date1 = new Date(mydate) + return DateFormatter.format(date1) + } + return mydate + }catch (e) { + return '' } - return mydate - }, - hasManyDays(mydatestart, mydateend) { - if (mydateend) - return this.getDateStr(mydatestart) !== this.getDateStr(mydateend) - else - return false }, getMinutesDuration(mydatestart, mydateend) {