- Added CDateTime component (to save in the db)... in the component CGridTableRec and for CEventsCalendar

This commit is contained in:
Paolo Arena
2019-10-28 16:00:37 +01:00
parent c95cded522
commit 340c813a7c
19 changed files with 383 additions and 153 deletions

View File

@@ -1,9 +1,22 @@
export const shared_consts = { export const shared_consts = {
Permissions: { Permissions: {
Normal: 0, Normal: {
Admin: 1, value: 0,
Manager: 2, label: '[None]'
},
Admin: {
value: 1,
label: 'Admin'
},
Manager: {
value: 2,
label: 'Manager'
},
Teacher: {
value: 4,
label: 'Teacher'
}
}, },
MessageOptions: { MessageOptions: {

View File

@@ -0,0 +1,6 @@
.calendar_comp{
max-width: 170px;
@media (max-width: 400px) {
max-width: 400px;
}
}

View File

@@ -0,0 +1,79 @@
import Vue from 'vue'
import { Component, Prop, Watch } from 'vue-property-decorator'
import { tools } from '@src/store/Modules/tools'
import { toolsext } from '@src/store/Modules/toolsext'
import { date } from 'quasar'
import { CalendarStore } from '../../store/Modules'
@Component({
name: 'CDateTime'
})
export default class CDateTime extends Vue {
public $q
public $t
@Prop() public value!: Date
@Prop({ required: false, default: '' }) public label: string
@Prop({ required: false, default: '' }) public data_class!: string
@Prop({ required: false, default: false }) public readonly!: boolean
@Prop({ required: false, default: false }) public disable!: boolean
@Prop({ required: false, default: '' }) public bgcolor!: string
@Prop({ required: false, default: false }) public dense: boolean
public mystyleicon: string = 'font-size: 1.5rem;'
public showDateTimeScroller: boolean = false
public saveit: boolean = false
public myvalue: Date = new Date()
public valueprec: Date = new Date()
get getclass() {
return 'calendar_comp ' + this.data_class
}
@Watch('showDateTimeScroller')
public Opening() {
if (this.showDateTimeScroller) {
this.saveit = false
this.valueprec = this.myvalue
this.$emit('show')
} else {
if (!this.saveit)
this.myvalue = this.valueprec
}
}
public savetoclose() {
this.saveit = true
this.showDateTimeScroller = false
this.$emit('savetoclose', this.myvalue, this.valueprec)
}
get scrollerPopupStyle280() {
if (this.$q.screen.lt.sm) {
return {
width: '100vw',
height: '100vh'
}
} else {
return {
maxHeight: '400px',
height: '400px',
width: '280px'
}
}
}
get locale() {
return CalendarStore.state.locale
}
public mounted() {
this.myvalue = this.value
}
public changeval(newval) {
console.log('changeval', newval)
this.$emit('update:value', newval)
}
}

View File

@@ -0,0 +1,46 @@
<template>
<q-input v-model="myvalue"
color="blue-6"
outlined
:label="label"
:bg-color="bgcolor"
:readonly="readonly"
:disable="disable"
:dense="dense"
mask="####-##-## ##:##"
debounce="500"
@input="changeval"
:class="getclass">
<template #append>
<q-icon name="event" class="cursor-pointer">
<q-popup-proxy v-model="showDateTimeScroller">
<q-date-time-scroller
v-model="myvalue"
:locale="locale"
:hour24-format="true"
:rounded-borders="true"
border-color="#2196f3"
bar-color="#2196f3"
color="white"
background-color="primary"
inner-color="primary"
inner-background-color="white"
:style="scrollerPopupStyle280"
@input="changeval"
@close="() => { savetoclose(); }"
/>
</q-popup-proxy>
</q-icon>
</template>
</q-input>
</template>
<script lang="ts" src="./CDateTime.ts">
</script>
<style lang="scss" scoped>
@import './CDateTime.scss';
</style>

View File

@@ -0,0 +1 @@
export {default as CDateTime} from './CDateTime.vue'

View File

@@ -247,13 +247,6 @@ $graytext: #555;
color: white; color: white;
} }
.calendar_comp{
max-width: 170px;
@media (max-width: 400px) {
max-width: 400px;
}
}
.myflex{ .myflex{
display: flex; display: flex;
flex: 1; flex: 1;

View File

@@ -31,11 +31,12 @@ import { lists } from '../../store/Modules/lists'
import { GlobalStore, MessageStore } from '../../store/Modules' import { GlobalStore, MessageStore } from '../../store/Modules'
import { IMessagePage, IMessage, IIdentity, MsgDefault } from '../../model' import { IMessagePage, IMessage, IIdentity, MsgDefault } from '../../model'
import MixinUsers from '../../mixins/mixin-users' import MixinUsers from '../../mixins/mixin-users'
import { CDateTime } from '../CDateTime'
@Component({ @Component({
mixins: [MixinUsers], mixins: [MixinUsers],
name: 'CEventsCalendar', name: 'CEventsCalendar',
components: { Logo, Footer, CTitle, CImgText, QDateTimeScroller, QDateScroller, CMySelect, CMyEditor } components: { Logo, Footer, CTitle, CImgText, QDateTimeScroller, QDateScroller, CMySelect, CMyEditor, CDateTime }
}) })
export default class CEventsCalendar extends Vue { export default class CEventsCalendar extends Vue {
public $q public $q
@@ -110,9 +111,6 @@ export default class CEventsCalendar extends Vue {
public dragging = false public dragging = false
public draggedEvent = null public draggedEvent = null
public ignoreNextSwipe = false public ignoreNextSwipe = false
public showDateScrollerAllDay = false
public showDateTimeScrollerStart = false
public showDateTimeScrollerEnd = false
public resources = [ public resources = [
{ {
@@ -319,21 +317,6 @@ export default class CEventsCalendar extends Vue {
} }
} }
get scrollerPopupStyle280() {
if (this.$q.screen.lt.sm) {
return {
width: '100vw',
height: '100vh'
}
} else {
return {
maxHeight: '400px',
height: '400px',
width: '280px'
}
}
}
get tools() { get tools() {
return tools return tools
} }

View File

@@ -121,58 +121,16 @@
<!--<q-checkbox v-model="eventForm.allday" :label="$t('cal.alldayevent')"></q-checkbox>--> <!--<q-checkbox v-model="eventForm.allday" :label="$t('cal.alldayevent')"></q-checkbox>-->
<div class="q-gutter-sm row myflex"> <div class="q-gutter-sm row myflex">
<q-input color="blue-6" outlined v-model="eventForm.dateTimeStart" <CDateTime
:label="$t('cal.eventstartdatetime')" mask="####-##-## ##:##" :value.sync="eventForm.dateTimeStart"
class="calendar_comp"> :label="$t('cal.eventstartdatetime')"
<template #append> :readonly="false">
<q-icon name="event" class="cursor-pointer"> </CDateTime>
<q-popup-proxy v-model="showDateTimeScrollerStart"> <CDateTime
:value.sync="eventForm.dateTimeEnd"
<q-date-time-scroller :label="$t('cal.enterEndDateTime')"
v-model="eventForm.dateTimeStart" :readonly="false">
:locale="locale" </CDateTime>
:hour24-format="true"
:rounded-borders="true"
border-color="#2196f3"
bar-color="#2196f3"
color="white"
background-color="primary"
inner-color="primary"
inner-background-color="white"
:style="scrollerPopupStyle280"
@close="() => { showDateTimeScrollerStart = false }"
/>
</q-popup-proxy>
</q-icon>
</template>
</q-input>
<q-input color="blue-6" outlined v-model="eventForm.dateTimeEnd"
:label="$t('cal.enterEndDateTime')" mask="####-##-## ##:##"
class="calendar_comp">
<template #append>
<q-icon name="event" class="cursor-pointer">
<q-popup-proxy v-model="showDateTimeScrollerEnd">
<q-date-time-scroller
v-model="eventForm.dateTimeEnd"
:locale="locale"
:hour24-format="true"
:rounded-borders="true"
border-color="#2196f3"
bar-color="#2196f3"
color="white"
background-color="primary"
inner-color="primary"
inner-background-color="white"
:style="scrollerPopupStyle280"
@close="() => { showDateTimeScrollerEnd = false }"
/>
</q-popup-proxy>
</q-icon>
</template>
</q-input>
<q-input dense v-model="eventForm.infoextra" :label="$t('cal.infoextra')"></q-input> <q-input dense v-model="eventForm.infoextra" :label="$t('cal.infoextra')"></q-input>
</div> </div>

View File

@@ -1,3 +1,8 @@
.colmodif { .colmodif {
cursor: pointer; cursor: pointer;
} }
.coldate {
max-width: 250px;
min-width: 200px;
}

View File

@@ -9,8 +9,13 @@ import { ICategory, IColGridTable, ITableRec } from '../../model'
import { CTodo } from '../todos/CTodo' import { CTodo } from '../todos/CTodo'
import { SingleProject } from '../projects/SingleProject' import { SingleProject } from '../projects/SingleProject'
import { lists } from '../../store/Modules/lists' import { lists } from '../../store/Modules/lists'
import { IParamsQuery } from '../../model/GlobalStore'
import { fieldsTable } from '../../store/Modules/fieldsTable'
import { CDateTime } from '../CDateTime'
@Component({}) @Component({
components: { CDateTime }
})
export default class CGridTableRec extends Vue { export default class CGridTableRec extends Vue {
@Prop({ required: false }) public prop_mytable: string @Prop({ required: false }) public prop_mytable: string
@Prop({ required: true }) public prop_mytitle: string @Prop({ required: true }) public prop_mytitle: string
@@ -24,6 +29,7 @@ export default class CGridTableRec extends Vue {
public mytitle: string public mytitle: string
public mycolumns: any[] public mycolumns: any[]
public colkey: string public colkey: string
public search: string = ''
public tablesel: string = '' public tablesel: string = ''
@@ -42,12 +48,12 @@ export default class CGridTableRec extends Vue {
public spinner_visible: boolean = false public spinner_visible: boolean = false
public idsel: string = '' public idsel: string = ''
public colsel: string = '' public colsel: IColGridTable = {name: ''}
public valPrec: string = '' public valPrec: string = ''
public separator: 'horizontal' public separator: 'horizontal'
public filter: string = '' public filter: string = ''
public selected: any public rowsel: any
public dark: boolean = true public dark: boolean = true
public funcActivated = [] public funcActivated = []
@@ -70,25 +76,27 @@ export default class CGridTableRec extends Vue {
} }
} }
public selItem(item, colsel) { public selItem(item, col: IColGridTable) {
// console.log('item', item) // console.log('item', item)
this.selected = item this.rowsel = item
this.idsel = item._id this.idsel = item._id
this.colsel = colsel this.colsel = col
this.updateValueExtra(col, this.rowsel[col.name])
// console.log('this.idsel', this.idsel) // console.log('this.idsel', this.idsel)
} }
public undoVal() { public undoVal() {
console.log('undoVal', 'colsel', this.colsel, 'valprec', this.valPrec, 'this.colkey', this.colkey, 'this.selected', this.selected) console.log('undoVal', 'colsel', this.colsel, 'valprec', this.valPrec, 'this.colkey', this.colkey, 'this.selected', this.rowsel)
console.table(this.serverData) console.table(this.serverData)
if (this.colsel) if (this.colsel)
this.selected[this.colsel] = this.valPrec this.rowsel[this.colsel.field] = this.valPrec
// this.serverData[this.colsel] = this.valPrec // this.serverData[this.colsel] = this.valPrec
} }
public SaveValue(newVal, valinitial) { public SaveValue(newVal, valinitial) {
// console.log('SaveValue', newVal, 'selected', this.selected) console.log('SaveValue', newVal, 'rowsel', this.rowsel)
const mydata = { const mydata = {
id: this.idsel, id: this.idsel,
@@ -96,7 +104,7 @@ export default class CGridTableRec extends Vue {
fieldsvalue: {} fieldsvalue: {}
} }
mydata.fieldsvalue[this.colsel] = newVal mydata.fieldsvalue[this.colsel.field] = newVal
this.valPrec = valinitial this.valPrec = valinitial
@@ -135,7 +143,7 @@ export default class CGridTableRec extends Vue {
public onRequest(props) { public onRequest(props) {
const { page, rowsPerPage, rowsNumber, sortBy, descending } = props.pagination const { page, rowsPerPage, rowsNumber, sortBy, descending } = props.pagination
const filter = props.filter const filter = this.filter
if (!this.mytable) if (!this.mytable)
return return
@@ -146,7 +154,7 @@ export default class CGridTableRec extends Vue {
// update rowsCount with appropriate value // update rowsCount with appropriate value
// get all rows if "All" (0) is selected // get all rows if "All" (0) is rowsel
const fetchCount = rowsPerPage === 0 ? rowsNumber : rowsPerPage const fetchCount = rowsPerPage === 0 ? rowsNumber : rowsPerPage
// calculate starting row of data // calculate starting row of data
@@ -193,7 +201,7 @@ export default class CGridTableRec extends Vue {
myobj[sortBy] = 1 myobj[sortBy] = 1
} }
const params = { const params: IParamsQuery = {
table: this.mytable, table: this.mytable,
startRow, startRow,
endRow, endRow,
@@ -269,7 +277,10 @@ export default class CGridTableRec extends Vue {
} }
public getclassCol(col) { public getclassCol(col) {
return (col.disable || !this.canEdit) ? '' : 'colmodif' let mycl = (col.disable || !this.canEdit) ? '' : 'colmodif'
mycl += (col.fieldtype === tools.FieldType.date) ? ' coldate flex flex-container' : ''
return mycl
} }
public async createNewRecord() { public async createNewRecord() {
@@ -279,6 +290,11 @@ export default class CGridTableRec extends Vue {
table: this.mytable, table: this.mytable,
data: {} data: {}
} }
// const mykey = fieldsTable.getKeyByTable(this.mytable)
// mydata.data[mykey] = ''
const data = await GlobalStore.actions.saveTable(mydata) const data = await GlobalStore.actions.saveTable(mydata)
this.serverData.push(data) this.serverData.push(data)
@@ -307,9 +323,13 @@ export default class CGridTableRec extends Vue {
} }
public refresh() { public refresh() {
if (this.search !== '')
this.filter = this.search
else
this.filter = ''
this.onRequest({ this.onRequest({
pagination: this.pagination, pagination: this.pagination
filter: undefined
}) })
} }
@@ -319,6 +339,7 @@ export default class CGridTableRec extends Vue {
} }
} }
public ActionAfterYes(action, item, data) { public ActionAfterYes(action, item, data) {
if (action === lists.MenuAction.DELETE_RECTABLE) { if (action === lists.MenuAction.DELETE_RECTABLE) {
if (this.serverData.length > 0) if (this.serverData.length > 0)
@@ -343,14 +364,19 @@ export default class CGridTableRec extends Vue {
} }
public visuValByType(col, val) { public visuValByType(col, val) {
if (col.fieldtype === 'date') { if (col.fieldtype === tools.FieldType.date) {
if (val === undefined) { if (val === undefined) {
return '[]' return '[]'
} else { } else {
return tools.getstrDateTime(val) return tools.getstrDateTime(val)
} }
} else if (col.fieldtype === 'boolean') { } else if (col.fieldtype === tools.FieldType.boolean) {
return (val) ? this.$t('dialog.yes') : this.$t('dialog.no') return (val) ? this.$t('dialog.yes') : this.$t('dialog.no')
} else if (col.fieldtype === tools.FieldType.binary) {
if (val === undefined)
return '[]'
else
return val
} else { } else {
if (val === undefined) if (val === undefined)
return '[]' return '[]'
@@ -395,4 +421,51 @@ export default class CGridTableRec extends Vue {
this.updatedcol() this.updatedcol()
this.refresh() this.refresh()
} }
get tools() {
return tools
}
get db_fieldsTable() {
return fieldsTable
}
public doSearch() {
this.refresh()
}
public setResultJoin(col: IColGridTable, row) {
let myval = 0
const tabjoin = fieldsTable.getTableJoinByName(col.jointable)
col.resultjoin.forEach((mycol) => {
myval = tools.SetBit(myval, mycol)
})
row[col.name] = myval
console.log('col.resultjoin')
console.table(col.resultjoin)
console.log('row[col.name]', row[col.name])
}
public updateValueExtra(col: IColGridTable, myval) {
if (col.jointable) {
const tabjoin = fieldsTable.getTableJoinByName(col.jointable)
const arr = []
if (myval !== undefined && tabjoin !== undefined) {
tabjoin.forEach((mybit) => {
if (tools.isBitActive(myval, mybit.value))
arr.push(mybit)
})
}
col.resultjoin = arr
console.log('col', col.field, 'myval', myval, 'arr', arr)
console.log('resultjoin')
console.table(col.resultjoin)
}
}
} }

View File

@@ -35,11 +35,16 @@
<!--<p style="color:red"> Rows: {{ getrows }}</p>--> <!--<p style="color:red"> Rows: {{ getrows }}</p>-->
<q-input v-model="search" filled dense type="search" hint="Search" v-on:keyup.enter="doSearch">
<template v-slot:after>
<q-btn v-if="mytable" label="" color="primary" @click="refresh" icon="search"></q-btn>
</template>
</q-input>
<q-toggle v-if="mytable" v-model="funcActivated" :val="lists.MenuAction.CAN_EDIT_TABLE" class="q-mx-sm" <q-toggle v-if="mytable" v-model="funcActivated" :val="lists.MenuAction.CAN_EDIT_TABLE" class="q-mx-sm"
:label="$t('grid.editvalues')"></q-toggle> :label="$t('grid.editvalues')"></q-toggle>
<q-btn v-if="mytable" label="Refresh" color="primary" @click="refresh" class="q-mx-sm"></q-btn> <q-btn v-if="mytable" flat dense color="primary" :disable="loading || !canEdit"
<q-btn v-if="mytable" flat dense color="primary" :disable="loading || !canEdit" :label="$t('grid.addrecord')" :label="$t('grid.addrecord')"
@click="createNewRecord"></q-btn> @click="createNewRecord"></q-btn>
<q-space/> <q-space/>
@@ -84,47 +89,26 @@
<q-tr v-if="mytable" slot="body" slot-scope="props" :props="props"> <q-tr v-if="mytable" slot="body" slot-scope="props" :props="props">
<q-td v-for="col in mycolumns" :key="col.name" :props="props" v-if="colVisib.includes(col.field)"> <q-td v-for="col in mycolumns" :key="col.name" :props="props" v-if="colVisib.includes(col.field)">
<div v-if="col.fieldtype === 'date'"> <div v-if="col.fieldtype === tools.FieldType.date">
<div style="max-width: 250px; min-width: 200px"> <div :class="getclassCol(col)">
<div class="flex flex-container"> <CDateTime
<q-icon name="event" class="cursor-pointer"> class="cursor-pointer"
<q-popup-edit transition-show="scale" transition-hide="scale" v-if="canEdit" :value.sync="props.row[col.name]"
v-model="props.row[col.name]" :disable="col.disable" :label="col.title"
:title="col.title" buttons :dense="true"
@save="SaveValue" @show="selItem(props.row, col.field)"> :readonly="true"
<q-date v-model="props.row[col.name]" mask="YYYY-MM-DD HH:mm"/> @savetoclose="SaveValue"
@show="selItem(props.row, col)"
</q-popup-edit> >
<!--<q-popup-proxy transition-show="scale" transition-hide="scale">--> </CDateTime>
<!--<q-date v-model="props.row[col.name]" mask="YYYY-MM-DD HH:mm" />-->
<!--</q-popup-proxy>-->
</q-icon>
<div>
{{ visuValByType(col, props.row[col.name]) }}
</div>
<q-icon name="access_time" class="cursor-pointer">
<q-popup-edit transition-show="scale" transition-hide="scale" v-if="canEdit"
v-model="props.row[col.name]" :disable="col.disable"
:title="col.title" buttons
@save="SaveValue" @show="selItem(props.row, col.field)">
<q-time v-model="props.row[col.name]" mask="YYYY-MM-DD HH:mm" format24h/>
</q-popup-edit>
<!--<q-popup-proxy transition-show="scale" transition-hide="scale">-->
<!--<q-time v-model="props.row[col.name]" mask="YYYY-MM-DD HH:mm" format24h />-->
<!--</q-popup-proxy>-->
</q-icon>
</div> </div>
</div> </div>
</div> <div v-else-if="col.fieldtype === tools.FieldType.boolean">
<div v-else-if="col.fieldtype === 'boolean'">
<div :class="getclassCol(col)"> <div :class="getclassCol(col)">
{{ visuValByType(col, props.row[col.name]) }} {{ visuValByType(col, props.row[col.name]) }}
<q-popup-edit v-if="canEdit" v-model="props.row[col.name]" :disable="col.disable" <q-popup-edit v-if="canEdit" v-model="props.row[col.name]" :disable="col.disable"
:title="col.title" buttons :title="col.title" buttons
@save="SaveValue" @show="selItem(props.row, col.field)"> @save="SaveValue" @show="selItem(props.row, col)">
<q-checkbox v-model="props.row[col.name]" label=""> <q-checkbox v-model="props.row[col.name]" label="">
</q-checkbox> </q-checkbox>
@@ -133,12 +117,41 @@
</q-popup-edit> </q-popup-edit>
</div> </div>
</div> </div>
<div v-else-if="col.fieldtype === tools.FieldType.binary">
<div :class="getclassCol(col)">
{{ visuValByType(col, props.row[col.name]) }}
<q-popup-edit v-if="canEdit" v-model="props.row[col.name]" :disable="col.disable"
:title="col.title" buttons
@save="SaveValue" @show="selItem(props.row, col)">
<q-select
v-model="col.resultjoin"
multiple
borderless
dense
options-dense
display-value="Valori:"
emit-value
map-options
:options="db_fieldsTable.getTableJoinByName(col.jointable)"
@input="setResultJoin(col, props.row)"
:option-value="db_fieldsTable.getKeyByTable(col.jointable)"
style="min-width: 150px">
</q-select>
<q-input v-model="props.row[col.name]"/>
{{ visuValByType(col, props.row[col.name]) }}
</q-popup-edit>
</div>
</div>
<div v-else> <div v-else>
<div :class="getclassCol(col)"> <div :class="getclassCol(col)">
{{ visuValByType(col, props.row[col.name]) }} {{ visuValByType(col, props.row[col.name]) }}
<q-popup-edit v-if="canEdit" v-model="props.row[col.name]" :disable="col.disable" <q-popup-edit v-if="canEdit" v-model="props.row[col.name]" :disable="col.disable"
:title="col.title" buttons :title="col.title" buttons
@save="SaveValue" @show="selItem(props.row, col.field)"> @save="SaveValue" @show="selItem(props.row, col)">
<q-input v-model="props.row[col.name]"/> <q-input v-model="props.row[col.name]"/>
</q-popup-edit> </q-popup-edit>

View File

@@ -15,6 +15,7 @@ export * from './CSignIn'
export * from './CSignUp' export * from './CSignUp'
export * from './CEventsCalendar' export * from './CEventsCalendar'
export * from './CDate' export * from './CDate'
export * from './CDateTime'
export * from './BannerCookies' export * from './BannerCookies'
export * from './PagePolicy' export * from './PagePolicy'
export * from './FormNewsletter' export * from './FormNewsletter'

View File

@@ -228,7 +228,9 @@ export interface IColGridTable {
action?: any action?: any
askaction?: string askaction?: string
foredit?: boolean foredit?: boolean
fieldtype?: string fieldtype?: number
jointable?: string
resultjoin?: string[]
visuonlyEditVal?: boolean visuonlyEditVal?: boolean
} }

View File

@@ -28,6 +28,11 @@ password?: string
lang lang
*/ */
export interface IPerm {
_id: number
label: string
}
export interface IUserState { export interface IUserState {
my: IUserFields my: IUserFields
lang?: string lang?: string
@@ -43,6 +48,8 @@ export interface IUserState {
isLogged?: boolean isLogged?: boolean
isAdmin?: boolean isAdmin?: boolean
isManager?: boolean isManager?: boolean
isTeacher?: boolean
usersList?: IUserFields[] usersList?: IUserFields[]
permissionsList?: IPerm[]
countusers?: number countusers?: number
} }

View File

@@ -23,6 +23,7 @@ import { IDataPass, IParamsQuery } from '@src/model/GlobalStore'
import { serv_constants } from '@src/store/Modules/serv_constants' import { serv_constants } from '@src/store/Modules/serv_constants'
import { IUserState } from '@src/model' import { IUserState } from '@src/model'
import { Calendar } from 'element-ui' import { Calendar } from 'element-ui'
import { fieldsTable } from '@src/store/Modules/fieldsTable'
// import { static_data } from '@src/db/static_data' // import { static_data } from '@src/db/static_data'
let stateConnDefault = 'online' let stateConnDefault = 'online'
@@ -284,6 +285,8 @@ namespace Mutations {
return UserStore.state.usersList return UserStore.state.usersList
else if (table === 'sendmsgs') else if (table === 'sendmsgs')
return MessageStore.state.last_msgs return MessageStore.state.last_msgs
else if (table === 'permissions')
return UserStore.state.permissionsList
else else
return null return null
@@ -296,8 +299,9 @@ namespace Mutations {
try { try {
const mylist = getListByTable(table) const mylist = getListByTable(table)
const mykey = fieldsTable.getKeyByTable(table)
const myrec = mylist.find((event) => event._id === id) const myrec = mylist.find((event) => event[mykey] === id)
// console.log('myrec', myrec) // console.log('myrec', myrec)
if (myrec) { if (myrec) {
for (const [key, value] of Object.entries(mydata.fieldsvalue)) { for (const [key, value] of Object.entries(mydata.fieldsvalue)) {
@@ -535,6 +539,10 @@ namespace Actions {
UserStore.mutations.setusersList(res.data.usersList) UserStore.mutations.setusersList(res.data.usersList)
} }
if (res.data.permissionsList) {
UserStore.state.permissionsList = res.data.permissionsList
}
if (res.data.last_msgs) { if (res.data.last_msgs) {
MessageStore.state.last_msgs = [...res.data.last_msgs] MessageStore.state.last_msgs = [...res.data.last_msgs]
} }

View File

@@ -41,6 +41,7 @@ const state: IUserState = {
isAdmin: false, isAdmin: false,
isManager: false, isManager: false,
usersList: [], usersList: [],
permissionsList: [],
countusers: 0 countusers: 0
} }
@@ -197,8 +198,9 @@ namespace Mutations {
function authUser(mystate: IUserState, data: IUserFields) { function authUser(mystate: IUserState, data: IUserFields) {
mystate.my = {...data} mystate.my = {...data}
mystate.isAdmin = tools.isBitActive(mystate.my.perm, shared_consts.Permissions.Admin) mystate.isAdmin = tools.isBitActive(mystate.my.perm, shared_consts.Permissions.Admin.value)
mystate.isManager = tools.isBitActive(mystate.my.perm, shared_consts.Permissions.Manager) 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.log('authUser', 'state.isAdmin', mystate.isAdmin)
console.table(mystate) console.table(mystate)

View File

@@ -1,6 +1,7 @@
import { IColGridTable } from '../../model' import { IColGridTable } from '../../model'
import { lists } from './lists' import { lists } from './lists'
import { tools } from '@src/store/Modules/tools' import { tools } from '@src/store/Modules/tools'
import { shared_consts } from '@src/common/shared_vuejs'
const DeleteRec = { const DeleteRec = {
name: 'deleterec', name: 'deleterec',
@@ -30,9 +31,10 @@ function AddCol(params: IColGridTable) {
icon: (params.icon === undefined) ? '' : params.icon, icon: (params.icon === undefined) ? '' : params.icon,
action: (params.action === undefined) ? '' : params.action, action: (params.action === undefined) ? '' : params.action,
foredit: (params.foredit === undefined) ? true : params.foredit, foredit: (params.foredit === undefined) ? true : params.foredit,
fieldtype: (params.fieldtype === undefined) ? 'string' : params.fieldtype, fieldtype: (params.fieldtype === undefined) ? tools.FieldType.string : params.fieldtype,
visuonlyEditVal: (params.visuonlyEditVal === undefined) ? false : params.visuonlyEditVal, visuonlyEditVal: (params.visuonlyEditVal === undefined) ? false : params.visuonlyEditVal,
askaction: (params.askaction === undefined) ? '' : params.askaction askaction: (params.askaction === undefined) ? '' : params.askaction,
jointable: (params.jointable === undefined) ? '' : params.jointable
} }
} }
@@ -45,7 +47,13 @@ const colTableWhere = [
const colcontribtype = [ const colcontribtype = [
AddCol({ name: 'label', label_trans: 'proj.longdescr' }), AddCol({ name: 'label', label_trans: 'proj.longdescr' }),
AddCol({ name: 'showprice', label_trans: 'event.showprice', fieldtype: 'boolean' }), AddCol({ name: 'showprice', label_trans: 'event.showprice', fieldtype: tools.FieldType.boolean }),
AddCol(DeleteRec)
]
const colTablePermission = [
AddCol({ name: '_id', label_trans: 'others.value' }),
AddCol({ name: 'label', label_trans: 'proj.longdescr' }),
AddCol(DeleteRec) AddCol(DeleteRec)
] ]
@@ -65,7 +73,7 @@ const colTableEvents = [
AddCol({ name: 'short_tit', label_trans: 'event.short_tit' }), AddCol({ name: 'short_tit', label_trans: 'event.short_tit' }),
AddCol({ name: 'title', label_trans: 'event.title' }), AddCol({ name: 'title', label_trans: 'event.title' }),
AddCol({ name: 'details', label_trans: 'event.details' }), AddCol({ name: 'details', label_trans: 'event.details' }),
AddCol({ name: 'dateTimeStart', label_trans: 'event.dateTimeStart', fieldtype: 'date' }), AddCol({ name: 'dateTimeStart', label_trans: 'event.dateTimeStart', fieldtype: tools.FieldType.date }),
AddCol({ name: 'dateTimeEnd', label_trans: 'event.dateTimeEnd' }), AddCol({ name: 'dateTimeEnd', label_trans: 'event.dateTimeEnd' }),
AddCol({ name: 'bgcolor', label_trans: 'event.bgcolor' }), AddCol({ name: 'bgcolor', label_trans: 'event.bgcolor' }),
AddCol({ name: 'icon', label_trans: 'event.icon' }), AddCol({ name: 'icon', label_trans: 'event.icon' }),
@@ -80,12 +88,12 @@ const colTableEvents = [
AddCol({ name: 'infoextra', label_trans: 'event.infoextra' }), AddCol({ name: 'infoextra', label_trans: 'event.infoextra' }),
AddCol({ name: 'linkpage', label_trans: 'event.linkpage' }), AddCol({ name: 'linkpage', label_trans: 'event.linkpage' }),
AddCol({ name: 'linkpdf', label_trans: 'event.linkpdf' }), AddCol({ name: 'linkpdf', label_trans: 'event.linkpdf' }),
AddCol({ name: 'nobookable', label_trans: 'event.nobookable', fieldtype: 'boolean' }), AddCol({ name: 'nobookable', label_trans: 'event.nobookable', fieldtype: tools.FieldType.boolean }),
AddCol({ name: 'news', label_trans: 'event.news', fieldtype: 'boolean' }), AddCol({ name: 'news', label_trans: 'event.news', fieldtype: tools.FieldType.boolean }),
AddCol({ name: 'canceled', label_trans: 'event.canceled', fieldtype: 'boolean' }), AddCol({ name: 'canceled', label_trans: 'event.canceled', fieldtype: tools.FieldType.boolean }),
AddCol({ name: 'deleted', label_trans: 'event.deleted', fieldtype: 'boolean' }), AddCol({ name: 'deleted', label_trans: 'event.deleted', fieldtype: tools.FieldType.boolean }),
AddCol({ name: 'dupId', label_trans: 'event.dupId' }), AddCol({ name: 'dupId', label_trans: 'event.dupId' }),
AddCol({ name: 'modified', label_trans: 'event.modified', fieldtype: 'boolean' }), AddCol({ name: 'modified', label_trans: 'event.modified', fieldtype: tools.FieldType.boolean }),
AddCol(DeleteRec), AddCol(DeleteRec),
AddCol({ AddCol({
name: 'copyrec', name: 'copyrec',
@@ -103,6 +111,26 @@ const colTableEvents = [
] ]
export const fieldsTable = { export const fieldsTable = {
getColByTable(table) {
if (table === 'permissions') {
return ['value', 'label']
}
},
getTableJoinByName(table) {
if (table === 'permissions') {
return [shared_consts.Permissions.Normal, shared_consts.Permissions.Admin, shared_consts.Permissions.Manager, shared_consts.Permissions.Teacher]
}
},
getrecTableList(mytable) {
return this.tablesList.find((rec) => rec.value === mytable)
},
getKeyByTable(mytable): string {
const myrec = this.getrecTableList(mytable)
if (myrec)
return ((myrec.colkey) ? myrec.colkey : '_id')
else
return '_id'
},
tablesList: [ tablesList: [
{ {
value: 'operators', value: 'operators',
@@ -127,6 +155,12 @@ export const fieldsTable = {
label: 'Tipi di Contributi', label: 'Tipi di Contributi',
columns: colcontribtype, columns: colcontribtype,
colkey: '_id' colkey: '_id'
},
{
value: 'permissions',
label: 'Permessi',
columns: colTablePermission,
colkey: 'value'
} }
], ],
@@ -136,8 +170,8 @@ export const fieldsTable = {
AddCol({ name: 'name', label_trans: 'reg.name' }), AddCol({ name: 'name', label_trans: 'reg.name' }),
AddCol({ name: 'surname', label_trans: 'reg.surname' }), AddCol({ name: 'surname', label_trans: 'reg.surname' }),
AddCol({ name: 'email', label_trans: 'reg.email' }), AddCol({ name: 'email', label_trans: 'reg.email' }),
AddCol({ name: 'date_reg', label_trans: 'reg.date_reg', fieldtype: 'date' }), AddCol({ name: 'date_reg', label_trans: 'reg.date_reg', fieldtype: tools.FieldType.date }),
AddCol({ name: 'perm', label_trans: 'reg.perm' }), AddCol({ name: 'perm', label_trans: 'reg.perm', fieldtype: tools.FieldType.binary, jointable: 'permissions' }),
AddCol({ name: 'img', label_trans: 'reg.img', sortable: false }), AddCol({ name: 'img', label_trans: 'reg.img', sortable: false }),
AddCol(DeleteRec), AddCol(DeleteRec),
AddCol({ AddCol({

View File

@@ -96,6 +96,13 @@ export const tools = {
COMPLETED: 10 COMPLETED: 10
}, },
FieldType: {
boolean: 1,
date: 2,
string: 4,
binary: 8
},
SelectListNumPeople: [ SelectListNumPeople: [
{ {
id: 1, id: 1,

View File

@@ -76,7 +76,6 @@ export default class Category extends Vue {
this.updatetable() this.updatetable()
} }
created() { created() {
this.loadCat() this.loadCat()
} }