@trudb/tru-common-lib 0.0.801 → 0.0.803

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.
@@ -3,6 +3,7 @@ import { Directive, Input, Injectable, Component, Inject, HostListener, Injectio
3
3
  import { EntityAspect, MetadataStore, DataService, EntityManager, EntityQuery, Predicate, FetchStrategy, EntityAction, EntityState, breeze, BinaryPredicate, AndOrPredicate } from 'breeze-client';
4
4
  import { BehaviorSubject, from, defer, of, Subject, Observable, skip, forkJoin, finalize, throwError } from 'rxjs';
5
5
  import * as _ from 'underscore';
6
+ import ___default from 'underscore';
6
7
  import * as i2 from '@angular/common/http';
7
8
  import { HttpClientModule, HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http';
8
9
  import * as i1 from '@angular/material/dialog';
@@ -2330,6 +2331,100 @@ class TruQueryPredicateManager {
2330
2331
  };
2331
2332
  }
2332
2333
 
2334
+ class TruValidatorFactory {
2335
+ satisfiesEntityMessageValidation = (entity, context) => {
2336
+ var messages = ___default.values(entity._customValidationErrors);
2337
+ if (!messages.length)
2338
+ return true;
2339
+ context.messageTemplate = messages.join('...');
2340
+ return false;
2341
+ };
2342
+ satisfiesRequiredValidation(value) {
2343
+ if (value === null || value === '')
2344
+ return false;
2345
+ return true;
2346
+ }
2347
+ satisfiesMaxLengthValidation = (value, context) => {
2348
+ if (!value)
2349
+ return true;
2350
+ return typeof value === 'string' && value.length <= context.maxLength;
2351
+ };
2352
+ satisfiesFloatValidation = (value) => {
2353
+ if (value === null)
2354
+ return true;
2355
+ return typeof value === 'number' && isFinite(value);
2356
+ };
2357
+ satisfiesIntegerValidation = (value) => {
2358
+ if (value === null)
2359
+ return true;
2360
+ //NOTE: Number.isInteger() would work, but is not implemented in all supported browsers
2361
+ return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
2362
+ };
2363
+ satisfiesDateValidation(value) {
2364
+ if (Object.prototype.toString.call(value) !== '[object Date]')
2365
+ return false;
2366
+ return isFinite(value.getTime());
2367
+ }
2368
+ satisfiesInvalidChoiceValidation(value, context) {
2369
+ if (context.entity.Is_Invalid === 'true') {
2370
+ context.error = context.propertyName + '\' invalid choice';
2371
+ return false;
2372
+ }
2373
+ return true;
2374
+ }
2375
+ satisfiesMergeValidation = (value, context) => {
2376
+ var mergeData = JSON.parse(context.entity.Merge_Data);
2377
+ if (!mergeData)
2378
+ return true;
2379
+ if (mergeData.hasOwnProperty(context.propertyName)) {
2380
+ var mergeValue = mergeData[context.propertyName].hid ? mergeData[context.propertyName].hid : mergeData[context.propertyName].value;
2381
+ context.error = mergeData[context.propertyName].modifiedBy + ' changed ' + context.propertyName + ' to ' + mergeValue + '.';
2382
+ return false;
2383
+ }
2384
+ return true;
2385
+ };
2386
+ createEntityMessageValidator = () => {
2387
+ return new breeze.Validator('entityMessage', this.satisfiesEntityMessageValidation);
2388
+ };
2389
+ createRequiredValidator = () => {
2390
+ return new breeze.Validator('required', this.satisfiesRequiredValidation, {
2391
+ messageTemplate: '\'%displayName%\' is required'
2392
+ });
2393
+ };
2394
+ createMaxLengthValidator = (maxLength) => {
2395
+ var context = {
2396
+ messageTemplate: '\'%displayName%\' exceeds maximum character length of %maxLength%',
2397
+ maxLength: maxLength
2398
+ };
2399
+ return new breeze.Validator('maxLength', this.satisfiesMaxLengthValidation, context);
2400
+ };
2401
+ createIntegerValidator = () => {
2402
+ return new breeze.Validator('integer', this.satisfiesIntegerValidation, {
2403
+ messageTemplate: '\'%displayName%\' must be an integer'
2404
+ });
2405
+ };
2406
+ createFloatValidator = () => {
2407
+ return new breeze.Validator('float', this.satisfiesFloatValidation, {
2408
+ messageTemplate: '\'%displayName%\' must be a number'
2409
+ });
2410
+ };
2411
+ createDateValidator = () => {
2412
+ return new breeze.Validator('date', this.satisfiesDateValidation, {
2413
+ messageTemplate: '\'%displayName%\' must be a date'
2414
+ });
2415
+ };
2416
+ createInvalidChoiceValidator = () => {
2417
+ return new breeze.Validator('invalid', this.satisfiesInvalidChoiceValidation, {
2418
+ messageTemplate: '\'%error%'
2419
+ });
2420
+ };
2421
+ createMergeValidator = () => {
2422
+ return new breeze.Validator('merge', this.satisfiesMergeValidation, {
2423
+ messageTemplate: '\'%error%\''
2424
+ });
2425
+ };
2426
+ }
2427
+
2333
2428
  class MaterialModule {
2334
2429
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.2", ngImport: i0, type: MaterialModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2335
2430
  static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.2", ngImport: i0, type: MaterialModule, exports: [A11yModule,
@@ -3254,7 +3349,8 @@ class TruDataGrid {
3254
3349
  this.onSearch(setupQuery);
3255
3350
  }));
