Skip to content

Commit e171ec2

Browse files
authored
Merge pull request #155 from netgrif/dev
Release/6.2.5
2 parents cd24876 + 1860efe commit e171ec2

File tree

16 files changed

+98
-85
lines changed

16 files changed

+98
-85
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
66
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
Full Changelog: [https://github.com/netgrif/components/commits/v6.2.4](https://github.com/netgrif/components/commits/v6.2.4)
8+
Full Changelog: [https://github.com/netgrif/components/commits/v6.2.5](https://github.com/netgrif/components/commits/v6.2.5)
9+
10+
## [6.2.5](https://github.com/netgrif/components/releases/tag/v6.2.5) (2022-12-05)
11+
12+
### Fixed
13+
14+
- [NAE-1752] MatPrefix for currency field overrides prefix for dateField
15+
- [NAE-1754] Currency field not displaying symbol
16+
- [NAE-1758] Task on single task view is not rendering
17+
- [NAE-1760] Enumeration autocomplete constantly sending value
18+
- [NAE-1763] FileField value is not promoted to the frontend after "set data event"
19+
- [NAE-1766] Options on multichoice autocomplete do not refresh in a specific situation
920

1021
## [6.2.4](https://github.com/netgrif/components/releases/tag/v6.2.4) (2022-10-12)
1122

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netgrif/components-project",
3-
"version": "6.2.4",
3+
"version": "6.2.5",
44
"description": "Netgrif Application Engine Frontend project. Project includes angular libraries as base for NAE applications.",
55
"homepage": "https://components.netgrif.com",
66
"license": "SEE LICENSE IN LICENSE",

projects/netgrif-components-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netgrif/components-core",
3-
"version": "6.2.4",
3+
"version": "6.2.5",
44
"description": "Netgrif Application engine frontend core Angular library",
55
"homepage": "https://components.netgrif.com",
66
"license": "SEE LICENSE IN LICENSE",

projects/netgrif-components-core/src/lib/data-fields/enumeration-field/enumeration-autocomplete-select-field/abstract-enumeration-autocomplete-select-field.component.ts

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import {Component, Input, OnDestroy, OnInit, ViewChild} from '@angular/core';
2-
import {FormControl, NgModel} from '@angular/forms';
1+
import {Component, ElementRef, Input, OnDestroy, OnInit, ViewChild} from '@angular/core';
2+
import {FormControl} from '@angular/forms';
33
import {Observable, of} from 'rxjs';
44
import {map, startWith} from 'rxjs/operators';
55
import {EnumerationField, EnumerationFieldValidation, EnumerationFieldValue} from '../models/enumeration-field';
66
import {WrappedBoolean} from '../../data-field-template/models/wrapped-boolean';
77
import {TranslateService} from '@ngx-translate/core';
8-
import {MatAutocompleteSelectedEvent} from '@angular/material/autocomplete';
9-
import {EnumerationAutocompleteFilterProperty} from './enumeration-autocomplete-filter-property';
8+
import {EnumerationAutocompleteFilterProperty} from "./enumeration-autocomplete-filter-property";
109

1110
@Component({
1211
selector: 'ncc-abstract-enumeration-autocomplete-field',
@@ -17,49 +16,24 @@ export abstract class AbstractEnumerationAutocompleteSelectFieldComponent implem
1716
@Input() enumerationField: EnumerationField;
1817
@Input() formControlRef: FormControl;
1918
@Input() showLargeLayout: WrappedBoolean;
20-
@ViewChild('input') text: NgModel;
21-
public tmpValue: string;
19+
@ViewChild('input') text: ElementRef;
2220

2321
filteredOptions: Observable<Array<EnumerationFieldValue>>;
2422

2523
constructor(protected _translate: TranslateService) {
2624
}
2725

2826
ngOnInit() {
29-
this.tmpValue = this.formControlRef.value ?? '';
3027
this.filteredOptions = this.formControlRef.valueChanges.pipe(
3128
startWith(''),
3229
map(value => this._filter(value))
3330
);
34-
this.enumerationField.touch$.subscribe(touch => {
35-
if (touch) {
36-
this.text.control.markAsTouched();
37-
}
38-
});
39-
this.formControlRef.valueChanges.subscribe(it => {
40-
this.tmpValue = it ?? '';
41-
});
4231
}
4332

4433
ngOnDestroy(): void {
4534
this.filteredOptions = undefined;
4635
}
4736

48-
change() {
49-
if (this.text.value !== undefined) {
50-
this.filteredOptions = of(this._filter(this.text.value));
51-
}
52-
}
53-
54-
select(event: MatAutocompleteSelectedEvent) {
55-
this.formControlRef.setValue(event.option.value);
56-
}
57-
58-
59-
isInvalid(): boolean {
60-
return !this.formControlRef.disabled && !this.formControlRef.valid && this.text.control.touched;
61-
}
62-
6337
protected checkPropertyInComponent(property: string): boolean {
6438
return !!this.enumerationField.component && !!this.enumerationField.component.properties && property in this.enumerationField.component.properties;
6539
}
@@ -104,6 +78,12 @@ export abstract class AbstractEnumerationAutocompleteSelectFieldComponent implem
10478
.replace(/[\u0300-\u036f]/g, '').indexOf(filterValue) === 0);
10579
}
10680

81+
change() {
82+
if (this.text.nativeElement.value !== undefined) {
83+
this.filteredOptions = of(this._filter(this.text.nativeElement.value));
84+
}
85+
}
86+
10787
public renderSelection = (key) => {
10888
if (key !== undefined && key !== '' && key !== null) {
10989
if (this.enumerationField.choices.find(choice => choice.key === key)) {

projects/netgrif-components-core/src/lib/data-fields/enumeration-field/models/enumeration-field.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {AbstractControl, ValidationErrors, ValidatorFn, Validators} from '@angul
55
import {FieldTypeResource} from '../../../task-content/model/field-type-resource';
66
import {Component} from '../../models/component';
77
import {Validation} from '../../models/validation';
8+
import {Observable} from "rxjs";
9+
import {debounceTime} from "rxjs/operators";
810

911
export interface EnumerationFieldValue {
1012
key: string;
@@ -17,6 +19,7 @@ export enum EnumerationFieldValidation {
1719
}
1820

1921
export class EnumerationField extends DataField<string> {
22+
protected REQUEST_DEBOUNCE_TIME = 600;
2023

2124
constructor(stringId: string, title: string, value: string,
2225
protected _choices: Array<EnumerationFieldValue>, behavior: Behavior, placeholder?: string, description?: string,
@@ -26,7 +29,7 @@ export class EnumerationField extends DataField<string> {
2629
}
2730

2831
set choices(choices: Array<EnumerationFieldValue>) {
29-
this._choices = choices;
32+
this._choices = choices;
3033
}
3134

3235
get choices(): Array<EnumerationFieldValue> {
@@ -37,6 +40,10 @@ export class EnumerationField extends DataField<string> {
3740
return this._fieldType;
3841
}
3942

43+
public valueChanges(): Observable<string> {
44+
return this._value.pipe(debounceTime(this.REQUEST_DEBOUNCE_TIME));
45+
}
46+
4047
protected resolveFormControlValidators(): Array<ValidatorFn> {
4148
const result = [];
4249

projects/netgrif-components-core/src/lib/data-fields/file-field/abstract-file-field.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ export abstract class AbstractFileFieldComponent extends AbstractDataFieldCompon
171171
if (!!this.filePreview
172172
&& !!this.dataField.value
173173
&& !!this.dataField.value.name) {
174+
this.fileForDownload = undefined;
175+
this.fileForPreview = undefined;
174176
this.initializePreviewIfDisplayable();
175177
}
176178
})

projects/netgrif-components-core/src/lib/data-fields/multichoice-field/multichoice-autocomplete-field/abstract-multichoice-autocomplete-field-component.component.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import {FormControl} from '@angular/forms';
44
import {WrappedBoolean} from '../../data-field-template/models/wrapped-boolean';
55
import {COMMA, ENTER} from '@angular/cdk/keycodes';
66
import {MatChipInputEvent} from '@angular/material/chips';
7-
import {Observable, of} from 'rxjs';
8-
import {map, startWith} from 'rxjs/operators';
7+
import {Observable, of, Subscription} from 'rxjs';
98
import {MultichoiceAutocompleteFilterProperty} from './multichoice-autocomplete-filter-property';
109

1110
@Component({
@@ -21,23 +20,26 @@ export abstract class AbstractMultichoiceAutocompleteFieldComponentComponent imp
2120

2221
separatorKeysCodes: number[] = [ENTER, COMMA];
2322

23+
subscriptionChangeData$: Subscription;
24+
2425
filteredOptions: Observable<Array<MultichoiceFieldValue>>;
2526

2627
ngOnInit() {
27-
this.filteredOptions = this.formControlRef.valueChanges.pipe(
28-
startWith(''),
29-
map(value => this._filter(value).filter((option) => !this.multichoiceField.value.includes(option.key)))
30-
);
28+
this.subscriptionChangeData$ =this.formControlRef.valueChanges.subscribe(newVal => {
29+
this.filteredOptions = of(this._filter(newVal ?? '').filter((option) => !this.multichoiceField.value?.includes(option.key)));
30+
})
3131
}
3232

3333
ngOnDestroy(): void {
3434
this.filteredOptions = undefined;
35+
this.subscriptionChangeData$.unsubscribe();
3536
}
3637

3738
add(event: MatChipInputEvent): void {
38-
const value = (event['key'] || '').trim();
39+
const value = event['key'] ?? '';
3940

4041
if (value) {
42+
this.multichoiceField.value = this.multichoiceField.value === null ? [] : this.multichoiceField.value
4143
const choiceArray = [...this.multichoiceField.value];
4244
choiceArray.push(value);
4345
this.multichoiceField.value = choiceArray;

projects/netgrif-components-core/src/lib/data-fields/number-field/currency-number-field/abstract-currency-number-field.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export abstract class AbstractCurrencyNumberFieldComponent extends AbstractNumbe
2323
this.fieldType = this.TEXT_TYPE;
2424
this.transformedValue = this.transformCurrency(this.numberField.value?.toString());
2525
this.numberField.valueChanges().subscribe(value => {
26-
if (value !== undefined) {
26+
if (value !== undefined && value !== null) {
2727
if (this.fieldType === this.TEXT_TYPE) {
2828
this.transformedValue = this.transformCurrency(value.toString()) + this.WHITESPACE;
2929
}

projects/netgrif-components-core/src/lib/task-content/services/task-content.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,20 +342,20 @@ export abstract class TaskContentService implements OnDestroy {
342342
private isFieldInTaskRef(changedField: string): boolean {
343343
return !!this.taskFieldsIndex &&
344344
Object.keys(this.taskFieldsIndex)
345-
.some(taskId => taskId !== this.task.stringId && this.taskFieldsIndex[taskId].fields[changedField]);
345+
.some(taskId => taskId !== this.task.stringId && this.taskFieldsIndex[taskId].fields[changedField]);
346346
}
347347

348348
private getReferencedTransitionId(changedField: string): string {
349349
if (!!this.taskFieldsIndex) {
350-
const taskFieldsIndexId = this.getReferencedFieldTask(changedField);
351-
return this.taskFieldsIndex[taskFieldsIndexId].transitionId;
350+
const taskFieldsIndexId = this.getReferencedFieldTask(changedField);
351+
return this.taskFieldsIndex[taskFieldsIndexId].transitionId;
352352
}
353353
return undefined;
354354
}
355355

356356
private getReferencedTaskId(changedField: string): string {
357357
if (!!this.taskFieldsIndex) {
358-
return Object.keys(this.taskFieldsIndex).find(taskId =>
358+
return Object.keys(this.taskFieldsIndex).find(taskId =>
359359
Object.keys(this.taskFieldsIndex[taskId].fields).includes(changedField));
360360
}
361361
return undefined;

projects/netgrif-components-core/src/lib/task/services/task-data.service.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ import {UserComparatorService} from '../../user/services/user-comparator.service
3131
import {TaskSetDataRequestContext} from '../models/task-set-data-request-context';
3232
import {EventOutcomeMessageResource} from '../../resources/interface/message-resource';
3333
import {EventService} from '../../event/services/event.service';
34-
import {EventOutcome} from '../../resources/interface/event-outcome';
3534
import {ChangedFieldsService} from '../../changed-fields/services/changed-fields.service';
3635
import {ChangedFieldsMap} from '../../event/services/interfaces/changed-fields-map';
3736
import {TaskFields} from '../../task-content/model/task-fields';
37+
import {EnumerationField} from "../../data-fields/enumeration-field/models/enumeration-field";
3838

3939
/**
4040
* Handles the loading and updating of data fields and behaviour of
@@ -149,7 +149,7 @@ export class TaskDataService extends TaskHandlingService implements OnDestroy {
149149

150150
/**
151151
* Processes a successful outcome of a `getData` request
152-
* @param gottenTaskId the Id of the task whose data was requested
152+
* @param gottenTaskId the ID of the task whose data was requested
153153
* @param dataGroups the returned data groups of the task
154154
* @param afterAction the action that should be performed after the request is processed
155155
* @param nextEvent indicates to the event queue that the next event can be processed
@@ -233,7 +233,7 @@ export class TaskDataService extends TaskHandlingService implements OnDestroy {
233233

234234
/**
235235
* Processes an erroneous outcome of a `getData` request
236-
* @param gottenTaskId the Id of the task whose data was requested
236+
* @param gottenTaskId the ID of the task whose data was requested
237237
* @param error the returned error
238238
* @param afterAction the action that should be performed after the request is processed
239239
* @param nextEvent indicates to the event queue that the next event can be processed
@@ -348,12 +348,16 @@ export class TaskDataService extends TaskHandlingService implements OnDestroy {
348348
field.changed = false;
349349
}
350350

351+
protected isAutocompleteEnumException(field: DataField<unknown>): boolean{
352+
return (field instanceof EnumerationField) && (field.getComponentType() === 'autocomplete') && !field.valid;
353+
}
354+
351355
/**
352356
* @param field the checked field
353357
* @returns whether the field was updated on frontend and thus the backend should be notified
354358
*/
355359
protected wasFieldUpdated(field: DataField<unknown>): boolean {
356-
return field.initialized && field.changed && (field.valid || field.sendInvalidValues);
360+
return field.initialized && field.changed && (field.valid || field.sendInvalidValues) && (!this.isAutocompleteEnumException(field));
357361
}
358362

359363
/**
@@ -397,7 +401,7 @@ export class TaskDataService extends TaskHandlingService implements OnDestroy {
397401

398402
/**
399403
* Performs a `setData` request on the task currently stored in the `taskContent` service
400-
* @param setTaskId id of the task
404+
* @param setTaskId ID of the task
401405
* @param body content of the `setData` request
402406
* @param afterAction the action that should be performed after the request is processed
403407
* @param nextEvent indicates to the event queue that the next event can be processed
@@ -434,18 +438,18 @@ export class TaskDataService extends TaskHandlingService implements OnDestroy {
434438
}
435439

436440
/**
437-
* Processes a unsuccessful outcome of a `setData` request
438-
* @param setTaskId the Id of the task whose data was set
441+
* Processes an unsuccessful outcome of a `setData` request
442+
* @param setTaskId the ID of the task whose data was set
439443
* @param response the resulting Event outcome of the set data request
440444
* @param afterAction the action that should be performed after the request is processed
441445
* @param nextEvent indicates to the event queue that the next event can be processed
442446
* @param body hold the data that was sent in request
443447
*/
444448
protected processUnsuccessfulSetDataRequest(setTaskId: string,
445-
response: EventOutcomeMessageResource,
446-
afterAction: AfterAction,
447-
nextEvent: AfterAction,
448-
body: TaskSetDataRequestBody) {
449+
response: EventOutcomeMessageResource,
450+
afterAction: AfterAction,
451+
nextEvent: AfterAction,
452+
body: TaskSetDataRequestBody) {
449453
if (response.error !== '') {
450454
this._snackBar.openErrorSnackBar(this._translate.instant(response.error));
451455
} else {
@@ -468,7 +472,7 @@ export class TaskDataService extends TaskHandlingService implements OnDestroy {
468472

469473
/**
470474
* Processes a successful outcome of a `setData` request
471-
* @param setTaskId the Id of the task whose data was set
475+
* @param setTaskId the ID of the task whose data was set
472476
* @param response the resulting Event outcome of the set data request
473477
* @param afterAction the action that should be performed after the request is processed
474478
* @param nextEvent indicates to the event queue that the next event can be processed
@@ -493,7 +497,7 @@ export class TaskDataService extends TaskHandlingService implements OnDestroy {
493497

494498
/**
495499
* Processes an erroneous outcome of a `setData` request
496-
* @param setTaskId the Id of the task whose data was set
500+
* @param setTaskId the ID of the task whose data was set
497501
* @param error the returned error
498502
* @param afterAction the action that should be performed after the request is processed
499503
* @param nextEvent indicates to the event queue that the next event can be processed
@@ -586,7 +590,7 @@ export class TaskDataService extends TaskHandlingService implements OnDestroy {
586590
*
587591
* @param afterAction the call chain steam of the update data method
588592
* @param result result of the update data request
589-
* @param setTaskId the Id of the {@link Task}, who's state should be updated
593+
* @param setTaskId the ID of the {@link Task}, who's state should be updated
590594
*/
591595
protected updateStateInfo(afterAction: AfterAction, result: boolean, setTaskId: string): void {
592596
this._taskState.stopLoading(setTaskId);

0 commit comments

Comments
 (0)