fix custom fields
This commit is contained in:
parent
01395a2726
commit
5d6e6f9441
|
@ -0,0 +1,24 @@
|
|||
# Generated by Django 3.1.7 on 2021-03-29 10:50
|
||||
|
||||
import django.contrib.postgres.fields
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0016_auto_20210319_1536'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='customfield',
|
||||
name='checkbox_value',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='customfield',
|
||||
name='default_values_multiple',
|
||||
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, max_length=255, null=True), blank=True, default=list, null=True, size=None),
|
||||
),
|
||||
]
|
|
@ -244,6 +244,13 @@ class CustomField(models.Model):
|
|||
name = models.TextField(null=True, blank=True)
|
||||
default_value = models.TextField(null=True, blank=True)
|
||||
required = models.BooleanField(blank=True, default=False)
|
||||
checkbox_value = models.BooleanField(default=False)
|
||||
default_values_multiple = ArrayField(
|
||||
models.CharField(max_length=255, null=True, blank=True),
|
||||
null=True,
|
||||
blank=True,
|
||||
default=list,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
unique_together = (("model", "name"),)
|
||||
|
|
|
@ -49,6 +49,10 @@
|
|||
hide-dropdown-icon
|
||||
input-debounce="0"
|
||||
new-value-mode="add"
|
||||
@input="
|
||||
localField.default_value = '';
|
||||
localField.default_values_multiple = [];
|
||||
"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
|
@ -87,23 +91,35 @@
|
|||
<q-toggle
|
||||
v-else-if="localField.type == 'checkbox'"
|
||||
label="Default Value"
|
||||
v-model="localField.default_value"
|
||||
v-model="localField.checkbox_value"
|
||||
color="green"
|
||||
/>
|
||||
|
||||
<!-- For dropdowns -->
|
||||
<!-- Dropdown Single -->
|
||||
<q-select
|
||||
v-else-if="localField.type === 'single' || localField.type === 'multiple'"
|
||||
v-else-if="localField.type === 'single'"
|
||||
label="Default Value"
|
||||
:options="localField.options"
|
||||
outlined
|
||||
dense
|
||||
:multiple="localField.type === 'multiple'"
|
||||
v-model="localField.default_value"
|
||||
:rules="[...defaultValueRules]"
|
||||
reactive-rules
|
||||
/>
|
||||
|
||||
<!-- Dropdown Multiple -->
|
||||
<q-select
|
||||
v-else-if="localField.type === 'multiple'"
|
||||
label="Default Value(s)"
|
||||
:options="localField.options"
|
||||
outlined
|
||||
dense
|
||||
multiple
|
||||
v-model="localField.default_values_multiple"
|
||||
:rules="[...defaultValueRules]"
|
||||
reactive-rules
|
||||
/>
|
||||
|
||||
<!-- For everything else -->
|
||||
<q-input
|
||||
v-else
|
||||
|
@ -149,6 +165,8 @@ export default {
|
|||
options: [],
|
||||
default_value: "",
|
||||
required: false,
|
||||
checkbox_value: false,
|
||||
default_values_multiple: [],
|
||||
},
|
||||
modelOptions: [
|
||||
{ label: "Client", value: "client" },
|
||||
|
@ -182,6 +200,8 @@ export default {
|
|||
submit() {
|
||||
this.$q.loading.show();
|
||||
|
||||
if (this.localField.type === "multiple") delete this.localField.default_value;
|
||||
|
||||
let data = {
|
||||
...this.localField,
|
||||
};
|
||||
|
|
|
@ -51,7 +51,13 @@
|
|||
{{ props.row.type }}
|
||||
</q-td>
|
||||
<!-- default value -->
|
||||
<q-td>
|
||||
<q-td v-if="props.row.type === 'checkbox'">
|
||||
{{ props.row.checkbox_value }}
|
||||
</q-td>
|
||||
<q-td v-else-if="props.row.type === 'multiple'">
|
||||
{{ props.row.default_values_multiple }}
|
||||
</q-td>
|
||||
<q-td v-else>
|
||||
{{ props.row.default_value }}
|
||||
</q-td>
|
||||
<!-- required -->
|
||||
|
@ -65,7 +71,7 @@
|
|||
|
||||
<script>
|
||||
import CustomFieldsForm from "@/components/modals/coresettings/CustomFieldsForm";
|
||||
import mixins from "@/mixins/mixins"
|
||||
import mixins from "@/mixins/mixins";
|
||||
|
||||
export default {
|
||||
name: "CustomFieldsTable",
|
||||
|
@ -88,7 +94,14 @@ export default {
|
|||
align: "left",
|
||||
sortable: true,
|
||||
},
|
||||
{ name: "type", label: "Field Type", field: "type", align: "left", sortable: true, format: (string => this.capitalize(string)) },
|
||||
{
|
||||
name: "type",
|
||||
label: "Field Type",
|
||||
field: "type",
|
||||
align: "left",
|
||||
sortable: true,
|
||||
format: string => this.capitalize(string),
|
||||
},
|
||||
{ name: "default_value", label: "Default Value", field: "default_value", align: "left", sortable: true },
|
||||
{ name: "required", label: "Required", field: "required", align: "left", sortable: true },
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue