adjust conditions modal
This commit is contained in:
@@ -29,21 +29,38 @@
|
|||||||
>Available in Pro</a>
|
>Available in Pro</a>
|
||||||
</div>
|
</div>
|
||||||
<form @submit.prevent="validateSaveAndClose">
|
<form @submit.prevent="validateSaveAndClose">
|
||||||
<div class="my-4">
|
<div class="my-4 space-y-5">
|
||||||
<div class="space-y-4">
|
<div
|
||||||
|
v-for="(condition, cindex) in conditions"
|
||||||
|
:key="cindex"
|
||||||
|
class="space-y-4 relative"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="conditions.length > 1"
|
||||||
|
class="flex justify-between border-b mx-1 -mb-1 pb-1"
|
||||||
|
>
|
||||||
|
<span class="text-sm">
|
||||||
|
{{ t('condition') }} {{ cindex + 1 }}
|
||||||
|
</span>
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
class="link text-sm"
|
||||||
|
@click.prevent="conditions.splice(cindex, 1)"
|
||||||
|
> {{ t('remove') }}</a>
|
||||||
|
</div>
|
||||||
<select
|
<select
|
||||||
class="select select-bordered select-sm w-full bg-white h-11 pl-4 text-base font-normal"
|
class="select select-bordered select-sm w-full bg-white h-11 pl-4 text-base font-normal"
|
||||||
required
|
required
|
||||||
@change="[
|
@change="[
|
||||||
newCondition.field_uuid = $event.target.value,
|
condition.field_uuid = $event.target.value,
|
||||||
delete newCondition.value,
|
delete condition.value,
|
||||||
(conditionActions.includes(newCondition.action) ? '' : newCondition.action = conditionActions[0])
|
(conditionActions(condition).includes(condition.action) ? '' : condition.action = conditionActions(condition)[0])
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
value=""
|
value=""
|
||||||
disabled
|
disabled
|
||||||
:selected="!newCondition.field_uuid"
|
:selected="!condition.field_uuid"
|
||||||
>
|
>
|
||||||
{{ t('select_field_') }}
|
{{ t('select_field_') }}
|
||||||
</option>
|
</option>
|
||||||
@@ -51,19 +68,19 @@
|
|||||||
v-for="f in fields"
|
v-for="f in fields"
|
||||||
:key="f.uuid"
|
:key="f.uuid"
|
||||||
:value="f.uuid"
|
:value="f.uuid"
|
||||||
:selected="newCondition.field_uuid === f.uuid"
|
:selected="condition.field_uuid === f.uuid"
|
||||||
>
|
>
|
||||||
{{ f.name || buildDefaultName(f, template.fields) }}
|
{{ f.name || buildDefaultName(f, template.fields) }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<select
|
<select
|
||||||
v-model="newCondition.action"
|
v-model="condition.action"
|
||||||
class="select select-bordered select-sm w-full h-11 pl-4 text-base font-normal"
|
class="select select-bordered select-sm w-full h-11 pl-4 text-base font-normal"
|
||||||
:class="{ 'bg-white': newCondition.field_uuid, 'bg-base-300': !newCondition.field_uuid }"
|
:class="{ 'bg-white': condition.field_uuid, 'bg-base-300': !condition.field_uuid }"
|
||||||
:required="newCondition.field_uuid"
|
:required="condition.field_uuid"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
v-for="action in conditionActions"
|
v-for="action in conditionActions(condition)"
|
||||||
:key="action"
|
:key="action"
|
||||||
:value="action"
|
:value="action"
|
||||||
>
|
>
|
||||||
@@ -71,10 +88,10 @@
|
|||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<select
|
<select
|
||||||
v-if="conditionField?.options?.length"
|
v-if="conditionField(condition)?.options?.length"
|
||||||
class="select select-bordered select-sm w-full bg-white h-11 pl-4 text-base font-normal"
|
class="select select-bordered select-sm w-full bg-white h-11 pl-4 text-base font-normal"
|
||||||
required
|
required
|
||||||
@change="newCondition.value = $event.target.value"
|
@change="condition.value = $event.target.value"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
value=""
|
value=""
|
||||||
@@ -84,16 +101,21 @@
|
|||||||
{{ t('select_value_') }}
|
{{ t('select_value_') }}
|
||||||
</option>
|
</option>
|
||||||
<option
|
<option
|
||||||
v-for="(option, index) in conditionField.options"
|
v-for="(option, index) in conditionField(condition).options"
|
||||||
:key="option.uuid"
|
:key="option.uuid"
|
||||||
:value="option.uuid"
|
:value="option.uuid"
|
||||||
:selected="newCondition.value === option.uuid"
|
:selected="condition.value === option.uuid"
|
||||||
>
|
>
|
||||||
{{ option.value || `${t('option')} ${index + 1}` }}
|
{{ option.value || `${t('option')} ${index + 1}` }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
class="inline float-right link text-right mb-3 px-2"
|
||||||
|
@click.prevent="conditions.push({})"
|
||||||
|
> + {{ t('add_condition') }}</a>
|
||||||
<button
|
<button
|
||||||
class="base-button w-full mt-2"
|
class="base-button w-full mt-2"
|
||||||
>
|
>
|
||||||
@@ -106,7 +128,7 @@
|
|||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="link"
|
class="link"
|
||||||
@click="[newCondition.field_uuid = null, delete field.conditions, validateSaveAndClose()]"
|
@click="[conditions = [], delete field.conditions, validateSaveAndClose()]"
|
||||||
>
|
>
|
||||||
{{ t('remove_condition') }}
|
{{ t('remove_condition') }}
|
||||||
</button>
|
</button>
|
||||||
@@ -133,16 +155,10 @@ export default {
|
|||||||
emits: ['close'],
|
emits: ['close'],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
newCondition: this.field.conditions?.[0] || {}
|
conditions: this.field.conditions?.[0] ? JSON.parse(JSON.stringify(this.field.conditions)) : [{}]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
conditionField () {
|
|
||||||
return this.fields.find((f) => f.uuid === this.newCondition.field_uuid)
|
|
||||||
},
|
|
||||||
conditionActions () {
|
|
||||||
return this.fieldActions(this.conditionField)
|
|
||||||
},
|
|
||||||
fields () {
|
fields () {
|
||||||
return this.template.fields.reduce((acc, f) => {
|
return this.template.fields.reduce((acc, f) => {
|
||||||
if (f !== this.field && f.submitter_uuid === this.field.submitter_uuid) {
|
if (f !== this.field && f.submitter_uuid === this.field.submitter_uuid) {
|
||||||
@@ -157,6 +173,12 @@ export default {
|
|||||||
this.field.conditions ||= []
|
this.field.conditions ||= []
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
conditionField (condition) {
|
||||||
|
return this.fields.find((f) => f.uuid === condition.field_uuid)
|
||||||
|
},
|
||||||
|
conditionActions (condition) {
|
||||||
|
return this.fieldActions(this.conditionField(condition))
|
||||||
|
},
|
||||||
fieldActions (field) {
|
fieldActions (field) {
|
||||||
const actions = []
|
const actions = []
|
||||||
|
|
||||||
@@ -181,8 +203,8 @@ export default {
|
|||||||
return alert('Available only in Pro')
|
return alert('Available only in Pro')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.newCondition.field_uuid) {
|
if (this.conditions.find((f) => f.field_uuid)) {
|
||||||
this.field.conditions = [this.newCondition]
|
this.field.conditions = this.conditions
|
||||||
} else {
|
} else {
|
||||||
delete this.field.conditions
|
delete this.field.conditions
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const en = {
|
|||||||
select_field_: 'Select field...',
|
select_field_: 'Select field...',
|
||||||
select_value_: 'Select value...',
|
select_value_: 'Select value...',
|
||||||
remove_condition: 'Remove condition',
|
remove_condition: 'Remove condition',
|
||||||
|
add_condition: 'Add condition',
|
||||||
are_you_sure: 'Are you sure?',
|
are_you_sure: 'Are you sure?',
|
||||||
sign_yourself: 'Sign Yourself',
|
sign_yourself: 'Sign Yourself',
|
||||||
set_signing_date: 'Set signing date',
|
set_signing_date: 'Set signing date',
|
||||||
|
|||||||
Reference in New Issue
Block a user