@memberjunction/ng-explorer-core 0.9.172 → 0.9.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.
@@ -2,7 +2,7 @@ import { ElementRef, OnInit, OnDestroy, AfterViewInit, Renderer2, ChangeDetector
2
2
  import { Location } from '@angular/common';
3
3
  import { Router, ActivatedRoute } from '@angular/router';
4
4
  import { DrawerItem, DrawerSelectEvent, DrawerComponent, DrawerMode, TabCloseEvent, TabStripComponent, SelectEvent } from "@progress/kendo-angular-layout";
5
- import { Metadata, ApplicationInfo, EntityInfo } from '@memberjunction/core';
5
+ import { Metadata, ApplicationInfo, EntityInfo, TransactionGroupBase } from '@memberjunction/core';
6
6
  import { MJEvent } from '@memberjunction/global';
7
7
  import { SharedService } from '@memberjunction/ng-shared';
8
8
  import { UserViewEntity, ViewInfo } from '@memberjunction/core-entities';
@@ -82,7 +82,7 @@ export declare class NavigationComponent implements OnInit, OnDestroy, AfterView
82
82
  SaveSingleWorkspaceItem(tab: Tab): Promise<boolean>;
83
83
  setTabContentLoadingStatus(tab: Tab, bLoading: boolean): void;
84
84
  onClose(ev: TabCloseEvent): Promise<void>;
85
- removeWorkspaceItem(tab: Tab): Promise<void>;
85
+ removeWorkspaceItem(tab: Tab, transGroup: TransactionGroupBase | null): Promise<void>;
86
86
  onTabSelect(e: SelectEvent): void;
87
87
  getActiveTabId(): any;
88
88
  isTabActive(tabId: number): boolean;
@@ -230,17 +230,23 @@ export class NavigationComponent {
230
230
  break;
231
231
  }
232
232
  this.contextMenuVisible = false;
233
+ const md = new Metadata();
234
+ const transGroup = yield md.CreateTransactionGroup();
233
235
  for (let i = 0; i < this.closedTabs.length; ++i) {
234
236
  const tab = this.closedTabs[i];
235
- yield this.removeWorkspaceItem(tab);
237
+ yield this.removeWorkspaceItem(tab, transGroup);
236
238
  }
237
- this.activeTabIndex = 0;
239
+ yield transGroup.Submit();
240
+ if (this.activeTabIndex > this.tabs.length)
241
+ this.activeTabIndex = this.tabs.length - 1;
238
242
  this.tabstrip.selectTab(this.activeTabIndex);
239
- // in this situation we have the home tab showing, so we need to update the URL path based on what's selected in the drawer
240
- let url = this.selectedDrawerItem ? this.selectedDrawerItem.path : '/home';
241
- this.router.navigate([url]);
242
- //this.location.go(url); // update the browser URL if needed
243
- this._mostRecentURL = url;
243
+ if (this.activeTabIndex === 0) {
244
+ // in this situation we have the home tab showing, so we need to update the URL path based on what's selected in the drawer
245
+ let url = this.selectedDrawerItem ? this.selectedDrawerItem.path : '/home';
246
+ this.router.navigate([url]);
247
+ //this.location.go(url); // update the browser URL if needed
248
+ this._mostRecentURL = url;
249
+ }
244
250
  });
245
251
  }
