Flip negated conditions to positive for readability (S7735)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 00:59:37 +08:00
parent 5a936cad97
commit 804d78837b
14 changed files with 102 additions and 102 deletions

View File

@@ -1670,7 +1670,7 @@ function checkCycleTime() {
return disabled;
}
function checkStartAndEnd(start, end) {
return !isAlreadySubmit.value ? !(start && end) : start !== end;
return isAlreadySubmit.value ? start !== end : !(start && end);
}
// created() logic

View File

@@ -173,7 +173,7 @@ const data = computed(() => {
// Sort the Activity List
return [...filteredData.value].sort((x, y) => {
const diff = y.occurrences - x.occurrences;
return diff !== 0 ? diff : sortNumEngZhtwForFilter(x.label, y.label);
return diff === 0 ? sortNumEngZhtwForFilter(x.label, y.label) : diff;
});
});

View File

@@ -113,8 +113,8 @@ function isRule(e, index) {
const rule = isRuleData.value[index];
// First get the rule object
// To preserve data order, set the value to 0 and remove it during submitAll
if (!e) temporaryData.value[index] = 0;
else temporaryData.value[index] = rule;
if (e) temporaryData.value[index] = rule;
else temporaryData.value[index] = 0;
}
/**

View File

@@ -1008,14 +1008,14 @@ function getTraceData(isExclude) {
* @param {Array} postData - The submitted filter data.
*/
function updateRules(postData) {
if (!temporaryData.value?.length) {
temporaryData.value.push(...postData);
isRuleData.value = Array.from(temporaryData.value);
ruleData.value = isRuleData.value.map((e) => setRule(e));
} else {
if (temporaryData.value?.length) {
temporaryData.value.push(...postData);
isRuleData.value.push(...postData);
ruleData.value.push(...postData.map((e) => setRule(e)));
} else {
temporaryData.value.push(...postData);
isRuleData.value = Array.from(temporaryData.value);
ruleData.value = isRuleData.value.map((e) => setRule(e));
}
}

View File

@@ -506,12 +506,12 @@ export async function renameModal(rename, type, id, baseName) {
const inputField = Swal.getInput();
inputField.addEventListener("input", function () {
if (!inputField.value.trim()) {
confirmButton.classList.add("disable-hover");
confirmButton.disabled = true;
} else {
if (inputField.value.trim()) {
confirmButton.classList.remove("disable-hover");
confirmButton.disabled = false;
} else {
confirmButton.classList.add("disable-hover");
confirmButton.disabled = true;
}
});
},

View File

@@ -231,7 +231,9 @@ export function getXIndex(data, xValue) {
* or null if the input is NaN.
*/
export function formatTime(seconds) {
if (!Number.isNaN(Number(seconds))) {
if (Number.isNaN(Number(seconds))) {
return null;
} else {
const remainingSeconds = seconds % 60;
const minutes = (Math.floor(seconds - remainingSeconds) / 60) % 60;
const hours = Math.floor(seconds / 3600) % 24;
@@ -250,8 +252,6 @@ export function formatTime(seconds) {
result += `${remainingSeconds}s`;
return result.trim(); // Remove trailing whitespace
} else {
return null;
}
}
/**

View File

@@ -129,23 +129,23 @@ export const useAllMapDataStore = defineStore("allMapDataStore", {
switch (copy.type) {
case "date":
copy.min =
copy.min !== null
? moment(copy.min).format("YYYY/MM/DD HH:mm")
: null;
copy.min === null
? null
: moment(copy.min).format("YYYY/MM/DD HH:mm");
copy.max =
copy.max !== null
? moment(copy.max).format("YYYY/MM/DD HH:mm")
: null;
copy.max === null
? null
: moment(copy.max).format("YYYY/MM/DD HH:mm");
break;
case "float":
copy.min =
copy.min !== null
? Number(new Decimal(copy.min).toFixed(2, 3))
: null;
copy.min === null
? null
: Number(new Decimal(copy.min).toFixed(2, 3));
copy.max =
copy.max !== null
? Number(new Decimal(copy.max).toFixed(2, 2))
: null;
copy.max === null
? null
: Number(new Decimal(copy.max).toFixed(2, 2));
break;
default:
break;
@@ -212,15 +212,15 @@ export const useAllMapDataStore = defineStore("allMapDataStore", {
switch (att.type) {
case "date":
att.value =
att.value !== null
? moment(att.value).format("YYYY/MM/DD HH:mm")
: null;
att.value === null
? null
: moment(att.value).format("YYYY/MM/DD HH:mm");
break;
case "float":
att.value =
att.value !== null
? Number(new Decimal(att.value).toFixed(2))
: null;
att.value === null
? null
: Number(new Decimal(att.value).toFixed(2));
break;
default:
break;
@@ -257,15 +257,15 @@ export const useAllMapDataStore = defineStore("allMapDataStore", {
switch (att.type) {
case "date":
att.value =
att.value !== null
? moment(att.value).format("YYYY/MM/DD HH:mm")
: null;
att.value === null
? null
: moment(att.value).format("YYYY/MM/DD HH:mm");
break;
case "float":
att.value =
att.value !== null
? Number(new Decimal(att.value).toFixed(2))
: null;
att.value === null
? null
: Number(new Decimal(att.value).toFixed(2));
break;
default:
break;
@@ -305,9 +305,9 @@ export const useAllMapDataStore = defineStore("allMapDataStore", {
this.allFilterTimeframe.x_axis.max_base = max;
// Convert to a time format without seconds
this.allFilterTimeframe.x_axis.min =
min !== null ? moment(min).format("YYYY/MM/DD HH:mm") : null;
min === null ? null : moment(min).format("YYYY/MM/DD HH:mm");
this.allFilterTimeframe.x_axis.max =
max !== null ? moment(max).format("YYYY/MM/DD HH:mm") : null;
max === null ? null : moment(max).format("YYYY/MM/DD HH:mm");
} catch (error) {
apiError(error, "Failed to load the Filter Parameters.");
}

View File

@@ -178,9 +178,9 @@ export const useConformanceStore = defineStore("conformanceStore", {
case "dummy": //sonar-qube
case "duration-list":
copy.value = copy.value.map((v) =>
v !== null
? abbreviateNumber(new Decimal(v.toFixed(2)))
: null,
v === null
? null
: abbreviateNumber(new Decimal(v.toFixed(2))),
);
copy.value = copy.value.map((v) => (v ?? "").trim()).join(", ");
break;
@@ -194,15 +194,15 @@ export const useConformanceStore = defineStore("conformanceStore", {
switch (copy.type) {
case "date":
copy.value =
copy.value !== null
? moment(copy.value).format("YYYY/MM/DD HH:mm:ss")
: null;
copy.value === null
? null
: moment(copy.value).format("YYYY/MM/DD HH:mm:ss");
break;
case "float":
copy.value =
copy.value !== null
? new Decimal(copy.value).toFixed(2)
: null;
copy.value === null
? null
: new Decimal(copy.value).toFixed(2);
break;
default:
break;
@@ -234,15 +234,15 @@ export const useConformanceStore = defineStore("conformanceStore", {
switch (copy.type) {
case "date":
copy.value =
copy.value !== null
? moment(copy.value).format("YYYY/MM/DD HH:mm:ss")
: null;
copy.value === null
? null
: moment(copy.value).format("YYYY/MM/DD HH:mm:ss");
break;
case "float":
copy.value =
copy.value !== null
? new Decimal(copy.value).toFixed(2)
: null;
copy.value === null
? null
: new Decimal(copy.value).toFixed(2);
break;
default:
break;
@@ -306,10 +306,10 @@ export const useConformanceStore = defineStore("conformanceStore", {
const api = getCheckApiBase(this);
try {
const response = await apiClient.get(api);
if (!getRouteFile) {
this.allConformanceTempReportData = response.data;
} else {
if (getRouteFile) {
this.allRouteFile = response.data.file;
} else {
this.allConformanceTempReportData = response.data;
}
} catch (error) {
apiError(error, "Failed to Get the Temporary Log Conformance Report.");

View File

@@ -408,12 +408,12 @@ watch(
if (newAccount.length > 0 && newName.length > 0) {
isConfirmDisabled.value = false;
}
if (whichCurrentModal.value !== MODAL_CREATE_NEW) {
if (isResetPwdSectionShow.value && newPwd.length < PWD_VALID_LENGTH) {
if (whichCurrentModal.value === MODAL_CREATE_NEW) {
if (newPwd.length < PWD_VALID_LENGTH) {
isConfirmDisabled.value = true;
}
} else {
if (newPwd.length < PWD_VALID_LENGTH) {
if (isResetPwdSectionShow.value && newPwd.length < PWD_VALID_LENGTH) {
isConfirmDisabled.value = true;
}
}

View File

@@ -1520,7 +1520,12 @@ function getAvgProcessTimeHorizontalBarChart(
contentData.avgWaitingTime,
"date",
);
if (compareDashboardData.value.time.avg_waiting_time_by_edge !== null) {
if (compareDashboardData.value.time.avg_waiting_time_by_edge === null) {
[avgWaitingTimeByEdgeData.value, avgWaitingTimeByEdgeOptions.value] = [
null,
null,
];
} else {
[avgWaitingTimeByEdgeData.value, avgWaitingTimeByEdgeOptions.value] =
getHorizontalBarChart(
compareDashboardData.value.time.avg_waiting_time_by_edge,
@@ -1528,11 +1533,6 @@ function getAvgProcessTimeHorizontalBarChart(
false,
"date",
);
} else {
[avgWaitingTimeByEdgeData.value, avgWaitingTimeByEdgeOptions.value] = [
null,
null,
];
}
[freqData.value, freqOptions.value] = getLineChart(
compareDashboardData.value.freq.cases,

View File

@@ -588,19 +588,19 @@ function setActivityBgImage(mapData) {
isLoading.value = true;
switch (routeParams.type) {
case "log":
if (!isCheckPage) {
logId.value = routeParams.fileId;
baseLogId.value = routeParams.fileId;
} else {
if (isCheckPage) {
logId.value = file.parent?.id;
baseLogId.value = file.parent?.id;
} else {
logId.value = routeParams.fileId;
baseLogId.value = routeParams.fileId;
}
break;
case "filter":
if (!isCheckPage) {
createFilterId.value = routeParams.fileId;
} else {
if (isCheckPage) {
createFilterId.value = file.parent?.id;
} else {
createFilterId.value = routeParams.fileId;
}
await allMapDataStore.fetchFunnel(createFilterId.value);
isRuleData.value = Array.from(temporaryData.value);

View File

@@ -85,16 +85,7 @@ let loadingTimerId = null;
const file = route.meta.file;
const isCheckPage = route.name.includes("Check");
if (!isCheckPage) {
switch (params.type) {
case "log":
conformanceLogId.value = params.fileId;
break;
case "filter":
conformanceFilterId.value = params.fileId;
break;
}
} else {
if (isCheckPage) {
switch (params.type) {
case "log":
conformanceLogId.value = file.parent?.id;
@@ -106,6 +97,15 @@ let loadingTimerId = null;
break;
}
await conformanceStore.getConformanceReport();
} else {
switch (params.type) {
case "log":
conformanceLogId.value = params.fileId;
break;
case "filter":
conformanceFilterId.value = params.fileId;
break;
}
}
await conformanceStore.getConformanceParams();
} catch (error) {

View File

@@ -577,19 +577,19 @@ function setActivityBgImage(mapData) {
isLoading.value = true;
switch (routeParams.type) {
case "log":
if (!isCheckPage) {
logId.value = routeParams.fileId;
baseLogId.value = routeParams.fileId;
} else {
if (isCheckPage) {
logId.value = file.parent?.id;
baseLogId.value = file.parent?.id;
} else {
logId.value = routeParams.fileId;
baseLogId.value = routeParams.fileId;
}
break;
case "filter":
if (!isCheckPage) {
createFilterId.value = routeParams.fileId;
} else {
if (isCheckPage) {
createFilterId.value = file.parent?.id;
} else {
createFilterId.value = routeParams.fileId;
}
await allMapDataStore.fetchFunnel(createFilterId.value);
isRuleData.value = Array.from(temporaryData.value);

View File

@@ -1059,10 +1059,10 @@ function getAvgWaitingTimeLineChart(chartData, content, yUnit) {
const file = route.meta.file;
let id;
if (!isCheckPage) {
id = routeParams.fileId;
} else {
if (isCheckPage) {
id = file.parent?.id;
} else {
id = routeParams.fileId;
}
// Fetch Performance Data
@@ -1112,7 +1112,12 @@ function getAvgWaitingTimeLineChart(chartData, content, yUnit) {
contentData.avgWaitingTime,
"date",
);
if (performanceData.value.time.avg_waiting_time_by_edge !== null) {
if (performanceData.value.time.avg_waiting_time_by_edge === null) {
[avgWaitingTimeByEdgeData.value, avgWaitingTimeByEdgeOptions.value] = [
null,
null,
];
} else {
[avgWaitingTimeByEdgeData.value, avgWaitingTimeByEdgeOptions.value] =
getHorizontalBarChart(
performanceData.value.time.avg_waiting_time_by_edge,
@@ -1120,11 +1125,6 @@ function getAvgWaitingTimeLineChart(chartData, content, yUnit) {
false,
"date",
);
} else {
[avgWaitingTimeByEdgeData.value, avgWaitingTimeByEdgeOptions.value] = [
null,
null,
];
}
[casesByTaskData.value, casesByTaskOptions.value] = getHorizontalBarChart(