inviton-powerduck 0.0.172 → 0.0.174

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.
@@ -4,6 +4,7 @@ import type { IPowerduckSystemResources } from './powerduck-system-resources';
4
4
  import jquery from 'jquery';
5
5
  import moment from 'moment';
6
6
  import select2 from 'select2';
7
+ import StorageProvider from '../common/local-storage-shim';
7
8
  import { isNullOrEmpty } from '../common/utils/is-null-or-empty';
8
9
  import { LanguageUtils } from '../common/utils/language-utils';
9
10
  import TemporalUtils from '../common/utils/temporal-utils';
@@ -29,9 +30,9 @@ export default class PowerduckInitializer {
29
30
 
30
31
  globalState.addEventListener('vite:preloadError', (event) => {
31
32
  const key = `${PowerduckState.getAppPrefix()}errLastReload`;
32
- const lastTry = Number(localStorage.getItem(key) || '0');
33
+ const lastTry = Number(StorageProvider.getString(key) || '0');
33
34
  if (TemporalUtils.dateNowMs() - lastTry > 3000) {
34
- localStorage.setItem(key, TemporalUtils.dateNowMs().toString());
35
+ StorageProvider.setString(key, TemporalUtils.dateNowMs().toString());
35
36
 
36
37
  if (globalState.__routerNextTo != null && !isNullOrEmpty(globalState.__routerNextTo.path)) {
37
38
  location.href = globalState.__routerNextTo.path;
@@ -2,6 +2,7 @@ import type { IDynamicComponentContainer } from '../components/app/dynamic-compo
2
2
  import type { IPowerduckSystemResources } from './powerduck-system-resources';
3
3
  import { Language } from '../common/enums/language';
4
4
  import { ModalSectionMode } from '../common/enums/modal';
5
+ import StorageProvider from '../common/local-storage-shim';
5
6
  import { isNullOrEmpty } from '../common/utils/is-null-or-empty';
6
7
  import { documentWrap, globalState } from './global-state';
7
8
 
@@ -100,8 +101,8 @@ export default class PowerduckState {
100
101
 
101
102
  static getModalSectionMode(): ModalSectionMode {
102
103
  if ((PowerduckState as any)._modalSectionMode == null) {
103
- if (localStorage.getItem(`${PowerduckState._prefix}modalSectionMode`) != null) {
104
- (PowerduckState as any)._modalSectionMode = Number(localStorage.getItem(`${PowerduckState._prefix}modalSectionMode`));
104
+ if (StorageProvider.getString(`${PowerduckState._prefix}modalSectionMode`) != null) {
105
+ (PowerduckState as any)._modalSectionMode = Number(StorageProvider.getString(`${PowerduckState._prefix}modalSectionMode`));
105
106
  } else {
106
107
  PowerduckState.setModalSectionMode(ModalSectionMode.navPills);
107
108
  }
@@ -111,7 +112,7 @@ export default class PowerduckState {
111
112
  }
112
113
 
113
114
  static setModalSectionMode(mode: ModalSectionMode): void {
114
- localStorage.setItem(`${PowerduckState._prefix}modalSectionMode`, mode.toString());
115
+ StorageProvider.setString(`${PowerduckState._prefix}modalSectionMode`, mode.toString());
115
116
  (PowerduckState as any)._modalSectionMode = mode;
116
117
  }
117
118
 
@@ -194,6 +194,13 @@ export interface AjaxLogProvider {
194
194
  log: (level: 'debug' | 'info' | 'warning' | 'error', message: string, data: any) => any;
195
195
  }
196
196
 
197
+ export interface AjaxMiddlewareArgs {
198
+ response: any;
199
+ httpCode: number;
200
+ }
201
+
202
+ export type AjaxMiddleware = (args: AjaxMiddlewareArgs) => Promise<void>;
203
+
197
204
  export class AppHttpProvider {
198
205
  static getRetryCount = 0;
199
206
  static postRetryCount = 0;
@@ -202,6 +209,7 @@ export class AppHttpProvider {
202
209
  static defaultRequestProvider: AppHttpRequestProvider = 'xhr';
203
210
  static xhrRequestProvider: AjaxRequestProvider = new AjaxProviderXhr();
204
211
  static cordovaRequestProvider: AjaxRequestProvider = null;
212
+ static middlewares: AjaxMiddleware[] = [];
205
213
  static getRequestTimeoutMessage(): string {
206
214
  return PowerduckState.getResourceValue('requestTimeout');
207
215
  }
@@ -402,7 +410,7 @@ export class AppHttpProvider {
402
410
  timeout: args.timeout,
403
411
  url,
404
412
  })
405
- .then((resp) => {
413
+ .then(async (resp) => {
406
414
  if (blockUiEnabled) {
407
415
  try {
408
416
  this.unblockUi(args);
@@ -415,6 +423,20 @@ export class AppHttpProvider {
415
423
  AppHttpProvider.postProcessJsObject(jsonData, args.jsonAdapter);
416
424
  }
417
425
 
426
+ if (AppHttpProvider.middlewares?.length > 0) {
427
+ for (const middleware of this.middlewares) {
428
+ try {
429
+ await middleware({
430
+ httpCode: resp.httpCode,
431
+ response: jsonData ?? resp.responseText,
432
+ });
433
+ } catch (e) {
434
+ reject(e);
435
+ return;
436
+ }
437
+ }
438
+ }
439
+
418
440
  if (resp.httpCode < 300 && resp.httpCode > 0) {
419
441
  if (resp.httpCode == 204) {
420
442
  AppHttpProvider.log('info', `Request success to ${url}, took ${stop - start}ms`);
@@ -745,7 +767,7 @@ export class AppHttpProvider {
745
767
  public static apiGet<T>(
746
768
  apiMethodName: string,
747
769
  data: object | string,
748
- timeout: number = null,
770
+ timeout: number = null,
749
771
  ): Promise<T> {
750
772
  return this.getJSON(
751
773
  this.getApiUrl(
@@ -770,7 +792,7 @@ export class AppHttpProvider {
770
792
  public static privateApiGet<T>(
771
793
  apiMethodName: string,
772
794
  data: object | string,
773
- timeout: number = null,
795
+ timeout: number = null,
774
796
  ): Promise<T> {
775
797
  return this.getJSON(
776
798
  this.getApiUrl(
@@ -9,6 +9,7 @@ import { globalState } from '../app/global-state';
9
9
  import PowerduckState from '../app/powerduck-state';
10
10
  import NotificationProvider from './../components/ui/notification';
11
11
  import { TryCallApiResult } from './enums/api';
12
+ import StorageProvider from './local-storage-shim';
12
13
  import ScrollUtils from './scroll-utils';
13
14
  import { isNullOrEmpty } from './utils/is-null-or-empty';
14
15
  import { PortalUtils } from './utils/utils';
@@ -193,12 +194,12 @@ export abstract class PowerduckViewModelBase extends Vue {
193
194
  * Validates current viewModel state based on given valdiation ruleset
194
195
  */
195
196
  async validate(showErrorMessage?: boolean, silent?: boolean): Promise<boolean> {
196
- if (localStorage.getItem('disableValidation') == '1') {
197
+ if (StorageProvider.getString('disableValidation') == '1') {
197
198
  return true;
198
199
  }
199
200
 
200
201
  if (this.v$ == null) {
201
- throw 'Validation rules not specified, has to be specified in @Component declaration!';
202
+ throw new Error('Validation rules not specified, has to be specified in @Component declaration!');
202
203
  }
203
204
 
204
205
  const isInvalid = !(await this.v$.$validate());
@@ -1,5 +1,6 @@
1
1
  import type { Temporal } from '@js-temporal/polyfill';
2
2
  import type { IWebApiClient, WebClientApiMethod } from '../../common/IWebClient';
3
+ import type { DropdownButtonItemArgs } from '../dropdown-button/dropdown-button-item';
3
4
  import type { DaterangeChangedArgs } from '../input/daterange-picker';
4
5
  import type { ColFilterModalShowResponse } from './filter-modal';
5
6
  import Mark from 'mark.js';
@@ -12,6 +13,7 @@ import { DialogResult, DialogUtils } from '../../common/dialog-utils';
12
13
  import { DialogIcons } from '../../common/enums/dialog-icons';
13
14
  import { sortBy } from '../../common/extensions/array-extensions';
14
15
  import { capitalize, latinize } from '../../common/extensions/string-extensions';
16
+ import StorageProvider from '../../common/local-storage-shim';
15
17
  import { QueryStringUtils } from '../../common/query-string-utils';
16
18
  import CheckboxUtils from '../../common/utils/checkbox-utils';
17
19
  import DropdownUtils from '../../common/utils/dropdown-utils';
@@ -75,7 +77,7 @@ interface DataTableArgs {
75
77
  sortComplete?: (args: DataTableOnSortedArgs) => void;
76
78
  mobileModeRowIcon?: string;
77
79
  mobileModeShouldAutoCollapse?: boolean;
78
- massOperationOptions?: typeof DropdownButtonItem.prototype[];
80
+ massOperationOptions?: MassOperationItem[];
79
81
  handleInitialFilter?: boolean;
80
82
  timezoneGmtOffset?: number;
81
83
  timezoneDstOffset?: number;
@@ -98,6 +100,10 @@ export interface DataTablePostBackData {
98
100
  Sort: DataTableSortDefinition;
99
101
  }
100
102
 
103
+ export interface MassOperationItem extends DropdownButtonItemArgs {
104
+
105
+ }
106
+
101
107
  interface DataTableFilterDefinition {
102
108
  FullText: string;
103
109
  FilterItems: DataTablePostBackFilterItem[];
@@ -208,7 +214,7 @@ class StorageHelper {
208
214
  }
209
215
 
210
216
  static getStoredState(id: string): StoredState {
211
- const retVal = localStorage.getItem(StorageHelper.getStorageKey(id));
217
+ const retVal = StorageProvider.getString(StorageHelper.getStorageKey(id));
212
218
  if (retVal != null) {
213
219
  try {
214
220
  return JSON.parse(retVal);
@@ -219,7 +225,7 @@ class StorageHelper {
219
225
  }
220
226
 
221
227
  static saveStoredState(id: string, state: StoredState): void {
222
- localStorage.setItem(StorageHelper.getStorageKey(id), JSON.stringify(state));
228
+ StorageProvider.setString(StorageHelper.getStorageKey(id), JSON.stringify(state));
223
229
  }
224
230
 
225
231
  static storeSortOrder(id: string, sortOrder: string[]) {
@@ -413,7 +419,7 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
413
419
  @Prop() mobileModeRowIcon!: string;
414
420
  @Prop() mobileModeShouldAutoCollapse!: boolean;
415
421
  @Prop() handleInitialFilter!: boolean;
416
- @Prop() massOperationOptions!: typeof DropdownButtonItem.prototype[];
422
+ @Prop() massOperationOptions!: MassOperationItem[];
417
423
  @Prop() checkboxesVisible!: boolean;
418
424
  @Prop() checkboxesTitle!: string;
419
425
  @Prop() checkboxButtonsVisible!: boolean;
@@ -1884,7 +1890,7 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
1884
1890
  return null;
1885
1891
  }
1886
1892
 
1887
- getMassOperationItems(): typeof DropdownButtonItem.prototype[] {
1893
+ getMassOperationItems(): MassOperationItem[] {
1888
1894
  return this.massOperationOptions || [];
1889
1895
  }
1890
1896
 
@@ -2051,7 +2057,21 @@ class DataTableComponent extends TsxComponent<DataTableArgs> implements DataTabl
2051
2057
  <div class="dt-pagination-length dt-massop-btn-wrap">
2052
2058
  <DropdownButton text="Hromadne operacie" layout={ButtonLayout.Secondary}>
2053
2059
  {this.getMassOperationItems().map(mi =>
2054
- (mi as any).isSeparator != true ? <DropdownButtonItem icon={mi.icon} text={mi.text} clicked={mi.clicked} /> : <div class="dropdown-divider" />)}
2060
+ (mi as any).isSeparator != true
2061
+ ? (
2062
+ <DropdownButtonItem
2063
+ icon={mi.icon}
2064
+ img={mi.img}
2065
+ text={mi.text}
2066
+ href={mi.href}
2067
+ disabled={mi.disabled}
2068
+ hrefBlank={mi.hrefBlank}
2069
+ clicked={mi.clicked}
2070
+ isSelected={mi.isSelected}
2071
+ emptySpace={mi.emptySpace}
2072
+ />
2073
+ )
2074
+ : <div class="dropdown-divider" />)}
2055
2075
 
2056
2076
  <DropdownButtonItem icon="icon icon-close" text={PowerduckState.getResourceValue('cancel')} clicked={() => this.toggleCheckboxes(false)} />
2057
2077
  </DropdownButton>
@@ -9,6 +9,7 @@ import DateUtils from '../../../../common/utils/date-utils';
9
9
  import TemporalUtils from '../../../../common/utils/temporal-utils';
10
10
  import DaterangePickerConfig from './daterangepicker-config';
11
11
  import './daterangepicker.css';
12
+ import '../../../../app/css/input-effects.css';
12
13
  import { utcEpochMilliseconds } from '../../../../common/extensions/temporal-extensions';
13
14
  import { globalState } from '../../../../app/global-state';
14
15
 
@@ -2086,23 +2087,31 @@ import { globalState } from '../../../../app/global-state';
2086
2087
  return;
2087
2088
  }
2088
2089
 
2090
+ let afterAnimFired = false
2089
2091
  const afterAnim = function () {
2092
+ if (afterAnimFired) {
2093
+ return;
2094
+ }
2095
+
2096
+ afterAnimFired = true;
2097
+ box.hide();
2090
2098
  $(self).data('date-picker-opened', false);
2091
2099
  $(self).trigger('datepicker-closed', {
2092
2100
  relatedTarget: box,
2093
2101
  });
2102
+ box.removeClass('pd-dropdown-open-animation pd-dropdown-open-animation-above pd-dropdown-close-animation pd-dropdown-close-animation-above');
2094
2103
  };
2095
2104
  if (opt.customCloseAnimation) {
2096
2105
  opt.customCloseAnimation.call(box.get(0), afterAnim);
2097
2106
  } else {
2098
2107
  box.removeClass('pd-dropdown-open-animation pd-dropdown-open-animation-above pd-dropdown-close-animation pd-dropdown-close-animation-above');
2099
2108
  box[0].offsetWidth; // reflow
2100
- box.addClass('pd-dropdown-close-animation');
2101
2109
 
2102
- box.one('animationend', function () {
2103
- box.hide();
2104
- afterAnim();
2105
- box.removeClass('pd-dropdown-open-animation pd-dropdown-open-animation-above pd-dropdown-close-animation pd-dropdown-close-animation-above');
2110
+ box.addClass('pd-dropdown-close-animation');
2111
+ const timeout = setTimeout(afterAnim, 450)
2112
+ box.one('animationend', () => {
2113
+ clearTimeout(timeout)
2114
+ afterAnim()
2106
2115
  });
2107
2116
  }
2108
2117
 
@@ -183,7 +183,9 @@ export class OpenStreetMapComponent extends TsxComponent<OpenStreetMapArgs> impl
183
183
  @Watch('geoJSON')
184
184
  onGeoJsonChanged () {
185
185
  if (this.geoJSONClustering) {
186
- this.initCluster();
186
+ this.waitForLeaflet().then(() => {
187
+ this.initCluster()
188
+ })
187
189
  }
188
190
  }
189
191
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "inviton-powerduck",
3
3
  "type": "module",
4
- "version": "0.0.172",
4
+ "version": "0.0.174",
5
5
  "files": [
6
6
  "app/",
7
7
  "common/",