Web Editor home made

This commit is contained in:
Surya Paolo
2022-11-17 08:10:43 +01:00
parent 711f1b515d
commit 495abc33be
77 changed files with 1742 additions and 1771 deletions

View File

@@ -13,6 +13,7 @@ import { CMySelect } from '../CMySelect'
import { CCurrencyValue } from '../CCurrencyValue'
import { CMyEditor } from '../CMyEditor'
import { CGallery } from '../CGallery'
import { CSelectImage } from '../CSelectImage'
import { CAccomodation } from '../CAccomodation'
import { tools } from '@store/Modules/tools'
import { costanti } from '@costanti'
@@ -46,13 +47,18 @@ export default defineComponent({
required: false,
default: null,
},
fielddb: {
type: Boolean,
required: false,
default: false,
},
isrec: {
type: Boolean,
required: false,
default: false,
},
mycol: {
type: Object as PropType<IColGridTable>,
type: Object as PropType<IColGridTable | undefined>,
required: true,
},
canEdit: {
@@ -185,9 +191,19 @@ export default defineComponent({
required: false,
default: false,
},
nosaveToDb: {
type: Boolean,
required: false,
default: false,
},
path: {
type: String,
required: false,
default: '',
},
},
components: { CMyChipList, CDateTime, CDate, CMyToggleList, CMySelect, CMyEditor, CGallery,
CCurrencyValue, CLabel, CAccomodation },
CCurrencyValue, CLabel, CAccomodation, CSelectImage },
setup(props, { emit }) {
const $q = useQuasar()
const { t } = useI18n()
@@ -203,14 +219,14 @@ export default defineComponent({
const myImgGall = ref([{}] as IImgGallery[])
const col = ref({
const col = ref(<IColGridTable>{
name: 'test',
fieldtype: 0,
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InEdit + costanti.showWhen.InView,
visible: true,
maxlength: props.mycol ? props.mycol.maxlength : 0,
minlength: props.mycol ? props.mycol.minlength : undefined
} as IColGridTable)
})
const { setValDb, getValDb } = MixinBase()
const { getMyUsername } = MixinUsers()
@@ -227,42 +243,42 @@ export default defineComponent({
})
function crea() {
// console.log('crea', isFieldDb())
// console.log('crea', isFieldDb(), 'props.mycol', props.mycol)
if (props.mycol && props.mycol.name) {
col.value = props.mycol
} else {
col.value.jointable = props.jointable
if (props.filter)
col.value.filter = props.filter
col.value.fieldtype = props.type
col.value.label = props.title
if (props.type === costanti.FieldType.image) {
myImgGall.value = [{
_id: '',
imagefile: myvalue.value,
// order: 1,
alt: 'img',
}]
} else if (props.type === costanti.FieldType.imgcard) {
myImgGall.value = [myvalue.value]
}
console.log('* col', col.value);
}
if (props.type) {
col.value.fieldtype = props.type
}
if (props.isrec) {
col.value = props.mycol
} else {
if (isFieldDb()) {
// mykey -> field
// mysubkey -> subfield
// table -> table
// serv -> serv
// id -> id
// idmain -> idmain
// console.table(props)
myvalue.value = getValDb(props.field, props.serv, '', props.table, props.subfield, props.id, props.idmain, props.indrec, props.mysubsubkey, props.specialField)
// console.log('myvalue.value', myvalue.value)
col.value.jointable = props.jointable
if (props.filter)
col.value.filter = props.filter
col.value.fieldtype = props.type
col.value.label = props.title
if (props.type === costanti.FieldType.image) {
myImgGall.value = [{
_id: '',
imagefile: myvalue.value,
// order: 1,
alt: 'img',
}]
}
// console.log('col', col.value);
} else {
col.value = { ...props.mycol }
if (props.mycol && props.mycol.name)
col.value = { ...props.mycol }
}
}
@@ -275,7 +291,8 @@ export default defineComponent({
function isFieldDb() {
return props.type !== 0
// return props.type !== 0
return props.fielddb
}
function isviewfield() {
@@ -404,6 +421,8 @@ export default defineComponent({
// console.log('myvalue.value', myvalue.value)
myvalueprec.value = myvalue.value
crea()
// console.log('myvalueprec', myvalueprec)
}
@@ -510,6 +529,9 @@ export default defineComponent({
if (col.value.fieldtype === costanti.FieldType.image) {
console.log('newVal.imagefile', newVal)
myvalue.value = newVal
} else if (col.value.fieldtype === costanti.FieldType.imgcard) {
console.log('newVal.imagefile', newVal)
myvalue.value = newVal
}
if (col.value.fieldtype === costanti.FieldType.listobj) {
@@ -660,52 +682,6 @@ export default defineComponent({
}
}
function getTitleGall() {
if (fieldsTable.tableForUsers.includes(props.table)) {
return 'Profilo'
} else {
return fieldsTable.getTitleImgByTable(props.table)
}
}
function getDirectoryGall() {
console.log('getDirectoryGall', myrow.value)
let ris = ''
try {
let username = myrow.value.hasOwnProperty('username') ? myrow.value['username'] : ''
const userId = myrow.value.hasOwnProperty('userId') ? myrow.value['userId'] : ''
if (username === '') {
if (userId === userStore.my._id)
username = userStore.my.username
}
if (username === '') {
username = userStore.my.username
}
if (fieldsTable.tableForUsers.includes(props.table)) {
ris = 'profile/' + username + '/' + props.table
} else if (props.table === 'users') {
ris = 'profile/' + userStore.my.username
} else if (props.table === 'mygroups') {
if (myrow.value.hasOwnProperty('groupname'))
ris = 'mygroups/' + myrow.value['groupname']
} else if (props.table === 'circuits') {
if (myrow.value.hasOwnProperty('path'))
ris = 'circuits/' + myrow.value['path']
} else if (!!myrow.value && !!myrow.value.directory) {
ris = myrow.value.directory
} else if (props.table === 'myelems') {
ris = 'pages/' + myrow.value.path
} else {
ris = props.table
}
} catch (e) {
console.error('err getDirectoryGall', e)
}
console.log('getDirectoryGall', ris)
return ris
}
function uploaded(info: any) {
@@ -726,6 +702,7 @@ export default defineComponent({
function noPopupeditByCol(mycol: IColGridTable) {
return (mycol.fieldtype !== costanti.FieldType.html
&& mycol.fieldtype !== costanti.FieldType.image
&& mycol.fieldtype !== costanti.FieldType.imgcard
&& mycol.fieldtype !== costanti.FieldType.listimages
&& mycol.fieldtype !== costanti.FieldType.listobj
&& mycol.fieldtype !== costanti.FieldType.number
@@ -749,7 +726,7 @@ export default defineComponent({
onBeforeMount(mounted)
crea()
return {
myvalue,
@@ -778,8 +755,6 @@ export default defineComponent({
onInput,
globalStore,
userStore,
getTitleGall,
getDirectoryGall,
removephoto,
isFieldDb,
col,

View File

@@ -79,6 +79,7 @@
<q-input
v-bind="$attrs"
v-model="myvalue"
:autogrow="col.fieldtype !== costanti.FieldType.crypted"
:style="$q.screen.lt.sm ? 'min-width: 300px' : ''"
counter
@@ -173,8 +174,8 @@
<div v-else-if="col.fieldtype === costanti.FieldType.listimages" style="text-align: center;">
<CGallery
:imagebak="col.showpicprofile_ifnotset ? ((userStore.getImgByProfile(row, true) === '') ? costanti.NESSUN_IMMAGINE : userStore.getImgByProfile(row, true)) : ''"
:title="getTitleGall()"
:directory="getDirectoryGall()"
:title="tools.getTitleGall()"
:directory="tools.getDirectoryGall(myrow, table, path)"
:imgGall="myvalue"
:isInModif="isInModif"
:edit="isviewfield() && isInModif"
@@ -196,13 +197,13 @@
{{ $t('reg.photo') }}
<CGallery
:imagebak="col.showpicprofile_ifnotset ? userStore.getImgByProfile(row['profile'], true) : ''"
:title="getTitleGall()"
:directory="getDirectoryGall()"
:title="tools.getTitleGall()"
:directory="tools.getDirectoryGall()"
:imgGall="[{ imagefile: myvalue }]"
:edit="isviewfield()"
:canModify="canModify"
:isInModif="isInModif"
:single="isFieldDb()"
:single="true"
@update:imgGall="changevalRec"
@showandsave="Savedb">
</CGallery>
@@ -232,6 +233,47 @@
</div>
</div>
<div v-else-if="col.fieldtype === costanti.FieldType.imgcard">
<div v-if="canEdit">
{{ $t('reg.photo') }}
<CSelectImage
v-bind="$attrs"
:imagebak="col.showpicprofile_ifnotset ? userStore.getImgByProfile(row['profile'], true) : ''"
:title="tools.getTitleGall()"
:directory="tools.getDirectoryGall()"
:imgGall="[myvalue]"
:edit="isviewfield()"
:canModify="canModify"
:isInModif="isInModif"
@update:imgGall="changevalRec"
@showandsave="Savedb">
</CSelectImage>
</div>
<div v-else>
<div v-if="myvalue" class="text-center">
<q-img
:src="myvalue"
class="text-center"
style="height: 100px; width: 100px;"
alt="foto">
</q-img>
</div>
<div v-else class="text-center">
<q-img
:src="col.showpicprofile_ifnotset ? userStore.getImgByProfile(row['profile'], true) : 'images/noimg-user.svg'"
class="text-center"
style="height: 100px; width: 100px;"
alt="nessuna immagine">
</q-img>
</div>
<q-btn
v-if="myvalue"
label="Rimuovi Foto"
color="blue" icon="fas fa-trash-alt" size="sm"
@click="removephoto"></q-btn>
</div>
</div>
<div v-else-if="col.fieldtype === costanti.FieldType.nationality">
<div v-if="isInModif" class="justify-center q-gutter-sm clgutter q-mt-sm">
<CMySelect
@@ -604,6 +646,7 @@
<div v-else>
<span v-html="visuValByType(myvalue, col, row)"></span>
</div>
<q-popup-edit
v-if="(!isInModif && canEdit && noPopupeditByCol(col))"
v-model="myvalue"