@dsivd/prestations-ng 16.0.0-beta6 → 16.0.0-beta8

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.
@@ -2062,7 +2062,6 @@ class UploaderHelper {
2062
2062
  this.dictionaryService = dictionaryService;
2063
2063
  this.applicationInfoService = applicationInfoService;
2064
2064
  this._accept = '.pdf';
2065
- this._maxSizeInMo = 1;
2066
2065
  this._maxFileNameLength = 64;
2067
2066
  this._illegalCharacters = '/,\\,?,%,*,:,|,",<,>,°';
2068
2067
  this._fileMinSizeInBytes = 20;
@@ -2071,7 +2070,8 @@ class UploaderHelper {
2071
2070
  if (appInfo.configuration.document) {
2072
2071
  this.accept = appInfo.configuration.document.fileExtensions;
2073
2072
  this.maxFileNameLength = Number(appInfo.configuration.document.maxFileNameLength);
2074
- this.maxSizeInMo = Number(appInfo.configuration.document.maxFileSizeInMo);
2073
+ this._fileMaxSizeInBytesByFormKey =
2074
+ appInfo.configuration.document.fileMaxSizeInBytesByFormKey;
2075
2075
  this.illegalCharacters =
2076
2076
  appInfo.configuration.document.illegalCharacters;
2077
2077
  }
@@ -2098,27 +2098,17 @@ class UploaderHelper {
2098
2098
  this._maxFileNameLength = value;
2099
2099
  }
2100
2100
  // eslint-disable-next-line @typescript-eslint/member-ordering
2101
- get maxSizeInMo() {
2102
- return this._maxSizeInMo;
2103
- }
2104
- set maxSizeInMo(value) {
2105
- this._maxSizeInMo = value;
2106
- }
2107
- // eslint-disable-next-line @typescript-eslint/member-ordering
2108
2101
  get accept() {
2109
2102
  return this._accept;
2110
2103
  }
2111
2104
  set accept(value) {
2112
2105
  this._accept = value;
2113
2106
  }
2114
- isFileTooBig(fileSizeInBytes, overrideMaxSizeInMo) {
2115
- if (!!overrideMaxSizeInMo) {
2116
- return this.isTooBig(fileSizeInBytes, overrideMaxSizeInMo);
2117
- }
2118
- if (!this.maxSizeInMo) {
2119
- return false;
2120
- }
2121
- return this.isTooBig(fileSizeInBytes, this.maxSizeInMo);
2107
+ getMaxFileSizeInBytesForFormKey(formKey) {
2108
+ return this._fileMaxSizeInBytesByFormKey[formKey];
2109
+ }
2110
+ isFileTooBig(formKey, fileSizeInBytes) {
2111
+ return this.isTooBig(fileSizeInBytes, this.getMaxFileSizeInBytesForFormKey(formKey));
2122
2112
  }
2123
2113
  isFileTooSmall(fileSizeInBytes) {
2124
2114
  if (!this.fileMinSizeInBytes) {
@@ -2158,19 +2148,19 @@ class UploaderHelper {
2158
2148
  .split(',')
2159
2149
  .includes(fileExtension.toUpperCase()));
2160
2150
  }
2161
- getUniqueErrorByCode(name, errorCode, fileName, customErrors, overrideMaxSizeInMo, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters) {
2151
+ getUniqueErrorByCode(name, errorCode, fileName, customErrors, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters) {
2162
2152
  const uniqSuffix = new Date().getTime();
2163
2153
  return {
2164
2154
  name,
2165
2155
  code: `${errorCode}_${uniqSuffix}`,
2166
- message: this.replaceErrorMessageKeys(customErrors[errorCode], fileName, errorCode, overrideMaxSizeInMo, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters)
2156
+ message: this.replaceErrorMessageKeys(name, customErrors[errorCode], fileName, errorCode, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters)
2167
2157
  };
2168
2158
  }
2169
- addCustomErrorOrDefault(name, destinationErrors, errorCode, fileName, customErrors, overrideMaxSizeInMo, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters) {
2159
+ addCustomErrorOrDefault(name, destinationErrors, errorCode, fileName, customErrors, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters) {
2170
2160
  // Check if we have a custom error to manage
2171
2161
  if (customErrors[errorCode]) {
2172
2162
  // Need to create unique error to ensure ability to display multiple error messages
2173
- destinationErrors.push(this.getUniqueErrorByCode(name, errorCode, fileName, customErrors, overrideMaxSizeInMo, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters));
2163
+ destinationErrors.push(this.getUniqueErrorByCode(name, errorCode, fileName, customErrors, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters));
2174
2164
  }
2175
2165
  else {
2176
2166
  destinationErrors.push({
@@ -2199,7 +2189,7 @@ class UploaderHelper {
2199
2189
  // MultiPartException from Zuul returns HTTP 0
2200
2190
  customErrors['0'] = customErrors['413'];
2201
2191
  }
2202
- getLocalErrors(name, files, customErrors, overrideMaxSizeInMo, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters) {
2192
+ getLocalErrors(name, files, customErrors, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters) {
2203
2193
  const errors = [];
2204
2194
  files.forEach(file => {
2205
2195
  // File bad extension
@@ -2207,30 +2197,30 @@ class UploaderHelper {
2207
2197
  if (!this.isFileExtensionValid(fileExtension, overrideAcceptedExtensions)) {
2208
2198
  // Default custom error 415 exist (see function 'createDefaultCustomErrors')
2209
2199
  // Need to create unique error to ensure ability to display multiple error messages
2210
- errors.push(this.getUniqueErrorByCode(name, '415', file.name, customErrors, overrideMaxSizeInMo, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters));
2200
+ errors.push(this.getUniqueErrorByCode(name, '415', file.name, customErrors, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters));
2211
2201
  }
2212
2202
  // File name contains illegal characters
2213
2203
  if (!this.isFileNameNameValid(file.name, overrideIllegalCharacters)) {
2214
2204
  // Default custom error FILENAME_SHOULD_NOT_CONTAIN exist (see function 'createDefaultCustomErrors')
2215
2205
  // Need to create unique error to ensure ability to display multiple error messages
2216
- errors.push(this.getUniqueErrorByCode(name, 'FILENAME_SHOULD_NOT_CONTAIN', file.name, customErrors, overrideMaxSizeInMo, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters));
2206
+ errors.push(this.getUniqueErrorByCode(name, 'FILENAME_SHOULD_NOT_CONTAIN', file.name, customErrors, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters));
2217
2207
  }
2218
2208
  // Files too big
2219
- if (this.isFileTooBig(file.size, overrideMaxSizeInMo)) {
2209
+ if (this.isFileTooBig(name, file.size)) {
2220
2210
  // Default custom error 413 exist (see function 'createDefaultCustomErrors')
2221
2211
  // Need to create unique error to ensure ability to display multiple error messages
2222
- errors.push(this.getUniqueErrorByCode(name, '413', file.name, customErrors, overrideMaxSizeInMo, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters));
2212
+ errors.push(this.getUniqueErrorByCode(name, '413', file.name, customErrors, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters));
2223
2213
  }
2224
2214
  if (this.isFileTooSmall(file.size)) {
2225
2215
  // Default custom error FILE_TOO_SMALL exist (see function 'createDefaultCustomErrors')
2226
2216
  // Need to create unique error to ensure ability to display multiple error messages
2227
- errors.push(this.getUniqueErrorByCode(name, 'FILE_TOO_SMALL', file.name, customErrors, overrideMaxSizeInMo, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters));
2217
+ errors.push(this.getUniqueErrorByCode(name, 'FILE_TOO_SMALL', file.name, customErrors, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters));
2228
2218
  }
2229
2219
  // File name too long (64 chars max)
2230
2220
  if (!this.isFileNameLengthValid(file.name, overrideMaxFileNameLength)) {
2231
2221
  // Default custom error FILENAME_TOO_LONG exist (see function 'createDefaultCustomErrors')
2232
2222
  // Need to create unique error to ensure ability to display multiple error messages
2233
- errors.push(this.getUniqueErrorByCode(name, 'FILENAME_TOO_LONG', file.name, customErrors, overrideMaxSizeInMo, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters));
2223
+ errors.push(this.getUniqueErrorByCode(name, 'FILENAME_TOO_LONG', file.name, customErrors, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters));
2234
2224
  }
2235
2225
  });
2236
2226
  return errors;
@@ -2329,16 +2319,15 @@ class UploaderHelper {
2329
2319
  removeCommasInLabel(label) {
2330
2320
  return label.split(',').join('');
2331
2321
  }
2332
- isTooBig(fileSizeInBytes, limitInMo) {
2333
- return fileSizeInBytes / (1024 * 1024) > limitInMo;
2322
+ isTooBig(fileSizeInBytes, limitInBytes) {
2323
+ return fileSizeInBytes > limitInBytes;
2334
2324
  }
2335
- replaceErrorMessageKeys(errorMsg, fileName, errorCode, overrideMaxSizeInMo, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters) {
2325
+ replaceErrorMessageKeys(name, errorMsg, fileName, errorCode, overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters) {
2336
2326
  const formattedErrorMsg = errorMsg.replace('%1$s', fileName);
2337
2327
  if (errorCode.startsWith('413')) {
2338
2328
  // REQUEST_ENTITY_TOO_LARGE_ERROR_MSG
2339
- const fileMaxSize = (overrideMaxSizeInMo
2340
- ? overrideMaxSizeInMo
2341
- : this.maxSizeInMo).toString();
2329
+ const fileMaxSize = (this._fileMaxSizeInBytesByFormKey[name] /
2330
+ (1024 * 1024)).toString();
2342
2331
  return formattedErrorMsg.replace('%2$s', fileMaxSize);
2343
2332
  }
2344
2333
  if (errorCode.startsWith('415')) {
@@ -11251,13 +11240,13 @@ class AbstractFoehnUploaderComponent extends FoehnInputComponent {
11251
11240
  this.deleteDocumentSubject.next(document);
11252
11241
  }
11253
11242
  displayLocalErrors(files) {
11254
- const errors = this.uploaderHelper.getLocalErrors(this.name, files, this.customErrors, this.overrideMaxSizeInMo, this.overrideAcceptedExtensions, this.overrideMaxFileNameLength, this.overrideIllegalCharacters);
11243
+ const errors = this.uploaderHelper.getLocalErrors(this.name, files, this.customErrors, this.overrideAcceptedExtensions, this.overrideMaxFileNameLength, this.overrideIllegalCharacters);
11255
11244
  this.refreshErrors([errors, true]);
11256
11245
  return errors;
11257
11246
  }
11258
11247
  }
11259
11248
  AbstractFoehnUploaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: AbstractFoehnUploaderComponent, deps: [{ token: ApplicationInfoService }, { token: FoehnConfirmModalService }, { token: SdkDictionaryService }], target: i0.ɵɵFactoryTarget.Directive });
11260
- AbstractFoehnUploaderComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.4", type: AbstractFoehnUploaderComponent, inputs: { required: "required", dragAndDrop: "dragAndDrop", showUploadButton: "showUploadButton", readonly: "readonly", hideGlobalInfos: "hideGlobalInfos", multiple: "multiple", key: "key", chooseButtonLabel: "chooseButtonLabel", chooseButtonLabelMultiple: "chooseButtonLabelMultiple", dropZoneLabel: "dropZoneLabel", dropZoneLabelMultiple: "dropZoneLabelMultiple", overrideAcceptedExtensions: "overrideAcceptedExtensions", overrideMaxSizeInMo: "overrideMaxSizeInMo", overrideMaxFileNameLength: "overrideMaxFileNameLength", overrideIllegalCharacters: "overrideIllegalCharacters", showDeleteConfirmationMessage: "showDeleteConfirmationMessage", deleteConfirmationMessage: "deleteConfirmationMessage" }, host: { listeners: { "window:dragover": "onDocumentDragOver($event)", "window:dragleave": "onDocumentDragLeave($event)", "window:drop": "onDocumentDrop($event)" } }, usesInheritance: true, ngImport: i0 });
11249
+ AbstractFoehnUploaderComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.4", type: AbstractFoehnUploaderComponent, inputs: { required: "required", dragAndDrop: "dragAndDrop", showUploadButton: "showUploadButton", readonly: "readonly", hideGlobalInfos: "hideGlobalInfos", multiple: "multiple", key: "key", chooseButtonLabel: "chooseButtonLabel", chooseButtonLabelMultiple: "chooseButtonLabelMultiple", dropZoneLabel: "dropZoneLabel", dropZoneLabelMultiple: "dropZoneLabelMultiple", overrideAcceptedExtensions: "overrideAcceptedExtensions", overrideMaxFileNameLength: "overrideMaxFileNameLength", overrideIllegalCharacters: "overrideIllegalCharacters", showDeleteConfirmationMessage: "showDeleteConfirmationMessage", deleteConfirmationMessage: "deleteConfirmationMessage" }, host: { listeners: { "window:dragover": "onDocumentDragOver($event)", "window:dragleave": "onDocumentDragLeave($event)", "window:drop": "onDocumentDrop($event)" } }, usesInheritance: true, ngImport: i0 });
11261
11250
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: AbstractFoehnUploaderComponent, decorators: [{
11262
11251
  type: Directive
11263
11252
  }], ctorParameters: function () { return [{ type: ApplicationInfoService }, { type: FoehnConfirmModalService }, { type: SdkDictionaryService }]; }, propDecorators: { required: [{
@@ -11284,8 +11273,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
11284
11273
  type: Input
11285
11274
  }], overrideAcceptedExtensions: [{
11286
11275
  type: Input
11287
- }], overrideMaxSizeInMo: [{
11288
- type: Input
11289
11276
  }], overrideMaxFileNameLength: [{
11290
11277
  type: Input
11291
11278
  }], overrideIllegalCharacters: [{
@@ -11412,7 +11399,7 @@ class FoehnMultiUploadComponent extends AbstractFoehnUploaderComponent {
11412
11399
  const errors = [];
11413
11400
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
11414
11401
  const { status } = error;
11415
- this.uploaderHelper.addCustomErrorOrDefault(this.name, errors, `${status}`, '', this.customErrors, this.overrideMaxSizeInMo, this.overrideAcceptedExtensions, this.overrideMaxFileNameLength, this.overrideIllegalCharacters);
11402
+ this.uploaderHelper.addCustomErrorOrDefault(this.name, errors, `${status}`, '', this.customErrors, this.overrideAcceptedExtensions, this.overrideMaxFileNameLength, this.overrideIllegalCharacters);
11416
11403
  this.refreshErrors([errors, true]);
11417
11404
  });
11418
11405
  // Delete document logic
@@ -11531,7 +11518,7 @@ class FoehnMultiUploadComponent extends AbstractFoehnUploaderComponent {
11531
11518
  return;
11532
11519
  }
11533
11520
  const newErrors = [];
11534
- errors.forEach(error => this.uploaderHelper.addCustomErrorOrDefault(this.name, newErrors, `${error.errorCode}`, error.label, this.customErrors, this.overrideMaxSizeInMo, this.overrideAcceptedExtensions, this.overrideMaxFileNameLength, this.overrideIllegalCharacters));
11521
+ errors.forEach(error => this.uploaderHelper.addCustomErrorOrDefault(this.name, newErrors, `${error.errorCode}`, error.label, this.customErrors, this.overrideAcceptedExtensions, this.overrideMaxFileNameLength, this.overrideIllegalCharacters));
11535
11522
  this.refreshErrors([newErrors, true]);
11536
11523
  }
11537
11524
  manageSingleFile(files) {
@@ -11721,7 +11708,7 @@ class FoehnBoMultiUploadComponent extends AbstractFoehnUploaderComponent {
11721
11708
  const errors = [];
11722
11709
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
11723
11710
  const { status } = error;
11724
- this.uploaderHelper.addCustomErrorOrDefault(this.name, errors, `${status}`, '', this.customErrors, this.overrideMaxSizeInMo, this.overrideAcceptedExtensions, this.overrideMaxFileNameLength, this.overrideIllegalCharacters);
11711
+ this.uploaderHelper.addCustomErrorOrDefault(this.name, errors, `${status}`, '', this.customErrors, this.overrideAcceptedExtensions, this.overrideMaxFileNameLength, this.overrideIllegalCharacters);
11725
11712
  this.refreshErrors([errors, true]);
11726
11713
  });
11727
11714
  // Delete document logic
@@ -11796,7 +11783,7 @@ class FoehnBoMultiUploadComponent extends AbstractFoehnUploaderComponent {
11796
11783
  return;
11797
11784
  }
11798
11785
  const newErrors = [];
11799
- errors.forEach(error => this.uploaderHelper.addCustomErrorOrDefault(this.name, newErrors, `${error.errorCode}`, error.label, this.customErrors, this.overrideMaxSizeInMo, this.overrideAcceptedExtensions, this.overrideMaxFileNameLength, this.overrideIllegalCharacters));
11786
+ errors.forEach(error => this.uploaderHelper.addCustomErrorOrDefault(this.name, newErrors, `${error.errorCode}`, error.label, this.customErrors, this.overrideAcceptedExtensions, this.overrideMaxFileNameLength, this.overrideIllegalCharacters));
11800
11787
  this.refreshErrors([newErrors, true]);
11801
11788
  }
11802
11789
  removeDocumentFromModel(document) {