246
252
  checkViewportSize() {
@@ -435,7 +441,8 @@ export class NavigationComponent {
435
441
  this.workSpace = workspaceRecord;
436
442
  const workspaceItemParams = {
437
443
  EntityName: "Workspace Items",
438
- ExtraFilter: `WorkspaceID='${this.workSpace.ID}'`
444
+ ExtraFilter: `WorkspaceID='${this.workSpace.ID}'`,
445
+ ResultType: "entity_object" /*we want entity objects back so that we can modify them as needed*/
439
446
  };
440
447
  const workspaceItems = yield rv.RunView(workspaceItemParams);
441
448
  if (workspaceItems.Success) {
@@ -463,7 +470,7 @@ export class NavigationComponent {
463
470
  labelLoading: true,
464
471
  contentLoading: false,
465
472
  data: resourceData,
466
- workspaceItem: null, // let this get populated later from the ID if we need to modify it
473
+ workspaceItem: item, // provide the entity object here so we can modify it later if needed
467
474
  icon: resourceData.ResourceIcon
468
475
  };
469
476
  this.tabs.push(newTab);
@@ -709,7 +716,7 @@ export class NavigationComponent {
709
716
  if (ev.tab.selected) {
710
717
  setTimeout(() => __awaiter(this, void 0, void 0, function* () {
711
718
  // find the closest tab to the one we just closed
712
- yield this.removeWorkspaceItem(this.tabs[ev.index - 1]);
719
+ yield this.removeWorkspaceItem(this.tabs[ev.index - 1], null /*no transaction group*/);
713
720
  if (ev.index < this.tabs.length + 1) {
714
721
  // NOT the last tab, kendo by defulat will show the next tab, so let that be, but we need to update our routing info
715
722
  // dont need to update active tab index or call selectTab() here because kendo does this and activetab index stays the same since we're closing the tab
@@ -751,7 +758,7 @@ export class NavigationComponent {
751
758
  }
752
759
  });
753
760
  }
754
- removeWorkspaceItem(tab) {
761
+ removeWorkspaceItem(tab, transGroup) {
755
762
  return __awaiter(this, void 0, void 0, function* () {
756
763
  // remove the tab from the tabs collection
757
764
  const index = this.tabs.indexOf(tab);
@@ -764,9 +771,16 @@ export class NavigationComponent {
764
771
  yield tab.workspaceItem.Load(tab.id);
765
772
  }
766
773
  if (tab.workspaceItem) {
767
- if (!(yield tab.workspaceItem.Delete())) {
768
- // error deleting the workspace item, alert the user
769
- this.sharedService.CreateSimpleNotification('Error deleting workspace item ' + tab.workspaceItem.Name + ' from the database. Please contact your system administrator.', 'error', 5000);
774
+ const entity = tab.workspaceItem;
775
+ if (!transGroup) {
776
+ if (!(yield entity.Delete())) {
777
+ // error deleting the workspace item, alert the user
778
+ this.sharedService.CreateSimpleNotification('Error deleting workspace item ' + tab.workspaceItem.Name + ' from the database. Please contact your system administrator.', 'error', 5000);
779
+ }
780
+ }
781
+ else {
782
+ entity.TransactionGroup = transGroup;
783
+ entity.Delete(); // no await here, we're in a transaction group so we don't want to block
770
784
  }
771
785
  }
772
786
  });
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { Component, ViewChild } from '@angular/core';
11
11
  import { SharedService } from '@memberjunction/ng-shared';
12
+ import { UserNotificationEntity } from '@memberjunction/core-entities';
12
13
  import { Metadata } from '@memberjunction/core';
13
14
  import * as i0 from "@angular/core";
14
15
  import * as i1 from "@memberjunction/ng-shared";
@@ -252,11 +253,20 @@ export class UserNotificationsComponent {
252
253
  markAsRead(notification, bRead, transGroup) {
253
254
  return __awaiter(this, void 0, void 0, function* () {
254
255
  if (notification) {
256
+ const notificationId = notification.ID;
255
257
  notification.Unread = !bRead;
256
- const md = new Metadata();
257
- const notificationEntity = yield md.GetEntityObject('User Notifications');
258
- yield notificationEntity.Load(notification.ID);
259
- notificationEntity.Unread = notification.Unread; //copy from local object
258
+ let notificationEntity;
259
+ if (notification instanceof UserNotificationEntity) {
260
+ // the passed in param truly is a UserNotificationEntity or subclass, so just use it, saves a DB round trip
261
+ notificationEntity = notification;
262
+ }
263
+ else {
264
+ // the passed in param is just a plain object, so we need to load the entity
265
+ const md = new Metadata();
266
+ notificationEntity = yield md.GetEntityObject('User Notifications');
267
+ yield notificationEntity.Load(notificationId);
268
+ notificationEntity.Unread = !bRead;
269
+ }
260
270
  // part of a transaction group, if so, add it as that will defer the actual network traffic/save
261
271
  if (transGroup) {
262
272
  notificationEntity.TransactionGroup = transGroup;
@@ -265,7 +275,7 @@ export class UserNotificationsComponent {
265
275
  }
266
276
  else {
267
277
  if (yield notificationEntity.Save()) {
268
- SharedService.RefreshUserNotifications();
278
+ //SharedService.RefreshUserNotifications(); don't need to save because angular binding already updtes the UI from the objects
269
279
  return true;
270
280
  }
271
281
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ng-explorer-core",
3
- "version": "0.9.172",
3
+ "version": "0.9.174",
4
4
  "description": "MemberJunction Explorer: Core Angular Components",
5
5
  "main": "./dist/public-api.js",
6
6
  "typings": "./dist/public-api.d.ts",
@@ -37,14 +37,14 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@memberjunction/global": "^0.9.146",
40
- "@memberjunction/core": "^0.9.162",
41
- "@memberjunction/ng-compare-records": "^0.9.161",
42
- "@memberjunction/ng-record-changes": "^0.9.95",
43
- "@memberjunction/ng-container-directives": "^0.9.129",
44
- "@memberjunction/ng-user-view-grid": "^0.9.186",
45
- "@memberjunction/ng-query-grid": "^0.9.41",
46
- "@memberjunction/ng-shared": "^0.9.15",
47
- "@memberjunction/ng-ask-skip": "^0.9.57",
40
+ "@memberjunction/core": "^0.9.164",
41
+ "@memberjunction/ng-compare-records": "^0.9.163",
42
+ "@memberjunction/ng-record-changes": "^0.9.97",
43
+ "@memberjunction/ng-container-directives": "^0.9.131",
44
+ "@memberjunction/ng-user-view-grid": "^0.9.188",
45
+ "@memberjunction/ng-query-grid": "^0.9.43",
46
+ "@memberjunction/ng-shared": "^0.9.17",
47
+ "@memberjunction/ng-ask-skip": "^0.9.59",
48
48
  "tslib": "^2.3.0"
49
49
  },
50
50
  "sideEffects": false