diff --git a/src/model/Calendar.ts b/src/model/Calendar.ts
index 9da46e4..79c90cc 100644
--- a/src/model/Calendar.ts
+++ b/src/model/Calendar.ts
@@ -1,5 +1,6 @@
export interface IEvents {
+ _id?: any
time?: string
duration?: number
duration2?: number
@@ -18,9 +19,19 @@ export interface IEvents {
avatar2?: string
infoextra?: string
linkpdf?: string
+ nobookable?: boolean
+}
+
+export interface IBookedEvent {
+ id_bookedevent: any
+ numpeople: number
}
export interface ICalendarState {
+ editable: boolean
+ eventlist: IEvents[]
+ bookedevent: IBookedEvent[]
+ // ---------------
titlebarHeight: number
locale: string,
maxDays: number,
diff --git a/src/model/GlobalStore.ts b/src/model/GlobalStore.ts
index 6f19060..ad84035 100644
--- a/src/model/GlobalStore.ts
+++ b/src/model/GlobalStore.ts
@@ -166,6 +166,7 @@ export interface IColl {
date: string
subtitle?: IAllLang
img: string
+ img2?: string
linkagg?: string
linkagg_type?: number
width?: number
@@ -176,3 +177,13 @@ export interface ICollaborations {
withwhom_title: IAllLang
list: IColl[]
}
+
+export interface IFunctionality {
+ SHOW_USER_MENU?: boolean
+ SHOW_IF_IS_SERVER_CONNECTION?: boolean
+ ENABLE_TODOS_LOADING?: boolean
+ ENABLE_PROJECTS_LOADING?: boolean
+ SHOW_NEWSLETTER?: boolean
+ SHOW_ONLY_POLICY?: boolean
+ EVENTS_CAN_BOOKING?: false
+}
diff --git a/src/model/index.ts b/src/model/index.ts
index dcb8eb8..57b0309 100644
--- a/src/model/index.ts
+++ b/src/model/index.ts
@@ -1,3 +1,5 @@
+import { IBookingState } from '@src/model/BookingStore'
+
export * from './UserStore'
export * from './GlobalStore'
export * from './signin-option'
@@ -11,3 +13,4 @@ export * from './Projects'
export * from './Calendar'
export * from './Estimate'
+export * from './BookingStore'
diff --git a/src/statics/i18n.js b/src/statics/i18n.js
index e944c0e..5016ec2 100644
--- a/src/statics/i18n.js
+++ b/src/statics/i18n.js
@@ -151,6 +151,9 @@ const msgglobal = {
themebgcolor: 'Tema Colore Sfondo'
},
cal: {
+ booked: 'Prenotato',
+ booking: 'Prenota Evento',
+ cancelbooking: 'Cancella Prenotazione',
event: 'Evento',
starttime: 'Dalle',
endtime: 'alle',
@@ -327,6 +330,9 @@ const msgglobal = {
themebgcolor: 'Tema Colores Fondo'
},
cal: {
+ booked: 'Reservado',
+ booking: 'Reserva Evento',
+ cancelbooking: 'Cancelar Reserva',
event: 'Evento',
starttime: 'Inicio',
endtime: 'fin',
@@ -502,6 +508,9 @@ const msgglobal = {
themebgcolor: 'Tema Colores Fondo'
},
cal: {
+ booked: 'Réservé',
+ booking: 'Réserver l\'événement',
+ cancelbooking: 'Annuler la réservation',
event: 'événement',
starttime: 'Accueil',
endtime: 'fin',
@@ -676,6 +685,9 @@ const msgglobal = {
themebgcolor: 'Theme Color Background'
},
cal: {
+ booked: 'Booked',
+ booking: 'Book the Event',
+ cancelbooking: 'Cancel Reservation',
event: 'Event',
starttime: 'From',
endtime: 'to',
@@ -687,7 +699,7 @@ const msgglobal = {
enterdate: 'Enter date',
details: 'Details',
infoextra: 'Extra Info DateTime',
- alldayevent: 'All-Day event',
+ alldayevent: 'All-Day myevent',
eventstartdatetime: 'Event start date and time',
enterEndDateTime: 'Event end date and time'
},
@@ -852,6 +864,9 @@ const msgglobal = {
themebgcolor: 'Theme Color Background'
},
cal: {
+ booked: 'Booked',
+ booking: 'Book the Event',
+ cancelbooking: 'Cancel Reservation',
event: 'Event',
starttime: 'From',
endtime: 'to',
@@ -863,7 +878,7 @@ const msgglobal = {
enterdate: 'Enter date',
details: 'Details',
infoextra: 'Extra Info DateTime',
- alldayevent: 'All-Day event',
+ alldayevent: 'All-Day myevent',
eventstartdatetime: 'Event start date and time',
enterEndDateTime: 'Event end date and time'
},
diff --git a/src/store/Modules/Projects.ts b/src/store/Modules/Projects.ts
index 4b28255..599b6d3 100644
--- a/src/store/Modules/Projects.ts
+++ b/src/store/Modules/Projects.ts
@@ -274,7 +274,7 @@ namespace Actions {
async function dbLoad(context, { checkPending, onlyiffirsttime }) {
- if (!static_data.ENABLE_PROJECTS_LOADING)
+ if (!static_data.functionality.ENABLE_PROJECTS_LOADING)
return null
if (onlyiffirsttime) {
@@ -442,7 +442,6 @@ namespace Actions {
modify: b.dispatch(modify),
ActionCutPaste: b.dispatch(ActionCutPaste)
}
-
}
// Module
diff --git a/src/store/Modules/Store/calendar/CalendarStore.ts b/src/store/Modules/Store/calendar/CalendarStore.ts
index 5d25538..f36a6bc 100644
--- a/src/store/Modules/Store/calendar/CalendarStore.ts
+++ b/src/store/Modules/Store/calendar/CalendarStore.ts
@@ -1,5 +1,5 @@
import Api from '@api'
-import { ICalendarState } from 'model'
+import { ICalendarState, IEvents } from 'model'
import { ILinkReg, IResult, IIdToken, IToken } from 'model/other'
import { storeBuilder } from '../Store'
@@ -8,9 +8,14 @@ import { tools } from '../../tools'
import translate from '../../../../globalroutines/util'
import * as Types from '../../../Api/ApiTypes'
+import { db_data } from '@src/db/db_data'
// State
const state: ICalendarState = {
+ editable: false,
+ eventlist: [],
+ bookedevent: [],
+ // ---------------
titlebarHeight: 0,
locale: 'it-IT',
maxDays: 1,
@@ -39,19 +44,15 @@ const stateGetter = b.state()
namespace Getters {
- // const lang = b.read((state) => {
- // if (state.lang !== '') {
- // return state.lang
- // } else {
- // return process.env.LANG_DEFAULT
- // }
- // }, 'lang')
- //
- // export const getters = {
- // get lang() {
- // return lang()
- // },
- // }
+ const findEventBooked = b.read((mystate) => (myevent: IEvents) => {
+ return mystate.bookedevent.find((bookedevent) => bookedevent.id_bookedevent === myevent._id)
+ }, 'findEventBooked')
+
+ export const getters = {
+ get findEventBooked() {
+ return findEventBooked()
+ }
+ }
}
@@ -67,6 +68,29 @@ namespace Mutations {
}
namespace Actions {
+ async function loadAfterLogin(context) {
+ // Load local data
+ state.editable = db_data.userdata.calendar_editable
+ state.eventlist = db_data.events
+ state.bookedevent = db_data.userdata.bookedevent
+ }
+
+ async function BookEvent(context, event: IEvents) {
+ console.log('BookEvent', event)
+ state.bookedevent.push({id_bookedevent: event._id, numpeople: 1})
+ }
+
+ async function CancelBookingEvent(context, event: IEvents) {
+ console.log('CancelBookingEvent', event)
+
+ state.bookedevent = state.bookedevent.filter((eventbooked) => (eventbooked.id_bookedevent !== event._id) )
+ }
+
+ export const actions = {
+ loadAfterLogin: b.dispatch(loadAfterLogin),
+ BookEvent: b.dispatch(BookEvent),
+ CancelBookingEvent: b.dispatch(CancelBookingEvent)
+ }
// async function resetpwd(context, paramquery: ICalendarState) {
// }
@@ -80,9 +104,9 @@ namespace Actions {
const CalendarModule = {
get state() {
return stateGetter()
- }
- // actions: Actions.actions,
- // getters: Getters.getters,
+ },
+ actions: Actions.actions,
+ getters: Getters.getters
// mutations: Mutations.mutations
}
diff --git a/src/store/Modules/Todos.ts b/src/store/Modules/Todos.ts
index 8fb2d1b..3335c7b 100644
--- a/src/store/Modules/Todos.ts
+++ b/src/store/Modules/Todos.ts
@@ -253,7 +253,7 @@ namespace Actions {
async function dbLoad(context, { checkPending }) {
- if (!static_data.ENABLE_PROJECTS_LOADING)
+ if (!static_data.functionality.ENABLE_PROJECTS_LOADING)
return null
console.log('dbLoad', nametable, checkPending, 'userid=', UserStore.state.userId)
diff --git a/src/store/Modules/UserStore.ts b/src/store/Modules/UserStore.ts
index 9be0d9d..0eaf30e 100644
--- a/src/store/Modules/UserStore.ts
+++ b/src/store/Modules/UserStore.ts
@@ -7,7 +7,7 @@ import router from '@router'
import { serv_constants } from '../Modules/serv_constants'
import { tools } from '../Modules/tools'
import { toolsext } from '@src/store/Modules/toolsext'
-import { GlobalStore, UserStore, Todos, Projects } from '@store'
+import { GlobalStore, UserStore, Todos, Projects, BookingStore, CalendarStore } from '@store'
import globalroutines from './../../globalroutines/index'
import translate from './../../globalroutines/util'
@@ -221,7 +221,6 @@ namespace Mutations {
setErrorCatch: b.commit(setErrorCatch),
getMsgError: b.commit(getMsgError)
}
-
}
namespace Actions {
@@ -512,6 +511,7 @@ namespace Actions {
}
async function setGlobal(isLogged: boolean) {
+ // console.log('setGlobal')
// state.isLogged = true
state.isLogged = isLogged
if (isLogged) {
@@ -522,6 +522,9 @@ namespace Actions {
GlobalStore.actions.checkUpdates()
}
+ const p = await BookingStore.actions.loadAfterLogin()
+ const p2 = await CalendarStore.actions.loadAfterLogin()
+
return await GlobalStore.actions.loadAfterLogin()
.then(() => {
return Todos.actions.dbLoad({ checkPending: true })
diff --git a/src/store/Modules/index.ts b/src/store/Modules/index.ts
index 941c962..f31ecf1 100644
--- a/src/store/Modules/index.ts
+++ b/src/store/Modules/index.ts
@@ -1,5 +1,6 @@
export {storeBuilder} from './Store/Store'
export {default as GlobalStore} from './GlobalStore'
+export {default as BookingStore} from './BookingStore'
export {default as UserStore} from './UserStore'
export {default as Todos} from './Todos'
export {default as Projects} from './Projects'