Browse Source

wip(gui-v2): reload after adding a new column

pull/3030/head
Wing-Kam Wong 2 years ago
parent
commit
0287974188
  1. 19
      packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue
  2. 11
      packages/nc-gui-v2/components/smartsheet/Form.vue

19
packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue

@ -6,7 +6,7 @@ import { uiTypes } from '~/utils/columnUtils'
import MdiPlusIcon from '~icons/mdi/plus-circle-outline' import MdiPlusIcon from '~icons/mdi/plus-circle-outline'
import MdiMinusIcon from '~icons/mdi/minus-circle-outline' import MdiMinusIcon from '~icons/mdi/minus-circle-outline'
const emit = defineEmits(['cancel']) const emit = defineEmits(['cancel', 'submit'])
const meta = inject(MetaInj) const meta = inject(MetaInj)
const advancedOptions = ref(false) const advancedOptions = ref(false)
const { getMeta } = useMetas() const { getMeta } = useMetas()
@ -39,9 +39,20 @@ const uiTypesOptions = computed<typeof uiTypes>(() => {
] ]
}) })
const reloadMeta = () => { const reloadMeta = async () => {
// FIXME: this not working
console.log('HEREEEE')
emit('cancel') emit('cancel')
getMeta(meta?.value.id as string, true) await getMeta(meta?.value.id as string, true)
}
async function handleSubmit() {
// FIXME: await addOrUpdate(reloadMeta)
await addOrUpdate()
await reloadMeta()
// FIXME: emit fails
emit('submit')
advancedOptions.value = false
} }
// create column meta if it's a new column // create column meta if it's a new column
@ -125,7 +136,7 @@ watchEffect(() => {
<!-- Cancel --> <!-- Cancel -->
{{ $t('general.cancel') }} {{ $t('general.cancel') }}
</a-button> </a-button>
<a-button html-type="submit" type="primary" size="small" @click="addOrUpdate(reloadMeta), (advancedOptions = false)"> <a-button html-type="submit" type="primary" size="small" @click="handleSubmit">
<!-- Save --> <!-- Save -->
{{ $t('general.save') }} {{ $t('general.save') }}
</a-button> </a-button>

11
packages/nc-gui-v2/components/smartsheet/Form.vue

@ -266,6 +266,12 @@ function onEmailChange() {
checkSMTPStatus() checkSMTPStatus()
} }
async function submitCallback() {
await loadFormView()
setFormData()
showColumnDropdown.value = false
}
const updateColMeta = useDebounceFn(async (col: Record<string, any>) => { const updateColMeta = useDebounceFn(async (col: Record<string, any>) => {
if (col.id) { if (col.id) {
try { try {
@ -387,12 +393,13 @@ onMounted(async () => {
{{ $t('activity.addField') }} {{ $t('activity.addField') }}
</div> </div>
</a-button> </a-button>
<!-- TODO #2: make the component out of sidebar --> <!-- TODO #1: make the component out of sidebar -->
<!-- TODO #3: reload view --> <!-- TODO #2: reload view -->
<SmartsheetColumnEditOrAdd <SmartsheetColumnEditOrAdd
v-if="showColumnDropdown" v-if="showColumnDropdown"
ref="editOrAddRef" ref="editOrAddRef"
@click.stop @click.stop
@submit="submitCallback"
@cancel="showColumnDropdown = false" @cancel="showColumnDropdown = false"
/> />
</template> </template>

Loading…
Cancel
Save