alchemy-form 0.3.0-alpha.2 → 0.3.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/assets/stylesheets/form/elements/_button.scss +1 -1
- package/assets/stylesheets/form/elements/_dropdown.scss +93 -0
- package/assets/stylesheets/form/elements/_enum_badge.scss +7 -0
- package/assets/stylesheets/form/elements/_select.scss +176 -176
- package/assets/stylesheets/form/elements/_table.scss +111 -50
- package/assets/stylesheets/form/elements/_tabs.scss +25 -35
- package/assets/stylesheets/form/elements/index.scss +2 -1
- package/config/routes.js +10 -0
- package/controller/form_api_controller.js +28 -0
- package/element/00_form_base.js +82 -27
- package/element/al_button.js +12 -1
- package/element/al_dropdown.js +123 -0
- package/element/al_dropdown_item.js +40 -0
- package/element/al_enum_badge.js +157 -0
- package/element/al_field.js +133 -38
- package/element/al_field_array.js +22 -0
- package/element/al_field_schema.js +222 -55
- package/element/al_form.js +9 -6
- package/element/al_select.js +2 -2
- package/element/al_table.js +6 -1
- package/helper/field_recompute_handler.js +0 -2
- package/package.json +1 -1
- package/view/form/elements/al_dropdown.hwk +21 -0
- package/view/form/elements/al_enum_badge.hwk +9 -0
- package/view/form/elements/alchemy_field.hwk +2 -0
- package/view/form/elements/alchemy_field_array.hwk +16 -6
- package/view/form/elements/alchemy_field_array_entry.hwk +10 -5
- package/view/form/elements/alchemy_field_schema.hwk +2 -2
- package/view/form/inputs/edit/enum.hwk +1 -1
- package/view/form/inputs/edit_sw/fallback.hwk +1 -0
- package/view/form/inputs/view/association_alias.hwk +16 -0
- package/view/form/inputs/view/schema.hwk +4 -0
- package/view/form/inputs/view/string.hwk +1 -1
- package/view/form/inputs/view_inline/belongs_to.hwk +16 -0
- package/view/form/inputs/view_inline/boolean.hwk +2 -2
- package/view/form/inputs/view_inline/datetime.hwk +1 -1
- package/view/form/inputs/view_inline/enum.hwk +2 -2
- package/view/form/inputs/view_inline/objectid.hwk +1 -1
- package/view/form/inputs/view_inline/string.hwk +1 -1
- package/view/form/wrappers/edit_sw/default.hwk +1 -0
- package/assets/stylesheets/form/elements/_badge.scss +0 -41
|
@@ -17,80 +17,87 @@ var FieldSchema = Function.inherits('Alchemy.Element.Form.FieldCustom', 'FieldSc
|
|
|
17
17
|
FieldSchema.setTemplateFile('form/elements/alchemy_field_schema');
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Get the
|
|
20
|
+
* Get the parent "schema" al-field element.
|
|
21
|
+
* This is NOT the `al-field[field-type="schema"]` element this
|
|
22
|
+
* `al-field-schema` is part of, but the one that is part of!
|
|
23
|
+
*
|
|
24
|
+
* It is possible this does not use the "schema" type in the HTML attribute.
|
|
21
25
|
*
|
|
22
26
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
23
|
-
* @since 0.
|
|
24
|
-
* @version 0.
|
|
27
|
+
* @since 0.3.0
|
|
28
|
+
* @version 0.3.0
|
|
25
29
|
*/
|
|
26
|
-
FieldSchema.setProperty(function
|
|
27
|
-
|
|
28
|
-
const field_element = this.alchemy_field;
|
|
29
|
-
const field = field_element?.config;
|
|
30
|
-
|
|
31
|
-
if (field?.options) {
|
|
32
|
-
|
|
33
|
-
let schema = field.options.schema;
|
|
34
|
-
|
|
35
|
-
// If the schema is a string, it's actually a reference to another field
|
|
36
|
-
// that *should* contain the schema.
|
|
37
|
-
if (typeof schema == 'string') {
|
|
38
|
-
|
|
39
|
-
let parent_schema_value;
|
|
30
|
+
FieldSchema.setProperty(function parent_schema_field() {
|
|
40
31
|
|
|
41
|
-
|
|
32
|
+
// Start looking from the parent element of our own `al-field` element
|
|
33
|
+
let current = this.alchemy_field?.parentElement;
|
|
42
34
|
|
|
43
|
-
|
|
44
|
-
parent_schema_value = parent_schema.value;
|
|
45
|
-
} else {
|
|
35
|
+
while (current) {
|
|
46
36
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
37
|
+
if (current.nodeName != 'AL-FIELD') {
|
|
38
|
+
current = current.parentElement;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
52
41
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
// If it is using the explicit schema type, return it
|
|
43
|
+
if (current.field_type == 'schema') {
|
|
44
|
+
return current;
|
|
45
|
+
}
|
|
57
46
|
|
|
58
|
-
|
|
59
|
-
if (index != null && Array.isArray(parent_schema_value)) {
|
|
60
|
-
parent_schema_value = parent_schema_value[index];
|
|
61
|
-
}
|
|
62
|
-
}
|
|
47
|
+
let field = current.config;
|
|
63
48
|
|
|
64
|
-
|
|
49
|
+
if (field && field instanceof Classes.Alchemy.Field.Schema) {
|
|
50
|
+
return current;
|
|
65
51
|
}
|
|
66
|
-
|
|
67
|
-
return schema;
|
|
68
52
|
}
|
|
53
|
+
|
|
54
|
+
return false;
|
|
69
55
|
});
|
|
70
56
|
|
|
71
57
|
/**
|
|
72
|
-
* Get the
|
|
58
|
+
* Get the parent schema value this field is part of
|
|
73
59
|
*
|
|
74
60
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
75
|
-
* @since 0.
|
|
76
|
-
* @version 0.
|
|
61
|
+
* @since 0.3.0
|
|
62
|
+
* @version 0.3.0
|
|
77
63
|
*/
|
|
78
|
-
FieldSchema.setProperty(function
|
|
64
|
+
FieldSchema.setProperty(function parent_schema_value() {
|
|
79
65
|
|
|
80
|
-
|
|
66
|
+
const field_element = this.alchemy_field;
|
|
81
67
|
|
|
82
|
-
if (
|
|
68
|
+
if (!field_element) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let parent_schema_value,
|
|
73
|
+
parent_schema = this.parent_schema_field;
|
|
74
|
+
|
|
75
|
+
if (parent_schema) {
|
|
76
|
+
parent_schema_value = parent_schema.value;
|
|
77
|
+
} else {
|
|
83
78
|
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
const form = field_element.alchemy_form;
|
|
80
|
+
|
|
81
|
+
if (form) {
|
|
82
|
+
let record_value = form.getMainValue();
|
|
83
|
+
parent_schema_value = record_value;
|
|
84
|
+
} else {
|
|
85
|
+
parent_schema_value = field_element.original_value_container;
|
|
86
86
|
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// If this field is inside an array, get the index
|
|
90
|
+
let array_entry_element = field_element.queryParents('al-field-array-entry');
|
|
91
|
+
if (array_entry_element) {
|
|
92
|
+
let index = array_entry_element.index;
|
|
87
93
|
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
// If it has an index, get the value at that index
|
|
95
|
+
if (index != null && Array.isArray(parent_schema_value)) {
|
|
96
|
+
parent_schema_value = parent_schema_value[index];
|
|
90
97
|
}
|
|
91
98
|
}
|
|
92
99
|
|
|
93
|
-
return
|
|
100
|
+
return parent_schema_value;
|
|
94
101
|
});
|
|
95
102
|
|
|
96
103
|
/**
|
|
@@ -118,12 +125,105 @@ FieldSchema.setProperty(function value() {
|
|
|
118
125
|
throw new Error('Unable to set value of schema field');
|
|
119
126
|
});
|
|
120
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Get the actual schema
|
|
130
|
+
*
|
|
131
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
132
|
+
* @since 0.1.0
|
|
133
|
+
* @version 0.3.0
|
|
134
|
+
*
|
|
135
|
+
* @return {Alchemy.Schema|Pledge<Alchemy.Schema>}
|
|
136
|
+
*/
|
|
137
|
+
FieldSchema.setMethod(function getSchema() {
|
|
138
|
+
|
|
139
|
+
const field_element = this.alchemy_field,
|
|
140
|
+
field = field_element?.config;
|
|
141
|
+
|
|
142
|
+
if (!field) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (Classes.Alchemy.Client.Schema.isSchema(field)) {
|
|
147
|
+
return field;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (field?.options) {
|
|
151
|
+
|
|
152
|
+
let schema = field.options.schema;
|
|
153
|
+
|
|
154
|
+
// If the schema is a string, it's actually a reference to another field
|
|
155
|
+
// that *should* contain the schema.
|
|
156
|
+
if (typeof schema == 'string') {
|
|
157
|
+
|
|
158
|
+
let parent_schema_value = this.parent_schema_value;
|
|
159
|
+
|
|
160
|
+
let schema_context = new Classes.Alchemy.OperationalContext.Schema();
|
|
161
|
+
schema_context.setHolder(parent_schema_value);
|
|
162
|
+
schema_context.setSchema(field.schema);
|
|
163
|
+
|
|
164
|
+
return field.getSubSchema(schema_context);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return schema;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Get the actual subschema fields
|
|
173
|
+
*
|
|
174
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
175
|
+
* @since 0.1.0
|
|
176
|
+
* @version 0.3.0
|
|
177
|
+
*/
|
|
178
|
+
FieldSchema.setMethod(function getSubFields() {
|
|
179
|
+
|
|
180
|
+
let schema = this.getSchema();
|
|
181
|
+
|
|
182
|
+
if (Pledge.isThenable(schema)) {
|
|
183
|
+
let pledge = new Swift();
|
|
184
|
+
|
|
185
|
+
Swift.done(schema, (err, result) => {
|
|
186
|
+
|
|
187
|
+
if (err) {
|
|
188
|
+
return pledge.reject(err);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
pledge.resolve(this.getFieldsFromSchema(result));
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
return pledge;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return this.getFieldsFromSchema(schema);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Get the fields from the given schema
|
|
202
|
+
*
|
|
203
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
204
|
+
* @since 0.1.0
|
|
205
|
+
* @version 0.3.0
|
|
206
|
+
*/
|
|
207
|
+
FieldSchema.setMethod(function getFieldsFromSchema(schema) {
|
|
208
|
+
|
|
209
|
+
if (!schema) {
|
|
210
|
+
return [];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (typeof schema != 'object') {
|
|
214
|
+
throw new Error('Expected a schema object, but found "' + typeof schema + '" instead');
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Don't show meta fields by default
|
|
218
|
+
return schema.getSorted().filter(field => !field.is_meta_field);
|
|
219
|
+
});
|
|
220
|
+
|
|
121
221
|
/**
|
|
122
222
|
* Get the optional field that is supplying the schema
|
|
123
223
|
*
|
|
124
224
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
125
225
|
* @since 0.1.3
|
|
126
|
-
* @version 0.
|
|
226
|
+
* @version 0.3.0
|
|
127
227
|
*/
|
|
128
228
|
FieldSchema.setMethod(function getSchemaSupplierField() {
|
|
129
229
|
|
|
@@ -134,7 +234,12 @@ FieldSchema.setMethod(function getSchemaSupplierField() {
|
|
|
134
234
|
let schema = this.alchemy_field.config.options.schema;
|
|
135
235
|
|
|
136
236
|
if (typeof schema == 'string') {
|
|
137
|
-
let other_field_path = this.
|
|
237
|
+
let other_field_path = this.resolvePathToArray(schema),
|
|
238
|
+
schema_path;
|
|
239
|
+
|
|
240
|
+
if (schema.includes('.')) {
|
|
241
|
+
schema_path = other_field_path.pop();
|
|
242
|
+
}
|
|
138
243
|
|
|
139
244
|
schema = null;
|
|
140
245
|
|
|
@@ -146,6 +251,41 @@ FieldSchema.setMethod(function getSchemaSupplierField() {
|
|
|
146
251
|
}
|
|
147
252
|
});
|
|
148
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Prepare variables
|
|
256
|
+
*
|
|
257
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
258
|
+
* @since 0.3.0
|
|
259
|
+
* @version 0.3.0
|
|
260
|
+
*/
|
|
261
|
+
FieldSchema.setMethod(function prepareRenderVariables() {
|
|
262
|
+
|
|
263
|
+
let schema = this.getSchema();
|
|
264
|
+
|
|
265
|
+
if (Pledge.isThenable(schema)) {
|
|
266
|
+
let pledge = new Pledge.Swift();
|
|
267
|
+
|
|
268
|
+
Pledge.Swift.done(schema, (err, schema) => {
|
|
269
|
+
|
|
270
|
+
if (err) {
|
|
271
|
+
return pledge.reject(err);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
pledge.resolve({
|
|
275
|
+
sub_fields: this.getFieldsFromSchema(schema),
|
|
276
|
+
sub_schema: schema,
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
return pledge;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return {
|
|
284
|
+
sub_fields: this.getFieldsFromSchema(schema),
|
|
285
|
+
sub_schema: schema,
|
|
286
|
+
};
|
|
287
|
+
});
|
|
288
|
+
|
|
149
289
|
/**
|
|
150
290
|
* Added to the DOM for the first time
|
|
151
291
|
*
|
|
@@ -163,6 +303,10 @@ FieldSchema.setMethod(function introduced() {
|
|
|
163
303
|
});
|
|
164
304
|
|
|
165
305
|
this.rerender();
|
|
306
|
+
} else {
|
|
307
|
+
// @TODO: Some fields seem to get added to the DOM for a second
|
|
308
|
+
// before being removed.
|
|
309
|
+
//console.warn('Failed to find supplier field for', this, this.parentElement);
|
|
166
310
|
}
|
|
167
311
|
});
|
|
168
312
|
|
|
@@ -171,18 +315,41 @@ FieldSchema.setMethod(function introduced() {
|
|
|
171
315
|
*
|
|
172
316
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
173
317
|
* @since 0.1.4
|
|
174
|
-
* @version 0.
|
|
318
|
+
* @version 0.3.0
|
|
175
319
|
*/
|
|
176
320
|
FieldSchema.setProperty(function original_value() {
|
|
177
321
|
|
|
178
322
|
let field = this.alchemy_field,
|
|
179
323
|
path = this.field_path_in_record;
|
|
180
324
|
|
|
325
|
+
let array_entry = this.queryUp('al-field-array-entry'),
|
|
326
|
+
original_value_context = field;
|
|
327
|
+
|
|
328
|
+
if (array_entry) {
|
|
329
|
+
if (!array_entry.isConnected || (field && field.contains(array_entry))) {
|
|
330
|
+
original_value_context = array_entry;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// This is needed for SemanticWiki's metadata fields.
|
|
335
|
+
// They use al-field-schema elements, but they refer to the main
|
|
336
|
+
// `al-form` element, and that is not where it can find the original value...
|
|
337
|
+
if (original_value_context && original_value_context.original_value) {
|
|
338
|
+
return original_value_context.original_value;
|
|
339
|
+
}
|
|
340
|
+
|
|
181
341
|
if (field && path) {
|
|
182
|
-
let form = field.alchemy_form || this.alchemy_form || this.field_context.alchemy_form
|
|
342
|
+
let form = field.alchemy_form || this.alchemy_form || this.field_context.alchemy_form,
|
|
343
|
+
value_container;
|
|
183
344
|
|
|
184
345
|
if (form) {
|
|
185
|
-
|
|
346
|
+
value_container = form.document;
|
|
347
|
+
} else {
|
|
348
|
+
value_container = field.original_value_container;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (value_container) {
|
|
352
|
+
return Object.path(value_container, path);
|
|
186
353
|
}
|
|
187
354
|
}
|
|
188
355
|
|
|
@@ -193,7 +360,7 @@ FieldSchema.setProperty(function original_value() {
|
|
|
193
360
|
data = context.original_value;
|
|
194
361
|
} else {
|
|
195
362
|
context = this.field_context.alchemy_form || this.alchemy_field.alchemy_form;
|
|
196
|
-
data = context
|
|
363
|
+
data = context?.document;
|
|
197
364
|
}
|
|
198
365
|
|
|
199
366
|
path = this.field_path_in_current_schema;
|
package/element/al_form.js
CHANGED
|
@@ -428,7 +428,7 @@ Form.setMethod(async function showViolations(err) {
|
|
|
428
428
|
*
|
|
429
429
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
430
430
|
* @since 0.1.0
|
|
431
|
-
* @version 0.
|
|
431
|
+
* @version 0.3.0
|
|
432
432
|
*
|
|
433
433
|
* @param {String} path
|
|
434
434
|
*
|
|
@@ -441,11 +441,15 @@ Form.setMethod(function findFieldByPath(path) {
|
|
|
441
441
|
}
|
|
442
442
|
|
|
443
443
|
let current = this,
|
|
444
|
-
|
|
445
|
-
pieces = path.split('.'),
|
|
444
|
+
pieces,
|
|
446
445
|
piece,
|
|
447
|
-
query
|
|
448
|
-
|
|
446
|
+
query;
|
|
447
|
+
|
|
448
|
+
if (Array.isArray(path)) {
|
|
449
|
+
pieces = path;
|
|
450
|
+
} else {
|
|
451
|
+
pieces = path.split('.');
|
|
452
|
+
}
|
|
449
453
|
|
|
450
454
|
for (piece of pieces) {
|
|
451
455
|
|
|
@@ -463,7 +467,6 @@ Form.setMethod(function findFieldByPath(path) {
|
|
|
463
467
|
}
|
|
464
468
|
|
|
465
469
|
return current;
|
|
466
|
-
|
|
467
470
|
});
|
|
468
471
|
|
|
469
472
|
/**
|
package/element/al_select.js
CHANGED
|
@@ -957,7 +957,7 @@ AlchemySelect.setMethod(function applyFetchedData(err, result, config) {
|
|
|
957
957
|
|
|
958
958
|
if (err) {
|
|
959
959
|
this.loading_dropdown = false;
|
|
960
|
-
alchemy.
|
|
960
|
+
alchemy.registerError(err);
|
|
961
961
|
return;
|
|
962
962
|
}
|
|
963
963
|
|
|
@@ -1165,7 +1165,7 @@ AlchemySelect.setMethod(function open(event) {
|
|
|
1165
1165
|
this.dropdown_content.scrollTop = 0;
|
|
1166
1166
|
|
|
1167
1167
|
// Make the dropdown the same width
|
|
1168
|
-
this.dropdown.style.width = ~~this.clientWidth + 'px';
|
|
1168
|
+
this.dropdown.style.width = (~~this.clientWidth + 1) + 'px';
|
|
1169
1169
|
|
|
1170
1170
|
if (event) {
|
|
1171
1171
|
if (event.key) {
|
package/element/al_table.js
CHANGED
|
@@ -602,7 +602,7 @@ Table.setMethod(function showPagination() {
|
|
|
602
602
|
* @param {FieldConfig} field_config The config on how to display the field
|
|
603
603
|
* @param {Object} container The container where the field should be in
|
|
604
604
|
*
|
|
605
|
-
* @return
|
|
605
|
+
* @return {Element.AlField}
|
|
606
606
|
*/
|
|
607
607
|
Table.setMethod(function getFieldConfigView(field_config, container) {
|
|
608
608
|
|
|
@@ -642,6 +642,11 @@ Table.setMethod(function getFieldConfigView(field_config, container) {
|
|
|
642
642
|
alchemy_field.original_value = value;
|
|
643
643
|
alchemy_field.model = field?.schema?.model_name;
|
|
644
644
|
|
|
645
|
+
// Since these fields are not inside a form,
|
|
646
|
+
// they won't be able to remember their original value container.
|
|
647
|
+
// So force them to:
|
|
648
|
+
alchemy_field.rememberOriginalValueContainer(container);
|
|
649
|
+
|
|
645
650
|
return alchemy_field;
|
|
646
651
|
});
|
|
647
652
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<div class="dropdown-trigger-wrapper">
|
|
2
|
+
<button
|
|
3
|
+
type="button"
|
|
4
|
+
:ref={% button_ref %}
|
|
5
|
+
prop:disabled={% state:disabled{:} %}
|
|
6
|
+
on:click={% self.toggleDropdown() %}
|
|
7
|
+
>
|
|
8
|
+
<slot name="dropdown-trigger"></slot>
|
|
9
|
+
<slot name="dropdown-trigger-icon" aria-hidden="true">
|
|
10
|
+
<al-icon icon-name="chevron-down"></al-icon>
|
|
11
|
+
</slot>
|
|
12
|
+
</button>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<div
|
|
16
|
+
:ref={% state:items_wrapper %}
|
|
17
|
+
class="dropdown-items-wrapper"
|
|
18
|
+
prop:hidden={% not state:is_open{:} %}
|
|
19
|
+
>
|
|
20
|
+
<slot name="dropdown-items"></slot>
|
|
21
|
+
</div>
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
<al-field-array
|
|
13
13
|
#field_context=<% self %>
|
|
14
14
|
#alchemy_field=<% self %>
|
|
15
|
+
max-entry-count={% self.max_entry_count %}
|
|
16
|
+
min-entry-count={% self.min_entry_count %}
|
|
15
17
|
></al-field-array>
|
|
16
18
|
<% } else if (view_files && view_files.length) { %>
|
|
17
19
|
<div class="field">
|
|
@@ -2,13 +2,24 @@
|
|
|
2
2
|
<% view_files = alchemy_field.view_files %>
|
|
3
3
|
<% values = self.original_value %>
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
{% if self.field_context.max_entry_count eq 1 %}
|
|
6
|
+
<%
|
|
7
|
+
if (!values) {
|
|
8
|
+
self.original_value = values = [];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (values.length === 0) {
|
|
12
|
+
values.push(undefined);
|
|
13
|
+
}
|
|
14
|
+
%>
|
|
15
|
+
{% else %}
|
|
16
|
+
<button class="add-entry">
|
|
17
|
+
{%t "add-entry" name=alchemy_field.field_name title=alchemy_field.field_title %}
|
|
18
|
+
</button>
|
|
19
|
+
{% /if %}
|
|
8
20
|
|
|
9
21
|
<div class="entries">
|
|
10
|
-
{%
|
|
11
|
-
{% each %}
|
|
22
|
+
{% each values as value %}
|
|
12
23
|
<al-field-array-entry
|
|
13
24
|
#alchemy_field_array=<% self %>
|
|
14
25
|
#field_context=<% self %>
|
|
@@ -18,5 +29,4 @@
|
|
|
18
29
|
index=<% $index %>
|
|
19
30
|
></al-field-array-entry>
|
|
20
31
|
{% /each %}
|
|
21
|
-
{% /with %}
|
|
22
32
|
</div>
|
|
@@ -10,8 +10,13 @@
|
|
|
10
10
|
<div class="field">
|
|
11
11
|
<% include(view_files, variables) %>
|
|
12
12
|
</div>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
|
|
14
|
+
{% if self.alchemy_field_array.max_entry_count eq 1 %}
|
|
15
|
+
|
|
16
|
+
{% else %}
|
|
17
|
+
<div class="button">
|
|
18
|
+
<button class="remove">
|
|
19
|
+
{%t "remove-entry" name=alchemy_field.field_name title=alchemy_field.field_title %}
|
|
20
|
+
</button>
|
|
21
|
+
</div>
|
|
22
|
+
{% /if %}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{% include "form/inputs/edit/" + alchemy_field.getFieldType() %}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<div>
|
|
2
|
+
<span class="alchemy-field-value">
|
|
3
|
+
<% if (value) { %>
|
|
4
|
+
{{ value.getDisplayTitle() }}
|
|
5
|
+
<% } else { %>
|
|
6
|
+
<span class="badge alchemy-field-empty-value-placeholder">
|
|
7
|
+
{%t
|
|
8
|
+
"empty-value"
|
|
9
|
+
field=field_context.config.name
|
|
10
|
+
path=field_context.config.path_in_document
|
|
11
|
+
zone=self.zone
|
|
12
|
+
%}
|
|
13
|
+
</span>
|
|
14
|
+
<% } %>
|
|
15
|
+
</span>
|
|
16
|
+
</div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<div>
|
|
2
|
+
<span class="alchemy-field-value">
|
|
3
|
+
<% if (value || value === false) { %>
|
|
4
|
+
{{ value }}
|
|
5
|
+
<% } else { %>
|
|
6
|
+
<span class="badge alchemy-field-empty-value-placeholder">
|
|
7
|
+
{%t
|
|
8
|
+
"empty-value"
|
|
9
|
+
field=field_context.config.name
|
|
10
|
+
path=field_context.config.path_in_document
|
|
11
|
+
zone=self.zone
|
|
12
|
+
%}
|
|
13
|
+
</span>
|
|
14
|
+
<% } %>
|
|
15
|
+
</span>
|
|
16
|
+
</div>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{% if (value_is_empty AND self.allow_empty_value_placeholder) %}
|
|
2
2
|
<span class="alchemy-field-value">
|
|
3
|
-
<span class="
|
|
3
|
+
<span class="badge alchemy-field-empty-value-placeholder">
|
|
4
4
|
{{ self.createEmptyValuePlaceholderText() }}
|
|
5
5
|
</span>
|
|
6
6
|
</span>
|
|
7
7
|
{% else %}
|
|
8
|
-
<span class="
|
|
8
|
+
<span class="badge alchemy-field-value">
|
|
9
9
|
<% $0.classList.add('boolean-' + value) %>
|
|
10
10
|
|
|
11
11
|
{% if value %}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{% if (value_is_empty AND self.allow_empty_value_placeholder) %}
|
|
2
2
|
<span class="alchemy-field-value">
|
|
3
|
-
<span class="
|
|
3
|
+
<span class="badge alchemy-field-empty-value-placeholder">
|
|
4
4
|
{{ self.createEmptyValuePlaceholderText() }}
|
|
5
5
|
</span>
|
|
6
6
|
</span>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{% if (value_is_empty AND self.allow_empty_value_placeholder) %}
|
|
2
2
|
<span class="alchemy-field-value">
|
|
3
|
-
<span class="
|
|
3
|
+
<span class="badge alchemy-field-empty-value-placeholder">
|
|
4
4
|
{{ self.createEmptyValuePlaceholderText() }}
|
|
5
5
|
</span>
|
|
6
6
|
</span>
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
{% set enum_config to self.config.getValueConfiguration(value) %}
|
|
9
9
|
{% set display_value to OR enum_config.title OR enum_config.name OR value %}
|
|
10
10
|
|
|
11
|
-
<span class="
|
|
11
|
+
<span class="badge alchemy-field-value alchemy-field-enum">
|
|
12
12
|
<% $0.classList.add('enum-' + value) %>
|
|
13
13
|
|
|
14
14
|
{% if enum_config.number %}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{% if (value_is_empty AND self.allow_empty_value_placeholder) %}
|
|
2
2
|
<span class="alchemy-field-value">
|
|
3
|
-
<span class="
|
|
3
|
+
<span class="badge alchemy-field-empty-value-placeholder">
|
|
4
4
|
{{ self.createEmptyValuePlaceholderText() }}
|
|
5
5
|
</span>
|
|
6
6
|
</span>
|