alchemy-form 0.2.6 → 0.2.8
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 +14 -0
- package/assets/stylesheets/form/elements/_apex_charts.scss +7 -0
- package/assets/stylesheets/form/elements/_field.scss +1 -1
- package/assets/stylesheets/form/elements/_toggle.scss +11 -5
- package/assets/stylesheets/form/elements/index.scss +2 -1
- package/element/al_apex_chart.js +38 -0
- package/element/al_field.js +29 -4
- package/element/al_table.js +4 -1
- package/helper/form_actions/00_form_action.js +0 -1
- package/helper/pathway/leaf.js +0 -5
- 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,17 @@
|
|
|
1
|
+
## 0.2.8 (2023-10-15)
|
|
2
|
+
|
|
3
|
+
* Add basic `al-apex-chart` element
|
|
4
|
+
* Fix `al-table` always turning `DocumentList` instances into dumb arrays
|
|
5
|
+
|
|
6
|
+
## 0.2.7 (2023-10-05)
|
|
7
|
+
|
|
8
|
+
* 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
|
|
9
|
+
* Make sure string fields use the `text` input type instead of `string` in some cases
|
|
10
|
+
* Automatically add the `does-not-expand` css class to `al-toggle` element
|
|
11
|
+
* Improve `al-toggle` styling
|
|
12
|
+
* Store a `al-field` element's applied options in the new `applied_options` property, so it can be used inside the view templates too
|
|
13
|
+
* Use relative (time-ago) dates by default for showing date/datetime fields inline
|
|
14
|
+
|
|
1
15
|
## 0.2.6 (2023-06-17)
|
|
2
16
|
|
|
3
17
|
* 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
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The apex-chart custom element
|
|
3
|
+
*
|
|
4
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
5
|
+
* @since 0.2.8
|
|
6
|
+
* @version 0.2.8
|
|
7
|
+
*/
|
|
8
|
+
const ApexChart = Function.inherits('Alchemy.Element.Form.Base', 'ApexChart');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The actual ApexChart config
|
|
12
|
+
*
|
|
13
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
14
|
+
* @since 0.2.8
|
|
15
|
+
* @version 0.2.8
|
|
16
|
+
*/
|
|
17
|
+
ApexChart.setAssignedProperty('apex_config');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The element has been added to the dom for the first time
|
|
21
|
+
*
|
|
22
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
23
|
+
* @since 0.2.8
|
|
24
|
+
* @version 0.2.8
|
|
25
|
+
*/
|
|
26
|
+
ApexChart.setMethod(async function introduced() {
|
|
27
|
+
|
|
28
|
+
await hawkejs.require('https://cdn.jsdelivr.net/npm/apexcharts');
|
|
29
|
+
|
|
30
|
+
let apex_config = this.apex_config;
|
|
31
|
+
|
|
32
|
+
let timeline = this.createElement('div');
|
|
33
|
+
timeline.classList.add('apex-chart-container');
|
|
34
|
+
this.append(timeline);
|
|
35
|
+
|
|
36
|
+
let instance = new ApexCharts(timeline, apex_config);
|
|
37
|
+
instance.render();
|
|
38
|
+
});
|
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
|
/**
|
|
@@ -840,13 +862,16 @@ Field.setMethod(async function loadData(config, element) {
|
|
|
840
862
|
}
|
|
841
863
|
}
|
|
842
864
|
|
|
865
|
+
let model = field.parent_schema?.model_name,
|
|
866
|
+
assoc_model = field.options?.model_name || field.options?.modelName;
|
|
867
|
+
|
|
843
868
|
let resource_options = {
|
|
844
869
|
name : 'FormApi#related',
|
|
845
870
|
post : true,
|
|
846
871
|
body : {
|
|
847
872
|
field : field.name,
|
|
848
|
-
model :
|
|
849
|
-
assoc_model :
|
|
873
|
+
model : model,
|
|
874
|
+
assoc_model : assoc_model,
|
|
850
875
|
config : config,
|
|
851
876
|
}
|
|
852
877
|
};
|
package/element/al_table.js
CHANGED
|
@@ -1121,7 +1121,7 @@ Table.setMethod(function getRemoteFetchConfig() {
|
|
|
1121
1121
|
*
|
|
1122
1122
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1123
1123
|
* @since 0.2.0
|
|
1124
|
-
* @version 0.2.
|
|
1124
|
+
* @version 0.2.8
|
|
1125
1125
|
*/
|
|
1126
1126
|
Table.setMethod(function applyFetchedData(err, result, config) {
|
|
1127
1127
|
|
|
@@ -1134,6 +1134,9 @@ Table.setMethod(function applyFetchedData(err, result, config) {
|
|
|
1134
1134
|
|
|
1135
1135
|
if (Array.isArray(result)) {
|
|
1136
1136
|
records = result;
|
|
1137
|
+
} else if (result.length) {
|
|
1138
|
+
// This way we keep `DocumentList` instances as they are!
|
|
1139
|
+
records = result;
|
|
1137
1140
|
} else {
|
|
1138
1141
|
records = result.records;
|
|
1139
1142
|
}
|
package/helper/pathway/leaf.js
CHANGED
|
@@ -137,18 +137,13 @@ Leaf.setMethod(async function getPage(page_nr) {
|
|
|
137
137
|
|
|
138
138
|
let provider = this.getProvider();
|
|
139
139
|
|
|
140
|
-
console.log('Getting page...', page_nr, 'from', provider)
|
|
141
|
-
|
|
142
140
|
if (!provider) {
|
|
143
141
|
return;
|
|
144
142
|
}
|
|
145
143
|
|
|
146
144
|
let records = await provider.getAll();
|
|
147
145
|
|
|
148
|
-
console.log('Got records:', records)
|
|
149
|
-
|
|
150
146
|
return records;
|
|
151
|
-
|
|
152
147
|
});
|
|
153
148
|
|
|
154
149
|
/**
|
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.8",
|
|
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>
|