@rws-framework/client 2.18.0 → 2.18.2
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/cfg/build_steps/webpack/_loaders.js +1 -1
- package/package.json +1 -1
- package/src/components/rws/loader/component.ts +3 -2
- package/src/components/rws/loader/styles/layout.scss +6 -6
- package/src/components/rws/reformer/component.ts +0 -1
- package/src/components/rws/reformer/fields/boolean/component.ts +0 -0
- package/src/components/rws/reformer/fields/boolean/template.html +0 -0
- package/src/components/rws/reformer/fields/date/component.ts +0 -0
- package/src/components/rws/reformer/fields/date/template.html +0 -0
- package/src/components/rws/reformer/fields/number/component.ts +0 -0
- package/src/components/rws/reformer/fields/number/template.html +0 -0
- package/src/components/rws/reformer/types/IReFormerTypes.ts +0 -0
- package/src/components/rws/rws-api-resource/variants/form/component.ts +0 -2
- package/src/components/rws/rws-modal/component.ts +6 -1
- package/src/services/ApiService.ts +8 -8
- package/src/services/_api/backend.ts +1 -1
- package/src/services/_api/calls.ts +52 -31
|
@@ -252,7 +252,7 @@ async function getTemplate(filePath, addDependency, templateName = null, isDev =
|
|
|
252
252
|
|
|
253
253
|
if (templateExists) {
|
|
254
254
|
const templateContent = fs.readFileSync(templatePath, 'utf-8').replace(/<!--[\s\S]*?-->/g, '');
|
|
255
|
-
htmlFastImports = `import * as T from '@microsoft/fast-element';\nimport './${templateName}.html';\n`;
|
|
255
|
+
htmlFastImports = `import * as T from '@microsoft/fast-element';\nimport { html, css, ref, when, repeat, slotted, children } from '@microsoft/fast-element'; \nimport './${templateName}.html';\n`;
|
|
256
256
|
template = `
|
|
257
257
|
//@ts-ignore
|
|
258
258
|
let rwsTemplate: any = T.html\`${templateContent}\`;
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { RWSView } from '../../_decorator';
|
|
2
2
|
import { RWSViewComponent } from '../../_component';
|
|
3
|
+
import { attr } from '@microsoft/fast-element';
|
|
3
4
|
|
|
4
|
-
@RWSView('
|
|
5
|
-
class RWSLoader extends RWSViewComponent {
|
|
5
|
+
@RWSView('rws-loader')
|
|
6
|
+
class RWSLoader extends RWSViewComponent {
|
|
6
7
|
connectedCallback(): void {
|
|
7
8
|
super.connectedCallback();
|
|
8
9
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
//loader
|
|
2
2
|
//save
|
|
3
|
-
$loader-color: var(--
|
|
4
|
-
$loader-size:
|
|
3
|
+
$loader-color: var(--rws-loader-color, #eb7b13);
|
|
4
|
+
$loader-size: 26px;
|
|
5
5
|
$loader-height: 20px;
|
|
6
6
|
$loader-border-size: 8px;
|
|
7
7
|
$loader-gap: 12px;
|
|
8
8
|
$loader-animation-duration: 1s;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
@import "~/scss-loading-animations/src/loaders";
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
.loader {
|
|
13
|
+
@include loader06;
|
|
14
|
+
}
|
|
@@ -27,7 +27,6 @@ class ReFormer extends RWSViewComponent {
|
|
|
27
27
|
|
|
28
28
|
modelTypesChanged(oldVal:IKDBTypesResponse, newVal: IKDBTypesResponse)
|
|
29
29
|
{
|
|
30
|
-
console.log({newVal})
|
|
31
30
|
if(newVal){
|
|
32
31
|
this.formFields = newVal.data.types.filter((item) => !['id', 'created_at', 'updated_at'].includes(item.fieldName))
|
|
33
32
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -5,8 +5,13 @@ import { RWSView} from '../../_decorator';
|
|
|
5
5
|
@RWSView('rws-modal')
|
|
6
6
|
class RWSModal extends RWSViewComponent {
|
|
7
7
|
@observable closeModal: () => void
|
|
8
|
+
@observable onShowModal: ($: ShadowRoot) => void
|
|
9
|
+
|
|
8
10
|
connectedCallback(): void {
|
|
9
|
-
super.connectedCallback();
|
|
11
|
+
super.connectedCallback();
|
|
12
|
+
if(this.onShowModal){
|
|
13
|
+
this.onShowModal(this.shadowRoot);
|
|
14
|
+
}
|
|
10
15
|
}
|
|
11
16
|
}
|
|
12
17
|
|
|
@@ -45,7 +45,7 @@ type IBackendRoute = IHTTProute | IPrefixedHTTProutes;
|
|
|
45
45
|
|
|
46
46
|
class ApiService extends TheService {
|
|
47
47
|
static _DEFAULT: boolean = true;
|
|
48
|
-
|
|
48
|
+
public token?: string;
|
|
49
49
|
|
|
50
50
|
constructor(@ConfigService public config: ConfigServiceInstance) {
|
|
51
51
|
super();
|
|
@@ -60,7 +60,7 @@ class ApiService extends TheService {
|
|
|
60
60
|
|
|
61
61
|
public async isGetTargetReachable(url: string, options: IAPIOptions = {}): Promise<boolean> {
|
|
62
62
|
try {
|
|
63
|
-
return !!(await calls.pureGet(url, options
|
|
63
|
+
return !!(await calls.pureGet.bind(this)(url, options));
|
|
64
64
|
} catch (error) {
|
|
65
65
|
return false;
|
|
66
66
|
}
|
|
@@ -89,16 +89,16 @@ class ApiService extends TheService {
|
|
|
89
89
|
public delete = calls.delete;
|
|
90
90
|
|
|
91
91
|
public back = {
|
|
92
|
-
get: <T>(routeName: string, options?: IAPIOptions): Promise<T> => calls.get(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), options
|
|
93
|
-
post: <T, P extends object = object>(routeName: string, payload?: P, options?: IAPIOptions): Promise<T> => calls.post(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), payload, options
|
|
94
|
-
put: <T, P extends object = object>(routeName: string, payload: P, options?: IAPIOptions): Promise<T> => calls.put(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), payload, options
|
|
95
|
-
delete: <T>(routeName: string, options?: IAPIOptions): Promise<T> => calls.delete(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), options
|
|
96
|
-
uploadFile: (routeName: string, file: File, onProgress: (progress: number) => void, options: IAPIOptions = {}, payload: any = {}): Promise<UploadResponse> => this.uploadFile(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), file, onProgress, payload),
|
|
92
|
+
get: async <T>(routeName: string, options?: IAPIOptions, token?: string): Promise<T> => calls.get.bind(this)(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), options) as Promise<T>,
|
|
93
|
+
post: async <T, P extends object = object>(routeName: string, payload?: P, options?: IAPIOptions): Promise<T> => calls.post.bind(this)(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), payload, options) as Promise<T>,
|
|
94
|
+
put: async <T, P extends object = object>(routeName: string, payload: P, options?: IAPIOptions): Promise<T> => calls.put.bind(this)(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), payload, options) as Promise<T>,
|
|
95
|
+
delete: async <T>(routeName: string, options?: IAPIOptions): Promise<T> => calls.delete.bind(this)(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), options) as Promise<T>,
|
|
96
|
+
uploadFile: async (routeName: string, file: File, onProgress: (progress: number) => void, options: IAPIOptions = {}, payload: any = {}): Promise<UploadResponse> => this.uploadFile(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), file, onProgress, payload),
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
async getResource(resourceName: string): Promise<IKDBTypesResponse>
|
|
100
100
|
{
|
|
101
|
-
return calls.get(`${this.config.get('backendUrl')}${this.config.get('apiPrefix') || ''}/api/rws/resource/${resourceName}`)
|
|
101
|
+
return calls.get.bind(this)(`${this.config.get('backendUrl')}${this.config.get('apiPrefix') || ''}/api/rws/resource/${resourceName}`) as Promise<IKDBTypesResponse>
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
@@ -2,7 +2,7 @@ import { ApiServiceInstance, IBackendRoute, IHTTProute } from "../ApiService";
|
|
|
2
2
|
import { ConfigServiceInstance } from "../ConfigService";
|
|
3
3
|
|
|
4
4
|
export const backend = {
|
|
5
|
-
getBackendUrl(this: ApiServiceInstance, routeName: string, params: {[key: string]: string} = {})
|
|
5
|
+
getBackendUrl(this: ApiServiceInstance, routeName: string, params: {[key: string]: string} = {}): string
|
|
6
6
|
{
|
|
7
7
|
const config = this.config;
|
|
8
8
|
const routesPackage = config.get('backendRoutes');
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { IAPIOptions } from "../ApiService";
|
|
1
|
+
import { ApiServiceInstance, IAPIOptions } from "../ApiService";
|
|
2
2
|
|
|
3
3
|
const _DEFAULT_CONTENT_TYPE = 'application/json';
|
|
4
4
|
|
|
5
|
+
type HeadersType = Headers | [string, string][] | Record<string, string>;
|
|
6
|
+
|
|
5
7
|
export const calls = {
|
|
6
|
-
addHeader(headers:
|
|
7
|
-
{
|
|
8
|
+
addHeader(headers: HeadersType, key: string, val: string): void {
|
|
8
9
|
if (headers instanceof Headers) {
|
|
9
10
|
headers.append(key, val);
|
|
10
11
|
} else if (Array.isArray(headers)) {
|
|
@@ -13,29 +14,31 @@ export const calls = {
|
|
|
13
14
|
headers[key] = val;
|
|
14
15
|
}
|
|
15
16
|
},
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
getHeaders(token: string | null = null, optHeaders: HeadersInit = {}): HeadersInit {
|
|
19
|
+
const headers: Record<string, string> = { ...(optHeaders as Record<string, string>) };
|
|
18
20
|
|
|
19
21
|
if (!('Content-Type' in headers)) {
|
|
20
22
|
this.addHeader(headers, 'Content-Type', _DEFAULT_CONTENT_TYPE);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
+
}
|
|
24
|
+
|
|
23
25
|
if (token) {
|
|
24
|
-
this.addHeader(headers, 'Authorization', `Bearer ${token}`);
|
|
25
|
-
}
|
|
26
|
+
this.addHeader(headers, 'Authorization', `Bearer ${token}`);
|
|
27
|
+
}
|
|
26
28
|
|
|
27
|
-
if(
|
|
29
|
+
if (headers['Content-Type']) {
|
|
28
30
|
this.addHeader(headers, 'Accept', '*/*');
|
|
29
|
-
}else{
|
|
30
|
-
this.addHeader(headers, 'Accept',
|
|
31
|
+
} else {
|
|
32
|
+
this.addHeader(headers, 'Accept', headers['Content-Type'] || _DEFAULT_CONTENT_TYPE);
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
return headers;
|
|
34
36
|
},
|
|
35
|
-
|
|
37
|
+
|
|
38
|
+
async pureGet(this: ApiServiceInstance, url: string, options: IAPIOptions = {}): Promise<string> {
|
|
36
39
|
try {
|
|
37
40
|
const response = await fetch(url, {
|
|
38
|
-
headers:
|
|
41
|
+
headers: calls.getHeaders(this.token, options.headers),
|
|
39
42
|
});
|
|
40
43
|
return await response.text();
|
|
41
44
|
} catch (error) {
|
|
@@ -43,53 +46,71 @@ export const calls = {
|
|
|
43
46
|
throw error;
|
|
44
47
|
}
|
|
45
48
|
},
|
|
46
|
-
|
|
49
|
+
|
|
50
|
+
async get<T>(this: ApiServiceInstance, url: string, options: IAPIOptions = {}): Promise<T> {
|
|
47
51
|
try {
|
|
48
52
|
const response = await fetch(url, {
|
|
49
|
-
headers:
|
|
53
|
+
headers: calls.getHeaders(this.token, options.headers),
|
|
50
54
|
});
|
|
51
|
-
|
|
55
|
+
const data: T = await response.json();
|
|
56
|
+
return data;
|
|
52
57
|
} catch (error) {
|
|
53
58
|
console.error('GET request failed:', error);
|
|
54
59
|
throw error;
|
|
55
60
|
}
|
|
56
|
-
},
|
|
57
|
-
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
async post<T, P extends object = object>(
|
|
64
|
+
this: ApiServiceInstance,
|
|
65
|
+
url: string,
|
|
66
|
+
payload?: P,
|
|
67
|
+
options: IAPIOptions = {}
|
|
68
|
+
): Promise<T> {
|
|
58
69
|
try {
|
|
59
70
|
const response = await fetch(url, {
|
|
60
71
|
method: 'POST',
|
|
61
|
-
headers:
|
|
72
|
+
headers: calls.getHeaders(this.token, options.headers),
|
|
62
73
|
body: payload ? JSON.stringify(payload) : null,
|
|
63
74
|
});
|
|
64
|
-
|
|
75
|
+
const data: T = await response.json();
|
|
76
|
+
return data;
|
|
65
77
|
} catch (error) {
|
|
66
78
|
console.error('POST request failed:', error);
|
|
67
79
|
throw error;
|
|
68
80
|
}
|
|
69
|
-
},
|
|
70
|
-
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
async put<T, P extends object = object>(
|
|
84
|
+
this: ApiServiceInstance,
|
|
85
|
+
url: string,
|
|
86
|
+
payload: P,
|
|
87
|
+
options: IAPIOptions = {}
|
|
88
|
+
): Promise<T> {
|
|
71
89
|
try {
|
|
72
90
|
const response = await fetch(url, {
|
|
73
91
|
method: 'PUT',
|
|
74
|
-
headers:
|
|
75
|
-
body:
|
|
92
|
+
headers: calls.getHeaders(this.token, options.headers),
|
|
93
|
+
body: JSON.stringify(payload),
|
|
76
94
|
});
|
|
77
|
-
|
|
95
|
+
const data: T = await response.json();
|
|
96
|
+
return data;
|
|
78
97
|
} catch (error) {
|
|
79
98
|
console.error('PUT request failed:', error);
|
|
80
99
|
throw error;
|
|
81
100
|
}
|
|
82
|
-
},
|
|
83
|
-
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
async delete<T>(this: ApiServiceInstance, url: string, options: IAPIOptions = {}): Promise<T> {
|
|
84
104
|
try {
|
|
85
105
|
const response = await fetch(url, {
|
|
86
106
|
method: 'DELETE',
|
|
87
|
-
headers:
|
|
107
|
+
headers: calls.getHeaders(this.token, options.headers),
|
|
88
108
|
});
|
|
89
|
-
|
|
109
|
+
const data: T = await response.json();
|
|
110
|
+
return data;
|
|
90
111
|
} catch (error) {
|
|
91
112
|
console.error('DELETE request failed:', error);
|
|
92
113
|
throw error;
|
|
93
114
|
}
|
|
94
115
|
}
|
|
95
|
-
}
|
|
116
|
+
};
|