@sumaris-net/ngx-components 2.6.4-rc10 → 2.6.4-rc12

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.
@@ -23019,13 +23019,6 @@ let NamedFilter = class NamedFilter extends Entity {
23019
23019
  throw e;
23020
23020
  }
23021
23021
  }
23022
- asObject(opts) {
23023
- const target = super.asObject(opts);
23024
- if (opts?.minify) {
23025
- target.content = JSON.stringify(this.content);
23026
- }
23027
- return target;
23028
- }
23029
23022
  };
23030
23023
  NamedFilter = __decorate([
23031
23024
  EntityClass({ typename: 'NamedFilterVO' })
@@ -23052,7 +23045,7 @@ NamedFilterFilter = __decorate([
23052
23045
  const APP_NAMED_FILTER_SERVICE = new InjectionToken('namedFilterService');
23053
23046
  // @dynamic
23054
23047
  class AbstractNamedFilterService extends BaseEntityService {
23055
- constructor(graphql, platform, dataType, filterType, options) {
23048
+ constructor(graphql, platform, account, dataType, filterType, options) {
23056
23049
  super(graphql, platform, dataType, filterType, {
23057
23050
  defaultSortBy: 'name',
23058
23051
  defaultSortDirection: 'asc',
@@ -23060,62 +23053,49 @@ class AbstractNamedFilterService extends BaseEntityService {
23060
23053
  });
23061
23054
  this.graphql = graphql;
23062
23055
  this.platform = platform;
23056
+ this.account = account;
23063
23057
  this.dataType = dataType;
23064
23058
  this.filterType = filterType;
23065
23059
  this.options = options;
23066
23060
  this._logPrefix = '[named-filter-service] ';
23067
23061
  }
23068
- watchAll(offset, size, sortBy, sortDirection, filter, options) {
23069
- if (!filter) {
23070
- filter = this.defaultFilter();
23071
- }
23072
- // Always ask total
23073
- options = {
23074
- ...options,
23075
- withTotal: true
23076
- };
23077
- // Set query if content is wanted
23078
- if (options?.withContent) {
23079
- options.query = this.queries.loadAllWithContent;
23080
- }
23081
- return super.watchAll(offset, size, sortBy, sortDirection, filter, options);
23082
- }
23083
- async loadAll(offset, size, sortBy, sortDirection, filter, options) {
23084
- if (!filter) {
23085
- filter = this.defaultFilter();
23086
- }
23087
- // Always ask total
23088
- options = {
23089
- ...options,
23090
- withTotal: true
23091
- };
23092
- // Set query if content is wanted
23093
- if (options?.withContent) {
23094
- options.query = this.queries.loadAllWithContent;
23095
- }
23096
- return super.loadAll(offset, size, sortBy, sortDirection, filter, options);
23097
- }
23098
23062
  async suggest(value, filter) {
23099
23063
  if (EntityUtils.isNotEmpty(value, 'id'))
23100
23064
  return { data: [value] };
23101
23065
  value = (typeof value === 'string' && value !== '*' && value) || undefined;
23102
- return await this.loadAll(0, 1000, 'name', 'asc', this.suggestFilter(value, filter), {
23066
+ return await this.loadAll(0, 1000, 'name', 'asc', this.asSuggestFilter(value, filter), {
23103
23067
  withTotal: true,
23104
- withContent: false
23105
23068
  });
23106
23069
  }
23107
- suggestFilter(searchText, filter) {
23070
+ asSuggestFilter(searchText, filter) {
23108
23071
  return {
23109
23072
  ...filter,
23110
23073
  searchText
23111
23074
  };
23112
23075
  }
23076
+ asFilter(source) {
23077
+ const filter = super.asFilter(source);
23078
+ // Default filter on current user
23079
+ if (isNil(filter.recorderPersonId) && isNil(filter.recorderDepartmentId))
23080
+ filter.recorderPersonId = this.account.person.id;
23081
+ return filter;
23082
+ }
23083
+ fillDefaultProperties(source) {
23084
+ super.fillDefaultProperties(source);
23085
+ // Default recorder
23086
+ if (isNil(source.recorderPersonId) && isNil(source.recorderDepartmentId))
23087
+ source.recorderPersonId = this.account.person.id;
23088
+ // Stringify content
23089
+ if (typeof source.content === 'object') {
23090
+ source.content = JSON.stringify(source.content);
23091
+ }
23092
+ }
23113
23093
  }
23114
23094
  AbstractNamedFilterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AbstractNamedFilterService, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
23115
23095
  AbstractNamedFilterService.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: AbstractNamedFilterService, usesInheritance: true, ngImport: i0 });
23116
23096
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AbstractNamedFilterService, decorators: [{
23117
23097
  type: Directive
23118
- }], ctorParameters: function () { return [{ type: GraphqlService }, { type: PlatformService }, { type: undefined }, { type: undefined }, { type: undefined }]; } });
23098
+ }], ctorParameters: function () { return [{ type: GraphqlService }, { type: PlatformService }, { type: AccountService }, { type: undefined }, { type: undefined }, { type: undefined }]; } });
23119
23099
 
23120
23100
  class AppGraphQLModule {
23121
23101
  constructor() {