@csmart/ngc-smart-core 0.7.87 → 0.7.91

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.
@@ -284,6 +284,7 @@
284
284
  * Offender
285
285
  * ************************************
286
286
  * @param {?} selectedOffender
287
+ * @param {?=} redirectFunction
287
288
  * @return {?}
288
289
  */
289
290
  XdmService.prototype.setSelectedOffender = /**
@@ -291,16 +292,23 @@
291
292
  * Offender
292
293
  * ************************************
293
294
  * @param {?} selectedOffender
295
+ * @param {?=} redirectFunction
294
296
  * @return {?}
295
297
  */
296
- function (selectedOffender) {
298
+ function (selectedOffender, redirectFunction) {
297
299
  var _this = this;
300
+ if (redirectFunction === void 0) {
301
+ redirectFunction = null;
302
+ }
298
303
  this.connection.promise.then(( /**
299
304
  * @param {?} child
300
305
  * @return {?}
301
306
  */function (child) {
302
307
  child.setSelectedOffender(selectedOffender);
303
308
  _this.offenderSubject.next(selectedOffender);
309
+ if (redirectFunction) {
310
+ redirectFunction();
311
+ }
304
312
  }));
305
313
  };
306
314
  /**
@@ -670,8 +678,7 @@
670
678
  // : false,
671
679
  // } as SelectedOffender;
672
680
  this.selectedOffender = offender;
673
- this.xdmService.setSelectedOffender(this.selectedOffender);
674
- this.reloadCurrentRoute();
681
+ this.xdmService.setSelectedOffender(this.selectedOffender, this.reloadCurrentRoute);
675
682
  }
676
683
  };
677
684
  /**
@@ -1856,10 +1863,10 @@
1856
1863
  * @param {?} p
1857
1864
  * @return {?}
1858
1865
  */function (p) {
1859
- return (p.appModuleId === accessControlConfig.appModuleId
1860
- && p.resource === resource
1861
- && (!roleId || p.roleId === roleId)
1862
- && p.assignmentStaffRelationId === assignmentStaffRelationId);
1866
+ return (p.appModuleId === accessControlConfig.appModuleId &&
1867
+ p.resource === resource &&
1868
+ (!roleId || p.roleId === roleId) &&
1869
+ p.assignmentStaffRelationId === assignmentStaffRelationId);
1863
1870
  }));
1864
1871
  if (permission) {
1865
1872
  if (accessType === 'read') {
@@ -1906,35 +1913,38 @@
1906
1913
  if (appModuleId === void 0) {
1907
1914
  appModuleId = null;
1908
1915
  }
1909
- if (!this.isAuthEnable(loginStaff.roles, appModuleId)) {
1910
- return true;
1911
- }
1916
+ // if (!this.isAuthEnable(loginStaff.roles, appModuleId)) {
1917
+ // return true;
1918
+ // }
1912
1919
  return this.hasAppFeaturePermission(loginStaff.permissions, feature, appModuleId);
1913
1920
  };
1914
- /**
1915
- * @param {?} roles
1916
- * @param {?} appModuleId
1917
- * @return {?}
1918
- */
1919
- SmartAuthService.prototype.isAuthEnable = /**
1920
- * @param {?} roles
1921
- * @param {?} appModuleId
1922
- * @return {?}
1923
- */
1924
- function (roles, appModuleId) {
1925
- if (roles && roles.length > 0) {
1926
- return (roles.findIndex(this.isExternalRole) > -1 || appModuleId === 'RR');
1927
- }
1928
- return false;
1929
- };
1921
+ // public isAuthEnable(roles: Role[], appModuleId: string) {
1922
+ // if (roles && roles.length > 0) {
1923
+ // return roles.map(r => r.roleId).findIndex(this.isExternalRole) > -1 || appModuleId === 'RR';
1924
+ // }
1925
+ // return false;
1926
+ // }
1927
+ // public isAuthEnable(roles: Role[], appModuleId: string) {
1928
+ // if (roles && roles.length > 0) {
1929
+ // return roles.map(r => r.roleId).findIndex(this.isExternalRole) > -1 || appModuleId === 'RR';
1930
+ // }
1931
+ // return false;
1932
+ // }
1930
1933
  /**
1931
1934
  * @param {?} roles
1932
1935
  * @return {?}
1933
1936
  */
1934
- SmartAuthService.prototype.hasIntakeRole = /**
1935
- * @param {?} roles
1936
- * @return {?}
1937
- */
1937
+ SmartAuthService.prototype.hasIntakeRole =
1938
+ // public isAuthEnable(roles: Role[], appModuleId: string) {
1939
+ // if (roles && roles.length > 0) {
1940
+ // return roles.map(r => r.roleId).findIndex(this.isExternalRole) > -1 || appModuleId === 'RR';
1941
+ // }
1942
+ // return false;
1943
+ // }
1944
+ /**
1945
+ * @param {?} roles
1946
+ * @return {?}
1947
+ */
1938
1948
  function (roles) {
1939
1949
  if (roles && roles.length > 0) {
1940
1950
  return roles.findIndex(this.isIntakeRole) > -1;
@@ -1958,34 +1968,32 @@
1958
1968
  function (permissions, feature, appModuleId) {
1959
1969
  if (permissions && permissions.length > 0) {
1960
1970
  if (appModuleId) {
1961
- return permissions.findIndex(( /**
1971
+ return (permissions.findIndex(( /**
1962
1972
  * @param {?} p
1963
1973
  * @return {?}
1964
- */function (p) {
1965
- return p.resource === feature && p.appModuleId === appModuleId;
1966
- })) > -1;
1974
+ */function (p) { return p.resource === feature && p.appModuleId === appModuleId; })) > -1);
1967
1975
  }
1968
1976
  else {
1969
- return (permissions.findIndex(( /**
1977
+ return permissions.findIndex(( /**
1970
1978
  * @param {?} p
1971
1979
  * @return {?}
1972
- */function (p) { return p.resource === feature; })) > -1);
1980
+ */function (p) { return p.resource === feature; })) > -1;
1973
1981
  }
