Skip to content

Commit 9363a5d

Browse files
committed
clean code #601
1 parent 1cc9c02 commit 9363a5d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

force-app/main/default/lwc/orgcheckApp/orgcheckApp.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ export default class OrgcheckApp extends LightningElement {
679679

680680
/**
681681
* @description List of internal transformers to get data from the API
682-
* @type {Map<string, {data: string, remove: Function, getAlias: Function, get: Function}>}
682+
* @type {Map<string, {data: string, remove: Function, getAlias: Function, get: Function, lastAlias?: string}>}
683683
* @private
684684
*/
685685
_internalTransformers = new Map([
@@ -1870,7 +1870,7 @@ export default class OrgcheckApp extends LightningElement {
18701870

18711871
/**
18721872
* @description Global View data from API
1873-
* @type {Map}
1873+
* @param {Map} data - The data from the API
18741874
*/
18751875
set _internalGlobalViewDataFromAPI(data) {
18761876
if (data) {
@@ -1932,7 +1932,9 @@ export default class OrgcheckApp extends LightningElement {
19321932
const transfomer = this._internalTransformers.get(alias);
19331933
const itemName = SUB_TABS.get(alias)?.tab?.title ?? alias;
19341934
const definitionName = transfomer.data.replace(/Data$/, 'Definition');
1935+
/** @type {ocui.Table} */
19351936
const definitionTable = this[definitionName];
1937+
/** @type {ocui.TableColumnWithData} */
19361938
const firstUrlColumn = definitionTable.columns.filter(c => c.type === ocui.ColumnType.URL)[0];
19371939
hardCodedURLsViewData.push({
19381940
type: itemName,
@@ -1946,10 +1948,12 @@ export default class OrgcheckApp extends LightningElement {
19461948
};
19471949
})
19481950
});
1949-
sheets.push(ocui.RowsFactory.createAndExport(definitionTable, item?.data?.filter(d => d?.length > 0 || false), itemName, ocapi.SecretSauce.GetScoreRuleDescription));
1951+
if (item?.data?.length > 0) {
1952+
sheets.push(ocui.RowsFactory.createAndExport(definitionTable, item?.data, itemName, ocapi.SecretSauce.GetScoreRuleDescription));
1953+
}
19501954
});
1951-
this.hardCodedURLsViewData = hardCodedURLsViewData; // no need to sort as the data will be shown in an extendetible table (which will be sorted by countBad desc by default)
1952-
this.hardCodedURLsViewItemsExport = sheets;
1955+
this.hardCodedURLsViewData = hardCodedURLsViewData; // no need to sort
1956+
this.hardCodedURLsViewItemsExport = sheets.sort((a, b) => (a?.rows?.length ?? 0) < (b?.rows?.length ?? 0) ? 1 : -1 ); // sorted by Nb Rows
19531957
this.showhardCodedURLsViewExportButton = true;
19541958
} else {
19551959
this.hardCodedURLsViewData = [];

0 commit comments

Comments
 (0)