alchemy-form 0.1.4 → 0.1.5
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
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## 0.1.5 (2022-03-21)
|
|
2
|
+
|
|
3
|
+
* Print `alchemy-select-item` contents as text, not html
|
|
4
|
+
* Only get a maximum of 50 related items
|
|
5
|
+
* Set the parent `alchemy-select` element when creating `alchemy-select-item` element
|
|
6
|
+
|
|
1
7
|
## 0.1.4 (2022-03-16)
|
|
2
8
|
|
|
3
9
|
* Make fields work with the new `Alchemy.Map.Backed` and `Alchemy.Map.Enum` class
|
|
@@ -17,7 +17,7 @@ const FormApi = Function.inherits('Alchemy.Controller', 'FormApi');
|
|
|
17
17
|
*
|
|
18
18
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
19
19
|
* @since 0.1.0
|
|
20
|
-
* @version 0.1.
|
|
20
|
+
* @version 0.1.5
|
|
21
21
|
*
|
|
22
22
|
* @param {Conduit} conduit
|
|
23
23
|
*/
|
|
@@ -26,8 +26,25 @@ FormApi.setAction(async function related(conduit) {
|
|
|
26
26
|
const body = conduit.body;
|
|
27
27
|
|
|
28
28
|
const model = this.getModel(body.assoc_model);
|
|
29
|
+
let crit = model.find();
|
|
30
|
+
crit.limit(50);
|
|
31
|
+
|
|
32
|
+
if (body.config && body.config.search) {
|
|
33
|
+
let display_fields = Array.cast(model.displayField);
|
|
34
|
+
|
|
35
|
+
let or = crit.or();
|
|
36
|
+
let rx = RegExp.interpretWildcard('*' + body.config.search + '*', 'i');
|
|
37
|
+
|
|
38
|
+
for (let field of display_fields) {
|
|
39
|
+
if (!field) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
crit.where(field).equals(rx);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
29
46
|
|
|
30
|
-
let records = await model.find('all');
|
|
47
|
+
let records = await model.find('all', crit);
|
|
31
48
|
|
|
32
49
|
let result = {
|
|
33
50
|
available : records.available,
|
|
@@ -1166,7 +1166,7 @@ AlchemySelect.setMethod(function close(event) {
|
|
|
1166
1166
|
*
|
|
1167
1167
|
* @author Jelle De Loecker <jelle@develry.be>
|
|
1168
1168
|
* @since 0.1.0
|
|
1169
|
-
* @version 0.1.
|
|
1169
|
+
* @version 0.1.5
|
|
1170
1170
|
*
|
|
1171
1171
|
* @param {String} type "value" or "option"
|
|
1172
1172
|
* @param {Mixed} value The actual value of this item
|
|
@@ -1184,6 +1184,9 @@ AlchemySelect.setMethod(function _makeValueItem(type, value, data) {
|
|
|
1184
1184
|
// Assign the value
|
|
1185
1185
|
item.value = value;
|
|
1186
1186
|
|
|
1187
|
+
// Add a reference to this element
|
|
1188
|
+
item.alchemy_select = this;
|
|
1189
|
+
|
|
1187
1190
|
if (!data) {
|
|
1188
1191
|
data = this.getValueData(value);
|
|
1189
1192
|
}
|
|
@@ -53,4 +53,36 @@ Item.setAssignedProperty('value');
|
|
|
53
53
|
* @since 0.1.0
|
|
54
54
|
* @version 0.1.0
|
|
55
55
|
*/
|
|
56
|
-
Item.setAssignedProperty('data');
|
|
56
|
+
Item.setAssignedProperty('data');
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The parent alchemy-select item
|
|
60
|
+
*
|
|
61
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
62
|
+
* @since 0.1.5
|
|
63
|
+
* @version 0.1.5
|
|
64
|
+
*/
|
|
65
|
+
Item.enforceProperty(function alchemy_select(new_value) {
|
|
66
|
+
|
|
67
|
+
if (new_value == null) {
|
|
68
|
+
new_value = this.closest('alchemy-select');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return new_value;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The display item
|
|
76
|
+
*
|
|
77
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
78
|
+
* @since 0.1.5
|
|
79
|
+
* @version 0.1.5
|
|
80
|
+
*/
|
|
81
|
+
Item.setProperty(function display_title() {
|
|
82
|
+
|
|
83
|
+
if (!this.data) {
|
|
84
|
+
return '';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return this.data.title || this.data.name || this.data.username || this.data.$pk || this.value;
|
|
88
|
+
});
|
package/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
<% data = self.data %>
|
|
2
|
-
{
|
|
2
|
+
{{ data.title or data.name or data.$pk or self.value }}
|