- Duplicate Event (1,2 4 times).

- Updated Calendar on database
This commit is contained in:
Paolo Arena
2019-11-01 19:58:52 +01:00
parent cdfc32c620
commit f30e6afd9e
6 changed files with 102 additions and 36 deletions

View File

@@ -501,14 +501,16 @@ export default class CEventsCalendar extends Vue {
tools.CancelEvent(this, eventparam) tools.CancelEvent(this, eventparam)
} }
public duplicateEvent(eventparam) { public duplicateEvent(eventparam, numgg, numev: number = 1 ) {
for (let i = 0; i < numev; ++i) {
GlobalStore.actions.DuplicateRec({ table: tools.TABEVENTS, id: eventparam._id }).then((rec) => { GlobalStore.actions.DuplicateRec({ table: tools.TABEVENTS, id: eventparam._id }).then((rec) => {
rec.dateTimeStart = new Date() rec.dateTimeStart = tools.addDays(new Date(rec.dateTimeStart), numgg * (i + 1))
rec.dateTimeEnd = new Date() rec.dateTimeEnd = tools.addDays(new Date(rec.dateTimeEnd), numgg * (i + 1))
CalendarStore.state.eventlist.push(rec) CalendarStore.state.eventlist.push(rec)
this.editEvent(rec) this.editEvent(rec)
}) })
}
// tools.ActionRecTable(this, lists.MenuAction.DUPLICATE_RECTABLE, tools.TABEVENTS, eventparam._id, eventparam, 'db.duplicatedrecord') // tools.ActionRecTable(this, lists.MenuAction.DUPLICATE_RECTABLE, tools.TABEVENTS, eventparam._id, eventparam, 'db.duplicatedrecord')
} }

View File

@@ -10,8 +10,23 @@
<q-toolbar-title> <q-toolbar-title>
{{ $t('cal.event') }} {{ $t('cal.event') }}
</q-toolbar-title> </q-toolbar-title>
<q-btn v-if="editable" flat round color="white" icon="fas fa-copy" v-close-popup <q-btn v-if="editable" flat round color="white" icon="fas fa-copy">
@click="duplicateEvent(myevent)"></q-btn> <q-menu
transition-show="flip-right"
transition-hide="flip-left">
<q-list style="min-width: 100px">
<q-item clickable @click="duplicateEvent(myevent, 7)">
<q-item-section>Tra 1 Settimana</q-item-section>
</q-item>
<q-item clickable @click="duplicateEvent(myevent, 14)">
<q-item-section>Tra 2 Settimane</q-item-section>
</q-item>
<q-item clickable @click="duplicateEvent(myevent, 7, 4)">
<q-item-section>4 Eventi ogni Settimana</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
<q-btn v-if="editable" flat round color="white" icon="delete" v-close-popup <q-btn v-if="editable" flat round color="white" icon="delete" v-close-popup
@click="deleteEvent(myevent)"></q-btn> @click="deleteEvent(myevent)"></q-btn>
<q-btn v-if="editable" flat round color="white" icon="edit" v-close-popup <q-btn v-if="editable" flat round color="white" icon="edit" v-close-popup
@@ -523,11 +538,27 @@
</q-chip> </q-chip>
<q-chip v-if="event === myevent && !displayEvent && editable" class="text-center shadow-5 glossy bg-blue chipmodif"> <q-chip v-if="event === myevent && !displayEvent && editable" class="text-center shadow-5 glossy bg-blue chipmodif">
<q-btn v-if="editable" flat round color="white" icon="fas fa-copy"
@click="duplicateEvent(myevent)"></q-btn> <q-btn v-if="editable" flat round color="white" icon="fas fa-copy">
<q-btn v-if="editable" flat round color="white" icon="delete" <q-menu
transition-show="flip-right"
transition-hide="flip-left">
<q-list style="min-width: 100px">
<q-item clickable @click="duplicateEvent(myevent, 7)">
<q-item-section>Tra 1 Settimana</q-item-section>
</q-item>
<q-item clickable @click="duplicateEvent(myevent, 14)">
<q-item-section>Tra 2 Settimane</q-item-section>
</q-item>
<q-item clickable @click="duplicateEvent(myevent, 7, 4)">
<q-item-section>4 Eventi ogni Settimana</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
<q-btn v-if="editable" flat round color="white" icon="delete" v-close-popup
@click="deleteEvent(myevent)"></q-btn> @click="deleteEvent(myevent)"></q-btn>
<q-btn v-if="editable" flat round color="white" icon="edit" <q-btn v-if="editable" flat round color="white" icon="edit" v-close-popup
@click="editEvent(myevent)"></q-btn> @click="editEvent(myevent)"></q-btn>
<q-btn flat round color="white" icon="cancel" @click="selectEvent(null)"></q-btn> <q-btn flat round color="white" icon="cancel" @click="selectEvent(null)"></q-btn>
</q-chip> </q-chip>

