@sumaris-net/ngx-components 18.16.3 → 18.16.5
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.
- package/doc/changelog.md +7 -0
- package/doc/feed/feed-en.json +2 -2
- package/doc/feed/feed-fr.json +2 -2
- package/esm2022/src/app/core/form/array/form-array.mjs +32 -32
- package/esm2022/src/app/core/graphql/graphql.service.mjs +9 -8
- package/esm2022/src/app/core/services/network.service.mjs +4 -1
- package/esm2022/src/app/shared/forms.mjs +30 -30
- package/esm2022/src/environments/environment.class.mjs +4 -2
- package/esm2022/src/environments/environment.mjs +2 -1
- package/fesm2022/sumaris-net.ngx-components.mjs +75 -68
- package/fesm2022/sumaris-net.ngx-components.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app/core/form/array/form-array.d.ts +25 -15
- package/src/app/shared/forms.d.ts +14 -8
- package/src/assets/manifest.json +1 -1
- package/src/environments/environment.class.d.ts +2 -1
|
@@ -162,6 +162,7 @@ const ENVIRONMENT = new InjectionToken('ENV');
|
|
|
162
162
|
class Environment {
|
|
163
163
|
name;
|
|
164
164
|
version;
|
|
165
|
+
buildDate;
|
|
165
166
|
production;
|
|
166
167
|
// An URL to load external environment file (e.g. 'assets/environments/environment.json'
|
|
167
168
|
externalEnvironmentUrl;
|
|
@@ -180,6 +181,8 @@ class Environment {
|
|
|
180
181
|
peerDefaultPrefix;
|
|
181
182
|
// Allow to select a peer by feature
|
|
182
183
|
enableSelectPeerByFeature;
|
|
184
|
+
// Send app version headers (X-App-Version, X-App-Name) in HTTP requests
|
|
185
|
+
sendAppVersionHeaders;
|
|
183
186
|
// Interval to check if web page must be reload, in millis
|
|
184
187
|
checkAppVersionIntervalInSeconds;
|
|
185
188
|
// Enable cache persistence ?
|
|
@@ -221,7 +224,6 @@ class Environment {
|
|
|
221
224
|
account;
|
|
222
225
|
entityEditor;
|
|
223
226
|
feed;
|
|
224
|
-
buildDate;
|
|
225
227
|
}
|
|
226
228
|
|
|
227
229
|
const DATE_ISO_PATTERN = 'YYYY-MM-DDTHH:mm:ss.SSSZ';
|
|
@@ -3467,37 +3469,37 @@ class FormArrayHelper {
|
|
|
3467
3469
|
}
|
|
3468
3470
|
/**
|
|
3469
3471
|
* @param value
|
|
3470
|
-
* @param
|
|
3472
|
+
* @param opts
|
|
3471
3473
|
*/
|
|
3472
|
-
add(value,
|
|
3474
|
+
add(value, opts) {
|
|
3473
3475
|
return addValueInArray(this._formArray, this.createControl, this.equals, this.isEmpty, value, {
|
|
3474
3476
|
allowManyNullValues: this.allowManyNullValues,
|
|
3475
3477
|
allowDuplicateValue: this.allowDuplicatedValues,
|
|
3476
|
-
...
|
|
3478
|
+
...opts,
|
|
3477
3479
|
});
|
|
3478
3480
|
}
|
|
3479
|
-
removeAt(index) {
|
|
3481
|
+
removeAt(index, opts) {
|
|
3480
3482
|
// Do not remove if last criterion
|
|
3481
3483
|
if (!this._allowEmptyArray && this._formArray.length === 1) {
|
|
3482
|
-
return clearValueInArray(this._formArray, this.isEmpty, index);
|
|
3484
|
+
return clearValueInArray(this._formArray, this.isEmpty, index, opts);
|
|
3483
3485
|
}
|
|
3484
3486
|
else {
|
|
3485
|
-
return removeValueInArray(this._formArray,
|
|
3487
|
+
return removeValueInArray(this._formArray, index, opts);
|
|
3486
3488
|
}
|
|
3487
3489
|
}
|
|
3488
|
-
resize(length,
|
|
3489
|
-
return resizeArray(this._formArray, this.createControl, length,
|
|
3490
|
+
resize(length, opts) {
|
|
3491
|
+
return resizeArray(this._formArray, this.createControl, length, opts);
|
|
3490
3492
|
}
|
|
3491
|
-
clearAt(index) {
|
|
3492
|
-
return clearValueInArray(this._formArray, this.isEmpty, index);
|
|
3493
|
+
clearAt(index, opts) {
|
|
3494
|
+
return clearValueInArray(this._formArray, this.isEmpty, index, opts);
|
|
3493
3495
|
}
|
|
3494
3496
|
isLast(index) {
|
|
3495
3497
|
return this._formArray.length - 1 === index;
|
|
3496
3498
|
}
|
|
3497
|
-
removeAllEmpty() {
|
|
3499
|
+
removeAllEmpty(opts) {
|
|
3498
3500
|
let index = this._formArray.controls.findIndex((c) => this.isEmpty(c.value));
|
|
3499
3501
|
while (index !== -1) {
|
|
3500
|
-
this.removeAt(index);
|
|
3502
|
+
this.removeAt(index, opts);
|
|
3501
3503
|
index = this._formArray.controls.findIndex((c) => this.isEmpty(c.value));
|
|
3502
3504
|
}
|
|
3503
3505
|
}
|
|
@@ -3521,11 +3523,11 @@ class FormArrayHelper {
|
|
|
3521
3523
|
* Resize the FormArray, then patch values
|
|
3522
3524
|
*
|
|
3523
3525
|
* @param values
|
|
3524
|
-
* @param
|
|
3526
|
+
* @param opts
|
|
3525
3527
|
*/
|
|
3526
|
-
patchValue(values,
|
|
3528
|
+
patchValue(values, opts) {
|
|
3527
3529
|
this.resize(values?.length || 0);
|
|
3528
|
-
this._formArray.patchValue(values,
|
|
3530
|
+
this._formArray.patchValue(values, opts);
|
|
3529
3531
|
}
|
|
3530
3532
|
disable(opts) {
|
|
3531
3533
|
this._formArray.controls.forEach((c) => c.disable(opts));
|
|
@@ -3606,8 +3608,8 @@ class AppFormArray extends UntypedFormArray {
|
|
|
3606
3608
|
// Clean all
|
|
3607
3609
|
this.resize(0, { emitEvent: options?.emitEvent });
|
|
3608
3610
|
// Recreate each control, with a default value
|
|
3609
|
-
(values || []).forEach((value) => {
|
|
3610
|
-
const control = this.createControl(value);
|
|
3611
|
+
(values || []).forEach((value, index) => {
|
|
3612
|
+
const control = this.createControl(value, index);
|
|
3611
3613
|
// Apply parent disabled state, before to push it into the array
|
|
3612
3614
|
// This is need to avoid parent form to be enabled, after calling AppFormArray.patchValue() (e.g. in table's row validator)
|
|
3613
3615
|
if (disabled && control.enabled)
|
|
@@ -3636,8 +3638,8 @@ class AppFormArray extends UntypedFormArray {
|
|
|
3636
3638
|
// Clean all
|
|
3637
3639
|
this.resize(0, { emitEvent: options?.emitEvent });
|
|
3638
3640
|
// Recreate each control, with a default value
|
|
3639
|
-
(values || []).forEach((value) => {
|
|
3640
|
-
const control = this.createControl(value);
|
|
3641
|
+
(values || []).forEach((value, index) => {
|
|
3642
|
+
const control = this.createControl(value, index);
|
|
3641
3643
|
// Apply parent disabled state, before to push it into the array
|
|
3642
3644
|
// This is need to avoid parent form to be enabled, after calling AppFormArray.patchValue() (e.g. in table's row validator)
|
|
3643
3645
|
if (disabled && control.enabled)
|
|
@@ -3673,38 +3675,38 @@ class AppFormArray extends UntypedFormArray {
|
|
|
3673
3675
|
}
|
|
3674
3676
|
/**
|
|
3675
3677
|
* @param value
|
|
3676
|
-
* @param
|
|
3678
|
+
* @param opts
|
|
3677
3679
|
*/
|
|
3678
|
-
add(value,
|
|
3679
|
-
addValueInArray(this, this.createControl, this.equals, this.isEmpty, value, { ...this.options, ...
|
|
3680
|
+
add(value, opts) {
|
|
3681
|
+
addValueInArray(this, this.createControl, this.equals, this.isEmpty, value, { ...this.options, ...opts });
|
|
3680
3682
|
}
|
|
3681
|
-
removeAt(index,
|
|
3683
|
+
removeAt(index, opts) {
|
|
3682
3684
|
// Do not remove if last criterion
|
|
3683
3685
|
if (this.options.allowEmptyArray === false && this.length === 1) {
|
|
3684
|
-
this.clearAt(index,
|
|
3686
|
+
this.clearAt(index, opts);
|
|
3685
3687
|
return false;
|
|
3686
3688
|
}
|
|
3687
3689
|
else if (index < this.length) {
|
|
3688
|
-
super.removeAt(index,
|
|
3689
|
-
this.markAsDirty();
|
|
3690
|
+
super.removeAt(index, opts);
|
|
3691
|
+
this.markAsDirty(opts);
|
|
3690
3692
|
return true;
|
|
3691
3693
|
}
|
|
3692
3694
|
return false;
|
|
3693
3695
|
}
|
|
3694
|
-
clearAt(index,
|
|
3696
|
+
clearAt(index, opts) {
|
|
3695
3697
|
const control = this.at(index);
|
|
3696
3698
|
if (this.isEmpty(control.value))
|
|
3697
3699
|
return; // skip (not need to clear)
|
|
3698
3700
|
if (control instanceof UntypedFormGroup) {
|
|
3699
|
-
copyEntity2Form({}, control,
|
|
3701
|
+
copyEntity2Form({}, control, opts);
|
|
3700
3702
|
}
|
|
3701
3703
|
else if (control instanceof UntypedFormArray) {
|
|
3702
|
-
control.setValue([],
|
|
3704
|
+
control.setValue([], opts);
|
|
3703
3705
|
}
|
|
3704
3706
|
else {
|
|
3705
|
-
control.setValue(null,
|
|
3707
|
+
control.setValue(null, opts);
|
|
3706
3708
|
}
|
|
3707
|
-
this.markAsDirty();
|
|
3709
|
+
this.markAsDirty(opts);
|
|
3708
3710
|
}
|
|
3709
3711
|
isLast(index) {
|
|
3710
3712
|
return this.length - 1 === index;
|
|
@@ -3779,7 +3781,7 @@ function adaptValueToControl(source, control, path) {
|
|
|
3779
3781
|
}
|
|
3780
3782
|
// Resizable array
|
|
3781
3783
|
if (control instanceof AppFormArray) {
|
|
3782
|
-
const exampleControl = control.createControl();
|
|
3784
|
+
const exampleControl = control.createControl(undefined, control.length);
|
|
3783
3785
|
return source.map((item, index) => adaptValueToControl(item, exampleControl, pathPrefix + '#' + index));
|
|
3784
3786
|
}
|
|
3785
3787
|
// Legacy array
|
|
@@ -4072,17 +4074,17 @@ function setControlEnabled(control, enabled, opts) {
|
|
|
4072
4074
|
}
|
|
4073
4075
|
}
|
|
4074
4076
|
}
|
|
4075
|
-
function addValueInArray(arrayControl, createControl, equals, isEmpty, value,
|
|
4077
|
+
function addValueInArray(arrayControl, createControl, equals, isEmpty, value, opts) {
|
|
4076
4078
|
const disabled = arrayControl.disabled;
|
|
4077
4079
|
let hasChanged = false;
|
|
4078
4080
|
let index = -1;
|
|
4079
4081
|
let isEmptyValue = isEmpty(value);
|
|
4080
4082
|
// Search if value already exists
|
|
4081
|
-
if (!isEmptyValue &&
|
|
4083
|
+
if (!isEmptyValue && opts?.allowDuplicateValue !== true) {
|
|
4082
4084
|
index = (arrayControl.value || []).findIndex((v) => equals(value, v));
|
|
4083
4085
|
}
|
|
4084
4086
|
// If value not exists, but last value is empty: reuse last value
|
|
4085
|
-
if (index === -1 &&
|
|
4087
|
+
if (index === -1 && opts?.allowManyNullValues !== true && arrayControl.length > 0) {
|
|
4086
4088
|
const lastValue = arrayControl.at(arrayControl.length - 1).value;
|
|
4087
4089
|
if (isEmpty(lastValue)) {
|
|
4088
4090
|
index = arrayControl.length - 1;
|
|
@@ -4091,31 +4093,31 @@ function addValueInArray(arrayControl, createControl, equals, isEmpty, value, op
|
|
|
4091
4093
|
// Replace the existing value
|
|
4092
4094
|
if (index !== -1) {
|
|
4093
4095
|
if (!isEmptyValue) {
|
|
4094
|
-
arrayControl.at(index).patchValue(value,
|
|
4096
|
+
arrayControl.at(index).patchValue(value, opts);
|
|
4095
4097
|
hasChanged = true;
|
|
4096
4098
|
}
|
|
4097
4099
|
}
|
|
4098
4100
|
else {
|
|
4099
|
-
const control = createControl(value);
|
|
4101
|
+
const control = createControl(value, arrayControl.length);
|
|
4100
4102
|
// Apply parent disabled state, before to push it into the array
|
|
4101
4103
|
// This is need to avoid parent form to be enabled
|
|
4102
4104
|
if (disabled && control.enabled)
|
|
4103
4105
|
control.disable({ emitEvent: false });
|
|
4104
4106
|
else if (!disabled && control.disabled)
|
|
4105
4107
|
control.enable({ emitEvent: false });
|
|
4106
|
-
if (isNotNilOrNaN(
|
|
4107
|
-
arrayControl.insert(
|
|
4108
|
+
if (isNotNilOrNaN(opts?.insertAt)) {
|
|
4109
|
+
arrayControl.insert(opts.insertAt, control, opts);
|
|
4108
4110
|
}
|
|
4109
4111
|
else {
|
|
4110
|
-
arrayControl.push(control,
|
|
4112
|
+
arrayControl.push(control, opts);
|
|
4111
4113
|
}
|
|
4112
4114
|
hasChanged = true;
|
|
4113
4115
|
}
|
|
4114
4116
|
if (hasChanged) {
|
|
4115
|
-
if (!
|
|
4117
|
+
if (!opts || opts.emitEvent !== false) {
|
|
4116
4118
|
// Mark array control dirty
|
|
4117
4119
|
if (!isEmptyValue) {
|
|
4118
|
-
arrayControl.markAsDirty();
|
|
4120
|
+
arrayControl.markAsDirty(opts);
|
|
4119
4121
|
}
|
|
4120
4122
|
}
|
|
4121
4123
|
}
|
|
@@ -4127,67 +4129,67 @@ function addValueInArray(arrayControl, createControl, equals, isEmpty, value, op
|
|
|
4127
4129
|
* @param arrayControl
|
|
4128
4130
|
* @param createControl
|
|
4129
4131
|
* @param defaultValues
|
|
4130
|
-
* @param
|
|
4132
|
+
* @param opts
|
|
4131
4133
|
*/
|
|
4132
|
-
function initArrayControlsFromValues(arrayControl, createControl, defaultValues,
|
|
4134
|
+
function initArrayControlsFromValues(arrayControl, createControl, defaultValues, opts) {
|
|
4133
4135
|
if (arrayControl.length === 0 && (!defaultValues || defaultValues.length === 0))
|
|
4134
4136
|
return false; // No changes need
|
|
4135
4137
|
const disabled = arrayControl.disabled;
|
|
4136
4138
|
while (arrayControl.length > 0) {
|
|
4137
|
-
arrayControl.removeAt(arrayControl.length - 1,
|
|
4139
|
+
arrayControl.removeAt(arrayControl.length - 1, opts);
|
|
4138
4140
|
}
|
|
4139
|
-
(defaultValues || []).forEach((value) => {
|
|
4140
|
-
const control = createControl(value);
|
|
4141
|
+
(defaultValues || []).forEach((value, index) => {
|
|
4142
|
+
const control = createControl(value, index);
|
|
4141
4143
|
// Apply parent disabled state, before to push it into the array
|
|
4142
4144
|
// This is need to avoid parent form to be enabled
|
|
4143
4145
|
if (disabled && control.enabled)
|
|
4144
4146
|
control.disable({ emitEvent: false });
|
|
4145
4147
|
else if (!disabled && control.disabled)
|
|
4146
4148
|
control.enable({ emitEvent: false });
|
|
4147
|
-
arrayControl.push(control,
|
|
4149
|
+
arrayControl.push(control, opts);
|
|
4148
4150
|
});
|
|
4149
4151
|
return true; // Has some changes
|
|
4150
4152
|
}
|
|
4151
|
-
function resizeArray(arrayControl, createControl, length,
|
|
4153
|
+
function resizeArray(arrayControl, createControl, length, opts) {
|
|
4152
4154
|
if (arrayControl.length === length)
|
|
4153
4155
|
return false; // No changes need
|
|
4154
4156
|
const disabled = arrayControl.disabled;
|
|
4155
4157
|
// Reduce size
|
|
4156
4158
|
while (arrayControl.length > length) {
|
|
4157
|
-
arrayControl.removeAt(arrayControl.length - 1,
|
|
4159
|
+
arrayControl.removeAt(arrayControl.length - 1, opts);
|
|
4158
4160
|
}
|
|
4159
4161
|
// Increase size
|
|
4160
4162
|
while (arrayControl.length < length) {
|
|
4161
|
-
const control = createControl();
|
|
4163
|
+
const control = createControl(undefined, arrayControl.length);
|
|
4162
4164
|
// Apply parent disabled state, before to push it into the array
|
|
4163
4165
|
// This is need to avoid parent form to be enabled, after calling resizeArray()
|
|
4164
4166
|
if (disabled && control.enabled)
|
|
4165
4167
|
control.disable({ emitEvent: false });
|
|
4166
4168
|
else if (!disabled && control.disabled)
|
|
4167
4169
|
control.enable({ emitEvent: false });
|
|
4168
|
-
arrayControl.push(control,
|
|
4170
|
+
arrayControl.push(control, opts);
|
|
4169
4171
|
}
|
|
4170
4172
|
return true; // Has some changes
|
|
4171
4173
|
}
|
|
4172
|
-
function removeValueInArray(arrayControl,
|
|
4173
|
-
arrayControl.removeAt(index);
|
|
4174
|
-
arrayControl.markAsDirty();
|
|
4174
|
+
function removeValueInArray(arrayControl, index, opts) {
|
|
4175
|
+
arrayControl.removeAt(index, opts);
|
|
4176
|
+
arrayControl.markAsDirty(opts);
|
|
4175
4177
|
return true;
|
|
4176
4178
|
}
|
|
4177
|
-
function clearValueInArray(arrayControl, isEmpty, index) {
|
|
4179
|
+
function clearValueInArray(arrayControl, isEmpty, index, opts) {
|
|
4178
4180
|
const control = arrayControl.at(index);
|
|
4179
4181
|
if (isEmpty(control.value))
|
|
4180
4182
|
return false; // skip (not need to clear)
|
|
4181
4183
|
if (control instanceof UntypedFormGroup) {
|
|
4182
|
-
copyEntity2Form({}, control);
|
|
4184
|
+
copyEntity2Form({}, control, opts);
|
|
4183
4185
|
}
|
|
4184
4186
|
else if (control instanceof UntypedFormArray) {
|
|
4185
|
-
control.setValue([]);
|
|
4187
|
+
control.setValue([], opts);
|
|
4186
4188
|
}
|
|
4187
4189
|
else {
|
|
4188
|
-
control.setValue(null);
|
|
4190
|
+
control.setValue(null, opts);
|
|
4189
4191
|
}
|
|
4190
|
-
arrayControl.markAsDirty();
|
|
4192
|
+
arrayControl.markAsDirty(opts);
|
|
4191
4193
|
return true;
|
|
4192
4194
|
}
|
|
4193
4195
|
function markAllAsTouched(control, opts) {
|
|
@@ -12992,6 +12994,7 @@ const environment = Object.freeze({
|
|
|
12992
12994
|
//offline: true,
|
|
12993
12995
|
peerMinVersion: '1.8.0',
|
|
12994
12996
|
enableSelectPeerByFeature: true,
|
|
12997
|
+
sendAppVersionHeaders: true,
|
|
12995
12998
|
defaultPeer: {
|
|
12996
12999
|
host: 'localhost',
|
|
12997
13000
|
port: 8081,
|
|
@@ -20110,6 +20113,9 @@ class NetworkService extends StartableObservableService {
|
|
|
20110
20113
|
}
|
|
20111
20114
|
/* -- Protected methods -- */
|
|
20112
20115
|
addVersionHeader(opts) {
|
|
20116
|
+
// Only add version headers if enabled in environment
|
|
20117
|
+
if (!this.environment.sendAppVersionHeaders)
|
|
20118
|
+
return opts;
|
|
20113
20119
|
const updatedOpts = { ...opts };
|
|
20114
20120
|
if (!updatedOpts.headers) {
|
|
20115
20121
|
updatedOpts.headers = {};
|
|
@@ -20758,13 +20764,14 @@ class GraphqlService extends StartableService {
|
|
|
20758
20764
|
if (authorization.length > 0) {
|
|
20759
20765
|
headers = headers.append('Authorization', authorization);
|
|
20760
20766
|
}
|
|
20761
|
-
// Add application version
|
|
20762
|
-
if (this.environment.
|
|
20763
|
-
|
|
20764
|
-
|
|
20765
|
-
|
|
20766
|
-
|
|
20767
|
-
|
|
20767
|
+
// Add application version headers (if enabled)
|
|
20768
|
+
if (this.environment.sendAppVersionHeaders) {
|
|
20769
|
+
if (this.environment.version) {
|
|
20770
|
+
headers = headers.append('X-App-Version', this.environment.version);
|
|
20771
|
+
}
|
|
20772
|
+
if (this.environment.defaultAppName) {
|
|
20773
|
+
headers = headers.append('X-App-Name', this.environment.defaultAppName);
|
|
20774
|
+
}
|
|
20768
20775
|
}
|
|
20769
20776
|
// Use the setContext method to set the HTTP headers.
|
|
20770
20777
|
operation.setContext({
|