1974
1982
  }
1975
1983
  return false;
1976
1984
  };
1977
1985
  /**
1978
1986
  * @private
1979
- * @param {?} role
1987
+ * @param {?} roleId
1980
1988
  * @return {?}
1981
1989
  */
1982
1990
  SmartAuthService.prototype.isExternalRole = /**
1983
1991
  * @private
1984
- * @param {?} role
1992
+ * @param {?} roleId
1985
1993
  * @return {?}
1986
1994
  */
1987
- function (role) {
1988
- switch (role.roleId) {
1995
+ function (roleId) {
1996
+ switch (roleId) {
1989
1997
  case 'EUDTL':
1990
1998
  case 'EUDUSM':
1991
1999
  case 'EUJDG':
@@ -2138,6 +2146,45 @@
2138
2146
  return null;
2139
2147
  })));
2140
2148
  };
2149
+ /**
2150
+ * @private
2151
+ * @param {?} appModuleId
2152
+ * @param {?} resource
2153
+ * @return {?}
2154
+ */
2155
+ SmartAuthService.prototype.getRolePermissions = /**
2156
+ * @private
2157
+ * @param {?} appModuleId
2158
+ * @param {?} resource
2159
+ * @return {?}
2160
+ */
2161
+ function (appModuleId, resource) {
2162
+ /** @type {?} */
2163
+ var queryString = "\n query findvRolePermissionPivots{\n findvRolePermissionPivots(input: {where: {appModuleId: " + appModuleId + ", resource: " + resource + "}}){\n totalCount\n message\n }\n }";
2164
+ return this.http
2165
+ .post(this.smartDataServiceUrl, { query: queryString })
2166
+ .pipe(operators.take(1), operators.map(( /**
2167
+ * @param {?} result
2168
+ * @return {?}
2169
+ */function (result) {
2170
+ if (i0.isDevMode) {
2171
+ console.log('##### findvRolePermissionPivots() from service ', result);
2172
+ }
2173
+ if (result.data.findvRolePermissionPivots.totalCount > 0) {
2174
+ return true;
2175
+ }
2176
+ else {
2177
+ return false;
2178
+ // return throwError('No access right.');
2179
+ }
2180
+ })), operators.catchError(( /**
2181
+ * @param {?} error
2182
+ * @return {?}
2183
+ */function (error) {
2184
+ console.log('error ' + error);
2185
+ return rxjs.throwError(error);
2186
+ })));
2187
+ };
2141
2188
  SmartAuthService.decorators = [
2142
2189
  { type: i0.Injectable, args: [{
2143
2190
  providedIn: 'root',
@@ -2190,11 +2237,10 @@
2190
2237
  !this.accessControlConfig.route.data.selectedOffender) {
2191
2238
  return;
2192
2239
  }
2193
- /** @type {?} */
2194
- var loginStaff = this.accessControlConfig.route.data.loginStaff;
2195
- if (!this.auth.isAuthEnable(loginStaff.roles, this.accessControlConfig.appModuleId)) {
2196
- return;
2197
- }
2240
+ // const loginStaff = this.accessControlConfig.route.data.loginStaff;
2241
+ // if (!this.auth.isAuthEnable(loginStaff.roles, this.accessControlConfig.appModuleId)) {
2242
+ // return;
2243
+ // }
2198
2244
  this.elementRef.nativeElement.style.display = this.auth.checkPermission(this.accessControlConfig)
2199
2245
  ? 'block'
2200
2246
  : 'none';
@@ -2243,9 +2289,9 @@
2243
2289
  if (!loginStaff || !route || !route.routeConfig) {
2244
2290
  return rxjs.of(false);
2245
2291
  }
2246
- if (!_this.authnService.isAuthEnable(loginStaff.roles, null)) {
2247
- return rxjs.of(true);
2248
- }
2292
+ // if (!this.authnService.isAuthEnable(loginStaff.roles, null)) {
2293
+ // return of(true);
2294
+ // }
2249
2295
  /** @type {?} */
2250
2296
  var resource = route.routeConfig.path
2251
2297
  ? route.routeConfig.path.split('/')[0]