@bcgov/nr-ngx-component-lib 0.0.58 → 0.0.59

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.
@@ -1322,6 +1322,31 @@ class ObservableAborter {
1322
1322
  return this._promise;
1323
1323
  }
1324
1324
  }
1325
+ class ObservableAborterGroup {
1326
+ constructor(delay = 500) {
1327
+ this.delay = delay;
1328
+ this._group = [];
1329
+ this._aborted = false;
1330
+ }
1331
+ add(observable) {
1332
+ if (this._aborted)
1333
+ throw Error('already aborted');
1334
+ let oa = new ObservableAborter(observable, this.delay);
1335
+ this._group.push(oa);
1336
+ return oa.promise;
1337
+ }
1338
+ abort() {
1339
+ if (this._aborted)
1340
+ return;
1341
+ this._group.forEach(oa => {
1342
+ oa.abort();
1343
+ });
1344
+ this._aborted = true;
1345
+ }
1346
+ get allCompleted() {
1347
+ return Promise.all(this._group.map(oa => oa.promise.then(res => { }, err => { }))).then(res => { });
1348
+ }
1349
+ }
1325
1350
 
1326
1351
  class PaginationBase extends NrclBase {
1327
1352
  constructor() {
@@ -1348,6 +1373,7 @@ class PaginationBase extends NrclBase {
1348
1373
  this._filter = this.clone(f);
1349
1374
  }
1350
1375
  ngAfterViewInit() {
1376
+ // console.log('PaginationBase.ngAfterViewInit')
1351
1377
  this.loadPageState();
1352
1378
  }
1353
1379
  clone(obj) {
@@ -1415,6 +1441,7 @@ class RowListBase extends PaginationBase {
1415
1441
  this.isLoadingChange = new EventEmitter();
1416
1442
  this._isLoading = false;
1417
1443
  this._rows = [];
1444
+ this._inProgress = new InProgress();
1418
1445
  }
1419
1446
  get isLoading() { return this._isLoading; }
1420
1447
  set isLoading(v) {
@@ -1425,15 +1452,47 @@ class RowListBase extends PaginationBase {
1425
1452
  }
1426
1453
  get rows() { return this._rows; }
1427
1454
  ngAfterViewInit() {
1455
+ // console.log('RowListBase.ngAfterViewInit')
1428
1456
  super.ngAfterViewInit();
1429
1457
  this.refreshRowList();
1430
1458
  }
1431
1459
  refreshRowList() {
1432
- return this.loadRowList().then(result => this.parseRowList(result));
1433
- }
1434
- loadRowList() {
1460
+ // console.warn('RowListBase.refreshRowList')
1435
1461
  this.isLoading = true;
1436
1462
  this.changeDetectorRef.detectChanges();
1463
+ if (!this._inProgress.isCompleted)
1464
+ this._inProgress.cancel();
1465
+ let inProgress = this._inProgress = new InProgress();
1466
+ return Promise.resolve()
1467
+ .then(() => {
1468
+ return this.loadRowList();
1469
+ })
1470
+ .then((res) => {
1471
+ if (!res)
1472
+ return;
1473
+ if (inProgress.isCancelled)
1474
+ return;
1475
+ return this.parseRowList(res);
1476
+ })
1477
+ .then(res => {
1478
+ if (inProgress.isCancelled)
1479
+ return;
1480
+ return this.completedRowListPage();
1481
+ })
1482
+ .catch((err) => {
1483
+ if (err instanceof Aborted)
1484
+ return;
1485
+ this.loadRowListPageFailed(err);
1486
+ })
1487
+ .finally(() => {
1488
+ if (inProgress.isCancelled)
1489
+ return;
1490
+ inProgress.complete();
1491
+ this.isLoading = false;
1492
+ this.changeDetectorRef.detectChanges();
1493
+ });
1494
+ }
1495
+ loadRowList() {
1437
1496
  if (this._loadRowListRequest)
1438
1497
  this._loadRowListRequest.abort();
1439
1498
  this._loadRowListRequest = new ObservableAborter(() => {
@@ -1446,15 +1505,6 @@ class RowListBase extends PaginationBase {
1446
1505
  .then(res => {
1447
1506
  this._totalRowCount = this.parseTotalRowCount(res);
1448
1507
  this._rows = this.parseRows(res);
1449
- })
1450
- .catch((e) => {
1451
- if (e instanceof Aborted)
1452
- return;
1453
- this.loadRowListPageFailed(e);
1454
- })
1455
- .finally(() => {
1456
- this.isLoading = false;
1457
- this.changeDetectorRef.detectChanges();
1458
1508
  });
1459
1509
  }
1460
1510
  parseTotalRowCount(res) {
@@ -1462,6 +1512,7 @@ class RowListBase extends PaginationBase {
1462
1512
  return res['totalRowCount'];
1463
1513
  throw 'Missing res.totalRowCount, might need to override RowListBase.parseTotalRowCount';
1464
1514
  }
1515
+ completedRowListPage() { }
1465
1516
  loadRowListPageFailed(error) {
1466
1517
  console.warn(error);
1467
1518
  this._rows = [];
@@ -1482,6 +1533,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
1482
1533
  }], propDecorators: { isLoadingChange: [{
1483
1534
  type: Output
1484
1535
  }] } });
1536
+ class InProgress {
1537
+ constructor() {
1538
+ this._completed = false;
1539
+ this._cancelled = false;
1540
+ }
1541
+ complete() {
1542
+ if (this.isCancelled)
1543
+ return;
1544
+ this._completed = true;
1545
+ }
1546
+ cancel() {
1547
+ if (this.isCompleted)
1548
+ return;
1549
+ this._cancelled = true;
1550
+ }
1551
+ get isCompleted() {
1552
+ return this._completed;
1553
+ }
1554
+ get isCancelled() {
1555
+ return this._cancelled;
1556
+ }
1557
+ }
1485
1558
 
1486
1559
  class RowListDesktopComponent extends NrclBase {
1487
1560
  constructor() {
@@ -2210,7 +2283,6 @@ class TabGroupComponent extends NrclBase {
2210
2283
  this.isClassic = false;
2211
2284
  }
2212
2285
  ngOnChanges(changes) {
2213
- console.log(changes);
2214
2286
  this.updateState();
2215
2287
  }
2216
2288
  ngAfterViewInit() {
@@ -2331,12 +2403,16 @@ class ScheduleComponent extends RowListBase {
2331
2403
  this._templates = [];
2332
2404
  }
2333
2405
  ngOnChanges(changes) {
2334
- this.refreshRowList();
2406
+ // this.refreshRowList()
2335
2407
  }
2336
2408
  ngAfterViewInit() {
2337
- setTimeout(() => {
2338
- super.ngAfterViewInit();
2339
- });
2409
+ // console.log('ScheduleComponent.ngAfterViewInit')
2410
+ super.ngAfterViewInit();
2411
+ }
2412
+ loadRowList() {
2413
+ if (!this.provider?.startloadSchedule)
2414
+ throw Error('ScheduleComponent.provider.startloadSchedule not set');
2415
+ return this.provider.startloadSchedule(super.loadRowList);
2340
2416
  }
2341
2417
  fetchRowListPage() {
2342
2418
  if (!this.provider?.fetchSchedule)
@@ -2350,17 +2426,23 @@ class ScheduleComponent extends RowListBase {
2350
2426
  }
2351
2427
  parseRows(res) {
2352
2428
  if (!this.provider?.parseSchedule)
2353
- throw Error('ResourceScheduleComponent.provider.parseSchedule not set');
2429
+ throw Error('ScheduleComponent.provider.parseSchedule not set');
2354
2430
  let rows = this.provider.parseSchedule(res);
2355
2431
  return this.makeRows(rows);
2356
2432
  }
2357
2433
  getInitialPageState() {
2358
2434
  if (!this.provider?.getInitialPageState)
2359
- throw Error('ResourceScheduleComponent.provider.getInitialPageState not set');
2435
+ throw Error('ScheduleComponent.provider.getInitialPageState not set');
2360
2436
  return this.provider.getInitialPageState();
2361
2437
  }
2438
+ completedRowListPage() {
2439
+ if (!this.provider?.completedLoadSchedule)
2440
+ throw Error('ScheduleComponent.provider.completedRowListPage not set');
2441
+ return this.provider.completedLoadSchedule(super.completedRowListPage);
2442
+ }
2362
2443
  onSamePageFilterChange(ev) {
2363
2444
  this.filter = ev;
2445
+ this.refreshRowList();
2364
2446
  }
2365
2447
  makeRows(schedule) {
2366
2448
  let start = moment(this.startDate);
@@ -2894,5 +2976,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
2894
2976
  * Generated bundle index. Do not edit.
2895
2977
  */
2896
2978
 
2897
- export { Aborted, ButtonComponent, CellContentComponent, CodeTable, ConfigurationService, ConfigurationSubscriberBase, DATE_FORMATS, DesktopViewDirective, DeviceViewComponent, DialogBase, DialogComponent, DialogConfirmComponent, DialogService, ExpansionPanelComponent, ExpansionPanelFooterComponent, ExpansionPanelHeaderComponent, ExpansionPanelSectionComponent, FilterContainerComponent, FilterDateComponent, FilterSearchComponent, FilterSelectComponent, FiltersPanelComponent, FormFieldComponent, FormLayoutComponent, GapComponent, IconComponent, IndicatorComponent, IndicatorSelectComponent, ListAttachmentsComponent, ListEventHistoryComponent, ListSelectComponent, LoadingStatusComponent, MobileViewDirective, NrNgxComponentLibModule, NrclBase, ObservableAborter, PageContainerComponent, PageHeaderComponent, PageStateService, PaginationBase, ResourceScheduleComponent, ResourceScheduleRowHeadingDirective, RowListBase, RowListDesktopComponent, RowListMobileComponent, RowListPaginationComponent, RowListSortingComponent, ScheduleComponent, ScheduleItemDirective, ScheduleRowHeadingDirective, SnackbarComponent, SnackbarUtilService, TabComponent, TabContentDirective, TabGroupComponent, TabLabelDirective, TagListComponent, mapToCodeDescription, unwrapFilterValue, wrapFilterValue };
2979
+ export { Aborted, ButtonComponent, CellContentComponent, CodeTable, ConfigurationService, ConfigurationSubscriberBase, DATE_FORMATS, DesktopViewDirective, DeviceViewComponent, DialogBase, DialogComponent, DialogConfirmComponent, DialogService, ExpansionPanelComponent, ExpansionPanelFooterComponent, ExpansionPanelHeaderComponent, ExpansionPanelSectionComponent, FilterContainerComponent, FilterDateComponent, FilterSearchComponent, FilterSelectComponent, FiltersPanelComponent, FormFieldComponent, FormLayoutComponent, GapComponent, IconComponent, IndicatorComponent, IndicatorSelectComponent, ListAttachmentsComponent, ListEventHistoryComponent, ListSelectComponent, LoadingStatusComponent, MobileViewDirective, NrNgxComponentLibModule, NrclBase, ObservableAborter, ObservableAborterGroup, PageContainerComponent, PageHeaderComponent, PageStateService, PaginationBase, ResourceScheduleComponent, ResourceScheduleRowHeadingDirective, RowListBase, RowListDesktopComponent, RowListMobileComponent, RowListPaginationComponent, RowListSortingComponent, ScheduleComponent, ScheduleItemDirective, ScheduleRowHeadingDirective, SnackbarComponent, SnackbarUtilService, TabComponent, TabContentDirective, TabGroupComponent, TabLabelDirective, TagListComponent, mapToCodeDescription, unwrapFilterValue, wrapFilterValue };
2898
2980
  //# sourceMappingURL=bcgov-nr-ngx-component-lib.mjs.map