|
|
|
@ -2,7 +2,7 @@
|
|
|
|
|
<div class="d-flex d-100 chips-wrapper" :class="{active}"> |
|
|
|
|
<template v-if="!isForm"> |
|
|
|
|
<div class="chips d-flex align-center img-container flex-grow-1 hm-items"> |
|
|
|
|
<template v-if="value||localState"> |
|
|
|
|
<template v-if="value|| localState"> |
|
|
|
|
<item-chip |
|
|
|
|
v-for="(ch,i) in (value|| localState)" |
|
|
|
|
:key="i" |
|
|
|
@ -54,7 +54,16 @@
|
|
|
|
|
:parent-meta="meta" |
|
|
|
|
:query-params="{ |
|
|
|
|
...childQueryParams, |
|
|
|
|
where: isNew ? null :`~not(${childForeignKey},eq,${parentId})~or(${childForeignKey},is,null)`, |
|
|
|
|
// check if it needs to bypass to |
|
|
|
|
// avoid foreign key constraint violation in real relation |
|
|
|
|
isByPass, |
|
|
|
|
where: |
|
|
|
|
// show all for new record |
|
|
|
|
isNew ? null : |
|
|
|
|
// filter out those selected items |
|
|
|
|
`~not(${childForeignKey},eq,${parentId})` + |
|
|
|
|
// allow the child with empty key |
|
|
|
|
'~or(' + childForeignKey + ',is,null)' |
|
|
|
|
}" |
|
|
|
|
:is-public="isPublic" |
|
|
|
|
:password="password" |
|
|
|
@ -142,7 +151,7 @@ import Pagination from '@/components/project/spreadsheet/components/pagination'
|
|
|
|
|
import ListItems from '@/components/project/spreadsheet/components/virtualCell/components/listItems' |
|
|
|
|
import ListChildItems from '@/components/project/spreadsheet/components/virtualCell/components/listChildItems' |
|
|
|
|
import listChildItemsModal |
|
|
|
|
from '@/components/project/spreadsheet/components/virtualCell/components/listChildItemsModal' |
|
|
|
|
from '@/components/project/spreadsheet/components/virtualCell/components/listChildItemsModal' |
|
|
|
|
import { parseIfInteger } from '@/helpers' |
|
|
|
|
import ItemChip from '~/components/project/spreadsheet/components/virtualCell/components/itemChip' |
|
|
|
|
|
|
|
|
@ -221,6 +230,23 @@ export default {
|
|
|
|
|
childForeignKey() { |
|
|
|
|
return this.childMeta && (this.childMeta.columns.find(c => c.cn === this.hm.cn) || {})._cn |
|
|
|
|
}, |
|
|
|
|
childForeignKeyVal() { |
|
|
|
|
return this.meta && this.meta.columns ? this.meta.columns.filter(c => c._cn === this.childForeignKey).map(c => this.row[c._cn] || '').join('___') : '' |
|
|
|
|
}, |
|
|
|
|
isVirtualRelation() { |
|
|
|
|
return (this.childMeta && (!!this.childMeta.columns.find(c => c.cn === this.hm.cn && this.hm.type === 'virtual'))) || false |
|
|
|
|
}, |
|
|
|
|
isByPass() { |
|
|
|
|
if (this.isVirtualRelation) { |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
// if child fk references a column in parent which is not pk, |
|
|
|
|
// then this column has to be filled |
|
|
|
|
if (((this.meta && this.meta.columns.find(c => !c.pk && c.cn === this.hm.rcn)) || false)) { |
|
|
|
|
return this.childForeignKeyVal === '' |
|
|
|
|
} |
|
|
|
|
return false |
|
|
|
|
}, |
|
|
|
|
disabledChildColumns() { |
|
|
|
|
return { [this.childForeignKey]: true } |
|
|
|
|
}, |
|
|
|
@ -251,7 +277,9 @@ export default {
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
parentId() { |
|
|
|
|
return this.meta && this.meta.columns ? this.meta.columns.filter(c => c.pk).map(c => this.row[c._cn]).join('___') : '' |
|
|
|
|
return (this.meta && this.meta.columns && |
|
|
|
|
(this.meta.columns.filter(c => c._cn === this.childForeignKey).map(c => this.row[c._cn] || '').join('___') || |
|
|
|
|
this.meta.columns.filter(c => c.pk).map(c => this.row[c._cn]).join('___'))) || '' |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
@ -358,7 +386,6 @@ export default {
|
|
|
|
|
const id = this.childMeta.columns.filter(c => c.pk).map(c => child[c._cn]).join('___') |
|
|
|
|
const _cn = this.childForeignKey |
|
|
|
|
this.newRecordModal = false |
|
|
|
|
|
|
|
|
|
await this.childApi.update(id, { |
|
|
|
|
[_cn]: parseIfInteger(this.parentId) |
|
|
|
|
}, { |
|
|
|
@ -367,7 +394,7 @@ export default {
|
|
|
|
|
|
|
|
|
|
this.$emit('loadTableData') |
|
|
|
|
if ((this.childListModal || this.isForm) && this.$refs.childList) { |
|
|
|
|
this.$refs.childList.loadData() |
|
|
|
|
await this.$refs.childList.loadData() |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
async editChild(child) { |
|
|
|
@ -496,6 +523,7 @@ export default {
|
|
|
|
|
* |
|
|
|
|
* @author Naveen MR <oof1lab@gmail.com> |
|
|
|
|
* @author Pranav C Balan <pranavxc@gmail.com> |
|
|
|
|
* @author Wing-Kam Wong <wingkwong.code@gmail.com> |
|
|
|
|
* |
|
|
|
|
* @license GNU AGPL version 3 or any later version |
|
|
|
|
* |
|
|
|
|