View File

@@ -118,6 +118,7 @@ export default class CGridTableRec extends Vue {
} }
public updatedcol() { public updatedcol() {
console.log('updatedcol')
if (this.mycolumns) { if (this.mycolumns) {
this.colVisib = [] this.colVisib = []
this.colExtra = [] this.colExtra = []
@@ -137,6 +138,7 @@ export default class CGridTableRec extends Vue {
} }
public onRequest(props) { public onRequest(props) {
console.log('onRequest')
const { page, rowsPerPage, rowsNumber, sortBy, descending } = props.pagination const { page, rowsPerPage, rowsNumber, sortBy, descending } = props.pagination
const filter = this.filter const filter = this.filter
@@ -314,20 +316,29 @@ export default class CGridTableRec extends Vue {
public mounted() { public mounted() {
this.canEdit = tools.getCookie(tools.CAN_EDIT) === 'true' this.canEdit = tools.getCookie(tools.CAN_EDIT, this.canEdit) === 'true'
this.tablesel = tools.getCookie('tablesel') this.tablesel = tools.getCookie('tablesel', this.tablesel)
if (this.tablesel === '') {
if (!!this.tablesList)
this.tablesel = this.tablesList[0].value
else
this.tablesel = this.mytable
}
this.changeTable(false) this.changeTable(false)
} }
public refresh() { public refresh() {
if (this.search !== '') // console.log('this.search', this.search)
if (!!this.search && this.search !== '')
this.filter = this.search this.filter = this.search
else else
this.filter = '' this.filter = ''
// console.log('this.filter', this.filter)
this.onRequest({ this.onRequest({
pagination: this.pagination pagination: this.pagination
}) })
@@ -409,7 +420,7 @@ export default class CGridTableRec extends Vue {
mytab = this.tablesList.find((rec) => rec.value === this.tablesel) mytab = this.tablesList.find((rec) => rec.value === this.tablesel)
} }
console.log('this.tablesel', this.tablesel) console.log('this.tablesel', this.tablesel, 'mytab', mytab)
if (mytab) { if (mytab) {
this.mytitle = mytab.label this.mytitle = mytab.label
@@ -417,10 +428,17 @@ export default class CGridTableRec extends Vue {
this.mycolumns = [...mytab.columns] this.mycolumns = [...mytab.columns]
} }
console.log('this.mycolumns')
console.log(this.mycolumns)
console.log('this.tablesList:')
console.table(this.tablesList)
if (!!this.mycolumns) {
this.mycolumns.forEach((rec: IColGridTable) => { this.mycolumns.forEach((rec: IColGridTable) => {
if (rec.label_trans) if (rec.label_trans)
rec.label = this.$t(rec.label_trans) rec.label = this.$t(rec.label_trans)
}) })
}
if (mytab) { if (mytab) {
this.mytable = mytab.value this.mytable = mytab.value
@@ -431,7 +449,7 @@ export default class CGridTableRec extends Vue {
this.updatedcol() this.updatedcol()
if (!!this.mytable) { if (!!this.mytable) {
const myselcol = tools.getCookie(this.mytable) const myselcol = tools.getCookie(this.mytable, '')
if (!!myselcol && myselcol.length > 0) { if (!!myselcol && myselcol.length > 0) {
this.colVisib = myselcol.split('|') this.colVisib = myselcol.split('|')
} }

View File

@@ -51,7 +51,7 @@ export const removeAuthHeaders = () => {
async function Request(type: string, path: string, payload: any): Promise<Types.AxiosSuccess | Types.AxiosError> { async function Request(type: string, path: string, payload: any): Promise<Types.AxiosSuccess | Types.AxiosError> {
let ricevuto = false let ricevuto = false
try { try {
console.log('Axios Request', path, type, payload) console.log('Axios Request', path, type, tools.notshowPwd(payload))
let response: AxiosResponse let response: AxiosResponse
if (type === 'post' || type === 'put' || type === 'patch') { if (type === 'post' || type === 'put' || type === 'patch') {
response = await axiosInstance[type](path, payload, { response = await axiosInstance[type](path, payload, {

View File

@@ -206,8 +206,8 @@ namespace Mutations {
mystate.isTeacher = tools.isBitActive(mystate.my.perm, shared_consts.Permissions.Teacher.value) mystate.isTeacher = tools.isBitActive(mystate.my.perm, shared_consts.Permissions.Teacher.value)
// console.log('authUser', 'state.isAdmin', mystate.isAdmin) // console.log('authUser', 'state.isAdmin', mystate.isAdmin)
console.table(mystate) // console.table(mystate)
console.table(data) // console.table(data)
// if (data.my.verified_email) { // if (data.my.verified_email) {
// mystate.my.verified_email = data.my.verified_email // mystate.my.verified_email = data.my.verified_email
@@ -564,7 +564,10 @@ namespace Actions {
localStorage.setItem(tools.localStorage.name, myuser.name) localStorage.setItem(tools.localStorage.name, myuser.name)
localStorage.setItem(tools.localStorage.surname, myuser.surname) localStorage.setItem(tools.localStorage.surname, myuser.surname)
localStorage.setItem(tools.localStorage.perm, String(myuser.perm) || '') localStorage.setItem(tools.localStorage.perm, String(myuser.perm) || '')
localStorage.setItem(tools.localStorage.img, String(myuser.profile.img) || '') if (myuser.profile !== undefined)
localStorage.setItem(tools.localStorage.img, (!!myuser.profile.img) ? String(myuser.profile.img) || '' : '')
else
localStorage.setItem(tools.localStorage.img, '')
localStorage.setItem(tools.localStorage.token, state.x_auth_token) localStorage.setItem(tools.localStorage.token, state.x_auth_token)
localStorage.setItem(tools.localStorage.expirationDate, expirationDate.toString()) localStorage.setItem(tools.localStorage.expirationDate, expirationDate.toString())
localStorage.setItem(tools.localStorage.isLogged, String(true)) localStorage.setItem(tools.localStorage.isLogged, String(true))

View File

@@ -1719,7 +1719,7 @@ export const tools = {
} else { } else {
mystr = `${tools.getstrDate(myevent.dateTimeStart)} mystr = `${tools.getstrDate(myevent.dateTimeStart)}
${mythis.$t('cal.starttime')} ${ tools.getstrTime(myevent.dateTimeStart) } ${mythis.$t('cal.starttime')} ${ tools.getstrTime(myevent.dateTimeStart) }
${ mythis.$t('cal.endtime')}: ${ tools.getstrTime(myevent.dateTimeEnd) }` ${ mythis.$t('cal.endtime')} ${ tools.getstrTime(myevent.dateTimeEnd) }`
} }
} else { } else {
mystr = `<span class="cal__where-content">${tools.getstrDate(myevent.dateTimeStart)}</span> mystr = `<span class="cal__where-content">${tools.getstrDate(myevent.dateTimeStart)}</span>
@@ -1783,10 +1783,7 @@ export const tools = {
}, },
// mystrdate "26.04.2013" // mystrdate "26.04.2013"
convertstrtoDate(mystrdate convertstrtoDate(mystrdate: string) {
:
string
) {
if (mystrdate.length < 10) { if (mystrdate.length < 10) {
return null return null
} }
@@ -2552,10 +2549,14 @@ export const tools = {
else else
return 'primary' return 'primary'
}, },
getCookie(mytok) { getCookie(mytok, oldval?) {
const ris = Cookies.get(mytok) const ris = Cookies.get(mytok)
console.log('getToken', ris) console.log('getCookie', ris)
if (!!ris) {
return ris return ris
} else {
return oldval
}
}, },
setCookie(mytok, value: string) { setCookie(mytok, value: string) {
@@ -2564,6 +2565,17 @@ export const tools = {
removeCookie(mytok) { removeCookie(mytok) {
return Cookies.remove(mytok) return Cookies.remove(mytok)
},
notshowPwd(payload) {
const mypay = {...payload}
try{
if (!!mypay.password) {
mypay.password = '**********'
}
}catch (e) {
console.log('error', e)
}
return mypay
} }
// getLocale() { // getLocale() {