2019-10-27 00:39:00 +02:00
|
|
|
import { IColGridTable } from '../../model'
|
|
|
|
|
import { lists } from './lists'
|
|
|
|
|
import { tools } from '@src/store/Modules/tools'
|
2019-10-28 16:00:37 +01:00
|
|
|
import { shared_consts } from '@src/common/shared_vuejs'
|
2019-11-04 20:29:35 +01:00
|
|
|
import { GlobalStore } from '@store'
|
2019-10-27 00:39:00 +02:00
|
|
|
|
|
|
|
|
const DeleteRec = {
|
|
|
|
|
name: 'deleterec',
|
|
|
|
|
label_trans: 'newsletter.reset',
|
|
|
|
|
align: 'right',
|
|
|
|
|
field: tools.NOFIELD,
|
|
|
|
|
sortable: false,
|
|
|
|
|
icon: 'fas fa-trash-alt',
|
|
|
|
|
action: lists.MenuAction.DELETE_RECTABLE,
|
|
|
|
|
askaction: 'db.deletetherecord',
|
|
|
|
|
required: true,
|
|
|
|
|
visuonlyEditVal: true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AddCol(params: IColGridTable) {
|
|
|
|
|
return {
|
|
|
|
|
name: params.name,
|
|
|
|
|
required: (params.required === undefined) ? false : params.required,
|
|
|
|
|
label: (params.label === undefined) ? '' : params.label,
|
|
|
|
|
label_trans: (params.label_trans === undefined) ? '' : params.label_trans,
|
|
|
|
|
align: (params.align === undefined) ? 'left' : params.align,
|
|
|
|
|
field: (params.field === undefined) ? params.name : params.field,
|
2019-11-04 20:29:35 +01:00
|
|
|
subfield: (params.subfield === undefined) ? '' : params.subfield,
|
2019-10-27 00:39:00 +02:00
|
|
|
sortable: (params.sortable === undefined) ? true : params.sortable,
|
|
|
|
|
disable: (params.disable === undefined) ? false : params.disable,
|
|
|
|
|
titlepopupedit: (params.titlepopupedit === undefined) ? '' : params.titlepopupedit,
|
|
|
|
|
visible: (params.visible === undefined) ? true : params.visible,
|
|
|
|
|
icon: (params.icon === undefined) ? '' : params.icon,
|
|
|
|
|
action: (params.action === undefined) ? '' : params.action,
|
|
|
|
|
foredit: (params.foredit === undefined) ? true : params.foredit,
|
2019-10-28 16:00:37 +01:00
|
|
|
fieldtype: (params.fieldtype === undefined) ? tools.FieldType.string : params.fieldtype,
|
2019-10-27 00:39:00 +02:00
|
|
|
visuonlyEditVal: (params.visuonlyEditVal === undefined) ? false : params.visuonlyEditVal,
|
2019-10-28 16:00:37 +01:00
|
|
|
askaction: (params.askaction === undefined) ? '' : params.askaction,
|
|
|
|
|
jointable: (params.jointable === undefined) ? '' : params.jointable
|
2019-10-27 00:39:00 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const colTableWhere = [
|
|
|
|
|
AddCol({ name: 'code', label_trans: 'where.code' }),
|
2019-11-04 20:29:35 +01:00
|
|
|
AddCol({ name: 'placename', label_trans: 'cal.where'} ),
|
2019-10-27 00:39:00 +02:00
|
|
|
AddCol({ name: 'whereicon', label_trans: 'where.whereicon' }),
|
|
|
|
|
AddCol(DeleteRec)
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const colcontribtype = [
|
|
|
|
|
AddCol({ name: 'label', label_trans: 'proj.longdescr' }),
|
2019-10-28 16:00:37 +01:00
|
|
|
AddCol({ name: 'showprice', label_trans: 'event.showprice', fieldtype: tools.FieldType.boolean }),
|
|
|
|
|
AddCol(DeleteRec)
|
|
|
|
|
]
|
|
|
|
|
|
2019-11-04 20:29:35 +01:00
|
|
|
const colsettings = [
|
|
|
|
|
AddCol({ name: 'key', label_trans: 'col.label' }),
|
|
|
|
|
AddCol({ name: 'type', label_trans: 'col.type', fieldtype: tools.FieldType.select, jointable: 'fieldstype' }),
|
|
|
|
|
AddCol({ name: 'value_str', label_trans: 'col.value', fieldtype: tools.FieldType.string }),
|
|
|
|
|
AddCol({ name: 'value_date', label_trans: 'cal.data', fieldtype: tools.FieldType.date }),
|
|
|
|
|
AddCol({ name: 'value_num', label_trans: 'cal.num', fieldtype: tools.FieldType.number }),
|
|
|
|
|
AddCol(DeleteRec)
|
|
|
|
|
]
|
|
|
|
|
|
2019-10-28 16:00:37 +01:00
|
|
|
const colTablePermission = [
|
|
|
|
|
AddCol({ name: '_id', label_trans: 'others.value' }),
|
|
|
|
|
AddCol({ name: 'label', label_trans: 'proj.longdescr' }),
|
2019-10-27 00:39:00 +02:00
|
|
|
AddCol(DeleteRec)
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const colTableOperator = [
|
|
|
|
|
AddCol({ name: 'username', label_trans: 'reg.username' }),
|
2019-11-01 15:52:58 +01:00
|
|
|
AddCol({ name: 'name', label_trans: 'reg.name' }),
|
|
|
|
|
AddCol({ name: 'surname', label_trans: 'reg.surname' }),
|
|
|
|
|
AddCol({ name: 'email', label_trans: 'reg.email' }),
|
|
|
|
|
AddCol({ name: 'img', label_trans: 'event.img' }),
|
|
|
|
|
AddCol({ name: 'cell', label_trans: 'reg.cell' }),
|
|
|
|
|
AddCol({ name: 'qualification', label_trans: 'op.qualification' }),
|
|
|
|
|
AddCol({ name: 'disciplines', label_trans: 'op.disciplines' }),
|
|
|
|
|
AddCol({ name: 'certifications', label_trans: 'op.certifications' }),
|
|
|
|
|
AddCol({ name: 'intro', label_trans: 'op.intro' , fieldtype: tools.FieldType.html }),
|
|
|
|
|
AddCol({ name: 'info', label_trans: 'op.info', fieldtype: tools.FieldType.html }),
|
|
|
|
|
AddCol({ name: 'webpage', label_trans: 'op.webpage' }),
|
|
|
|
|
AddCol({ name: 'days_working', label_trans: 'op.days_working' }),
|
|
|
|
|
AddCol({ name: 'facebook', label_trans: 'op.facebook' }),
|
2019-10-27 00:39:00 +02:00
|
|
|
AddCol(DeleteRec)]
|
|
|
|
|
|
|
|
|
|
const colTableEvents = [
|
|
|
|
|
AddCol({ name: '_id', label_trans: 'event._id' }),
|
|
|
|
|
AddCol({ name: 'typol', label_trans: 'event.typol' }),
|
|
|
|
|
AddCol({ name: 'short_tit', label_trans: 'event.short_tit' }),
|
|
|
|
|
AddCol({ name: 'title', label_trans: 'event.title' }),
|
|
|
|
|
AddCol({ name: 'details', label_trans: 'event.details' }),
|
2019-10-28 16:00:37 +01:00
|
|
|
AddCol({ name: 'dateTimeStart', label_trans: 'event.dateTimeStart', fieldtype: tools.FieldType.date }),
|
2019-11-01 15:52:58 +01:00
|
|
|
AddCol({ name: 'dateTimeEnd', label_trans: 'event.dateTimeEnd', fieldtype: tools.FieldType.date }),
|
2019-10-27 00:39:00 +02:00
|
|
|
AddCol({ name: 'bgcolor', label_trans: 'event.bgcolor' }),
|
|
|
|
|
AddCol({ name: 'icon', label_trans: 'event.icon' }),
|
|
|
|
|
AddCol({ name: 'img_small', label_trans: 'event.img_small' }),
|
|
|
|
|
AddCol({ name: 'img', label_trans: 'event.img' }),
|
2019-11-04 20:29:35 +01:00
|
|
|
AddCol({ name: 'wherecode', label_trans: 'event.where', fieldtype: tools.FieldType.select, jointable: 'wheres' }),
|
|
|
|
|
AddCol({ name: 'contribtype', label_trans: 'event.contribtype', fieldtype: tools.FieldType.select, jointable: 'contribtype' }),
|
2019-10-27 00:39:00 +02:00
|
|
|
AddCol({ name: 'price', label_trans: 'event.price' }),
|
|
|
|
|
AddCol({ name: 'infoafterprice', label_trans: 'event.infoafterprice' }),
|
2019-11-04 20:29:35 +01:00
|
|
|
AddCol({ name: 'teacher', label_trans: 'event.teacher', fieldtype: tools.FieldType.select, jointable: 'operators' }),
|
|
|
|
|
AddCol({ name: 'teacher2', label_trans: 'event.teacher2', fieldtype: tools.FieldType.select, jointable: 'operators' }),
|
2019-10-27 00:39:00 +02:00
|
|
|
AddCol({ name: 'infoextra', label_trans: 'event.infoextra' }),
|
|
|
|
|
AddCol({ name: 'linkpage', label_trans: 'event.linkpage' }),
|
|
|
|
|
AddCol({ name: 'linkpdf', label_trans: 'event.linkpdf' }),
|
2019-10-28 16:00:37 +01:00
|
|
|
AddCol({ name: 'nobookable', label_trans: 'event.nobookable', fieldtype: tools.FieldType.boolean }),
|
|
|
|
|
AddCol({ name: 'news', label_trans: 'event.news', fieldtype: tools.FieldType.boolean }),
|
|
|
|
|
AddCol({ name: 'canceled', label_trans: 'event.canceled', fieldtype: tools.FieldType.boolean }),
|
|
|
|
|
AddCol({ name: 'deleted', label_trans: 'event.deleted', fieldtype: tools.FieldType.boolean }),
|
2019-10-27 00:39:00 +02:00
|
|
|
AddCol({ name: 'dupId', label_trans: 'event.dupId' }),
|
2019-10-28 16:00:37 +01:00
|
|
|
AddCol({ name: 'modified', label_trans: 'event.modified', fieldtype: tools.FieldType.boolean }),
|
2019-10-27 00:39:00 +02:00
|
|
|
AddCol(DeleteRec),
|
|
|
|
|
AddCol({
|
|
|
|
|
name: 'copyrec',
|
|
|
|
|
label_trans: 'event.duplicate',
|
|
|
|
|
align: 'right',
|
|
|
|
|
field: tools.NOFIELD,
|
|
|
|
|
sortable: false,
|
|
|
|
|
icon: 'fas fa-copy',
|
|
|
|
|
action: lists.MenuAction.DUPLICATE_RECTABLE,
|
|
|
|
|
askaction: 'db.duplicatedrecord',
|
|
|
|
|
visuonlyEditVal: true,
|
|
|
|
|
required: true,
|
|
|
|
|
visible: true
|
|
|
|
|
})
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
export const fieldsTable = {
|
2019-10-28 19:00:06 +01:00
|
|
|
getArrStrByValueBinary(mythis, col: IColGridTable, val) {
|
|
|
|
|
const arr = this.getArrByValueBinary(mythis, col, val)
|
|
|
|
|
if (arr.length > 0)
|
|
|
|
|
return arr.join(' - ')
|
|
|
|
|
else
|
|
|
|
|
return '[---]'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getArrByValueBinary(mythis, col: IColGridTable, val) {
|
|
|
|
|
if (col.jointable) {
|
|
|
|
|
const mylist = this.getTableJoinByName(col.jointable)
|
|
|
|
|
const key = this.getKeyByTable(col.jointable)
|
|
|
|
|
const myres = []
|
|
|
|
|
mylist.forEach((myrec) => {
|
|
|
|
|
if (tools.isBitActive(val, myrec[key]))
|
|
|
|
|
myres.push(mythis.$t(myrec.label))
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return myres
|
|
|
|
|
} else {
|
|
|
|
|
return []
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-11-04 20:29:35 +01:00
|
|
|
getValueByTable(col: IColGridTable, val) {
|
|
|
|
|
if (col.jointable) {
|
|
|
|
|
const mylist = this.getTableJoinByName(col.jointable)
|
|
|
|
|
const key = this.getKeyByTable(col.jointable)
|
|
|
|
|
const collab = this.getLabelByTable(col.jointable)
|
|
|
|
|
|
|
|
|
|
// console.table(mylist)
|
|
|
|
|
// console.log('key=', key, 'collab', collab, 'val', val)
|
|
|
|
|
|
|
|
|
|
const myris = mylist.find((myrec) => myrec[key] === val)
|
|
|
|
|
// console.log('myris', myris)
|
|
|
|
|
if (myris) {
|
|
|
|
|
return myris[collab]
|
|
|
|
|
} else {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-10-28 16:00:37 +01:00
|
|
|
getColByTable(table) {
|
|
|
|
|
if (table === 'permissions') {
|
|
|
|
|
return ['value', 'label']
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getTableJoinByName(table) {
|
2019-11-04 20:29:35 +01:00
|
|
|
if (table === 'permissions')
|
2019-10-28 19:00:06 +01:00
|
|
|
return [shared_consts.Permissions.Admin, shared_consts.Permissions.Manager, shared_consts.Permissions.Teacher]
|
2019-11-04 20:29:35 +01:00
|
|
|
else if (table === 'fieldstype')
|
|
|
|
|
return tools.FieldTypeArr
|
|
|
|
|
else
|
|
|
|
|
return GlobalStore.getters.getListByTable(table)
|
|
|
|
|
|
2019-10-28 16:00:37 +01:00
|
|
|
},
|
|
|
|
|
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'
|
|
|
|
|
},
|
2019-10-28 19:00:06 +01:00
|
|
|
getLabelByTable(mytable): string {
|
|
|
|
|
const myrec = this.getrecTableList(mytable)
|
|
|
|
|
if (myrec)
|
|
|
|
|
return ((myrec.collabel) ? myrec.collabel : 'label')
|
|
|
|
|
else
|
|
|
|
|
return 'label'
|
|
|
|
|
},
|
|
|
|
|
getIconByTable(mytable): string {
|
|
|
|
|
const myrec = this.getrecTableList(mytable)
|
|
|
|
|
if (myrec)
|
|
|
|
|
return ((myrec.icon) ? myrec.icon : '')
|
|
|
|
|
else
|
|
|
|
|
return ''
|
|
|
|
|
},
|
2019-10-27 00:39:00 +02:00
|
|
|
tablesList: [
|
|
|
|
|
{
|
|
|
|
|
value: 'operators',
|
|
|
|
|
label: 'Insegnanti',
|
|
|
|
|
columns: colTableOperator,
|
2019-11-04 20:29:35 +01:00
|
|
|
colkey: 'username',
|
2019-10-28 19:00:06 +01:00
|
|
|
collabel: 'username'
|
2019-10-27 00:39:00 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 'wheres',
|
|
|
|
|
label: 'Luoghi',
|
|
|
|
|
columns: colTableWhere,
|
2019-11-04 20:29:35 +01:00
|
|
|
colkey: 'code',
|
2019-10-28 19:00:06 +01:00
|
|
|
collabel: 'placename'
|
2019-10-27 00:39:00 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: tools.TABEVENTS,
|
|
|
|
|
label: 'Eventi',
|
|
|
|
|
columns: colTableEvents,
|
2019-10-28 19:00:06 +01:00
|
|
|
colkey: '_id',
|
|
|
|
|
collabel: 'title'
|
2019-10-27 00:39:00 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 'contribtype',
|
|
|
|
|
label: 'Tipi di Contributi',
|
|
|
|
|
columns: colcontribtype,
|
2019-10-28 19:00:06 +01:00
|
|
|
colkey: '_id',
|
|
|
|
|
collabel: 'label'
|
2019-10-28 16:00:37 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 'permissions',
|
|
|
|
|
label: 'Permessi',
|
|
|
|
|
columns: colTablePermission,
|
2019-10-28 19:00:06 +01:00
|
|
|
colkey: 'value',
|
|
|
|
|
collabel: 'label',
|
|
|
|
|
colicon: 'icon'
|
2019-11-04 20:29:35 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 'fieldstype',
|
|
|
|
|
label: 'Tipi di Campi',
|
|
|
|
|
colkey: 'value',
|
|
|
|
|
collabel: 'label'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 'settings',
|
|
|
|
|
label: 'Impostazioni',
|
|
|
|
|
columns: colsettings,
|
|
|
|
|
colkey: 'key',
|
|
|
|
|
collabel: 'key'
|
|
|
|
|
},
|
2019-10-27 00:39:00 +02:00
|
|
|
],
|
|
|
|
|
|
|
|
|
|
// IColGridTable
|
|
|
|
|
colTableUsers: [
|
|
|
|
|
AddCol({ name: 'username', label_trans: 'reg.username' }),
|
|
|
|
|
AddCol({ name: 'name', label_trans: 'reg.name' }),
|
|
|
|
|
AddCol({ name: 'surname', label_trans: 'reg.surname' }),
|
|
|
|
|
AddCol({ name: 'email', label_trans: 'reg.email' }),
|
2019-11-01 15:52:58 +01:00
|
|
|
AddCol({ name: 'cell', label_trans: 'reg.cell' }),
|
2019-11-04 20:29:35 +01:00
|
|
|
AddCol({ name: 'profile.img', field: 'profile', subfield: 'img', label_trans: 'reg.img', sortable: false }),
|
2019-10-28 16:00:37 +01:00
|
|
|
AddCol({ name: 'date_reg', label_trans: 'reg.date_reg', fieldtype: tools.FieldType.date }),
|
|
|
|
|
AddCol({ name: 'perm', label_trans: 'reg.perm', fieldtype: tools.FieldType.binary, jointable: 'permissions' }),
|
2019-10-27 00:39:00 +02:00
|
|
|
AddCol(DeleteRec),
|
|
|
|
|
AddCol({
|
|
|
|
|
name: 'copyrec',
|
|
|
|
|
label_trans: 'event.duplicate',
|
|
|
|
|
align: 'right',
|
|
|
|
|
field: tools.NOFIELD,
|
|
|
|
|
sortable: false,
|
|
|
|
|
icon: 'fas fa-copy',
|
|
|
|
|
action: lists.MenuAction.DUPLICATE_RECTABLE,
|
|
|
|
|
askaction: 'db.duplicatedrecord',
|
|
|
|
|
visuonlyEditVal: true,
|
|
|
|
|
visible: true
|
|
|
|
|
})
|
|
|
|
|
]
|
|
|
|
|
}
|