Commit 8d436c34 authored by janis.streib's avatar janis.streib 🦉
Browse files

FMT + FIX: handle lazy-open in db-editor

parent e17ea212
Pipeline #112531 passed with stages
in 8 minutes and 30 seconds
<template>
<b-modal v-if="object_definition != null" @ok="commit()" cancel-variant="outline-secondary" cancel-title="Abbrechen"
:ok-title="function2text(object_function)"
:ok-variant="function2variant(object_function)" size="lg" scrollable :busy="object_definition == null"
:id="modal_id"
:title="object_definition.name.replace(/^\w/, c => c.toUpperCase()) + ' ' + function2text(object_function)"
:static="false">
<form :id="modal_id + '-dbeditform'" v-if="object_definition != null">
<template v-if="!non_optionals_order">
<template v-for="(data,attr) in object_functions[object_function].parameters">
<DataEditField :object_attribute="data" :attribute_preset="presets[attr]"
:attribute_reference_name="object_definition_reference_names_by_attribute[attr]"
:attribute_referencing="object_definition_referencing_by_attribute[attr]"
:attribute_name="attr"
:input_reducer="input_reducer[attr]"
v-bind:key="attr"
v-if="data.new.isRequired || non_optionals.includes(attr)"></DataEditField>
</template>
<template>
<b-link v-b-toggle.collapse-optional>Optionale Parameter</b-link>
<b-collapse id="collapse-optional">
<hr/>
<template v-for="(data,attr) in object_functions[object_function].parameters">
<DataEditField :object_attribute="data" :attribute_preset="presets[attr]"
:attribute_reference_name="object_definition_reference_names_by_attribute[attr]"
:attribute_referencing="object_definition_referencing_by_attribute[attr]"
:attribute_name="attr"
:input_reducer="input_reducer[attr]"
v-bind:key="attr"
v-if="!data.new.isRequired && !non_optionals.includes(attr)"></DataEditField>
</template>
<b-modal v-if="object_definition != null" @ok="commit()" cancel-variant="outline-secondary" cancel-title="Abbrechen"
:ok-title="function2text(object_function)"
:ok-variant="function2variant(object_function)" size="lg" scrollable :busy="object_definition == null"
:id="modal_id"
:title="object_definition.name.replace(/^\w/, c => c.toUpperCase()) + ' ' + function2text(object_function)"
:static="false"
@show="shown">
<form :id="modal_id + '-dbeditform'" v-if="object_definition != null">
<template v-if="!non_optionals_order">
<template v-for="(data,attr) in object_functions[object_function].parameters">
<DataEditField :object_attribute="data" :attribute_preset="presets[attr]"
:attribute_reference_name="object_definition_reference_names_by_attribute[attr]"
:attribute_referencing="object_definition_referencing_by_attribute[attr]"
:attribute_name="attr"
:input_reducer="input_reducer[attr]"
v-bind:key="attr"
v-if="data.new.isRequired || non_optionals.includes(attr)"></DataEditField>
</template>
<template>
<b-link v-b-toggle.collapse-optional>Optionale Parameter</b-link>
<b-collapse id="collapse-optional">
<hr/>
<template v-for="(data,attr) in object_functions[object_function].parameters">
<DataEditField :object_attribute="data" :attribute_preset="presets[attr]"
:attribute_reference_name="object_definition_reference_names_by_attribute[attr]"
:attribute_referencing="object_definition_referencing_by_attribute[attr]"
:attribute_name="attr"
:input_reducer="input_reducer[attr]"
v-bind:key="attr"
v-if="!data.new.isRequired && !non_optionals.includes(attr)"></DataEditField>
</template>
</b-collapse>
</template>
</template>
<template v-else>
<template v-for="attr in non_optionals_order">
<DataEditField :object_attribute="object_functions[object_function].parameters[attr]"
:attribute_preset="presets[attr]"
:attribute_reference_name="object_definition_reference_names_by_attribute[attr]"
:attribute_referencing="object_definition_referencing_by_attribute[attr]"
:attribute_name="attr"
:input_reducer="input_reducer[attr]"
v-bind:key="attr"></DataEditField>
</b-collapse>
</template>
</template>
<template>
<b-link v-b-toggle.collapse-optional>Optionale Parameter</b-link>
<b-collapse id="collapse-optional">
<hr/>
<template v-for="(data,attr) in object_functions[object_function].parameters">
<DataEditField :object_attribute="data" :attribute_preset="presets[attr]"
:attribute_reference_name="object_definition_reference_names_by_attribute[attr]"
:attribute_referencing="object_definition_referencing_by_attribute[attr]"
:attribute_name="attr"
:input_reducer="input_reducer[attr]"
v-bind:key="attr"
v-if="!non_optionals_order.includes(attr)"></DataEditField>
</template>
<template v-else>
<template v-for="attr in non_optionals_order">
<DataEditField :object_attribute="object_functions[object_function].parameters[attr]"
:attribute_preset="presets[attr]"
:attribute_reference_name="object_definition_reference_names_by_attribute[attr]"
:attribute_referencing="object_definition_referencing_by_attribute[attr]"
:attribute_name="attr"
:input_reducer="input_reducer[attr]"
v-bind:key="attr"></DataEditField>
</template>
<template>
<b-link v-b-toggle.collapse-optional>Optionale Parameter</b-link>
<b-collapse id="collapse-optional">
<hr/>
<template v-for="(data,attr) in object_functions[object_function].parameters">
<DataEditField :object_attribute="data" :attribute_preset="presets[attr]"
:attribute_reference_name="object_definition_reference_names_by_attribute[attr]"
:attribute_referencing="object_definition_referencing_by_attribute[attr]"
:attribute_name="attr"
:input_reducer="input_reducer[attr]"
v-bind:key="attr"
v-if="!non_optionals_order.includes(attr)"></DataEditField>
</template>
</b-collapse>
</b-collapse>
</template>
</template>
</template>
</form>
</b-modal>
</form>
</b-modal>
</template>
<script>
......@@ -70,24 +71,38 @@ import FunctionService from '@/api-services.gen/wapi.function'
import ApiUtil from '@/util/apiutil'
import DataEditField from './DataEditField'
import TransactionUtil from '@/util/transactionutil'
import { v4 as uuidv4 } from 'uuid'
import {v4 as uuidv4} from 'uuid'
export default {
name: 'DBEditor',
components: { DataEditField },
data () {
components: {DataEditField},
data() {
return {
should_open: false,
object_definition: null,
object_definition_referencing_by_attribute: null,
object_definition_reference_names_by_attribute: null,
object_functions: null
}
},
mounted() {
const self = this
this.$root.$on('bv::show::modal', (ev) => {
if (ev === this.modal_id) {
self.should_open = true
}
})
},
methods: {
commit () {
shown() {
if (this.should_open) {
this.should_open = false
}
},
commit() {
const form = new FormData(document.getElementById(this.modal_id + '-dbeditform'))
const elems = form.entries()
const ta = { object_fq_name: this.object_fq_name, object_function: this.object_function }
const ta = {object_fq_name: this.object_fq_name, object_function: this.object_function}
const new_params = {}
for (const e of elems) {
new_params[e[0]] = e[1]
......@@ -128,7 +143,7 @@ export default {
this.$store.state.show_sidebar = true
}
},
async validateObjectFQName () {
async validateObjectFQName() {
const parts = this.object_fq_name.split('.')
const system = parts[0]
const name = parts[1]
......@@ -157,7 +172,7 @@ export default {
},
function2variant: TransactionUtil.function2variant,
function2text: TransactionUtil.function2text,
async validateObjectFunction () {
async validateObjectFunction() {
// TODO
}
},
......@@ -172,26 +187,26 @@ export default {
},
presets: {
type: Object,
default () {
default() {
return {}
}
},
input_reducer: {
type: Object,
default () {
default() {
return {}
}
},
old_data: {
required: false,
default () {
default() {
return {}
},
type: Object
},
non_optionals: {
required: false,
default () {
default() {
return []
},
type: Array
......@@ -203,20 +218,20 @@ export default {
old_uuid: {
required: false,
type: String,
default () {
default() {
return null
}
},
preview_fields: {
required: false,
type: Array,
default () {
default() {
return null
}
},
object_title: {
required: false,
default () {
default() {
return null
}
}
......@@ -225,8 +240,7 @@ export default {
$props: {
immediate: true,
deep: true,
async handler () {
window.console.debug('Watch update')
async handler() {
if (this.object_fq_name == null || (this.object_definition != null && this.object_fq_name === this.object_definition.fq_name)) {
window.console.debug('Skip object_fq_name check')
return
......@@ -247,6 +261,9 @@ export default {
}
this.object_functions = data.object_functions
this.$emit('ready')
if (this.should_open) {
this.$root.$nextTick(() => this.$root.$emit('bv::show::modal', this.modal_id))
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment