- 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)
}
public duplicateEvent(eventparam) {
GlobalStore.actions.DuplicateRec({ table: tools.TABEVENTS, id: eventparam._id }).then((rec) => {
rec.dateTimeStart = new Date()
rec.dateTimeEnd = new Date()
CalendarStore.state.eventlist.push(rec)
this.editEvent(rec)
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) => {
rec.dateTimeStart = tools.addDays(new Date(rec.dateTimeStart), numgg * (i + 1))
rec.dateTimeEnd = tools.addDays(new Date(rec.dateTimeEnd), numgg * (i + 1))
CalendarStore.state.eventlist.push(rec)
this.editEvent(rec)
})
})
}
// tools.ActionRecTable(this, lists.MenuAction.DUPLICATE_RECTABLE, tools.TABEVENTS, eventparam._id, eventparam, 'db.duplicatedrecord')
}

View File

@@ -10,8 +10,23 @@
<q-toolbar-title>
{{ $t('cal.event') }}
</q-toolbar-title>
<q-btn v-if="editable" flat round color="white" icon="fas fa-copy" v-close-popup
@click="duplicateEvent(myevent)"></q-btn>
<q-btn v-if="editable" flat round color="white" icon="fas fa-copy">
<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>
<q-btn v-if="editable" flat round color="white" icon="edit" v-close-popup
@@ -523,11 +538,27 @@
</q-chip>
<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="delete"
<q-btn v-if="editable" flat round color="white" icon="fas fa-copy">
<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>
<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>
<q-btn flat round color="white" icon="cancel" @click="selectEvent(null)"></q-btn>
</q-chip>

View File

@@ -50,7 +50,7 @@ export default class CGridTableRec extends Vue {
public spinner_visible: boolean = false
public idsel: string = ''
public colsel: IColGridTable = {name: ''}
public colsel: IColGridTable = { name: '' }
public valPrec: string = ''
public separator: 'horizontal'
@@ -118,6 +118,7 @@ export default class CGridTableRec extends Vue {
}
public updatedcol() {
console.log('updatedcol')
if (this.mycolumns) {
this.colVisib = []
this.colExtra = []
@@ -137,6 +138,7 @@ export default class CGridTableRec extends Vue {
}
public onRequest(props) {
console.log('onRequest')
const { page, rowsPerPage, rowsNumber, sortBy, descending } = props.pagination
const filter = this.filter
@@ -314,20 +316,29 @@ export default class CGridTableRec extends Vue {
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)
}
public refresh() {
if (this.search !== '')
// console.log('this.search', this.search)
if (!!this.search && this.search !== '')
this.filter = this.search
else
this.filter = ''
// console.log('this.filter', this.filter)
this.onRequest({
pagination: this.pagination
})
@@ -409,7 +420,7 @@ export default class CGridTableRec extends Vue {
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) {
this.mytitle = mytab.label
@@ -417,10 +428,17 @@ export default class CGridTableRec extends Vue {
this.mycolumns = [...mytab.columns]
}
this.mycolumns.forEach((rec: IColGridTable) => {
if (rec.label_trans)
rec.label = this.$t(rec.label_trans)
})
console.log('this.mycolumns')
console.log(this.mycolumns)
console.log('this.tablesList:')
console.table(this.tablesList)
if (!!this.mycolumns) {
this.mycolumns.forEach((rec: IColGridTable) => {
if (rec.label_trans)
rec.label = this.$t(rec.label_trans)
})
}
if (mytab) {
this.mytable = mytab.value
@@ -431,7 +449,7 @@ export default class CGridTableRec extends Vue {
this.updatedcol()
if (!!this.mytable) {
const myselcol = tools.getCookie(this.mytable)
const myselcol = tools.getCookie(this.mytable, '')
if (!!myselcol && myselcol.length > 0) {
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> {
let ricevuto = false
try {
console.log('Axios Request', path, type, payload)
console.log('Axios Request', path, type, tools.notshowPwd(payload))
let response: AxiosResponse
if (type === 'post' || type === 'put' || type === 'patch') {
response = await axiosInstance[type](path, payload, {

View File

@@ -199,15 +199,15 @@ namespace Getters {
namespace Mutations {
function authUser(mystate: IUserState, data: IUserFields) {
mystate.my = {...data}
mystate.my = { ...data }
mystate.isAdmin = tools.isBitActive(mystate.my.perm, shared_consts.Permissions.Admin.value)
mystate.isManager = tools.isBitActive(mystate.my.perm, shared_consts.Permissions.Manager.value)
mystate.isTeacher = tools.isBitActive(mystate.my.perm, shared_consts.Permissions.Teacher.value)
// console.log('authUser', 'state.isAdmin', mystate.isAdmin)
console.table(mystate)
console.table(data)
// console.table(mystate)
// console.table(data)
// if (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.surname, myuser.surname)
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.expirationDate, expirationDate.toString())
localStorage.setItem(tools.localStorage.isLogged, String(true))

View File

@@ -1719,7 +1719,7 @@ export const tools = {
} else {
mystr = `${tools.getstrDate(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 {
mystr = `<span class="cal__where-content">${tools.getstrDate(myevent.dateTimeStart)}</span>
@@ -1783,10 +1783,7 @@ export const tools = {
},
// mystrdate "26.04.2013"
convertstrtoDate(mystrdate
:
string
) {
convertstrtoDate(mystrdate: string) {
if (mystrdate.length < 10) {
return null
}
@@ -2552,10 +2549,14 @@ export const tools = {
else
return 'primary'
},
getCookie(mytok) {
getCookie(mytok, oldval?) {
const ris = Cookies.get(mytok)
console.log('getToken', ris)
return ris
console.log('getCookie', ris)
if (!!ris) {
return ris
} else {
return oldval
}
},
setCookie(mytok, value: string) {
@@ -2564,6 +2565,17 @@ export const tools = {
removeCookie(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() {