saasufy-components 3.22.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 +3 -0
- package/model-input.js +12 -0
- package/model-text.js +14 -1
- package/oauth-handler.js +4 -3
- 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
|
|
@@ -811,6 +813,7 @@ When using an OAuth provider, the callback URL which you register with the provi
|
|
|
811
813
|
- `provider` (required): The name of the provider. It must match the provider name specified on the `Authentication` page of your Saasufy control panel and also the value provided to the `oauth-link` component at the start of the OAuth flow.
|
|
812
814
|
- `success-location-hash`: If authentication is successful, the browser's `location.hash` will be set to this value. It can be used to redirect the user to their dashboard, for example.
|
|
813
815
|
- `success-url`: If authentication is successful, the browser's `location.href` will be set to this value. It can be used to redirect the user to their dashboard, for example.
|
|
816
|
+
- `extra-data`: This attribute can be used to pass additional data to the OAuth `getAccessTokenURL` endpoint. For Google OAuth, for example, an additional `redirect_uri` field is required, so it should be set using `extra-data="redirect_uri=http://localhost.com:8000/"` (substitute the URI with your own).
|
|
814
817
|
- `navigate-event-path`: If authentication is successful and a path is set via this attribute, the component will emit a `navigate` event which will bubble up the component hierarchy and can be used by a parent component to perform the success redirection. This approach can be used as an alternative to `success-location-hash` or `success-url` for doing the final redirect.
|
|
815
818
|
- `state-session-storage-key`: The state string is stored in the browser's `sessionStorage` under this key. Defaults to `oauth.state`. It must match the value provided to the `oauth-link` component at the start of the OAuth flow.
|
|
816
819
|
- `code-param-name`: The name of the query parameter which holds the `code` as provided by the OAuth provider within the OAuth callback URL. Defaults to `code`.
|
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/oauth-handler.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SocketConsumer } from './socket.js';
|
|
2
|
-
import { generateRandomHexString } from './utils.js';
|
|
2
|
+
import { generateRandomHexString, convertStringToFieldParams } from './utils.js';
|
|
3
3
|
|
|
4
4
|
const DEFAULT_AUTH_TIMEOUT = 10000;
|
|
5
5
|
|
|
@@ -49,9 +49,10 @@ class OAuthHandler extends SocketConsumer {
|
|
|
49
49
|
|
|
50
50
|
let codeParamName = this.getAttribute('code-param-name') || 'code';
|
|
51
51
|
let stateParamName = this.getAttribute('state-param-name') || 'state';
|
|
52
|
+
let extraDataString = this.getAttribute('extra-data') || '';
|
|
53
|
+
let { fieldValues: extraData } = convertStringToFieldParams(extraDataString);
|
|
52
54
|
|
|
53
55
|
let authTimeout = Number(this.getAttribute('auth-timeout') || DEFAULT_AUTH_TIMEOUT);
|
|
54
|
-
|
|
55
56
|
let urlSearchParams = new URLSearchParams(location.search);
|
|
56
57
|
let code = urlSearchParams.get(codeParamName);
|
|
57
58
|
|
|
@@ -63,7 +64,7 @@ class OAuthHandler extends SocketConsumer {
|
|
|
63
64
|
|
|
64
65
|
if (state === expectedOAuthState) {
|
|
65
66
|
try {
|
|
66
|
-
await socket.invoke('log-in-oauth', { provider, data: { code } });
|
|
67
|
+
await socket.invoke('log-in-oauth', { provider, data: { code, ...extraData } });
|
|
67
68
|
} catch (error) {
|
|
68
69
|
this.innerHTML = `
|
|
69
70
|
<div class="error">OAuth authentication failed. ${error.message}</div>
|
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"
|