Lines 9-33
Link Here
|
9 |
<template v-for="available_field in available_fields"> |
9 |
<template v-for="available_field in available_fields"> |
10 |
<template |
10 |
<template |
11 |
v-if=" |
11 |
v-if=" |
12 |
available_field.authorised_value_category && |
12 |
available_field.authorised_value_category_name && |
13 |
!available_field.repeatable |
13 |
!available_field.repeatable |
14 |
" |
14 |
" |
15 |
> |
15 |
> |
16 |
<li> |
16 |
<li> |
17 |
<label :for="`additional_field_` + available_field.id" |
17 |
<label |
|
|
18 |
:for=" |
19 |
`additional_field_` + |
20 |
available_field.additional_field_id |
21 |
" |
18 |
>{{ available_field.name }}: |
22 |
>{{ available_field.name }}: |
19 |
</label> |
23 |
</label> |
20 |
<v-select |
24 |
<v-select |
21 |
:id="`additional_field_` + available_field.id" |
25 |
:id=" |
|
|
26 |
`additional_field_` + |
27 |
available_field.additional_field_id |
28 |
" |
22 |
:name="available_field.name" |
29 |
:name="available_field.name" |
23 |
v-model=" |
30 |
v-model=" |
24 |
current_additional_fields_values[ |
31 |
current_additional_fields_values[ |
25 |
available_field.id |
32 |
available_field.additional_field_id |
26 |
] |
33 |
] |
27 |
" |
34 |
" |
28 |
:options=" |
35 |
:options=" |
29 |
av_options[ |
36 |
av_options[ |
30 |
available_field.authorised_value_category |
37 |
available_field |
|
|
38 |
.authorised_value_category_name |
31 |
] |
39 |
] |
32 |
" |
40 |
" |
33 |
/> |
41 |
/> |
Lines 35-73
Link Here
|
35 |
</template> |
43 |
</template> |
36 |
<template |
44 |
<template |
37 |
v-if=" |
45 |
v-if=" |
38 |
available_field.authorised_value_category && |
46 |
available_field.authorised_value_category_name && |
39 |
available_field.repeatable |
47 |
available_field.repeatable |
40 |
" |
48 |
" |
41 |
> |
49 |
> |
42 |
<li> |
50 |
<li> |
43 |
<label :for="`additional_field_` + available_field.id" |
51 |
<label |
|
|
52 |
:for=" |
53 |
`additional_field_` + |
54 |
available_field.additional_field_id |
55 |
" |
44 |
>{{ available_field.name }}: |
56 |
>{{ available_field.name }}: |
45 |
</label> |
57 |
</label> |
46 |
<v-select |
58 |
<v-select |
47 |
:id="`additional_field_` + available_field.id" |
59 |
:id=" |
|
|
60 |
`additional_field_` + |
61 |
available_field.additional_field_id |
62 |
" |
48 |
:name="available_field.name" |
63 |
:name="available_field.name" |
49 |
:multiple="available_field.repeatable" |
64 |
:multiple="available_field.repeatable" |
50 |
v-model=" |
65 |
v-model=" |
51 |
current_additional_fields_values[ |
66 |
current_additional_fields_values[ |
52 |
available_field.id |
67 |
available_field.additional_field_id |
53 |
] |
68 |
] |
54 |
" |
69 |
" |
55 |
:options=" |
70 |
:options=" |
56 |
av_options[ |
71 |
av_options[ |
57 |
available_field.authorised_value_category |
72 |
available_field |
|
|
73 |
.authorised_value_category_name |
58 |
] |
74 |
] |
59 |
" |
75 |
" |
60 |
/> |
76 |
/> |
61 |
</li> |
77 |
</li> |
62 |
</template> |
78 |
</template> |
63 |
|
79 |
|
64 |
<template v-if="!available_field.authorised_value_category"> |
80 |
<template |
|
|
81 |
v-if="!available_field.authorised_value_category_name" |
82 |
> |
65 |
<li |
83 |
<li |
66 |
v-for="current in current_additional_fields_values[ |
84 |
v-for="current in current_additional_fields_values[ |
67 |
available_field.id |
85 |
available_field.additional_field_id |
68 |
]" |
86 |
]" |
69 |
> |
87 |
> |
70 |
<label :for="`additional_field_` + available_field.id" |
88 |
<label |
|
|
89 |
:for=" |
90 |
`additional_field_` + |
91 |
available_field.additional_field_id |
92 |
" |
71 |
>{{ available_field.name }}: |
93 |
>{{ available_field.name }}: |
72 |
</label> |
94 |
</label> |
73 |
<input type="text" v-model="current.value" /> |
95 |
<input type="text" v-model="current.value" /> |
Lines 133-139
export default {
Link Here
|
133 |
if (available_fields) { |
155 |
if (available_fields) { |
134 |
const client_av = APIClient.authorised_values |
156 |
const client_av = APIClient.authorised_values |
135 |
let av_cat_array = available_fields |
157 |
let av_cat_array = available_fields |
136 |
.map(field => field.authorised_value_category) |
158 |
.map(field => field.authorised_value_category_name) |
137 |
.filter(field => field) |
159 |
.filter(field => field) |
138 |
|
160 |
|
139 |
client_av.values |
161 |
client_av.values |
Lines 158-171
export default {
Link Here
|
158 |
available_fields.forEach(available_field => { |
180 |
available_fields.forEach(available_field => { |
159 |
// Initialize current field as empty array |
181 |
// Initialize current field as empty array |
160 |
this.current_additional_fields_values[ |
182 |
this.current_additional_fields_values[ |
161 |
available_field.id |
183 |
available_field.additional_field_id |
162 |
] = [] |
184 |
] = [] |
163 |
|
185 |
|
164 |
// Grab all existing field values of this field |
186 |
// Grab all existing field values of this field |
165 |
let existing_field_values = |
187 |
let existing_field_values = |
166 |
this.additional_field_values.filter( |
188 |
this.additional_field_values.filter( |
167 |
afv => |
189 |
afv => |
168 |
afv.field_id == available_field.id && |
190 |
afv.field_id == |
|
|
191 |
available_field.additional_field_id && |
169 |
afv.value |
192 |
afv.value |
170 |
) |
193 |
) |
171 |
|
194 |
|
Lines 175-185
export default {
Link Here
|
175 |
existing_field_value => { |
198 |
existing_field_value => { |
176 |
let label = "" |
199 |
let label = "" |
177 |
if ( |
200 |
if ( |
178 |
available_field.authorised_value_category |
201 |
available_field.authorised_value_category_name |
179 |
) { |
202 |
) { |
180 |
let av_value = this.av_options[ |
203 |
let av_value = this.av_options[ |
181 |
available_field |
204 |
available_field |
182 |
.authorised_value_category |
205 |
.authorised_value_category_name |
183 |
].filter( |
206 |
].filter( |
184 |
av_option => |
207 |
av_option => |
185 |
av_option.value == |
208 |
av_option.value == |
Lines 201-210
export default {
Link Here
|
201 |
// Otherwise add them as empty if not AV field |
224 |
// Otherwise add them as empty if not AV field |
202 |
} else { |
225 |
} else { |
203 |
if ( |
226 |
if ( |
204 |
!available_field.authorised_value_category |
227 |
!available_field.authorised_value_category_name |
205 |
) { |
228 |
) { |
206 |
this.current_additional_fields_values[ |
229 |
this.current_additional_fields_values[ |
207 |
available_field.id |
230 |
available_field.additional_field_id |
208 |
] = [ |
231 |
] = [ |
209 |
{ |
232 |
{ |
210 |
label: "", |
233 |
label: "", |
Lines 225-231
export default {
Link Here
|
225 |
}, |
248 |
}, |
226 |
cloneField: function (available_field, current, event) { |
249 |
cloneField: function (available_field, current, event) { |
227 |
event.preventDefault() |
250 |
event.preventDefault() |
228 |
this.current_additional_fields_values[available_field.id].push({ |
251 |
this.current_additional_fields_values[ |
|
|
252 |
available_field.additional_field_id |
253 |
].push({ |
229 |
value: current.value, |
254 |
value: current.value, |
230 |
label: available_field.name, |
255 |
label: available_field.name, |
231 |
}) |
256 |
}) |