diff --git a/src/components/Discover/Conformance/ConformanceSidebar.vue b/src/components/Discover/Conformance/ConformanceSidebar.vue index c07b430..c1cdc97 100644 --- a/src/components/Discover/Conformance/ConformanceSidebar.vue +++ b/src/components/Discover/Conformance/ConformanceSidebar.vue @@ -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 diff --git a/src/components/Discover/Map/Filter/ActAndSeq.vue b/src/components/Discover/Map/Filter/ActAndSeq.vue index 7b08058..15a7578 100644 --- a/src/components/Discover/Map/Filter/ActAndSeq.vue +++ b/src/components/Discover/Map/Filter/ActAndSeq.vue @@ -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; }); }); diff --git a/src/components/Discover/Map/Filter/FunnelFilter.vue b/src/components/Discover/Map/Filter/FunnelFilter.vue index 365b2fd..0f62bdd 100644 --- a/src/components/Discover/Map/Filter/FunnelFilter.vue +++ b/src/components/Discover/Map/Filter/FunnelFilter.vue @@ -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; } /** diff --git a/src/components/Discover/Map/SidebarFilter.vue b/src/components/Discover/Map/SidebarFilter.vue index 2d7c8a1..53ac6f4 100644 --- a/src/components/Discover/Map/SidebarFilter.vue +++ b/src/components/Discover/Map/SidebarFilter.vue @@ -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)); } } diff --git a/src/module/alertModal.js b/src/module/alertModal.js index 2acd51a..41e82bd 100644 --- a/src/module/alertModal.js +++ b/src/module/alertModal.js @@ -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; } }); }, diff --git a/src/module/setChartData.js b/src/module/setChartData.js index 23068d7..d8278bb 100644 --- a/src/module/setChartData.js +++ b/src/module/setChartData.js @@ -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; } } /** diff --git a/src/stores/allMapData.ts b/src/stores/allMapData.ts index b48f531..8f0ad2b 100644 --- a/src/stores/allMapData.ts +++ b/src/stores/allMapData.ts @@ -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."); } diff --git a/src/stores/conformance.ts b/src/stores/conformance.ts index 5b16f7c..9cadb2a 100644 --- a/src/stores/conformance.ts +++ b/src/stores/conformance.ts @@ -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."); diff --git a/src/views/AccountManagement/ModalAccountEditCreate.vue b/src/views/AccountManagement/ModalAccountEditCreate.vue index 29ef122..cb254df 100644 --- a/src/views/AccountManagement/ModalAccountEditCreate.vue +++ b/src/views/AccountManagement/ModalAccountEditCreate.vue @@ -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; } } diff --git a/src/views/Compare/Dashboard/CompareDashboard.vue b/src/views/Compare/Dashboard/CompareDashboard.vue index 007ddfd..86de8c6 100644 --- a/src/views/Compare/Dashboard/CompareDashboard.vue +++ b/src/views/Compare/Dashboard/CompareDashboard.vue @@ -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, diff --git a/src/views/Compare/MapCompare.vue b/src/views/Compare/MapCompare.vue index 167a46c..6d34d71 100644 --- a/src/views/Compare/MapCompare.vue +++ b/src/views/Compare/MapCompare.vue @@ -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); diff --git a/src/views/Discover/Conformance/ConformancePage.vue b/src/views/Discover/Conformance/ConformancePage.vue index ae43210..eea81df 100644 --- a/src/views/Discover/Conformance/ConformancePage.vue +++ b/src/views/Discover/Conformance/ConformancePage.vue @@ -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) { diff --git a/src/views/Discover/Map/MapPage.vue b/src/views/Discover/Map/MapPage.vue index 22d434e..5ceca09 100644 --- a/src/views/Discover/Map/MapPage.vue +++ b/src/views/Discover/Map/MapPage.vue @@ -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); diff --git a/src/views/Discover/Performance/PerformancePage.vue b/src/views/Discover/Performance/PerformancePage.vue index 26ef4e3..f0268f2 100644 --- a/src/views/Discover/Performance/PerformancePage.vue +++ b/src/views/Discover/Performance/PerformancePage.vue @@ -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(