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
@@ -77,7 +77,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
'@typescript-eslint/await-thenable': 'error',
|
'@typescript-eslint/await-thenable': 'error',
|
||||||
'@typescript-eslint/prefer-optional-chain': 'warn',
|
'@typescript-eslint/prefer-optional-chain': 'error',
|
||||||
'@typescript-eslint/no-inferrable-types': 'off',
|
'@typescript-eslint/no-inferrable-types': 'off',
|
||||||
'@typescript-eslint/no-require-imports': 'off',
|
'@typescript-eslint/no-require-imports': 'off',
|
||||||
'@typescript-eslint/no-var-requires': 'error',
|
'@typescript-eslint/no-var-requires': 'error',
|
||||||
|
|||||||
+1
-1
@@ -160,7 +160,7 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apply(model: Partial<{ from: Date; to: Date }>, isValidValue: boolean, updateContext = true) {
|
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;
|
this.isActive = true;
|
||||||
|
|
||||||
const start = DateFnsUtils.utcToLocal(startOfMinute(model.from)).toISOString();
|
const start = DateFnsUtils.utcToLocal(startOfMinute(model.from)).toISOString();
|
||||||
|
|||||||
+1
-1
@@ -82,7 +82,7 @@ export class SearchLogicalFilterComponent implements SearchWidget, OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
submitValues(updateContext = true) {
|
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();
|
this.updateDisplayValue();
|
||||||
const fields = this.settings.field.split(',').map((field) => (field += ':'));
|
const fields = this.settings.field.split(',').map((field) => (field += ':'));
|
||||||
let query = '';
|
let query = '';
|
||||||
|
|||||||
+1
-1
@@ -128,7 +128,7 @@ export class SearchSliderComponent implements SearchWidget, OnInit {
|
|||||||
private updateQuery(value: number | null, updateContext = true) {
|
private updateQuery(value: number | null, updateContext = true) {
|
||||||
this.context.filterRawParams[this.id] = value;
|
this.context.filterRawParams[this.id] = value;
|
||||||
this.displayValue$.next(this.value ? `${this.value} ${this.settings.unit ?? ''}` : '');
|
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) {
|
if (value === null) {
|
||||||
this.context.queryFragments[this.id] = '';
|
this.context.queryFragments[this.id] = '';
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ export class SearchTextComponent implements SearchWidget, OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.displayValue$.next(value);
|
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()}'` : '';
|
this.context.queryFragments[this.id] = value ? `${this.settings.field}:'${this.getSearchPrefix()}${value}${this.getSearchSuffix()}'` : '';
|
||||||
if (updateContext) {
|
if (updateContext) {
|
||||||
this.context.update();
|
this.context.update();
|
||||||
|
|||||||
@@ -963,7 +963,7 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges,
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCellTooltip(row: DataRow, col: DataColumn): string {
|
getCellTooltip(row: DataRow, col: DataColumn): string {
|
||||||
if (row && col && col.formatTooltip) {
|
if (row && col?.formatTooltip) {
|
||||||
const result: string = col.formatTooltip(row, col);
|
const result: string = col.formatTooltip(row, col);
|
||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ const render = (args: DataColumnComponent & { rows: DataRow[] }) => ({
|
|||||||
|
|
||||||
// Text Column
|
// Text Column
|
||||||
export const TextColumn: Story = {
|
export const TextColumn: Story = {
|
||||||
render: render,
|
render,
|
||||||
args: {
|
args: {
|
||||||
rows: mockData.textColumnRows,
|
rows: mockData.textColumnRows,
|
||||||
key: 'firstname',
|
key: 'firstname',
|
||||||
@@ -368,7 +368,7 @@ export const TextColumn: Story = {
|
|||||||
|
|
||||||
// Text Column With Custom Tooltip
|
// Text Column With Custom Tooltip
|
||||||
export const TextColumnWithCustomTooltip: Story = {
|
export const TextColumnWithCustomTooltip: Story = {
|
||||||
render: render,
|
render,
|
||||||
argTypes: {
|
argTypes: {
|
||||||
formatTooltip: { control: { disable: false } }
|
formatTooltip: { control: { disable: false } }
|
||||||
},
|
},
|
||||||
@@ -383,7 +383,7 @@ export const TextColumnWithCustomTooltip: Story = {
|
|||||||
|
|
||||||
// Icon Column
|
// Icon Column
|
||||||
export const IconColumn: Story = {
|
export const IconColumn: Story = {
|
||||||
render: render,
|
render,
|
||||||
argTypes: {
|
argTypes: {
|
||||||
copyContent: { control: { disable: true } }
|
copyContent: { control: { disable: true } }
|
||||||
},
|
},
|
||||||
@@ -397,7 +397,7 @@ export const IconColumn: Story = {
|
|||||||
|
|
||||||
// Image Column
|
// Image Column
|
||||||
export const ImageColumn: Story = {
|
export const ImageColumn: Story = {
|
||||||
render: render,
|
render,
|
||||||
argTypes: {
|
argTypes: {
|
||||||
copyContent: { control: { disable: true } }
|
copyContent: { control: { disable: true } }
|
||||||
},
|
},
|
||||||
@@ -411,7 +411,7 @@ export const ImageColumn: Story = {
|
|||||||
|
|
||||||
// Date Column
|
// Date Column
|
||||||
export const DateColumn: Story = {
|
export const DateColumn: Story = {
|
||||||
render: render,
|
render,
|
||||||
argTypes: {
|
argTypes: {
|
||||||
copyContent: { control: { disable: true } },
|
copyContent: { control: { disable: true } },
|
||||||
dateConfig: { control: { disable: false } }
|
dateConfig: { control: { disable: false } }
|
||||||
@@ -426,7 +426,7 @@ export const DateColumn: Story = {
|
|||||||
|
|
||||||
// Date Column Time Ago
|
// Date Column Time Ago
|
||||||
export const DateColumnTimeAgo: Story = {
|
export const DateColumnTimeAgo: Story = {
|
||||||
render: render,
|
render,
|
||||||
argTypes: {
|
argTypes: {
|
||||||
copyContent: { control: { disable: true } },
|
copyContent: { control: { disable: true } },
|
||||||
dateConfig: { control: { disable: false } }
|
dateConfig: { control: { disable: false } }
|
||||||
@@ -442,7 +442,7 @@ export const DateColumnTimeAgo: Story = {
|
|||||||
|
|
||||||
// File Size Column
|
// File Size Column
|
||||||
export const FileSizeColumn: Story = {
|
export const FileSizeColumn: Story = {
|
||||||
render: render,
|
render,
|
||||||
argTypes: {
|
argTypes: {
|
||||||
copyContent: { control: { disable: true } }
|
copyContent: { control: { disable: true } }
|
||||||
},
|
},
|
||||||
@@ -456,7 +456,7 @@ export const FileSizeColumn: Story = {
|
|||||||
|
|
||||||
// Location Column
|
// Location Column
|
||||||
export const LocationColumn: Story = {
|
export const LocationColumn: Story = {
|
||||||
render: render,
|
render,
|
||||||
argTypes: {
|
argTypes: {
|
||||||
copyContent: { control: { disable: true } },
|
copyContent: { control: { disable: true } },
|
||||||
format: { control: { disable: false } },
|
format: { control: { disable: false } },
|
||||||
@@ -473,7 +473,7 @@ export const LocationColumn: Story = {
|
|||||||
|
|
||||||
// Boolean Column
|
// Boolean Column
|
||||||
export const BooleanColumn: Story = {
|
export const BooleanColumn: Story = {
|
||||||
render: render,
|
render,
|
||||||
argTypes: {
|
argTypes: {
|
||||||
copyContent: { control: { disable: true } }
|
copyContent: { control: { disable: true } }
|
||||||
},
|
},
|
||||||
@@ -487,7 +487,7 @@ export const BooleanColumn: Story = {
|
|||||||
|
|
||||||
// Json Column
|
// Json Column
|
||||||
export const JsonColumn: Story = {
|
export const JsonColumn: Story = {
|
||||||
render: render,
|
render,
|
||||||
argTypes: {
|
argTypes: {
|
||||||
editable: { control: { disable: false } },
|
editable: { control: { disable: false } },
|
||||||
copyContent: { control: { disable: true } }
|
copyContent: { control: { disable: true } }
|
||||||
@@ -502,7 +502,7 @@ export const JsonColumn: Story = {
|
|||||||
|
|
||||||
// Amount Column
|
// Amount Column
|
||||||
export const AmountColumn: Story = {
|
export const AmountColumn: Story = {
|
||||||
render: render,
|
render,
|
||||||
argTypes: {
|
argTypes: {
|
||||||
copyContent: { control: { disable: true } },
|
copyContent: { control: { disable: true } },
|
||||||
currencyConfig: { control: { disable: false } }
|
currencyConfig: { control: { disable: false } }
|
||||||
@@ -517,7 +517,7 @@ export const AmountColumn: Story = {
|
|||||||
|
|
||||||
// Number Column
|
// Number Column
|
||||||
export const NumberColumn: Story = {
|
export const NumberColumn: Story = {
|
||||||
render: render,
|
render,
|
||||||
argTypes: {
|
argTypes: {
|
||||||
decimalConfig: { control: { disable: false } },
|
decimalConfig: { control: { disable: false } },
|
||||||
copyContent: { control: { disable: true } }
|
copyContent: { control: { disable: true } }
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ export class SuperagentHttpClient implements HttpClient {
|
|||||||
const newParams: { [key: string]: any } = {};
|
const newParams: { [key: string]: any } = {};
|
||||||
|
|
||||||
for (const key in params) {
|
for (const key in params) {
|
||||||
if (Object.prototype.hasOwnProperty.call(params, key) && params[key] !== undefined && params[key] !== null) {
|
if (Object.prototype.hasOwnProperty.call(params, key) && params[key] != null) {
|
||||||
const value = params[key];
|
const value = params[key];
|
||||||
if (SuperagentHttpClient.isFileParam(value) || Array.isArray(value)) {
|
if (SuperagentHttpClient.isFileParam(value) || Array.isArray(value)) {
|
||||||
newParams[key] = value;
|
newParams[key] = value;
|
||||||
|
|||||||
@@ -1905,7 +1905,7 @@ describe('retrieve metadata on submit', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle outcomeId correctly when completing form with confirmation dialog', () => {
|
it('should handle outcomeId correctly when completing form with confirmation dialog', () => {
|
||||||
let matDialog = TestBed.inject(MatDialog);
|
const matDialog = TestBed.inject(MatDialog);
|
||||||
spyOn(matDialog, 'open').and.returnValue({ afterClosed: () => of(true) } as any);
|
spyOn(matDialog, 'open').and.returnValue({ afterClosed: () => of(true) } as any);
|
||||||
spyOn(formComponent['formCloudService'], 'completeTaskForm').and.returnValue(of({} as any));
|
spyOn(formComponent['formCloudService'], 'completeTaskForm').and.returnValue(of({} as any));
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export interface OutputData {
|
|||||||
export class RichTextParserService {
|
export class RichTextParserService {
|
||||||
private static readonly CUSTOM_PARSER = {
|
private static readonly CUSTOM_PARSER = {
|
||||||
header: (block: any): string => {
|
header: (block: any): string => {
|
||||||
if (!block.data || !block.data.text || !block.data.level) {
|
if (!block.data?.text || !block.data.level) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
const paragraphAlign = block.data.alignment || block.data.align || block.tunes?.anyTuneName?.alignment;
|
const paragraphAlign = block.data.alignment || block.data.align || block.tunes?.anyTuneName?.alignment;
|
||||||
@@ -40,7 +40,7 @@ export class RichTextParserService {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
paragraph: (block: any): string => {
|
paragraph: (block: any): string => {
|
||||||
if (!block.data || !block.data.text) {
|
if (!block.data?.text) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
const paragraphAlign = block.data.alignment || block.data.align || block.tunes?.anyTuneName?.alignment;
|
const paragraphAlign = block.data.alignment || block.data.align || block.tunes?.anyTuneName?.alignment;
|
||||||
|
|||||||
Reference in New Issue
Block a user