3256
3351
  this.subs.push(this.dataContext.onPropertyChanged().subscribe((changeArgs) => {
3257
- if (changeArgs.entityAction === EntityAction.Attach) {
3352
+ if (changeArgs.entityAction === EntityAction.Attach &&
3353
+ this.config.resultConfig.entityType === changeArgs.entity?.entityType) {
3258
3354
  this.addEntity(changeArgs.entity);
3259
3355
  }
3260
3356
  }));
@@ -6469,9 +6565,10 @@ class TruValidationDialog {
6469
6565
  //let originalValues = entity.entityAspect.originalValues;
6470
6566
  //let propertyName = '';
6471
6567
  //let mergeData = JSON.parse(entity.Merge_Data_Set);
6472
- //let propertyNameKey = propertyName as keyof typeof this.mergeData;
6568
+ //let propertyNameKey = propertyName as keyof typeof this.config.mergeData;
6473
6569
  //entity[propertyName] = this.config.mergeData?.getData(propertyNameKey)!.value;
6474
- //delete this.mergeData[propertyNameKey];
6570
+ //if (this.config.mergeData)
6571
+ // delete this.config.mergeData[propertyNameKey];
6475
6572
  //if (originalValues.hasOwnProperty(propertyName) && (Object.keys(originalValues).length === 0 && originalValues.constructor === Object))
6476
6573
  // delete originalValues[propertyName];
6477
6574
  //if (!Object.keys(this.mergeData).length)
@@ -6480,12 +6577,13 @@ class TruValidationDialog {
6480
6577
  //entity.entityAspect.validateProperty(propertyName);
6481
6578
  };
6482
6579
  onDecline = () => {
6483
- //let entity = this.entity as any;
6580
+ //let entity = this.config.entity as any;
6484
6581
  //let propertyName = '';
6485
- //this.mergeData = JSON.parse(entity.Merge_Data);
6486
- //let propertyNameKey = propertyName as keyof typeof this.mergeData;
6487
- //delete this.mergeData[propertyNameKey];
6488
- //entity.Merge_Data = JSON.stringify(this.mergeData);
6582
+ //this.config.mergeData = JSON.parse(entity.Merge_Data);
6583
+ //let propertyNameKey = propertyName as keyof typeof this.config.mergeData;
6584
+ //if (this.config.mergeData)
6585
+ // delete this.config.mergeData[propertyNameKey];
6586
+ //entity.Merge_Data = JSON.stringify(this.config.mergeData);
6489
6587
  //entity.entityAspect.validateProperty(propertyName);
6490
6588
  };
6491
6589
  ngOnInit() {
@@ -6700,6 +6798,9 @@ class TruValidationDialogConfig {
6700
6798
  get mergeData() {
6701
6799
  return this._mergeData;
6702
6800
  }
6801
+ set mergeData(value) {
6802
+ this._mergeData = value;
6803
+ }
6703
6804
  constructor(entity, propertyName, errorMsg, mergeData = null) {
6704
6805
  this._entity = entity;
6705
6806
  this._propertyName = propertyName;
@@ -7240,5 +7341,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.2", ngImpor
7240
7341
  * Generated bundle index. Do not edit.
7241
7342
  */
7242
7343
 
7243
- export { DetailViewModule, TruAppEnvironment, TruAuth, TruAuthInterceptor, TruBreezeContext, TruBreezeContextFactory, TruBreezeGridValidator, TruBreezeGridValidatorModule, TruBreezeMetadataProvider, TruBreezeValidator, TruBreezeValidatorModule, TruChoice, TruColumn, TruColumnModule, TruCommonModule, TruComponentConfigBase, TruComponentLookup, TruConfirmDialog, TruConfirmDialogConfig, TruConfirmDialogModule, TruConnectionHub, TruContextFilter, TruContextFilterChoice, TruContextFilters, TruControlComponentConfigBase, TruDataChange, TruDataContext, TruDataGrid, TruDataGridModule, TruDataGridTypes, TruDesktop, TruDesktopManager, TruDesktopModule, TruDesktopViewConfig, TruDetailViewBase, TruEditControlBase, TruEditControlConfigBase, TruEditParentControlConfigBase, TruEditPkeyControlConfigBase, TruEntityAccessor, TruEntityBase, TruExportDialog, TruExportDialogConfig, TruExportDialogModule, TruForm, TruFormModule, TruFormulaEval, TruGridValidationDialog, TruGridValidationDialogModule, TruGroupBox, TruGroupBoxModule, TruIconModule, TruListControlConfigBase, TruLogin, TruLoginModule, TruMatSelectPanel, TruMatSelectPanelModule, TruModelPropertyLookup, TruNameValue, TruPasswordDialog, TruPasswordDialogModule, TruPredicate, TruPredicateMap, TruPropertyConfigBase, TruPropertyConfigCloudFile, TruPropertyConfigDate, TruPropertyConfigDecimal, TruPropertyConfigFile, TruPropertyConfigForeignKey, TruPropertyConfigInteger, TruPropertyConfigPassword, TruPropertyConfigPercentage, TruPropertyConfigScientific, TruPropertyConfigText, TruPropertyConfigTextChoices, TruPropertyConfigUsaAddress, TruPropertyConfigZipCode, TruQueryPredicateManager, TruRow, TruRowModule, TruSearchConfigBase, TruSearchControlBase, TruSearchControlConfigBase, TruSearchControlRangeBase, TruSearchIconModule, TruSearchPanelPositionManager, TruSearchPanelPositionManagerModule, TruSearchResultViewBase, TruSearchResultViewBaseModule, TruSearchResultViewManager, TruSearchViewBase, TruSearchViewBaseModule, TruSearchViewControlEventHandler, TruSearchViewEventHandler, TruSort, TruTableConfigBase, TruTableRegistry, TruTextManager, TruToolbar, TruToolbarButton, TruToolbarButtonModule, TruToolbarContextFilter, TruToolbarContextFilterModule, TruToolbarDropdown, TruToolbarDropdownModule, TruToolbarMenu, TruToolbarMenuModule, TruToolbarModule, TruToolbarSeparator, TruToolbarSeparatorModule, TruToolbarText, TruToolbarTextModule, TruToolbarUserProfile, TruToolbarUserProfileModule, TruUiNotification, TruUser, TruUtil, TruValidationDialog, TruValidationDialogModule, TruWindowActionEventHandler, TruWindowEventArgs, TruWindowEventHandler };
7344
+ export { DetailViewModule, TruAppEnvironment, TruAuth, TruAuthInterceptor, TruBreezeContext, TruBreezeContextFactory, TruBreezeGridValidator, TruBreezeGridValidatorModule, TruBreezeMetadataProvider, TruBreezeValidator, TruBreezeValidatorModule, TruChoice, TruColumn, TruColumnModule, TruCommonModule, TruComponentConfigBase, TruComponentLookup, TruConfirmDialog, TruConfirmDialogConfig, TruConfirmDialogModule, TruConnectionHub, TruContextFilter, TruContextFilterChoice, TruContextFilters, TruControlComponentConfigBase, TruDataChange, TruDataContext, TruDataGrid, TruDataGridModule, TruDataGridTypes, TruDesktop, TruDesktopManager, TruDesktopModule, TruDesktopViewConfig, TruDetailViewBase, TruEditControlBase, TruEditControlConfigBase, TruEditParentControlConfigBase, TruEditPkeyControlConfigBase, TruEntityAccessor, TruEntityBase, TruExportDialog, TruExportDialogConfig, TruExportDialogModule, TruForm, TruFormModule, TruFormulaEval, TruGridValidationDialog, TruGridValidationDialogModule, TruGroupBox, TruGroupBoxModule, TruIconModule, TruListControlConfigBase, TruLogin, TruLoginModule, TruMatSelectPanel, TruMatSelectPanelModule, TruModelPropertyLookup, TruNameValue, TruPasswordDialog, TruPasswordDialogModule, TruPredicate, TruPredicateMap, TruPropertyConfigBase, TruPropertyConfigCloudFile, TruPropertyConfigDate, TruPropertyConfigDecimal, TruPropertyConfigFile, TruPropertyConfigForeignKey, TruPropertyConfigInteger, TruPropertyConfigPassword, TruPropertyConfigPercentage, TruPropertyConfigScientific, TruPropertyConfigText, TruPropertyConfigTextChoices, TruPropertyConfigUsaAddress, TruPropertyConfigZipCode, TruQueryPredicateManager, TruRow, TruRowModule, TruSearchConfigBase, TruSearchControlBase, TruSearchControlConfigBase, TruSearchControlRangeBase, TruSearchIconModule, TruSearchPanelPositionManager, TruSearchPanelPositionManagerModule, TruSearchResultViewBase, TruSearchResultViewBaseModule, TruSearchResultViewManager, TruSearchViewBase, TruSearchViewBaseModule, TruSearchViewControlEventHandler, TruSearchViewEventHandler, TruSort, TruTableConfigBase, TruTableRegistry, TruTextManager, TruToolbar, TruToolbarButton, TruToolbarButtonModule, TruToolbarContextFilter, TruToolbarContextFilterModule, TruToolbarDropdown, TruToolbarDropdownModule, TruToolbarMenu, TruToolbarMenuModule, TruToolbarModule, TruToolbarSeparator, TruToolbarSeparatorModule, TruToolbarText, TruToolbarTextModule, TruToolbarUserProfile, TruToolbarUserProfileModule, TruUiNotification, TruUser, TruUtil, TruValidationDialog, TruValidationDialogModule, TruValidatorFactory, TruWindowActionEventHandler, TruWindowEventArgs, TruWindowEventHandler };
7244
7345
  //# sourceMappingURL=trudb-tru-common-lib.mjs.map