Skip to content

Commit 09abaf8

Browse files
authored
Merge pull request #142 from netgrif/dev
Release/6.2.4
2 parents 79436fc + 6e791e8 commit 09abaf8

File tree

12 files changed

+135
-27
lines changed

12 files changed

+135
-27
lines changed

CHANGELOG.md

Lines changed: 14 additions & 5 deletions
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.3](https://github.com/netgrif/components/commits/v6.2.3)
8+
Full Changelog: [https://github.com/netgrif/components/commits/v6.2.4](https://github.com/netgrif/components/commits/v6.2.4)
9+
10+
## [6.2.4](https://github.com/netgrif/components/releases/tag/v6.2.4) (2022-10-12)
11+
12+
### Fixed
13+
14+
- [NAE-1744] Public view does not work delete file
15+
- [NAE-1745] Enumeration autocomplete constantly sending value
16+
17+
### Added
18+
19+
- [NAE-1751] Autocomplete new filter "include"
920

1021
## [6.2.3](https://github.com/netgrif/components/releases/tag/v6.2.3) (2022-10-06)
1122

@@ -24,8 +35,7 @@ Full Changelog: [https://github.com/netgrif/components/commits/v6.2.3](https://g
2435
- [NAE-1740] Disable "create case" button, while case is creating
2536
- [NAE-1741] 'Undefined' error on frontend when checking i18n translation equality
2637
- [NAE-1742] I18nField throws error on frontend when its value is null
27-
- [NAE-1743] File preview change to null object
28-
38+
- [NAE-1743] File preview change to null object
2939

3040
## [6.2.2](https://github.com/netgrif/components/releases/tag/v6.2.2) (2022-09-28)
3141

@@ -40,7 +50,6 @@ Full Changelog: [https://github.com/netgrif/components/commits/v6.2.3](https://g
4050
- [NAE-1721] Create case event bad handling on frontend
4151
- [NAE-1724] Incorrect german translation
4252

43-
4453
## [6.2.1](https://github.com/netgrif/components/releases/tag/v6.2.1) (2022-09-15)
4554

4655
### Fixed
@@ -95,7 +104,7 @@ Full Changelog: [https://github.com/netgrif/components/commits/v6.2.3](https://g
95104
### Fixed
96105

97106
- [NAE-1649] File field preview component bug
98-
- [NAE-1656] Export nc-panel-item
107+
- [NAE-1656] Export nc-panel-item
99108
- [NAE-1653] Create view schematic not functional after angular 13 update
100109

101110
## [6.1.0](https://github.com/netgrif/components/releases/tag/v6.1.0) (2022-06-01)

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.3",
3+
"version": "6.2.4",
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.3",
3+
"version": "6.2.4",
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: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import {Component, ElementRef, Input, OnDestroy, OnInit, ViewChild} from '@angular/core';
2-
import {FormControl} from '@angular/forms';
1+
import {Component, Input, OnDestroy, OnInit, ViewChild} from '@angular/core';
2+
import {FormControl, NgModel} 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';
810

911
@Component({
1012
selector: 'ncc-abstract-enumeration-autocomplete-field',
@@ -15,42 +17,93 @@ export abstract class AbstractEnumerationAutocompleteSelectFieldComponent implem
1517
@Input() enumerationField: EnumerationField;
1618
@Input() formControlRef: FormControl;
1719
@Input() showLargeLayout: WrappedBoolean;
18-
@ViewChild('input') text: ElementRef;
20+
@ViewChild('input') text: NgModel;
21+
public tmpValue: string;
1922

2023
filteredOptions: Observable<Array<EnumerationFieldValue>>;
2124

2225
constructor(protected _translate: TranslateService) {
2326
}
2427

2528
ngOnInit() {
29+
this.tmpValue = this.formControlRef.value ?? '';
2630
this.filteredOptions = this.formControlRef.valueChanges.pipe(
2731
startWith(''),
2832
map(value => this._filter(value))
2933
);
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+
});
3042
}
3143

3244
ngOnDestroy(): void {
3345
this.filteredOptions = undefined;
3446
}
3547

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+
63+
protected checkPropertyInComponent(property: string): boolean {
64+
return !!this.enumerationField.component && !!this.enumerationField.component.properties && property in this.enumerationField.component.properties;
65+
}
66+
67+
protected filterType(): string | undefined {
68+
if (this.checkPropertyInComponent('filter')) {
69+
return this.enumerationField.component.properties.filter;
70+
}
71+
}
72+
73+
protected _filter(value: string): Array<EnumerationFieldValue> {
74+
let filterType = this.filterType()?.toLowerCase()
75+
switch (filterType) {
76+
case EnumerationAutocompleteFilterProperty.SUBSTRING:
77+
return this._filterInclude(value);
78+
case EnumerationAutocompleteFilterProperty.PREFIX:
79+
return this._filterIndexOf(value);
80+
default:
81+
return this._filterIndexOf(value);
82+
}
83+
}
84+
85+
protected _filterInclude(value: string): Array<EnumerationFieldValue> {
86+
const filterValue = value?.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '');
87+
return this.enumerationField.choices.filter(option =>
88+
option.value.toLowerCase()
89+
.normalize('NFD')
90+
.replace(/[\u0300-\u036f]/g, '')
91+
.includes(filterValue));
92+
}
93+
94+
3695
/**
3796
* Function to filter out matchless options without accent and case-sensitive differences
3897
* @param value to compare matching options
3998
* @return return matched options
4099
*/
41-
private _filter(value: string): Array<EnumerationFieldValue> {
100+
protected _filterIndexOf(value: string): Array<EnumerationFieldValue> {
42101
const filterValue = value?.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '');
43102

44103
return this.enumerationField.choices.filter(option => option.value.toLowerCase().normalize('NFD')
45104
.replace(/[\u0300-\u036f]/g, '').indexOf(filterValue) === 0);
46105
}
47106

48-
change() {
49-
if (this.text.nativeElement.value !== undefined) {
50-
this.filteredOptions = of(this._filter(this.text.nativeElement.value));
51-
}
52-
}
53-
54107
public renderSelection = (key) => {
55108
if (key !== undefined && key !== '' && key !== null) {
56109
if (this.enumerationField.choices.find(choice => choice.key === key)) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export enum EnumerationAutocompleteFilterProperty {
2+
PREFIX='prefix',
3+
SUBSTRING='substring'
4+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ export abstract class DataField<T> {
273273
this._touch.next(set);
274274
}
275275

276+
get touch$(): Observable<boolean> {
277+
return this._touch.asObservable();
278+
}
279+
276280
get component(): Component {
277281
return this._component;
278282
}

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {COMMA, ENTER} from '@angular/cdk/keycodes';
66
import {MatChipInputEvent} from '@angular/material/chips';
77
import {Observable, of} from 'rxjs';
88
import {map, startWith} from 'rxjs/operators';
9+
import {MultichoiceAutocompleteFilterProperty} from './multichoice-autocomplete-filter-property';
910

1011
@Component({
1112
selector: 'ncc-abstract-multichoice-autocomplete-field',
@@ -65,7 +66,37 @@ export abstract class AbstractMultichoiceAutocompleteFieldComponentComponent imp
6566
}
6667
}
6768

68-
private _filter(value: string): Array<MultichoiceFieldValue> {
69+
protected checkPropertyInComponent(property: string): boolean {
70+
return !!this.multichoiceField.component && !!this.multichoiceField.component.properties && property in this.multichoiceField.component.properties;
71+
}
72+
73+
protected filterType(): string | undefined {
74+
if (this.checkPropertyInComponent('filter')) {
75+
return this.multichoiceField.component.properties.filter;
76+
}
77+
}
78+
79+
protected _filter(value: string): Array<MultichoiceFieldValue> {
80+
let filterType = this.filterType()?.toLowerCase()
81+
switch (filterType) {
82+
case MultichoiceAutocompleteFilterProperty.SUBSTRING:
83+
return this._filterInclude(value);
84+
case MultichoiceAutocompleteFilterProperty.PREFIX:
85+
return this._filterIndexOf(value);
86+
default:
87+
return this._filterIndexOf(value);
88+
}
89+
}
90+
91+
protected _filterInclude(value: string): Array<MultichoiceFieldValue> {
92+
if (Array.isArray(value)) {
93+
value = '';
94+
}
95+
const filterValue = value?.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '');
96+
return this.multichoiceField.choices.filter(option => option.value.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '').includes(filterValue));
97+
}
98+
99+
protected _filterIndexOf(value: string): Array<MultichoiceFieldValue> {
69100
if (Array.isArray(value)) {
70101
value = '';
71102
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export enum MultichoiceAutocompleteFilterProperty {
2+
PREFIX='prefix',
3+
SUBSTRING='substring'
4+
}

projects/netgrif-components-core/src/lib/data-fields/public-api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ export * from './filter-field/models/filter-field-injection-token';
8080
/* Enums */
8181
export * from './models/template-appearance';
8282
export * from './models/material-appearance';
83+
export * from './enumeration-field/enumeration-autocomplete-select-field/enumeration-autocomplete-filter-property'
84+
export * from './multichoice-field/multichoice-autocomplete-field/multichoice-autocomplete-filter-property'
8385

8486
/* Services */
8587
export * from './i18n-field/language-icons.service';

projects/netgrif-components-core/src/lib/resources/engine-endpoint/public/public-task-resource.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {TaskReference} from '../../interface/task-reference';
1414
import {DataGroup} from '../../interface/data-groups';
1515
import {DataField} from '../../../data-fields/models/abstract-data-field';
1616
import {Task} from '../../interface/task';
17-
import {HttpEventType} from '@angular/common/http';
17+
import {HttpEventType, HttpParams} from '@angular/common/http';
1818
import {EventOutcomeMessageResource, MessageResource} from '../../interface/message-resource';
1919
import {GetDataGroupsEventOutcome} from '../../../event/model/event-outcomes/data-outcomes/get-data-groups-event-outcome';
2020

@@ -169,9 +169,9 @@ export class PublicTaskResourceService extends TaskResourceService {
169169
* Delete file from the task
170170
* DELETE
171171
*/
172-
public deleteFile(taskId: string, fieldId: string, name?: string): Observable<MessageResource> {
172+
public deleteFile(taskId: string, fieldId: string, name?: string, param?: HttpParams): Observable<MessageResource> {
173173
const url = !!name ? `public/task/${taskId}/file/${fieldId}/${name}` : `public/task/${taskId}/file/${fieldId}`;
174-
return this._resourceProvider.delete$(url, this.SERVER_URL).pipe(
174+
return this._resourceProvider.delete$(url, this.SERVER_URL, param).pipe(
175175
map(r => this.changeType(r, undefined))
176176
);
177177
}

0 commit comments

Comments
 (0)