Web Editor home made
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user