chrv-components 1.11.44 → 1.11.46
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.
|
Binary file
|
|
@@ -1346,7 +1346,6 @@ class ChrBaseInputComponent {
|
|
|
1346
1346
|
if (this.control() != null) {
|
|
1347
1347
|
this.control().valueAccessor = this;
|
|
1348
1348
|
}
|
|
1349
|
-
this.value.subscribe((v) => console.log(`[BaseInput] Value changed to: ${v}`));
|
|
1350
1349
|
effect(() => {
|
|
1351
1350
|
//this.displayValue.set(this.value());
|
|
1352
1351
|
});
|
|
@@ -1388,6 +1387,7 @@ class ChrBaseInputComponent {
|
|
|
1388
1387
|
*/
|
|
1389
1388
|
ngOnDestroy() {
|
|
1390
1389
|
this.valueSubject?.unsubscribe();
|
|
1390
|
+
this.displayValueSubject.unsubscribe();
|
|
1391
1391
|
}
|
|
1392
1392
|
writeValue(obj) {
|
|
1393
1393
|
this.value.set(obj);
|
|
@@ -1511,8 +1511,8 @@ class ChrSearchSelectComponent extends ChrBaseInputComponent {
|
|
|
1511
1511
|
if (this.acceptText() && this.value()?.trim()) {
|
|
1512
1512
|
const addCallback = this.addCallback();
|
|
1513
1513
|
const value = addCallback
|
|
1514
|
-
? addCallback(this.value, this.addSubject)
|
|
1515
|
-
: this.value;
|
|
1514
|
+
? addCallback(this.value(), this.addSubject)
|
|
1515
|
+
: this.value();
|
|
1516
1516
|
if (this.addCallback() && (value === null || value === undefined)) {
|
|
1517
1517
|
this.value.set('');
|
|
1518
1518
|
return;
|
|
@@ -1550,15 +1550,14 @@ class ChrSearchSelectComponent extends ChrBaseInputComponent {
|
|
|
1550
1550
|
super.ngOnInit();
|
|
1551
1551
|
this.registerFilters();
|
|
1552
1552
|
this.addSubject.subscribe((entry) => {
|
|
1553
|
-
if (this.value != entry) {
|
|
1554
|
-
this.value
|
|
1555
|
-
this.onValueChange(this.value);
|
|
1553
|
+
if (this.value() != entry) {
|
|
1554
|
+
this.onValueChange(this.value());
|
|
1556
1555
|
}
|
|
1557
1556
|
});
|
|
1558
1557
|
// Only when the value is valid, we override the display value with the value
|
|
1559
1558
|
// We need to avoid setting it when the value is set to null because it would
|
|
1560
1559
|
// Remove the user's input a few milliseconds after he starts typing to replace a value
|
|
1561
|
-
this.
|
|
1560
|
+
this.value.subscribe((v) => {
|
|
1562
1561
|
if (v !== null && v !== undefined) {
|
|
1563
1562
|
this.displayValue.set(v);
|
|
1564
1563
|
}
|
|
@@ -1807,15 +1806,17 @@ class ChrTagSelectComponent extends ChrBaseInputComponent {
|
|
|
1807
1806
|
//Call the callback and retrive it's return value
|
|
1808
1807
|
const res = editCallback(entry, this.editSubject);
|
|
1809
1808
|
//If the callback returns null, we remove the value.
|
|
1810
|
-
if (res === null && this.value !== null) {
|
|
1809
|
+
if (res === null && this.value() !== null) {
|
|
1811
1810
|
this.remove(entry);
|
|
1812
1811
|
}
|
|
1812
|
+
if (entry == res) {
|
|
1813
|
+
return this.editSubject.next(res);
|
|
1814
|
+
}
|
|
1813
1815
|
//If the callback returns a different value (different by reference (ex: different object)), we replace the edited entry by the returned entry.
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
// return this.onValueChange(this.value);
|
|
1816
|
+
this.value.update((value) => {
|
|
1817
|
+
value[value.indexOf(entry)] = res;
|
|
1818
|
+
return [...(value ?? [])];
|
|
1819
|
+
});
|
|
1819
1820
|
};
|
|
1820
1821
|
this.registerFilters = () => {
|
|
1821
1822
|
this.filteredModelOptions = this.values.pipe(startWith(''), combineLatestWith(this.data$), map((value) => this._filterModel(this.textInputValue() || -1)), map((values) => {
|
|
@@ -1890,10 +1891,9 @@ class ChrTagSelectComponent extends ChrBaseInputComponent {
|
|
|
1890
1891
|
.includes(input.trim().toLowerCase());
|
|
1891
1892
|
};
|
|
1892
1893
|
this.addSubject.subscribe((entry) => {
|
|
1893
|
-
console.log(`[TagSelect] Adding value:`, entry, this.value);
|
|
1894
1894
|
if (!this.value()?.find((v) => v == entry)) {
|
|
1895
1895
|
this.value.set([...(this.value() ?? []), entry]);
|
|
1896
|
-
this.onValueChange(this.value());
|
|
1896
|
+
//this.onValueChange(this.value());
|
|
1897
1897
|
}
|
|
1898
1898
|
});
|
|
1899
1899
|
this.editSubject.subscribe((entry) => {
|
|
@@ -1902,7 +1902,7 @@ class ChrTagSelectComponent extends ChrBaseInputComponent {
|
|
|
1902
1902
|
value[index] = entry;
|
|
1903
1903
|
return [...(value ?? [])];
|
|
1904
1904
|
});
|
|
1905
|
-
return this.onValueChange(this.value());
|
|
1905
|
+
//return this.onValueChange(this.value());
|
|
1906
1906
|
});
|
|
1907
1907
|
effect(() => {
|
|
1908
1908
|
this.data$.next(this.data() || []);
|
|
@@ -1912,31 +1912,15 @@ class ChrTagSelectComponent extends ChrBaseInputComponent {
|
|
|
1912
1912
|
super.ngOnInit();
|
|
1913
1913
|
//console.log(this.value);
|
|
1914
1914
|
this.registerFilters();
|
|
1915
|
-
// if (this.acceptText() === null)
|
|
1916
|
-
// //Register subject listeners
|
|
1917
|
-
// this.addSubject.subscribe((entry) => {
|
|
1918
|
-
// console.log(`[TagSelect] Adding value:`, entry);
|
|
1919
|
-
// if (!this.value?.find((v: any) => v == entry)) {
|
|
1920
|
-
// this.value = [...(this.value ?? []), entry];
|
|
1921
|
-
// this.onValueChange(this.value);
|
|
1922
|
-
// }
|
|
1923
|
-
// });
|
|
1924
|
-
// this.editSubject.subscribe((entry) => {
|
|
1925
|
-
// const index = this.value?.indexOf(entry)!;
|
|
1926
|
-
// this.value![index] = entry;
|
|
1927
|
-
// this.value = [...(this.value ?? [])];
|
|
1928
|
-
// return this.onValueChange(this.value);
|
|
1929
|
-
// });
|
|
1930
1915
|
}
|
|
1931
1916
|
writeValue(obj) {
|
|
1932
1917
|
super.writeValue(obj);
|
|
1933
1918
|
}
|
|
1934
1919
|
remove(value) {
|
|
1935
|
-
if (this.value !== null)
|
|
1920
|
+
if (this.value() !== null)
|
|
1936
1921
|
this.value.set(this.value()?.filter((v) => v != value));
|
|
1937
1922
|
if (this.value()?.length === 0)
|
|
1938
1923
|
this.value.set(null);
|
|
1939
|
-
this.onValueChange(this.value());
|
|
1940
1924
|
this.removeCallback()?.(value);
|
|
1941
1925
|
}
|
|
1942
1926
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: ChrTagSelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|