saasufy-components 3.23.0 → 3.24.0
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/README.md +2 -0
- package/model-input.js +12 -0
- package/model-text.js +14 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -499,6 +499,7 @@ Used for displaying and editing a single field of a model instance in real time.
|
|
|
499
499
|
- `default-value`: A default value to show the user if the underlying model field's value is null or undefined. Note that setting a default value will not affect the underlying model's value.
|
|
500
500
|
- `value`: Used to set the model's value.
|
|
501
501
|
- `computable-value`: If this attribute is present, it will be possible to execute expressions using the `{{expression}}` syntax inside the `value` attribute.
|
|
502
|
+
- `slice-to`: Optional field which can be set to a number to trim strings down to a maximum number of characters. This is useful when dealing with potentially very long field values. Extra care should be taken when using this attribute on a `model-input` element as it will cause values to be overwritten with shortened values if the user edits the input box. Note also that it may affect caching if the same field is being referenced in multiple parts of the application at the same time within the same `socket-provider`.
|
|
502
503
|
- `hide-error-logs`: By default, this component will log errors to the console. If set, this attribute will suppress such errors from showing up on the console.
|
|
503
504
|
- `autocapitalize`: Can be `on` or `off` - It will set the auto-capitalize attribute on the inner input element. This is useful for mobile devices to enable or disable auto-capitalization of the first character which is typed into the input element.
|
|
504
505
|
- `autocorrect`: Can be `on` or `off` - It will set the auto-correct attribute on the inner input element. This is useful for mobile devices to enable or disable auto-correct.
|
|
@@ -533,6 +534,7 @@ Used to displaying a field of a model instance in real time.
|
|
|
533
534
|
- `model-type` (required): Specifies the type of model to bind to. This should match a `Model` available in your Saasufy service.
|
|
534
535
|
- `model-id` (required): The id of the model instance/record to bind to.
|
|
535
536
|
- `model-field` (required): The field of the model instance/record to bind to for reading.
|
|
537
|
+
- `slice-to`: Optional field which can be set to a number to trim strings down to a maximum number of characters when reading. This is useful when dealing with potentially very long field values. Note that it may affect caching if the same field is being referenced in multiple parts of the application at the same time within the same `socket-provider`.
|
|
536
538
|
- `hide-error-logs`: By default, this component will log errors to the console. If set, this attribute will suppress such errors from showing up on the console.
|
|
537
539
|
|
|
538
540
|
### model-viewer
|
package/model-input.js
CHANGED
|
@@ -31,6 +31,7 @@ class ModelInput extends SocketConsumer {
|
|
|
31
31
|
'model-type',
|
|
32
32
|
'model-id',
|
|
33
33
|
'model-field',
|
|
34
|
+
'slice-to',
|
|
34
35
|
'debounce-delay',
|
|
35
36
|
'enable-rebound',
|
|
36
37
|
'options',
|
|
@@ -109,6 +110,7 @@ class ModelInput extends SocketConsumer {
|
|
|
109
110
|
let modelType = this.getAttribute('model-type');
|
|
110
111
|
let modelId = this.getAttribute('model-id');
|
|
111
112
|
let modelField = this.getAttribute('model-field');
|
|
113
|
+
let sliceTo = this.getAttribute('slice-to');
|
|
112
114
|
let options = this.getAttribute('options');
|
|
113
115
|
let height = this.getAttribute('height');
|
|
114
116
|
let hideErrorLogs = this.hasAttribute('hide-error-logs');
|
|
@@ -141,11 +143,21 @@ class ModelInput extends SocketConsumer {
|
|
|
141
143
|
|
|
142
144
|
let modelFieldList = writeOnly ? [] : [ modelField ];
|
|
143
145
|
|
|
146
|
+
let fieldTransformations;
|
|
147
|
+
if (sliceTo != null) {
|
|
148
|
+
fieldTransformations = {
|
|
149
|
+
[modelField]: { sliceTo: Number(sliceTo) }
|
|
150
|
+
};
|
|
151
|
+
} else {
|
|
152
|
+
fieldTransformations = {};
|
|
153
|
+
}
|
|
154
|
+
|
|
144
155
|
let model = new AGModel({
|
|
145
156
|
socket: this.socket,
|
|
146
157
|
type: modelType,
|
|
147
158
|
id: modelId,
|
|
148
159
|
fields: modelFieldList,
|
|
160
|
+
fieldTransformations,
|
|
149
161
|
enableRebound
|
|
150
162
|
});
|
|
151
163
|
if (!hideErrorLogs) {
|
package/model-text.js
CHANGED
|
@@ -24,6 +24,7 @@ class ModelText extends SocketConsumer {
|
|
|
24
24
|
'model-type',
|
|
25
25
|
'model-id',
|
|
26
26
|
'model-field',
|
|
27
|
+
'slice-to',
|
|
27
28
|
'hide-error-logs'
|
|
28
29
|
];
|
|
29
30
|
}
|
|
@@ -40,6 +41,7 @@ class ModelText extends SocketConsumer {
|
|
|
40
41
|
let modelType = this.getAttribute('model-type');
|
|
41
42
|
let modelId = this.getAttribute('model-id');
|
|
42
43
|
let modelField = this.getAttribute('model-field');
|
|
44
|
+
let sliceTo = this.getAttribute('slice-to');
|
|
43
45
|
let hideErrorLogs = this.hasAttribute('hide-error-logs');
|
|
44
46
|
|
|
45
47
|
let socket;
|
|
@@ -63,11 +65,22 @@ class ModelText extends SocketConsumer {
|
|
|
63
65
|
socket = this.getSocket();
|
|
64
66
|
}
|
|
65
67
|
this.socket = socket;
|
|
68
|
+
|
|
69
|
+
let fieldTransformations;
|
|
70
|
+
if (sliceTo != null) {
|
|
71
|
+
fieldTransformations = {
|
|
72
|
+
[modelField]: { sliceTo: Number(sliceTo) }
|
|
73
|
+
};
|
|
74
|
+
} else {
|
|
75
|
+
fieldTransformations = {};
|
|
76
|
+
}
|
|
77
|
+
|
|
66
78
|
let model = new AGModel({
|
|
67
79
|
socket: this.socket,
|
|
68
80
|
type: modelType,
|
|
69
81
|
id: modelId,
|
|
70
|
-
fields: [ modelField ]
|
|
82
|
+
fields: [ modelField ],
|
|
83
|
+
fieldTransformations
|
|
71
84
|
});
|
|
72
85
|
if (!hideErrorLogs) {
|
|
73
86
|
(async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "saasufy-components",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.24.0",
|
|
4
4
|
"description": "Components for Saasufy.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"author": "Jonathan Gros-Dubois",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"ag-collection": "^5.0
|
|
21
|
-
"ag-model": "^3.0
|
|
20
|
+
"ag-collection": "^5.1.0",
|
|
21
|
+
"ag-model": "^3.1.0",
|
|
22
22
|
"capitalisk-auth-client": "^1.5.1",
|
|
23
23
|
"socketcluster-client": "^19.1.0",
|
|
24
24
|
"uuid": "^8.3.2"
|