- Message notify when 'Ask Info' and user is not logged

- Ask Info and Book show message if not logged
- TableField fixed and added some features
This commit is contained in:
Paolo Arena
2019-11-04 20:29:35 +01:00
parent f30e6afd9e
commit b27f7e3cbf
26 changed files with 577 additions and 372 deletions

View File

@@ -34,6 +34,7 @@ getstateConnSaved()
})
const state: IGlobalState = {
finishLoading: false,
conta: 0,
wasAlreadySubscribed: false,
wasAlreadySubOnDb: false,
@@ -66,7 +67,8 @@ const state: IGlobalState = {
table: '',
type: 0,
_id: 0
}
},
settings: []
}
async function getConfig(id) {
@@ -152,6 +154,45 @@ namespace Getters {
return ris
}, 't')
const getListByTable = b.read((state) => (table) => {
if (table === tools.TABEVENTS)
return CalendarStore.state.eventlist
else if (table === 'operators')
return CalendarStore.state.operators
else if (table === 'wheres')
return CalendarStore.state.wheres
else if (table === 'contribtype')
return CalendarStore.state.contribtype
else if (table === 'bookings')
return CalendarStore.state.bookedevent
else if (table === 'users')
return UserStore.state.usersList
else if (table === 'sendmsgs')
return MessageStore.state.last_msgs
else if (table === 'settings')
return UserStore.state.settings
else if (table === 'permissions')
return UserStore.state.permissionsList
else
return null
}, 'getListByTable')
const getValueSettingsByKey = b.read((mystate: IGlobalState) => (key): any => {
const myrec = mystate.settings.find((rec) => rec.key === key)
if (!!myrec) {
if (myrec.type === tools.FieldType.date)
return myrec.value_date
if (myrec.type === tools.FieldType.number)
return myrec.value_num
else
return myrec.value_str
} else {
return ''
}
}, 'getValueSettingsByKey')
export const getters = {
get testpao1_getter_contatore() {
return testpao1_getter_contatore()
@@ -187,6 +228,14 @@ namespace Getters {
return getmenu()
},
get getListByTable() {
return getListByTable()
},
get getValueSettingsByKey() {
return getValueSettingsByKey()
},
get t() {
return t()
},
@@ -270,35 +319,13 @@ namespace Mutations {
}
function getListByTable(table): any[] {
if (table === tools.TABEVENTS)
return CalendarStore.state.eventlist
else if (table === 'operators')
return CalendarStore.state.operators
else if (table === 'wheres')
return CalendarStore.state.wheres
else if (table === 'contribtype')
return CalendarStore.state.contribtype
else if (table === 'bookings')
return CalendarStore.state.bookedevent
else if (table === 'users')
return UserStore.state.usersList
else if (table === 'sendmsgs')
return MessageStore.state.last_msgs
else if (table === 'permissions')
return UserStore.state.permissionsList
else
return null
}
function UpdateValuesInMemory(mystate: IGlobalState, mydata: IDataPass) {
const id = mydata.id
const table = mydata.table
try {
const mylist = getListByTable(table)
const mylist = Getters.getters.getListByTable(table)
const mykey = fieldsTable.getKeyByTable(table)
const myrec = mylist.find((event) => event[mykey] === id)
@@ -653,13 +680,14 @@ namespace Actions {
const myuserid = (UserStore.state.my._id) ? UserStore.state.my._id : '0'
const ris = await Api.SendReq('/loadsite/' + myuserid + '/' + process.env.APP_ID + '/' + showall, 'GET', null)
return await Api.SendReq('/loadsite/' + myuserid + '/' + process.env.APP_ID + '/' + showall, 'GET', null)
.then((res) => {
CalendarStore.state.bookedevent = (res.data.bookedevent) ? res.data.bookedevent : []
CalendarStore.state.eventlist = (res.data.eventlist) ? res.data.eventlist : []
CalendarStore.state.operators = (res.data.operators) ? res.data.operators : []
CalendarStore.state.wheres = (res.data.wheres) ? res.data.wheres : []
CalendarStore.state.contribtype = (res.data.contribtype) ? res.data.contribtype : []
GlobalStore.state.settings = (res.data.settings) ? [...res.data.settings] : []
})
.catch((error) => {
@@ -668,8 +696,6 @@ namespace Actions {
return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, tools.ERR_GENERICO, error)
})
return ris
}
export const actions = {

View File

@@ -122,7 +122,7 @@ namespace Actions {
data.datemsg = tools.getDateNow()
data.status = StatusMessage.WaitingToSend
// Options
// data.options = tools.SetBit(data.options, shared_consts.MessageOptions.Notify_ByEmail)
data.options = tools.SetBit(data.options, shared_consts.MessageOptions.Notify_ByEmail)
data.options = tools.SetBit(data.options, shared_consts.MessageOptions.Notify_ByPushNotification)
console.log('DOPO:')

View File

@@ -86,13 +86,13 @@ namespace Getters {
const getImgTeacherByUsername = b.read((mystate: ICalendarState) => (username): string => {
if (username === '')
return 'images/avatar/avatar3_small.png'
return ''
// Check if is this User!
const myop = CalendarStore.getters.getOperatorByUsername(username)
if (myop && !!myop.img && myop.img !== '' && myop.img !== 'undefined') {
return myop.img
} else {
return 'images/avatar/avatar3_small.png'
return ''
}
}, 'getImgTeacherByUsername')

View File

@@ -20,21 +20,23 @@ import { shared_consts } from '../../common/shared_vuejs'
const bcrypt = require('bcryptjs')
const DefaultUser: IUserFields = {
_id: '',
email: '',
username: '',
name: '',
surname: '',
password: '',
tokens: [],
verified_email: false,
profile: {
img: ''
}
}
// State
const state: IUserState = {
my: {
_id: '',
email: '',
username: '',
name: '',
surname: '',
password: '',
tokens: [],
verified_email: false,
profile: {
img: ''
}
},
my: DefaultUser,
lang: process.env.LANG_DEFAULT,
repeatPassword: '',
categorySel: 'personal',
@@ -143,13 +145,14 @@ namespace Getters {
const getImgByUsername = b.read((mystate: IUserState) => (username): string => {
if (username === '')
return 'images/avatar/avatar3_small.png'
return ''
// Check if is this User!
const myrec = UserStore.getters.getUserByUsername(username)
// console.log('myrec', myrec)
if (myrec && myrec.profile && !!myrec.profile.img && myrec.profile.img !== '' && myrec.profile.img !== 'undefined') {
return myrec.profile.img
} else {
return 'images/avatar/avatar3_small.png'
return ''
}
}, 'getImgByUsername')
@@ -192,7 +195,7 @@ namespace Getters {
},
get getUsersList() {
return getUsersList()
}
},
}
}
@@ -613,6 +616,7 @@ namespace Actions {
localStorage.removeItem(tools.localStorage.wasAlreadySubOnDb)
state.isLogged = false
state.my = { ...DefaultUser }
await GlobalStore.actions.clearDataAfterLogout()
@@ -634,7 +638,6 @@ namespace Actions {
async function setGlobal(isLogged: boolean) {
console.log('setGlobal')
// state.isLogged = true
state.isLogged = isLogged
if (isLogged) {
// console.log('state.isLogged', state.isLogged)
@@ -646,12 +649,17 @@ namespace Actions {
const p3 = await GlobalStore.actions.loadAfterLogin()
state.isLogged = isLogged
if (static_data.functionality.ENABLE_TODOS_LOADING)
await Todos.actions.dbLoad({ checkPending: true })
if (static_data.functionality.ENABLE_PROJECTS_LOADING)
await Projects.actions.dbLoad({ checkPending: true, onlyiffirsttime: true })
GlobalStore.state.finishLoading = true
return true
// console.log('setGlobal: END')
}
@@ -698,11 +706,11 @@ namespace Actions {
}
}
await setGlobal(isLogged)
return await setGlobal(isLogged)
// console.log('autologin _id STATE ', state._id)
return true
// return true
} catch (e) {
console.error('ERR autologin ', e.message)
return false

View File

@@ -2,6 +2,7 @@ import { IColGridTable } from '../../model'
import { lists } from './lists'
import { tools } from '@src/store/Modules/tools'
import { shared_consts } from '@src/common/shared_vuejs'
import { GlobalStore } from '@store'
const DeleteRec = {
name: 'deleterec',
@@ -24,6 +25,7 @@ function AddCol(params: IColGridTable) {
label_trans: (params.label_trans === undefined) ? '' : params.label_trans,
align: (params.align === undefined) ? 'left' : params.align,
field: (params.field === undefined) ? params.name : params.field,
subfield: (params.subfield === undefined) ? '' : params.subfield,
sortable: (params.sortable === undefined) ? true : params.sortable,
disable: (params.disable === undefined) ? false : params.disable,
titlepopupedit: (params.titlepopupedit === undefined) ? '' : params.titlepopupedit,
@@ -40,7 +42,7 @@ function AddCol(params: IColGridTable) {
const colTableWhere = [
AddCol({ name: 'code', label_trans: 'where.code' }),
AddCol({ name: 'placename', label_trans: 'cal.where' }),
AddCol({ name: 'placename', label_trans: 'cal.where'} ),
AddCol({ name: 'whereicon', label_trans: 'where.whereicon' }),
AddCol(DeleteRec)
]
@@ -51,6 +53,15 @@ const colcontribtype = [
AddCol(DeleteRec)
]
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)
]
const colTablePermission = [
AddCol({ name: '_id', label_trans: 'others.value' }),
AddCol({ name: 'label', label_trans: 'proj.longdescr' }),
@@ -86,12 +97,12 @@ const colTableEvents = [
AddCol({ name: 'icon', label_trans: 'event.icon' }),
AddCol({ name: 'img_small', label_trans: 'event.img_small' }),
AddCol({ name: 'img', label_trans: 'event.img' }),
AddCol({ name: 'wherecode', label_trans: 'event.where' }),
AddCol({ name: 'contribtype', label_trans: 'event.contribtype' }),
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' }),
AddCol({ name: 'price', label_trans: 'event.price' }),
AddCol({ name: 'infoafterprice', label_trans: 'event.infoafterprice' }),
AddCol({ name: 'teacher', label_trans: 'event.teacher' }),
AddCol({ name: 'teacher2', label_trans: 'event.teacher2' }),
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' }),
AddCol({ name: 'infoextra', label_trans: 'event.infoextra' }),
AddCol({ name: 'linkpage', label_trans: 'event.linkpage' }),
AddCol({ name: 'linkpdf', label_trans: 'event.linkpdf' }),
@@ -142,15 +153,41 @@ export const fieldsTable = {
}
},
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 ''
}
},
getColByTable(table) {
if (table === 'permissions') {
return ['value', 'label']
}
},
getTableJoinByName(table) {
if (table === 'permissions') {
if (table === 'permissions')
return [shared_consts.Permissions.Admin, shared_consts.Permissions.Manager, shared_consts.Permissions.Teacher]
}
else if (table === 'fieldstype')
return tools.FieldTypeArr
else
return GlobalStore.getters.getListByTable(table)
},
getrecTableList(mytable) {
return this.tablesList.find((rec) => rec.value === mytable)
@@ -181,14 +218,14 @@ export const fieldsTable = {
value: 'operators',
label: 'Insegnanti',
columns: colTableOperator,
colkey: '_id',
colkey: 'username',
collabel: 'username'
},
{
value: 'wheres',
label: 'Luoghi',
columns: colTableWhere,
colkey: '_id',
colkey: 'code',
collabel: 'placename'
},
{
@@ -212,7 +249,20 @@ export const fieldsTable = {
colkey: 'value',
collabel: 'label',
colicon: 'icon'
}
},
{
value: 'fieldstype',
label: 'Tipi di Campi',
colkey: 'value',
collabel: 'label'
},
{
value: 'settings',
label: 'Impostazioni',
columns: colsettings,
colkey: 'key',
collabel: 'key'
},
],
// IColGridTable
@@ -222,9 +272,9 @@ export const fieldsTable = {
AddCol({ name: 'surname', label_trans: 'reg.surname' }),
AddCol({ name: 'email', label_trans: 'reg.email' }),
AddCol({ name: 'cell', label_trans: 'reg.cell' }),
AddCol({ name: 'profile.img', field: 'profile', subfield: 'img', label_trans: 'reg.img', sortable: false }),
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' }),
AddCol({ name: 'img', label_trans: 'reg.img', sortable: false }),
AddCol(DeleteRec),
AddCol({
name: 'copyrec',

View File

@@ -4,6 +4,9 @@ import { costanti } from './costanti'
import { toolsext } from './toolsext'
import { translation } from './translation'
import Quasar, { colors, date, Screen } from 'quasar'
import { scroll } from 'quasar'
const { getScrollTarget, setScrollPosition } = scroll
import {
IBookedEvent,
ICollaborations,
@@ -124,9 +127,22 @@ export const tools = {
date: 2,
string: 4,
binary: 8,
html: 16
html: 16,
select: 32,
number: 64,
typeinrec: 128,
},
FieldTypeArr: [
{ label: 'Boolean', value: 1 },
{ label: 'Date', value: 2 },
{ label: 'String', value: 4 },
{ label: 'Binary', value: 8 },
{ label: 'Html', value: 16 },
{ label: 'Select', value: 32 },
{ label: 'Number', value: 64 }
],
SelectListNumPeople: [
{
id: 1,
@@ -1430,7 +1446,7 @@ export const tools = {
},
showNeutralNotif(q: any, msg) {
tools.showNotif(q, msg, { color: 'warning', icon: 'notifications' })
tools.showNotif(q, msg, { color: 'info', icon: 'notifications' })
},
showNotif(q: any, msg, data ?: INotify | null
@@ -2567,17 +2583,33 @@ export const tools = {
return Cookies.remove(mytok)
},
notshowPwd(payload) {
const mypay = {...payload}
try{
const mypay = { ...payload }
try {
if (!!mypay.password) {
mypay.password = '**********'
}
}catch (e) {
} catch (e) {
console.log('error', e)
}
return mypay
},
scrollToTop() {
const element = document.getElementById('mypage')
this.scrollToElement(element)
},
scrollToElementId(myid) {
const element = document.getElementById(myid)
this.scrollToElement(element)
},
scrollToElement(el) {
const target = getScrollTarget(el)
const offset = el.offsetTop
const duration = 500
console.log('target', target, 'offset', offset, 'duration', duration)
setScrollPosition(target, offset, duration)
}
// getLocale() {
// if (navigator.languages && navigator.languages.length > 0) {
// return navigator.languages[0]