mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
ACS-11155: update conditional checks to use optional chaining (#11658)
- Modified several components to use optional chaining for safer property access, enhancing code robustness. - Updated ESLint configuration to enforce stricter rules on the use of optional chaining. - Adjusted tests to reflect changes in property access patterns.
This commit is contained in:
+1
-1
@@ -160,7 +160,7 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit {
|
||||
}
|
||||
|
||||
apply(model: Partial<{ from: Date; to: Date }>, isValidValue: boolean, updateContext = true) {
|
||||
if (isValidValue && this.id && this.context && this.settings && this.settings.field) {
|
||||
if (isValidValue && this.id && this.context?.queryFragments && this.settings?.field) {
|
||||
this.isActive = true;
|
||||
|
||||
const start = DateFnsUtils.utcToLocal(startOfMinute(model.from)).toISOString();
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ export class SearchLogicalFilterComponent implements SearchWidget, OnInit {
|
||||
}
|
||||
|
||||
submitValues(updateContext = true) {
|
||||
if (this.hasValidValue() && this.id && this.context && this.settings && this.settings.field) {
|
||||
if (this.hasValidValue() && this.id && this.context?.queryFragments && this.settings?.field) {
|
||||
this.updateDisplayValue();
|
||||
const fields = this.settings.field.split(',').map((field) => (field += ':'));
|
||||
let query = '';
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ export class SearchSliderComponent implements SearchWidget, OnInit {
|
||||
private updateQuery(value: number | null, updateContext = true) {
|
||||
this.context.filterRawParams[this.id] = value;
|
||||
this.displayValue$.next(this.value ? `${this.value} ${this.settings.unit ?? ''}` : '');
|
||||
if (this.id && this.context && this.settings && this.settings.field) {
|
||||
if (this.id && this.context?.queryFragments && this.settings?.field) {
|
||||
if (value === null) {
|
||||
this.context.queryFragments[this.id] = '';
|
||||
} else {
|
||||
|
||||
@@ -118,7 +118,7 @@ export class SearchTextComponent implements SearchWidget, OnInit {
|
||||
}
|
||||
|
||||
this.displayValue$.next(value);
|
||||
if (this.context && this.settings && this.settings.field) {
|
||||
if (this.context?.queryFragments && this.settings?.field) {
|
||||
this.context.queryFragments[this.id] = value ? `${this.settings.field}:'${this.getSearchPrefix()}${value}${this.getSearchSuffix()}'` : '';
|
||||
if (updateContext) {
|
||||
this.context.update();
|
||||
|
||||
Reference in New Issue
Block a user