alchemy-form 0.2.6 → 0.2.7
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 +9 -0
- package/assets/stylesheets/form/elements/_field.scss +1 -1
- package/assets/stylesheets/form/elements/_toggle.scss +11 -5
- package/element/al_field.js +35 -4
- package/package.json +2 -2
- package/view/form/elements/alchemy_toggle.hwk +2 -0
- package/view/form/inputs/edit/string.hwk +2 -0
- package/view/form/inputs/edit/text.hwk +1 -1
- package/view/form/inputs/view_inline/date.hwk +1 -4
- package/view/form/inputs/view_inline/datetime.hwk +25 -5
- package/view/form/wrappers/default/default.hwk +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## 0.2.7 (2023-10-05)
|
|
2
|
+
|
|
3
|
+
* If a `al-field` element is assigned a `Field` instance to its `config` property without a parent `schema` property, it will be stored in its `assigned_data` property
|
|
4
|
+
* Make sure string fields use the `text` input type instead of `string` in some cases
|
|
5
|
+
* Automatically add the `does-not-expand` css class to `al-toggle` element
|
|
6
|
+
* Improve `al-toggle` styling
|
|
7
|
+
* Store a `al-field` element's applied options in the new `applied_options` property, so it can be used inside the view templates too
|
|
8
|
+
* Use relative (time-ago) dates by default for showing date/datetime fields inline
|
|
9
|
+
|
|
1
10
|
## 0.2.6 (2023-06-17)
|
|
2
11
|
|
|
3
12
|
* Fix `al-field-schema` element not being able to get schema of an arrayable field
|
|
@@ -2,6 +2,7 @@ al-toggle {
|
|
|
2
2
|
display: flex;
|
|
3
3
|
position: relative;
|
|
4
4
|
align-items: center;
|
|
5
|
+
cursor: pointer;
|
|
5
6
|
|
|
6
7
|
input {
|
|
7
8
|
opacity: 0;
|
|
@@ -14,7 +15,7 @@ al-toggle {
|
|
|
14
15
|
background-color: #20c05b;
|
|
15
16
|
|
|
16
17
|
&:before {
|
|
17
|
-
content:
|
|
18
|
+
content: " ";
|
|
18
19
|
left: 0;
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -36,8 +37,9 @@ al-toggle {
|
|
|
36
37
|
border-radius: 4px;
|
|
37
38
|
min-width: 134px;
|
|
38
39
|
|
|
40
|
+
box-shadow: 0px 0px 2px rgba(0,0,0,0.3);
|
|
39
41
|
transition: background-color 0.3s cubic-bezier(0, 1, 0.5, 1);
|
|
40
|
-
background: #
|
|
42
|
+
background: #b7b7b7;
|
|
41
43
|
position: relative;
|
|
42
44
|
|
|
43
45
|
&:before,
|
|
@@ -48,9 +50,9 @@ al-toggle {
|
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
&:before {
|
|
51
|
-
content:
|
|
53
|
+
content: " ";
|
|
52
54
|
left: 67px;
|
|
53
|
-
font-size:
|
|
55
|
+
font-size: 14px;
|
|
54
56
|
line-height: 36px;
|
|
55
57
|
width: 67px;
|
|
56
58
|
padding: 0 12px;
|
|
@@ -65,11 +67,15 @@ al-toggle {
|
|
|
65
67
|
|
|
66
68
|
&:after {
|
|
67
69
|
content: attr(data-unchecked);
|
|
70
|
+
display: flex;
|
|
71
|
+
justify-content: center;
|
|
72
|
+
align-items: center;
|
|
73
|
+
height: calc(100% - 4px);
|
|
74
|
+
|
|
68
75
|
top: 2px;
|
|
69
76
|
left: 2px;
|
|
70
77
|
border-radius: 2px;
|
|
71
78
|
width: 65px;
|
|
72
|
-
line-height: 32px;
|
|
73
79
|
font-size: 12px;
|
|
74
80
|
font-weight: bold;
|
|
75
81
|
|
package/element/al_field.js
CHANGED
|
@@ -88,6 +88,15 @@ Field.setAttribute('readonly', {boolean: true});
|
|
|
88
88
|
*/
|
|
89
89
|
Field.setAssignedProperty('widget_settings');
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Applied options
|
|
93
|
+
*
|
|
94
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
95
|
+
* @since 0.2.7
|
|
96
|
+
* @version 0.2.7
|
|
97
|
+
*/
|
|
98
|
+
Field.setAssignedProperty('applied_options');
|
|
99
|
+
|
|
91
100
|
/**
|
|
92
101
|
* The placeholder
|
|
93
102
|
*
|
|
@@ -151,10 +160,22 @@ Field.enforceProperty(function alchemy_field_schema(new_value, old_value) {
|
|
|
151
160
|
*
|
|
152
161
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
153
162
|
* @since 0.1.0
|
|
154
|
-
* @version 0.
|
|
163
|
+
* @version 0.2.7
|
|
155
164
|
*/
|
|
156
165
|
Field.enforceProperty(function config(new_value, old_value) {
|
|
157
166
|
|
|
167
|
+
// If an explicit field is set without a schema,
|
|
168
|
+
// we need to remember it for serializing purposes
|
|
169
|
+
if (new_value && !new_value.schema) {
|
|
170
|
+
this.assigned_data.field_config = new_value;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// See if there is a rememberd field available
|
|
174
|
+
if (!new_value && this.assigned_data?.field_config) {
|
|
175
|
+
new_value = this.assigned_data.field_config;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// There is no remembered field, so check the schema
|
|
158
179
|
if (!new_value && this.field_name) {
|
|
159
180
|
|
|
160
181
|
let schema = this.schema;
|
|
@@ -590,7 +611,7 @@ Field.setProperty(function value() {
|
|
|
590
611
|
*
|
|
591
612
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
592
613
|
* @since 0.1.12
|
|
593
|
-
* @version 0.
|
|
614
|
+
* @version 0.2.7
|
|
594
615
|
*
|
|
595
616
|
* @param {Object} options
|
|
596
617
|
*/
|
|
@@ -632,6 +653,7 @@ Field.setMethod(function applyOptions(options) {
|
|
|
632
653
|
this.field_title = options.title;
|
|
633
654
|
}
|
|
634
655
|
|
|
656
|
+
this.applied_options = options;
|
|
635
657
|
});
|
|
636
658
|
|
|
637
659
|
/**
|
|
@@ -824,10 +846,14 @@ Field.setMethod(async function loadData(config, element) {
|
|
|
824
846
|
|
|
825
847
|
if (field) {
|
|
826
848
|
|
|
849
|
+
console.log('Loading data...', config, element);
|
|
850
|
+
|
|
827
851
|
let result;
|
|
828
852
|
|
|
829
853
|
if (typeof field.loadData == 'function') {
|
|
830
854
|
|
|
855
|
+
console.log(' -- Using loadData of', field);
|
|
856
|
+
|
|
831
857
|
try {
|
|
832
858
|
result = await field.loadData(config, element);
|
|
833
859
|
} catch (err) {
|
|
@@ -840,17 +866,22 @@ Field.setMethod(async function loadData(config, element) {
|
|
|
840
866
|
}
|
|
841
867
|
}
|
|
842
868
|
|
|
869
|
+
let model = field.parent_schema?.model_name,
|
|
870
|
+
assoc_model = field.options?.model_name || field.options?.modelName;
|
|
871
|
+
|
|
843
872
|
let resource_options = {
|
|
844
873
|
name : 'FormApi#related',
|
|
845
874
|
post : true,
|
|
846
875
|
body : {
|
|
847
876
|
field : field.name,
|
|
848
|
-
model :
|
|
849
|
-
assoc_model :
|
|
877
|
+
model : model,
|
|
878
|
+
assoc_model : assoc_model,
|
|
850
879
|
config : config,
|
|
851
880
|
}
|
|
852
881
|
};
|
|
853
882
|
|
|
883
|
+
console.log('Resource options:', resource_options)
|
|
884
|
+
|
|
854
885
|
if (this.data_src) {
|
|
855
886
|
resource_options.name = this.data_src;
|
|
856
887
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alchemy-form",
|
|
3
3
|
"description": "Form plugin for Alchemy",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.7",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type" : "git",
|
|
7
7
|
"url" : "https://github.com/11ways/alchemy-form.git"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|
|
10
10
|
"alchemymvc" : ">=1.3.0",
|
|
11
|
-
"alchemy-media" : ">=0.7.
|
|
11
|
+
"alchemy-media" : ">=0.7.6"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"engines": {
|
|
@@ -1,8 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<%
|
|
2
|
+
date_format = '';
|
|
3
|
+
|
|
4
|
+
if (alchemy_field && alchemy_field.applied_options) {
|
|
5
|
+
date_format = alchemy_field.applied_options.date_format;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (!date_format || date_format == 'timeago' || date_format == 'time-ago' || date_format == 'time_ago') {
|
|
9
|
+
date_format = 'relative';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (alchemy_field?.config?.options?.time_ago) {
|
|
13
|
+
date_format = 'relative';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
%>
|
|
17
|
+
|
|
18
|
+
<% if (date_format == 'relative') { %>
|
|
19
|
+
<time-ago
|
|
20
|
+
class="alchemy-field-value"
|
|
21
|
+
date={% value.toISOString() %}
|
|
22
|
+
></time-ago>
|
|
23
|
+
<% } else { %>
|
|
4
24
|
<time
|
|
5
25
|
class="alchemy-field-value"
|
|
6
26
|
datetime={% value.toISOString() %}
|
|
7
|
-
>{{ value.format(
|
|
8
|
-
|
|
27
|
+
>{{ value.format(date_format) }}</time>
|
|
28
|
+
<% } %>
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<span
|
|
4
4
|
data-he-name="field-title"
|
|
5
5
|
data-he-slot="field-title"
|
|
6
|
-
|
|
6
|
+
>{{ alchemy_field.field_title }}</span>
|
|
7
7
|
<small
|
|
8
8
|
data-he-name="field-description"
|
|
9
9
|
data-he-slot="field-description"
|
|
10
|
-
|
|
10
|
+
>{{ alchemy_field.field_description }}</small>
|
|
11
11
|
</al-label>
|
|
12
12
|
</div>
|
|
13
13
|
<div data-he-name="field"></div>
|