fhdp-fh-starter 4.10.301 → 4.10.401

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/FhApplication.ts CHANGED
@@ -1,367 +1,367 @@
1
- import "reflect-metadata";
2
- import {
3
- ApplicationLock,
4
- Connector,
5
- CustomActions,
6
- FH,
7
- FhContainer,
8
- FhModule,
9
- FormsHandler,
10
- I18n,
11
- ServiceManagerUtil,
12
- SocketHandler,
13
- Util
14
- } from "fh-forms-handler";
15
- import {BasicControls} from "fh-basic-controls";
16
- import {ChartsControls} from "fh-charts-controls";
17
- import {FhDPControls} from "fhdp-controls";
18
- import {DynamicRelocatorExclusionRule, DynamicRelocatorExtensionRule, getCookie, FHDPExtender} from 'fhdp-extenders';
19
-
20
- export interface LiferayConfig {
21
- /** Defines if liferay is enabled or not */
22
- enabled: boolean;
23
- /** Local websocket addres For debug */
24
- localPumaWsURL: string;
25
- /** Remote websocket address */
26
- fhBaseUrl: string;
27
- /** Remote context path */
28
- fhContextPath: string;
29
- }
30
-
31
- export interface ExtenderConfig {
32
- extendFHML?: boolean;
33
- mobileMaxWidth?: number;
34
- enableMobileNavbar?: boolean;
35
- enableErrorBelowField?: boolean;
36
- enableDynamicFooterPosition?: boolean;
37
- enableCurrentMenuElementHighlight?: boolean;
38
- currentMenuElementHighlighBottomBorderStyle?: string;
39
- enableFHMLinTooltips?: boolean;
40
- enableSessionCounterRules?: boolean;
41
- enableCookieAlert?: boolean;
42
- additionalRules?: Array<DynamicRelocatorExclusionRule | DynamicRelocatorExtensionRule>;
43
- }
44
-
45
- export interface FhApplicationConfig {
46
- /** Defines registration of standard modules (FormsHandler and BasicControls) */
47
- registerStandardModules?: boolean;
48
- /** Defines registration of Charts module */
49
- registerChartsControls?: boolean;
50
- /** Defines registration of FHDP controls module*/
51
- registerFHDPControls?: boolean;
52
- /** Defines registration of additional modules*/
53
- additionalModules?: ({ new(): FhModule})[];
54
- /** Defines translations for connection lost message Default contains messages for polish and english languages */
55
- connectionLostTranslations?: {[key: string]: string};
56
- /** Defines config for liferay If empty it will act as normal application */
57
- liferay?: LiferayConfig;
58
- /** Defines config for FHDPExtender If empty it will act as normal fh app without extensions */
59
- extensionsConfig?: ExtenderConfig
60
- }
61
-
62
- type ConnectorType = (target: string, reconnectCallback: () => void, openCallback: () => void) => Connector;
63
-
64
- class FhApplication {
65
- /** Instance of FhApplication */
66
- private static __instance: FhApplication;
67
-
68
- /** Current config */
69
- private __config: FhApplicationConfig;
70
-
71
- /** Instance of Liferay config */
72
- private __liferay?: LiferayConfig;
73
-
74
- /** Instance of connector */
75
- private __connector?: Connector;
76
-
77
- /**
78
- * Private and used internally
79
- * @param config main configuration
80
- */
81
- private constructor(config: FhApplicationConfig) {
82
- this.__config = config;
83
- if (config.registerStandardModules) {
84
- this.registerModule(FormsHandler);
85
- this.registerModule(BasicControls);
86
- }
87
- if (config.registerChartsControls) {
88
- this.registerModule(ChartsControls);
89
- }
90
- if (config.registerFHDPControls) {
91
- this.registerModule(FhDPControls);
92
- }
93
- if (config.additionalModules) {
94
- config.additionalModules.forEach(mod => {
95
- this.registerModule(mod);
96
- })
97
- }
98
- if (config.liferay && config.liferay.enabled) {
99
- this.__liferay = config.liferay;
100
- }
101
-
102
-
103
- }
104
-
105
- /**
106
- * At first use must be called with `config` param, to properly init instance
107
- * Later uses can be without param, and it will return same instance as one inited at begin
108
- * @param config main configuration
109
- */
110
- static getInstance(config?: FhApplicationConfig) {
111
- if (!FhApplication.__instance && config) {
112
- FhApplication.__instance = new FhApplication(config);
113
- } else if (!FhApplication.__instance && !config) {
114
- console.error('Init instance first with config');
115
- }
116
- return FhApplication.__instance;
117
- }
118
-
119
- /**
120
- * Getter for connection lost translations
121
- */
122
- private get currentConnectionLostTranslation(): string {
123
- let i18n = FhContainer.get<I18n>('I18n');
124
- return i18n.translateString('connectionLostRetry', undefined, i18n.selectedLanguage);
125
- }
126
-
127
- private isJSON(data:string) {
128
- try {
129
- return JSON.parse(data);
130
- } catch (e) {
131
- return false;
132
- }
133
- }
134
-
135
- /**
136
- * Getter for connector;
137
- * @returns Connector
138
- */
139
- getConnector(): Connector {
140
- return this.__connector;
141
- }
142
-
143
- /**
144
- * Registers new module Its alternative function to config node `additionalModules`
145
- * @param module an module that will be registered in fh app
146
- */
147
- registerModule(module: { new(): FhModule}) {
148
- new module().init();
149
- }
150
-
151
- /**
152
- * Registers callback for backend calls
153
- * @param name callback name (key)
154
- * @param callback actual callback function
155
- */
156
- registerCallback(name: string, callback: (...args) => void) {
157
- let customActions = FhContainer.get<CustomActions>('CustomActions');
158
-
159
- if (customActions == null) {
160
- return new Error('CustomActions is not registered.');
161
- }
162
-
163
- customActions.callbacks[name] = callback;
164
- }
165
-
166
- /**
167
- * Function for initialise extenders
168
- */
169
- private initExtenders() {
170
- const i18n = FhContainer.get<I18n>('I18n');
171
- new FHDPExtender({
172
- i18n,
173
- ...this.__config.extensionsConfig
174
- });
175
- }
176
-
177
- /**
178
- * Adds translation string
179
- */
180
- public addTranslation(lang, key, translation) {
181
- let i18n = FhContainer.get<I18n>('I18n');
182
- i18n.registerStrings(
183
- lang,
184
- {
185
- [key]: translation
186
- },
187
- true
188
- );
189
- }
190
-
191
- /**
192
- * get translation string
193
- */
194
- public translate(key, args) {
195
- let i18n = FhContainer.get<I18n>('I18n');
196
- return i18n.translateString(key, args, i18n.selectedLanguage);
197
- }
198
-
199
- /**
200
- * Initialise translations for connection lost
201
- */
202
- private initConnectionLostTranslations() {
203
- let i18n = FhContainer.get<I18n>('I18n');
204
- i18n.registerStrings(
205
- 'pl',
206
- {
207
- connectionLostRetry: 'Połączenie z serwerem zostało przerwane. Ponawiam próbę połączenia...'
208
- },
209
- true
210
- );
211
- i18n.registerStrings(
212
- 'en',
213
- {
214
- connectionLostRetry: 'Connection with server is broken. Trying to reconnect...'
215
- },
216
- true
217
- );
218
- if (this.__config.connectionLostTranslations) {
219
- Object.keys(this.__config.connectionLostTranslations).forEach(iso => {
220
- i18n.registerStrings(
221
- iso,
222
- {
223
- connectionLostRetry: this.__config.connectionLostTranslations[iso]
224
- },
225
- true
226
- );
227
- })
228
- }
229
- }
230
-
231
- /**
232
- * Main init function
233
- * @param context app context for sockets Default 'socketForms'
234
- */
235
- init(context: string = 'socketForms') {
236
- let util = FhContainer.get<Util>('Util');
237
- let i18n = FhContainer.get<I18n>('I18n');
238
- if (this.__config.extensionsConfig) {
239
- this.initExtenders();
240
- }
241
- this.initConnectionLostTranslations();
242
-
243
- let contextPath: string;
244
- if (this.__liferay) {
245
- if (this.__liferay.fhBaseUrl != null) {
246
- contextPath = `${this.__liferay.fhBaseUrl.replace('http:/', 'ws:/').replace('https:/', 'wss:/')}${this.__liferay.fhContextPath}/socketForms`;
247
- } else {
248
- contextPath = this.__liferay.localPumaWsURL;
249
- }
250
- } else {
251
- contextPath = util.getPath(context);
252
- }
253
-
254
- this.__connector = FhContainer.get<ConnectorType>("Connector")(
255
- contextPath, () => {
256
- FhContainer.get<ApplicationLock>('ApplicationLock')
257
- .createInfoDialog(this.currentConnectionLostTranslation);
258
- }, () => {
259
- FhContainer.get<ApplicationLock>('ApplicationLock')
260
- .closeInfoDialog();
261
- }
262
- );
263
-
264
- if (this.__liferay && (window as any).Liferay) {
265
- this.__connector.incomingMessageCallback = function (data) {
266
- const isJSON = (data:any) => {
267
- try {
268
- return JSON.parse(data);
269
- } catch (e) {
270
- return false;
271
- }
272
- }
273
- const json = isJSON(data);
274
- console.log('incomingMessageCallback');
275
- if ((window as any).Liferay.Session && (!json || json.eventType !== 'onTimer')) {
276
- (window as any).Liferay.Session.extend();
277
- }
278
- };
279
- this.__connector.outcomingMessageCallback = function (data) {
280
- const isJSON = (data:any) => {
281
- try {
282
- return JSON.parse(data);
283
- } catch (e) {
284
- return false;
285
- }
286
- }
287
- const json = isJSON(data);
288
- console.log('outcomingMessageCallback');
289
- if ((window as any).Liferay.Session && (!json || json.eventType !== 'onTimer')) {
290
- (window as any).Liferay.Session.extend();
291
- }
292
- // after init discard any query parameters from url to prevent repeated actions (e.g. redirect from external page with action in parameter)
293
- if (json && json.command == 'Init') {
294
- history.replaceState(history.state, document.title, location.origin + location.pathname);
295
- if (parent) {
296
- parent.history.replaceState(parent.history.state, parent.document.title, parent.location.origin + parent.location.pathname);
297
- }
298
- }
299
- };
300
- }
301
-
302
- FhContainer.rebind<Connector>("Connector").toConstantValue(this.__connector);
303
- FhContainer.get<SocketHandler>('SocketHandler').addConnector(this.__connector);
304
-
305
- try {
306
- const cookie = getCookie();
307
- if(cookie && cookie['GUEST_LANGUAGE_ID']) {
308
- i18n.selectLanguage(cookie['GUEST_LANGUAGE_ID']);
309
- console.log("LANGUAGE SELECTED ON START(GUEST_LANGUAGE_ID): ", cookie['GUEST_LANGUAGE_ID'])
310
- } else if (cookie && cookie['USERLANG']) {
311
- i18n.selectLanguage(cookie['USERLANG']);
312
- console.log("LANGUAGE SELECTED ON START: ", cookie['USERLANG'])
313
- }
314
- } catch (e) {
315
- console.warn(e);
316
- }
317
- if (this.__liferay) {
318
- FhContainer.get<FH>('FH').initExternal(this.__liferay.localPumaWsURL);
319
- } else {
320
- FhContainer.get<FH>('FH').init();
321
- }
322
- this.registerCallback('callUcAction', (actionName) => {
323
- FhContainer.get<ServiceManagerUtil>('ServiceManagerUtil').callAction('callUcAction', actionName);
324
- });
325
- }
326
-
327
- /**
328
- * Edits classlist of element provided by id
329
- * @param id Id of DOM element
330
- * @param remove class name that should be removed from element
331
- * @param add class name that should be added in element
332
- */
333
- createCallbackById(id: string, remove?: string, add?: string) {
334
- const element = document.getElementById(id);
335
- if(!!element) {
336
- if(!!remove) {
337
- element.classList.remove(remove);
338
- }
339
- if(!!add) {
340
- element.classList.add(add);
341
- }
342
- }
343
- }
344
-
345
- /**
346
- * Edits classlist of element wrapper provided by id
347
- * @param id Id of DOM element
348
- * @param remove class name that should be removed from element wrapper
349
- * @param add class name that should be added in element wrapper
350
- */
351
- createCallbackByWrapper(id: string, remove?: string, add?: string) {
352
- const element = document.getElementById(id);
353
- if(!!element) {
354
- const wrapper = (element.parentNode as HTMLElement);
355
- if(!!wrapper) {
356
- if(!!remove) {
357
- wrapper.classList.remove(remove);
358
- }
359
- if(!!add) {
360
- wrapper.classList.add(add);
361
- }
362
- }
363
- }
364
- }
365
- }
366
-
367
- export {FhApplication};
1
+ import "reflect-metadata";
2
+ import {
3
+ ApplicationLock,
4
+ Connector,
5
+ CustomActions,
6
+ FH,
7
+ FhContainer,
8
+ FhModule,
9
+ FormsHandler,
10
+ I18n,
11
+ ServiceManagerUtil,
12
+ SocketHandler,
13
+ Util
14
+ } from "fh-forms-handler";
15
+ import {BasicControls} from "fh-basic-controls";
16
+ import {ChartsControls} from "fh-charts-controls";
17
+ import {FhDPControls} from "fhdp-controls";
18
+ import {DynamicRelocatorExclusionRule, DynamicRelocatorExtensionRule, getCookie, FHDPExtender} from 'fhdp-extenders';
19
+
20
+ export interface LiferayConfig {
21
+ /** Defines if liferay is enabled or not */
22
+ enabled: boolean;
23
+ /** Local websocket addres For debug */
24
+ localPumaWsURL: string;
25
+ /** Remote websocket address */
26
+ fhBaseUrl: string;
27
+ /** Remote context path */
28
+ fhContextPath: string;
29
+ }
30
+
31
+ export interface ExtenderConfig {
32
+ extendFHML?: boolean;
33
+ mobileMaxWidth?: number;
34
+ enableMobileNavbar?: boolean;
35
+ enableErrorBelowField?: boolean;
36
+ enableDynamicFooterPosition?: boolean;
37
+ enableCurrentMenuElementHighlight?: boolean;
38
+ currentMenuElementHighlighBottomBorderStyle?: string;
39
+ enableFHMLinTooltips?: boolean;
40
+ enableSessionCounterRules?: boolean;
41
+ enableCookieAlert?: boolean;
42
+ additionalRules?: Array<DynamicRelocatorExclusionRule | DynamicRelocatorExtensionRule>;
43
+ }
44
+
45
+ export interface FhApplicationConfig {
46
+ /** Defines registration of standard modules (FormsHandler and BasicControls) */
47
+ registerStandardModules?: boolean;
48
+ /** Defines registration of Charts module */
49
+ registerChartsControls?: boolean;
50
+ /** Defines registration of FHDP controls module*/
51
+ registerFHDPControls?: boolean;
52
+ /** Defines registration of additional modules*/
53
+ additionalModules?: ({ new(): FhModule})[];
54
+ /** Defines translations for connection lost message Default contains messages for polish and english languages */
55
+ connectionLostTranslations?: {[key: string]: string};
56
+ /** Defines config for liferay If empty it will act as normal application */
57
+ liferay?: LiferayConfig;
58
+ /** Defines config for FHDPExtender If empty it will act as normal fh app without extensions */
59
+ extensionsConfig?: ExtenderConfig
60
+ }
61
+
62
+ type ConnectorType = (target: string, reconnectCallback: () => void, openCallback: () => void) => Connector;
63
+
64
+ class FhApplication {
65
+ /** Instance of FhApplication */
66
+ private static __instance: FhApplication;
67
+
68
+ /** Current config */
69
+ private __config: FhApplicationConfig;
70
+
71
+ /** Instance of Liferay config */
72
+ private __liferay?: LiferayConfig;
73
+
74
+ /** Instance of connector */
75
+ private __connector?: Connector;
76
+
77
+ /**
78
+ * Private and used internally
79
+ * @param config main configuration
80
+ */
81
+ private constructor(config: FhApplicationConfig) {
82
+ this.__config = config;
83
+ if (config.registerStandardModules) {
84
+ this.registerModule(FormsHandler);
85
+ this.registerModule(BasicControls);
86
+ }
87
+ if (config.registerChartsControls) {
88
+ this.registerModule(ChartsControls);
89
+ }
90
+ if (config.registerFHDPControls) {
91
+ this.registerModule(FhDPControls);
92
+ }
93
+ if (config.additionalModules) {
94
+ config.additionalModules.forEach(mod => {
95
+ this.registerModule(mod);
96
+ })
97
+ }
98
+ if (config.liferay && config.liferay.enabled) {
99
+ this.__liferay = config.liferay;
100
+ }
101
+
102
+
103
+ }
104
+
105
+ /**
106
+ * At first use must be called with `config` param, to properly init instance
107
+ * Later uses can be without param, and it will return same instance as one inited at begin
108
+ * @param config main configuration
109
+ */
110
+ static getInstance(config?: FhApplicationConfig) {
111
+ if (!FhApplication.__instance && config) {
112
+ FhApplication.__instance = new FhApplication(config);
113
+ } else if (!FhApplication.__instance && !config) {
114
+ console.error('Init instance first with config');
115
+ }
116
+ return FhApplication.__instance;
117
+ }
118
+
119
+ /**
120
+ * Getter for connection lost translations
121
+ */
122
+ private get currentConnectionLostTranslation(): string {
123
+ let i18n = FhContainer.get<I18n>('I18n');
124
+ return i18n.translateString('connectionLostRetry', undefined, i18n.selectedLanguage);
125
+ }
126
+
127
+ private isJSON(data:string) {
128
+ try {
129
+ return JSON.parse(data);
130
+ } catch (e) {
131
+ return false;
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Getter for connector;
137
+ * @returns Connector
138
+ */
139
+ getConnector(): Connector {
140
+ return this.__connector;
141
+ }
142
+
143
+ /**
144
+ * Registers new module Its alternative function to config node `additionalModules`
145
+ * @param module an module that will be registered in fh app
146
+ */
147
+ registerModule(module: { new(): FhModule}) {
148
+ new module().init();
149
+ }
150
+
151
+ /**
152
+ * Registers callback for backend calls
153
+ * @param name callback name (key)
154
+ * @param callback actual callback function
155
+ */
156
+ registerCallback(name: string, callback: (...args) => void) {
157
+ let customActions = FhContainer.get<CustomActions>('CustomActions');
158
+
159
+ if (customActions == null) {
160
+ return new Error('CustomActions is not registered.');
161
+ }
162
+
163
+ customActions.callbacks[name] = callback;
164
+ }
165
+
166
+ /**
167
+ * Function for initialise extenders
168
+ */
169
+ private initExtenders() {
170
+ const i18n = FhContainer.get<I18n>('I18n');
171
+ new FHDPExtender({
172
+ i18n,
173
+ ...this.__config.extensionsConfig
174
+ });
175
+ }
176
+
177
+ /**
178
+ * Adds translation string
179
+ */
180
+ public addTranslation(lang, key, translation) {
181
+ let i18n = FhContainer.get<I18n>('I18n');
182
+ i18n.registerStrings(
183
+ lang,
184
+ {
185
+ [key]: translation
186
+ },
187
+ true
188
+ );
189
+ }
190
+
191
+ /**
192
+ * get translation string
193
+ */
194
+ public translate(key, args) {
195
+ let i18n = FhContainer.get<I18n>('I18n');
196
+ return i18n.translateString(key, args, i18n.selectedLanguage);
197
+ }
198
+
199
+ /**
200
+ * Initialise translations for connection lost
201
+ */
202
+ private initConnectionLostTranslations() {
203
+ let i18n = FhContainer.get<I18n>('I18n');
204
+ i18n.registerStrings(
205
+ 'pl',
206
+ {
207
+ connectionLostRetry: 'Połączenie z serwerem zostało przerwane. Ponawiam próbę połączenia...'
208
+ },
209
+ true
210
+ );
211
+ i18n.registerStrings(
212
+ 'en',
213
+ {
214
+ connectionLostRetry: 'Connection with server is broken. Trying to reconnect...'
215
+ },
216
+ true
217
+ );
218
+ if (this.__config.connectionLostTranslations) {
219
+ Object.keys(this.__config.connectionLostTranslations).forEach(iso => {
220
+ i18n.registerStrings(
221
+ iso,
222
+ {
223
+ connectionLostRetry: this.__config.connectionLostTranslations[iso]
224
+ },
225
+ true
226
+ );
227
+ })
228
+ }
229
+ }
230
+
231
+ /**
232
+ * Main init function
233
+ * @param context app context for sockets Default 'socketForms'
234
+ */
235
+ init(context: string = 'socketForms') {
236
+ let util = FhContainer.get<Util>('Util');
237
+ let i18n = FhContainer.get<I18n>('I18n');
238
+ if (this.__config.extensionsConfig) {
239
+ this.initExtenders();
240
+ }
241
+ this.initConnectionLostTranslations();
242
+
243
+ let contextPath: string;
244
+ if (this.__liferay) {
245
+ if (this.__liferay.fhBaseUrl != null) {
246
+ contextPath = `${this.__liferay.fhBaseUrl.replace('http:/', 'ws:/').replace('https:/', 'wss:/')}${this.__liferay.fhContextPath}/socketForms`;
247
+ } else {
248
+ contextPath = this.__liferay.localPumaWsURL;
249
+ }
250
+ } else {
251
+ contextPath = util.getPath(context);
252
+ }
253
+
254
+ this.__connector = FhContainer.get<ConnectorType>("Connector")(
255
+ contextPath, () => {
256
+ FhContainer.get<ApplicationLock>('ApplicationLock')
257
+ .createInfoDialog(this.currentConnectionLostTranslation);
258
+ }, () => {
259
+ FhContainer.get<ApplicationLock>('ApplicationLock')
260
+ .closeInfoDialog();
261
+ }
262
+ );
263
+
264
+ if (this.__liferay && (window as any).Liferay) {
265
+ this.__connector.incomingMessageCallback = function (data) {
266
+ const isJSON = (data:any) => {
267
+ try {
268
+ return JSON.parse(data);
269
+ } catch (e) {
270
+ return false;
271
+ }
272
+ }
273
+ const json = isJSON(data);
274
+ console.log('incomingMessageCallback');
275
+ if ((window as any).Liferay.Session && (!json || json.eventType !== 'onTimer')) {
276
+ (window as any).Liferay.Session.extend();
277
+ }
278
+ };
279
+ this.__connector.outcomingMessageCallback = function (data) {
280
+ const isJSON = (data:any) => {
281
+ try {
282
+ return JSON.parse(data);
283
+ } catch (e) {
284
+ return false;
285
+ }
286
+ }
287
+ const json = isJSON(data);
288
+ console.log('outcomingMessageCallback');
289
+ if ((window as any).Liferay.Session && (!json || json.eventType !== 'onTimer')) {
290
+ (window as any).Liferay.Session.extend();
291
+ }
292
+ // after init discard any query parameters from url to prevent repeated actions (e.g. redirect from external page with action in parameter)
293
+ if (json && json.command == 'Init') {
294
+ history.replaceState(history.state, document.title, location.origin + location.pathname);
295
+ if (parent) {
296
+ parent.history.replaceState(parent.history.state, parent.document.title, parent.location.origin + parent.location.pathname);
297
+ }
298
+ }
299
+ };
300
+ }
301
+
302
+ FhContainer.rebind<Connector>("Connector").toConstantValue(this.__connector);
303
+ FhContainer.get<SocketHandler>('SocketHandler').addConnector(this.__connector);
304
+
305
+ try {
306
+ const cookie = getCookie();
307
+ if(cookie && cookie['GUEST_LANGUAGE_ID']) {
308
+ i18n.selectLanguage(cookie['GUEST_LANGUAGE_ID']);
309
+ console.log("LANGUAGE SELECTED ON START(GUEST_LANGUAGE_ID): ", cookie['GUEST_LANGUAGE_ID'])
310
+ } else if (cookie && cookie['USERLANG']) {
311
+ i18n.selectLanguage(cookie['USERLANG']);
312
+ console.log("LANGUAGE SELECTED ON START: ", cookie['USERLANG'])
313
+ }
314
+ } catch (e) {
315
+ console.warn(e);
316
+ }
317
+ if (this.__liferay) {
318
+ FhContainer.get<FH>('FH').initExternal(this.__liferay.localPumaWsURL);
319
+ } else {
320
+ FhContainer.get<FH>('FH').init();
321
+ }
322
+ this.registerCallback('callUcAction', (actionName) => {
323
+ FhContainer.get<ServiceManagerUtil>('ServiceManagerUtil').callAction('callUcAction', actionName);
324
+ });
325
+ }
326
+
327
+ /**
328
+ * Edits classlist of element provided by id
329
+ * @param id Id of DOM element
330
+ * @param remove class name that should be removed from element
331
+ * @param add class name that should be added in element
332
+ */
333
+ createCallbackById(id: string, remove?: string, add?: string) {
334
+ const element = document.getElementById(id);
335
+ if(!!element) {
336
+ if(!!remove) {
337
+ element.classList.remove(remove);
338
+ }
339
+ if(!!add) {
340
+ element.classList.add(add);
341
+ }
342
+ }
343
+ }
344
+
345
+ /**
346
+ * Edits classlist of element wrapper provided by id
347
+ * @param id Id of DOM element
348
+ * @param remove class name that should be removed from element wrapper
349
+ * @param add class name that should be added in element wrapper
350
+ */
351
+ createCallbackByWrapper(id: string, remove?: string, add?: string) {
352
+ const element = document.getElementById(id);
353
+ if(!!element) {
354
+ const wrapper = (element.parentNode as HTMLElement);
355
+ if(!!wrapper) {
356
+ if(!!remove) {
357
+ wrapper.classList.remove(remove);
358
+ }
359
+ if(!!add) {
360
+ wrapper.classList.add(add);
361
+ }
362
+ }
363
+ }
364
+ }
365
+ }
366
+
367
+ export {FhApplication};
package/Module.ts CHANGED
@@ -1,5 +1,5 @@
1
- import {FhApplication} from './FhApplication';
2
-
3
- export {
4
- FhApplication
1
+ import {FhApplication} from './FhApplication';
2
+
3
+ export {
4
+ FhApplication
5
5
  }
package/README.md CHANGED
@@ -1,67 +1,67 @@
1
- # QuickStart!
2
-
3
- ## Example use:
4
-
5
- ```
6
- const fhInstance = FhApplication.getInstance({
7
- registerStandardModules: true,
8
- registerChartsControls: true,
9
- registerFhDPControls: true,
10
- extensionsConfig: {
11
- extendFHML: true
12
- }
13
- });
14
-
15
- fhInstance.init();
16
- ```
17
-
18
- ## Example use in portlet:
19
-
20
- ```
21
- const localPumaWsURL = 'ws://localhost:8090/socketForms';
22
- const fhInstance = FhApplication.getInstance({
23
- registerStandardModules: true,
24
- registerChartsControls: true,
25
- registerFhDPControls: true,
26
- extensionsConfig: {
27
- extendFHML: true
28
- },
29
- liferay: {
30
- enabled: true,
31
- fhBaseUrl,
32
- fhContextPath,
33
- localPumaWsURL,
34
- Liferay
35
- }
36
- });
37
-
38
- fhInstance.init();
39
- ```
40
-
41
- Values `fhBaseUrl`, `fhContextPath` and `Liferay` should be provided from template jsp file, and defined at the top as:
42
-
43
- ```
44
- declare const Liferay: any;
45
- declare const fhBaseUrl: string;
46
- declare const fhContextPath: string;
47
- ```
48
-
49
- ## Additional info
50
-
51
- 1. Type `extensionsConfig` is provided by library `fhdp-extenders`.
52
- 2. This package contains the latest versions of fh components, fhdp-components and fdhp-extenders, if you're including this package you don't have need to including them.
53
-
54
- ## Versions table:
55
-
56
- | fhdp-fh-starter version | lib name | included version |
57
- |:------------------------:|:------------------|:----------------:|
58
- | v.18.0.0 - v.18.0.11 | fh-basic-controls | 4.6.25-test2 |
59
- | | fh-charts-controls| 4.6.25 |
60
- | | fh-designer | 4.6.25 |
61
- | | fh-forms-handler | 4.6.25 |
62
- | | fh-maps-controls | 4.6.25 |
63
- | | fh-printer-agent | 4.6.25 |
64
- | | fh-sensors | 4.6.25 |
65
- | | fhdp-controls | 18.1.3 |
66
- | | fhdp-extenders | 18.0.4 |
67
- |--------------------------|-------------------|------------------|
1
+ # QuickStart!
2
+
3
+ ## Example use:
4
+
5
+ ```
6
+ const fhInstance = FhApplication.getInstance({
7
+ registerStandardModules: true,
8
+ registerChartsControls: true,
9
+ registerFhDPControls: true,
10
+ extensionsConfig: {
11
+ extendFHML: true
12
+ }
13
+ });
14
+
15
+ fhInstance.init();
16
+ ```
17
+
18
+ ## Example use in portlet:
19
+
20
+ ```
21
+ const localPumaWsURL = 'ws://localhost:8090/socketForms';
22
+ const fhInstance = FhApplication.getInstance({
23
+ registerStandardModules: true,
24
+ registerChartsControls: true,
25
+ registerFhDPControls: true,
26
+ extensionsConfig: {
27
+ extendFHML: true
28
+ },
29
+ liferay: {
30
+ enabled: true,
31
+ fhBaseUrl,
32
+ fhContextPath,
33
+ localPumaWsURL,
34
+ Liferay
35
+ }
36
+ });
37
+
38
+ fhInstance.init();
39
+ ```
40
+
41
+ Values `fhBaseUrl`, `fhContextPath` and `Liferay` should be provided from template jsp file, and defined at the top as:
42
+
43
+ ```
44
+ declare const Liferay: any;
45
+ declare const fhBaseUrl: string;
46
+ declare const fhContextPath: string;
47
+ ```
48
+
49
+ ## Additional info
50
+
51
+ 1. Type `extensionsConfig` is provided by library `fhdp-extenders`.
52
+ 2. This package contains the latest versions of fh components, fhdp-components and fdhp-extenders, if you're including this package you don't have need to including them.
53
+
54
+ ## Versions table:
55
+
56
+ | fhdp-fh-starter version | lib name | included version |
57
+ |:------------------------:|:------------------|:----------------:|
58
+ | v.18.0.0 - v.18.0.11 | fh-basic-controls | 4.6.25-test2 |
59
+ | | fh-charts-controls| 4.6.25 |
60
+ | | fh-designer | 4.6.25 |
61
+ | | fh-forms-handler | 4.6.25 |
62
+ | | fh-maps-controls | 4.6.25 |
63
+ | | fh-printer-agent | 4.6.25 |
64
+ | | fh-sensors | 4.6.25 |
65
+ | | fhdp-controls | 18.1.3 |
66
+ | | fhdp-extenders | 18.0.4 |
67
+ |--------------------------|-------------------|------------------|
@@ -1 +1 @@
1
- {"name":"fhdp-fh-starter","version":"4.10.301","author":{"name":"Jakub Kosecki","email":"j.kosecki@doittechnology.pl"},"description":"Configurable starter for asseco/fh","main":"dist/Module.js","types":"dist/Module.d.ts","scripts":{"prepublish":"node prepublish","postpublish":"node postpublish","build":"tsc","docgen":"npx typedoc ./FhApplication.ts","prepare":"yarn build","test":"echo \"Error: no test specified\" && exit 1"},"devDependencies":{"@types/bootstrap":"4.3.1","@types/jquery":"3.3.31","@types/node":"14.14.36","typedoc":"^0.20.20","typescript":"3.9"},"dependencies":{"fh-basic-controls":"4.10.301","fh-charts-controls":"4.10.301","fh-forms-handler":"4.10.301","fhdp-controls":"4.10.301","fhdp-extenders":"4.10.301"}}
1
+ {"name":"fhdp-fh-starter","version":"4.10.401","author":{"name":"Jakub Kosecki","email":"j.kosecki@doittechnology.pl"},"description":"Configurable starter for asseco/fh","main":"dist/Module.js","types":"dist/Module.d.ts","scripts":{"prepublish":"node prepublish","postpublish":"node postpublish","build":"tsc","docgen":"npx typedoc ./FhApplication.ts","prepare":"yarn build","test":"echo \"Error: no test specified\" && exit 1"},"devDependencies":{"@types/bootstrap":"4.3.1","@types/jquery":"3.3.31","@types/node":"14.14.36","typedoc":"^0.20.20","typescript":"3.9"},"dependencies":{"fh-basic-controls":"4.10.401","fh-charts-controls":"4.10.401","fh-forms-handler":"4.10.401","fhdp-controls":"4.10.401","fhdp-extenders":"4.10.401"}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fhdp-fh-starter",
3
- "version": "4.10.301",
3
+ "version": "4.10.401",
4
4
  "author": {
5
5
  "name": "Jakub Kosecki",
6
6
  "email": "j.kosecki@doittechnology.pl"
@@ -24,10 +24,10 @@
24
24
  "typescript": "3.9"
25
25
  },
26
26
  "dependencies": {
27
- "fh-basic-controls": "4.10.301",
28
- "fh-charts-controls": "4.10.301",
29
- "fh-forms-handler": "4.10.301",
30
- "fhdp-controls": "4.10.301",
31
- "fhdp-extenders": "4.10.301"
27
+ "fh-basic-controls": "4.10.401",
28
+ "fh-charts-controls": "4.10.401",
29
+ "fh-forms-handler": "4.10.401",
30
+ "fhdp-controls": "4.10.401",
31
+ "fhdp-extenders": "4.10.401"
32
32
  }
33
33
  }
package/postpublish.js CHANGED
@@ -1,15 +1,15 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const ORIG_PKG_PATH = path.resolve(__dirname, 'package.json');
4
- const CACHED_PKG_PATH = path.resolve(__dirname, 'cached-package.json');
5
- const pkgData = JSON.stringify(require(CACHED_PKG_PATH), null, 2) + '\n';
6
-
7
- fs.writeFile(ORIG_PKG_PATH, pkgData, function (err) {
8
- if (err) throw err;
9
- });
10
-
11
- pkgData.main = 'Module.ts';
12
-
13
- fs.unlink(CACHED_PKG_PATH, function (err) {
14
- if (err) throw err;
15
- });
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const ORIG_PKG_PATH = path.resolve(__dirname, 'package.json');
4
+ const CACHED_PKG_PATH = path.resolve(__dirname, 'cached-package.json');
5
+ const pkgData = JSON.stringify(require(CACHED_PKG_PATH), null, 2) + '\n';
6
+
7
+ fs.writeFile(ORIG_PKG_PATH, pkgData, function (err) {
8
+ if (err) throw err;
9
+ });
10
+
11
+ pkgData.main = 'Module.ts';
12
+
13
+ fs.unlink(CACHED_PKG_PATH, function (err) {
14
+ if (err) throw err;
15
+ });
package/prepublish.js CHANGED
@@ -1,15 +1,15 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const ORIG_PKG_PATH = path.resolve(__dirname, 'package.json');
4
- const CACHED_PKG_PATH = path.resolve(__dirname, 'cached-package.json');
5
- const pkgData = require(ORIG_PKG_PATH);
6
-
7
- fs.writeFile(CACHED_PKG_PATH, JSON.stringify(pkgData), function (err) {
8
- if (err) throw err;
9
- });
10
-
11
- pkgData.main = 'dist/Module.js';
12
-
13
- fs.writeFile(ORIG_PKG_PATH, JSON.stringify(pkgData, null, 2), function (err) {
14
- if (err) throw err;
15
- });
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const ORIG_PKG_PATH = path.resolve(__dirname, 'package.json');
4
+ const CACHED_PKG_PATH = path.resolve(__dirname, 'cached-package.json');
5
+ const pkgData = require(ORIG_PKG_PATH);
6
+
7
+ fs.writeFile(CACHED_PKG_PATH, JSON.stringify(pkgData), function (err) {
8
+ if (err) throw err;
9
+ });
10
+
11
+ pkgData.main = 'dist/Module.js';
12
+
13
+ fs.writeFile(ORIG_PKG_PATH, JSON.stringify(pkgData, null, 2), function (err) {
14
+ if (err) throw err;
15
+ });
package/tsconfig.json CHANGED
@@ -1,18 +1,18 @@
1
- {
2
- "compilerOptions": {
3
- "jsx": "react",
4
- "sourceMap": true,
5
- "target": "es5",
6
- "outDir": "dist",
7
- "lib": ["es6", "dom"],
8
- "types": ["reflect-metadata", "jquery", "jqueryui", "bootstrap", "node"],
9
- "module": "commonjs",
10
- "baseUrl": "types",
11
- "moduleResolution": "node",
12
- "declaration": true,
13
- "experimentalDecorators": true,
14
- "emitDecoratorMetadata": true,
15
- "resolveJsonModule": true,
16
- },
17
- "exclude": ["node_modules", "target", "dist"]
18
- }
1
+ {
2
+ "compilerOptions": {
3
+ "jsx": "react",
4
+ "sourceMap": true,
5
+ "target": "es5",
6
+ "outDir": "dist",
7
+ "lib": ["es6", "dom"],
8
+ "types": ["reflect-metadata", "jquery", "jqueryui", "bootstrap", "node"],
9
+ "module": "commonjs",
10
+ "baseUrl": "types",
11
+ "moduleResolution": "node",
12
+ "declaration": true,
13
+ "experimentalDecorators": true,
14
+ "emitDecoratorMetadata": true,
15
+ "resolveJsonModule": true,
16
+ },
17
+ "exclude": ["node_modules", "target", "dist"]
18
+ }