From f288ace2a74980b25d78aa9d598f7df91d962a9c Mon Sep 17 00:00:00 2001 From: Paolo Arena Date: Mon, 28 Oct 2019 22:01:47 +0100 Subject: [PATCH 1/7] Fixed CDateTime component and CMyChipList --- src/common/shared_vuejs.ts | 9 +- src/components/CDateTime/CDateTime.scss | 4 + src/components/CDateTime/CDateTime.ts | 16 +++- src/components/CDateTime/CDateTime.vue | 92 ++++++++++++------- .../CGridTableRec/CGridTableRec.vue | 4 +- src/components/CMyChipList/CMyChipList.ts | 14 ++- src/components/CMyToggleList/CMyToggleList.ts | 2 +- 7 files changed, 95 insertions(+), 46 deletions(-) diff --git a/src/common/shared_vuejs.ts b/src/common/shared_vuejs.ts index 49718ec..edccfd1 100644 --- a/src/common/shared_vuejs.ts +++ b/src/common/shared_vuejs.ts @@ -4,17 +4,20 @@ export const shared_consts = { Admin: { value: 1, label: 'pages.Admin', - icon: 'fas fa-user-shield' + icon: 'fas fa-user-shield', + color: 'red' }, Manager: { value: 2, label: 'otherpages.manage.manager', - icon: 'fas fa-tools' + icon: 'fas fa-tools', + color: 'green' }, Teacher: { value: 4, label: 'event.teacher', - icon: 'fas fa-user-tie' + icon: 'fas fa-user-tie', + color: 'blue' } }, diff --git a/src/components/CDateTime/CDateTime.scss b/src/components/CDateTime/CDateTime.scss index 7dfc793..830259d 100644 --- a/src/components/CDateTime/CDateTime.scss +++ b/src/components/CDateTime/CDateTime.scss @@ -4,3 +4,7 @@ max-width: 400px; } } + +.calendar_comp { + vertical-align: center; +} diff --git a/src/components/CDateTime/CDateTime.ts b/src/components/CDateTime/CDateTime.ts index 1da8a3e..acc5288 100644 --- a/src/components/CDateTime/CDateTime.ts +++ b/src/components/CDateTime/CDateTime.ts @@ -5,18 +5,20 @@ import { toolsext } from '@src/store/Modules/toolsext' import { date } from 'quasar' import { CalendarStore } from '../../store/Modules' +import MixinBase from '../../mixins/mixin-base' @Component({ - name: 'CDateTime' + name: 'CDateTime', + mixins: [MixinBase] }) export default class CDateTime extends Vue { public $q public $t @Prop() public value!: Date - @Prop({ required: false, default: '' }) public label: string + @Prop({ required: true, default: 'Val:' }) public label: string @Prop({ required: false, default: '' }) public data_class!: string - @Prop({ required: false, default: false }) public readonly!: boolean + @Prop({ required: false, default: true }) public canEdit!: boolean @Prop({ required: false, default: false }) public disable!: boolean @Prop({ required: false, default: '' }) public bgcolor!: string @Prop({ required: false, default: false }) public dense: boolean @@ -74,10 +76,18 @@ export default class CDateTime extends Vue { public mounted() { this.myvalue = this.value + console.log('myvalue', this.myvalue) } public changeval(newval) { // console.log('changeval', newval) this.$emit('update:value', newval) } + + public mystyle() { + if (this.label !== '') + return '' + else + return '' + } } diff --git a/src/components/CDateTime/CDateTime.vue b/src/components/CDateTime/CDateTime.vue index 0238e01..10b4909 100644 --- a/src/components/CDateTime/CDateTime.vue +++ b/src/components/CDateTime/CDateTime.vue @@ -1,41 +1,65 @@ + + diff --git a/src/components/CMyAvatar/index.ts b/src/components/CMyAvatar/index.ts new file mode 100644 index 0000000..e261b6d --- /dev/null +++ b/src/components/CMyAvatar/index.ts @@ -0,0 +1 @@ +export {default as CMyAvatar} from './CMyAvatar.vue' diff --git a/src/components/CMyPopupEdit/CMyPopupEdit.scss b/src/components/CMyPopupEdit/CMyPopupEdit.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/components/CMyPopupEdit/CMyPopupEdit.ts b/src/components/CMyPopupEdit/CMyPopupEdit.ts new file mode 100644 index 0000000..00f2408 --- /dev/null +++ b/src/components/CMyPopupEdit/CMyPopupEdit.ts @@ -0,0 +1,138 @@ +import Vue from 'vue' +import { Component, Prop } from 'vue-property-decorator' + +import { tools } from '../../store/Modules/tools' +import { toolsext } from '@src/store/Modules/toolsext' +import { IColGridTable } from '../../model' +import { fieldsTable } from '../../store/Modules/fieldsTable' +import { CMyChipList } from '../CMyChipList' +import { CDateTime } from '../CDateTime' +import { CMyToggleList } from '../CMyToggleList' +import { CMySelect } from '../CMySelect' + +@Component({ + name: 'CMyPopupEdit', + components: {CMyChipList, CDateTime, CMyToggleList, CMySelect} +}) + +export default class CMyPopupEdit extends Vue { + @Prop({ required: true }) public row + @Prop({ required: true }) public col + @Prop({ required: false, default: false }) public canEdit + @Prop({ required: false, default: '' }) public field + @Prop({ required: false, default: '' }) public subfield + + public myvalue = '' + + get tools() { + return tools + } + + get db_fieldsTable() { + return fieldsTable + } + public changeval(newval) { + this.$emit('update:row', newval) + } + + public mounted() { + if ((this.subfield !== '') && (this.subfield !== '')) { + if (this.row[this.field] === undefined) { + this.row[this.field] = {} + this.myvalue = '' + } else { + this.myvalue = this.row[this.field][this.subfield] + } + } else { + if (this.field !== '') + this.myvalue = this.row[this.field] + else + this.myvalue = this.row + } + } + + public OpenEdit() { + console.log('OpenEdit') + this.$emit('show') + } + + public SaveValueInt(newVal, valinitial) { + + console.log('SaveValueInt', newVal) + + // Update value in table memory + if (this.subfield !== '') { + if (this.row[this.field] === undefined) + this.row[this.field] = {} + this.row[this.field][this.subfield] = newVal + } else { + if (this.field !== '') + this.row[this.field] = newVal + else + this.row = newVal + } + + this.$emit('save', newVal, valinitial) + } + + public visuValByType(val, col: IColGridTable, row) { + if (col === undefined || row === undefined) + return + + // let val = '' + // if (col.subfield !== '') { + // if (row[col.field] === undefined) + // row[col.field] = {} + // + // val = row[col.field][col.subfield] + // } else { + // val = row[col.field] + // } + // + if (col.fieldtype === tools.FieldType.date) { + if (val === undefined) { + return '[]' + } else { + return tools.getstrDateTime(val) + } + } else if (col.fieldtype === tools.FieldType.boolean) { + return (val) ? this.$t('dialog.yes') : this.$t('dialog.no') + } else if (col.fieldtype === tools.FieldType.binary) { + if (val === undefined) + return '[---]' + else + return fieldsTable.getArrStrByValueBinary(this, col, val) + } else if (col.fieldtype === tools.FieldType.select) { + if (val === undefined) + return '[---]' + else + return fieldsTable.getValueByTable(col, val) + } else { + if (val === undefined) + return '[]' + else if (val === '') { + return '[]' + } else { + let mystr = tools.firstchars(val, tools.MAX_CHARACTERS) + if (val) { + if (val.length > tools.MAX_CHARACTERS) + mystr += '...' + } else { + return val + } + return mystr + } + } + } + + public getclassCol(col) { + if (col) { + let mycl = (col.disable || !this.canEdit) ? '' : 'colmodif' + mycl += (col.fieldtype === tools.FieldType.date) ? ' coldate flex flex-container' : '' + + return mycl + } else { + return '' + } + } +} diff --git a/src/components/CMyPopupEdit/CMyPopupEdit.vue b/src/components/CMyPopupEdit/CMyPopupEdit.vue new file mode 100644 index 0000000..587bc8b --- /dev/null +++ b/src/components/CMyPopupEdit/CMyPopupEdit.vue @@ -0,0 +1,103 @@ + + + + + diff --git a/src/components/CMyPopupEdit/index.ts b/src/components/CMyPopupEdit/index.ts new file mode 100644 index 0000000..be462fe --- /dev/null +++ b/src/components/CMyPopupEdit/index.ts @@ -0,0 +1 @@ +export {default as CMyPopupEdit} from './CMyPopupEdit.vue' diff --git a/src/components/Footer/Footer.ts b/src/components/Footer/Footer.ts index e809394..efcd5a7 100644 --- a/src/components/Footer/Footer.ts +++ b/src/components/Footer/Footer.ts @@ -13,8 +13,10 @@ import { static_data } from '@src/db/static_data' import Quasar from 'quasar' import { FormNewsletter } from '../FormNewsletter' import { IUserState } from '../../model' +import MixinBase from '../../mixins/mixin-base' @Component({ + mixins: [MixinBase], name: 'Footer', components: { Logo, FormNewsletter } }) @@ -54,4 +56,8 @@ export default class Footer extends Vue { return static_data } + get ChatWhatsapp() { + return tools.getHttpForWhatsapp(this.Whatsapp_Cell) + } + } diff --git a/src/components/Footer/Footer.vue b/src/components/Footer/Footer.vue index 0bac19f..b893f9c 100644 --- a/src/components/Footer/Footer.vue +++ b/src/components/Footer/Footer.vue @@ -26,7 +26,34 @@

{{$t('homepage.titlecontatti')}}

-

+

+ + {{ getValDb('MAIN_EMAIL') + }}
+
+ + {{ rec.name }}: {{ rec.phone }} + + +
+ {{rec.email}} +
+
+
orari per chiamate:
+
+ + +

- {{$t('privacy_policy')}} + {{$t('privacy_policy')}}

@@ -77,11 +108,12 @@ - + - - + + diff --git a/src/mixins/mixin-base.ts b/src/mixins/mixin-base.ts new file mode 100644 index 0000000..72975e3 --- /dev/null +++ b/src/mixins/mixin-base.ts @@ -0,0 +1,43 @@ +import Vue from 'vue' + +import Component from 'vue-class-component' +import { func_tools } from '../store/Modules/toolsext' +import { tools } from '../store/Modules/tools' +import { toolsext } from '@src/store/Modules/toolsext' +import { GlobalStore } from '../store/Modules' + +// You can declare a mixin as the same style as components. +@Component +export default class MixinBase extends Vue { + public mythis() { + return this + } + + get toolsext() { + return toolsext + } + + get func_tools() { + return func_tools + } + + get tools() { + return tools + } + + public getValDb(keystr) { + return GlobalStore.getters.getValueSettingsByKey(keystr) + } + public getarrValDb(keystr) { + const myval = GlobalStore.getters.getValueSettingsByKey(keystr) + // console.log('myval', myval) + if (myval) { + const myrec = JSON.parse(myval) + // console.log('*************** getarrValDb') + // console.table(myrec) + return myrec + } else { + return [] + } + } +} diff --git a/src/mixins/mixin-operator.ts b/src/mixins/mixin-operator.ts new file mode 100644 index 0000000..7aa741c --- /dev/null +++ b/src/mixins/mixin-operator.ts @@ -0,0 +1,30 @@ +import Vue from 'vue' + +import Component from 'vue-class-component' +import { CalendarStore } from '../store/Modules' +import { UserStore } from '@modules' + +@Component +export default class MixinOperator extends Vue { + public getOperators() { + return CalendarStore.state.operators + } + + public getOperatorByUsername(username) { + return CalendarStore.getters.getOperatorByUsername(username) + } + + public getImgTeacherByUsername(username) { + return `statics/images/` + CalendarStore.getters.getImgTeacherByUsername(username) + } + + public getTeacherByUsername(username) { + const op = this.getOperatorByUsername(username) + if (!!op) { + return op.name + ' ' + op.surname + } else { + return '' + } + } + +} diff --git a/src/store/Modules/GlobalStore.ts b/src/store/Modules/GlobalStore.ts index 5164271..1bafb88 100644 --- a/src/store/Modules/GlobalStore.ts +++ b/src/store/Modules/GlobalStore.ts @@ -328,12 +328,14 @@ namespace Mutations { const mylist = Getters.getters.getListByTable(table) const mykey = fieldsTable.getKeyByTable(table) - const myrec = mylist.find((event) => event[mykey] === 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 + if (!!mylist) { + const myrec = mylist.find((event) => event[mykey] === 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) { diff --git a/src/store/Modules/tools.ts b/src/store/Modules/tools.ts index 4fbd5a9..3e7e1e7 100644 --- a/src/store/Modules/tools.ts +++ b/src/store/Modules/tools.ts @@ -1379,7 +1379,7 @@ export const tools = { notify: par.param2 === true ? '1' : '0' }).then((ris) => { if (ris) { - tools.showPositiveNotif(myself.$q, myself.$t('cal.canceledbooking') + ' "' + par.param1.title + '"') + tools.showPositiveNotif(myself.$q, myself.$t('cal.canceledbooking') + ' "' + par.param3 + '"') if (myself.bookEventpage) myself.bookEventpage.show = false } else @@ -2476,7 +2476,8 @@ export const tools = { console.log('CancelBookingEvent ', eventparam) 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 + param2: notify, + param3: eventparam.title }) } , @@ -2607,8 +2608,25 @@ export const tools = { const duration = 500 console.log('target', target, 'offset', offset, 'duration', duration) setScrollPosition(target, offset, duration) - } + }, + getCellForWhatsapp(numbercell) { + let mynum = numbercell.replace(/\-/g, '') + const intcode = GlobalStore.getters.getValueSettingsByKey('INT_CODE') + if (numbercell.substring(0, 1) !== '+') + mynum = intcode + mynum + else + mynum = mynum.substring(1) + return mynum + }, + + getHttpForWhatsapp(numbercell) { + const mynum = this.getCellForWhatsapp(numbercell) + if (mynum) + return 'https://wa.me/' + mynum + else + return '' + } // getLocale() { // if (navigator.languages && navigator.languages.length > 0) {