diff --git a/src/components/Navbar.vue b/src/components/Navbar.vue index e967437..9e4587b 100644 --- a/src/components/Navbar.vue +++ b/src/components/Navbar.vue @@ -62,19 +62,19 @@ export default { const store = filesStore(); const allMapDataStore = AllMapDataStore(); const conformanceStore = ConformanceStore(); - const { logId, tempFilterId, createFilterId, filterName, postRuleData, isUpdataFilter } = storeToRefs(allMapDataStore); + const { logId, tempFilterId, createFilterId, filterName, postRuleData, isUpdateFilter } = storeToRefs(allMapDataStore); const { conformanceRuleData, conformanceLogId, conformanceFilterId, conformanceLogTempCheckId, conformanceFilterTempCheckId, conformanceLogCreateCheckId, conformanceFilterCreateCheckId, - isUpdataConformance, conformanceFileName + isUpdateConformance, conformanceFileName } = storeToRefs(conformanceStore); return { store, allMapDataStore, logId, tempFilterId, createFilterId, - filterName, postRuleData, isUpdataFilter, conformanceStore, conformanceRuleData, + filterName, postRuleData, isUpdateFilter, conformanceStore, conformanceRuleData, conformanceLogId, conformanceFilterId, conformanceLogTempCheckId, conformanceFilterTempCheckId, conformanceLogCreateCheckId, - conformanceFilterCreateCheckId, isUpdataConformance, conformanceFileName, + conformanceFilterCreateCheckId, isUpdateConformance, conformanceFileName, }; }, components: { @@ -300,8 +300,8 @@ export default { }, async handleMapSave() { if (this.createFilterId) { - await this.allMapDataStore.updataFilter(); - if (this.isUpdataFilter) { + await this.allMapDataStore.updateFilter(); + if (this.isUpdateFilter) { await savedSuccessfully(this.filterName); } } else if (this.logId) { @@ -321,8 +321,8 @@ export default { }, async handleConformanceSave() { if (this.conformanceFilterCreateCheckId || this.conformanceLogCreateCheckId) { - await this.conformanceStore.updataConformance(); - if (this.isUpdataConformance) { + await this.conformanceStore.updateConformance(); + if (this.isUpdateConformance) { await savedSuccessfully(this.conformanceFileName); } } else { @@ -340,7 +340,7 @@ export default { }, ...mapActions(PageAdminStore, [ 'setPendingActivePage', - 'setPrevioiusPage', + 'setPreviousPage', 'setActivePage', 'setActivePageComputedByRoute', 'setIsPagePendingBoolean', diff --git a/src/module/alertModal.js b/src/module/alertModal.js index 1fed4bb..fa84e6b 100644 --- a/src/module/alertModal.js +++ b/src/module/alertModal.js @@ -109,8 +109,8 @@ export async function leaveFilter(next, addFilterId, toPath, logOut) { if(result.isConfirmed) { if(allMapDataStore.createFilterId) { - await allMapDataStore.updataFilter(); - if(allMapDataStore.isUpdataFilter) { + await allMapDataStore.updateFilter(); + if(allMapDataStore.isUpdateFilter) { await savedSuccessfully(allMapDataStore.filterName); } } else { @@ -212,8 +212,8 @@ async function showConfirmationDialog() { async function handleConfirmed(conformanceStore, addConformanceCreateCheckId) { if (conformanceStore.conformanceFilterCreateCheckId || conformanceStore.conformanceLogCreateCheckId) { - await conformanceStore.updataConformance(); - if (conformanceStore.isUpdataConformance) { + await conformanceStore.updateConformance(); + if (conformanceStore.isUpdateConformance) { await savedSuccessfully(conformanceStore.conformanceFileName); } } else { @@ -486,9 +486,9 @@ export async function deleteSuccess() { /** * Really deleted information * @param {string} files 被刪除的檔案 html - * @param {array} reallyDeldetData 被刪除的檔案 data,未取得 recordId 而傳入 + * @param {array} reallyDeleteData 被刪除的檔案 data,未取得 recordId 而傳入 */ -export async function reallyDeldetInformation(files, reallyDeldetData) { +export async function reallyDeleteInformation(files, reallyDeleteData) { const filesStore = FilesStore(); const deleteCustomClass = { ...customClass }; const htmlText = `

The following file(s) have been deleted by other user(s):

`; @@ -508,7 +508,7 @@ export async function reallyDeldetInformation(files, reallyDeldetData) { confirmButton.style.border = '1px solid #0099FF'; } }); - await Promise.all(reallyDeldetData.map(file => filesStore.deletionRecord(file.id))); + await Promise.all(reallyDeleteData.map(file => filesStore.deletionRecord(file.id))); await filesStore.fetchAllFiles(); } diff --git a/src/stores/allMapData.js b/src/stores/allMapData.js index 673bfa8..97f18d5 100644 --- a/src/stores/allMapData.js +++ b/src/stores/allMapData.js @@ -34,7 +34,7 @@ export default defineStore('allMapDataStore', { ruleData: [], // Funnle view's data isRuleData: [], // toggle button data allFunnelData: [], - isUpdataFilter: false, // 是否成功儲存 Filter 檔 + isUpdateFilter: false, // 是否成功儲存 Filter 檔 selectTimeFrame: [], // user select time start and end infinite404: null, // 無限滾動式是否到底要換頁 infiniteStart: 0, // 無限滾動 case 開始的數字 @@ -354,19 +354,19 @@ export default defineStore('allMapDataStore', { } }, /** - * Updata an Existing Filter + * Update an Existing Filter */ - async updataFilter() { + async updateFilter() { let createFilterId = this.createFilterId const api = `/api/filters/${createFilterId}`; const data = this.postRuleData; try { const response = await this.$axios.put(api, data); - this.isUpdataFilter = response.status === 200; + this.isUpdateFilter = response.status === 200; this.tempFilterId = null; }catch(error) { - apiError(error, 'Failed to updata an Existing Filter.'); + apiError(error, 'Failed to update an Existing Filter.'); } }, }, diff --git a/src/stores/conformance.js b/src/stores/conformance.js index 5f750ac..6c36e75 100644 --- a/src/stores/conformance.js +++ b/src/stores/conformance.js @@ -36,7 +36,7 @@ export default defineStore('conformanceStore', { isStartSelected: null, // start & end 連動先選擇 start isEndSelected: null, // start & end 連動先選擇 end conformanceRuleData: null, // create checkId's data to save - isUpdataConformance: false, // 成功儲存後要跳 Modal + isUpdateConformance: false, // 成功儲存後要跳 Modal conformanceFileName: null, // 儲存成功的 Modal 用 }), getters: { @@ -436,9 +436,9 @@ export default defineStore('conformanceStore', { }; }, /** - * Updata an Existing Conformance Check, log and filter + * Update an Existing Conformance Check, log and filter */ - async updataConformance() { + async updateConformance() { let logCreateCheckId = this.conformanceLogCreateCheckId; let filterCreateCheckId = this.conformanceFilterCreateCheckId; let api = ''; @@ -450,11 +450,11 @@ export default defineStore('conformanceStore', { try { const response = await this.$axios.put(api, data); - this.isUpdataConformance = response.status === 200; + this.isUpdateConformance = response.status === 200; this.conformanceLogTempCheckId = null; this.conformanceFilterTempCheckId = null; }catch(error) { - apiError(error, 'Failed to updata an Existing Conformance.'); + apiError(error, 'Failed to update an Existing Conformance.'); } }, /** diff --git a/src/stores/login.ts b/src/stores/login.ts index a72ddcf..cc5e12a 100644 --- a/src/stores/login.ts +++ b/src/stores/login.ts @@ -88,7 +88,7 @@ export default defineStore('loginStore', { } }, /** - * Logout, tooken expired + * Logout, token expired */ logOut() { delete axios.defaults.headers.common["Authorization"]; diff --git a/src/stores/pageAdmin.js b/src/stores/pageAdmin.js index 3df36e9..a307f48 100644 --- a/src/stores/pageAdmin.js +++ b/src/stores/pageAdmin.js @@ -1,6 +1,6 @@ import { defineStore } from "pinia"; import { mapPageNameToCapitalUnifiedName } from "../utils/pageUtils"; -const printPageAdiminLog = false; +const printPageAdminLog = false; // There are at least two ways to trigger a page navigation: // clicking the navigation button and refreshing the page. @@ -23,7 +23,7 @@ export default defineStore('pageAdminStore', { setActivePageComputedByRoute(routeMatched){ if (routeMatched.length && routeMatched[routeMatched.length - 1] && routeMatched[routeMatched.length - 1].name) { - printPageAdiminLog && console.log('setActivePageComputedByRoute()', mapPageNameToCapitalUnifiedName(routeMatched[routeMatched.length - 1].name)); + printPageAdminLog && console.log('setActivePageComputedByRoute()', mapPageNameToCapitalUnifiedName(routeMatched[routeMatched.length - 1].name)); this.activePageComputedByRoute = mapPageNameToCapitalUnifiedName( routeMatched[routeMatched.length - 1].name); } @@ -33,20 +33,20 @@ export default defineStore('pageAdminStore', { * @param {string} activePage */ setActivePage(activePage) { - printPageAdiminLog && console.log("setActivePage", activePage) + printPageAdminLog && console.log("setActivePage", activePage) this.activePage = mapPageNameToCapitalUnifiedName(activePage); }, /** * Specify previous page state value. * @param {string} prevPage */ - setPrevioiusPage(prevPage) { + setPreviousPage(prevPage) { this.previousPage = mapPageNameToCapitalUnifiedName(prevPage); }, /** * Set the previous(usually current) pages to the ones we just decide. */ - setPrevioiusPageUsingActivePage() { + setPreviousPageUsingActivePage() { this.previousPage = this.activePage; }, /** @@ -61,7 +61,7 @@ export default defineStore('pageAdminStore', { * Copy(transit) the value of pendingActivePage to activePage */ copyPendingPageToActivePage() { - printPageAdiminLog && console.log('pinia copying this.pendingActivePage', this.pendingActivePage); + printPageAdminLog && console.log('pinia copying this.pendingActivePage', this.pendingActivePage); this.activePage = this.pendingActivePage; }, /** @@ -72,7 +72,7 @@ export default defineStore('pageAdminStore', { * @param {string} pendingActivePage */ setPendingActivePage(argPendingActivePage) { - printPageAdiminLog && console.log('pinia setting this.pendingActivePage', this.pendingActivePage); + printPageAdminLog && console.log('pinia setting this.pendingActivePage', this.pendingActivePage); this.pendingActivePage = mapPageNameToCapitalUnifiedName(argPendingActivePage); }, /** @@ -87,7 +87,7 @@ export default defineStore('pageAdminStore', { * instead, we apply the previous page. */ keepPreviousPage() { - printPageAdiminLog && console.log('pinia keeping this.previousPage', this.previousPage); + printPageAdminLog && console.log('pinia keeping this.previousPage', this.previousPage); this.activePage = this.previousPage; this.shouldKeepPreviousPage = true; }, @@ -95,7 +95,7 @@ export default defineStore('pageAdminStore', { * Clean up the state of the boolean related to modal showing phase */ clearShouldKeepPreviousPageBoolean(){ - printPageAdiminLog && console.log('clearShouldKeepPreviousPageBoolean()'); + printPageAdminLog && console.log('clearShouldKeepPreviousPageBoolean()'); this.shouldKeepPreviousPage = false; }, setCurrentMapFile(fileName){ diff --git a/src/views/Files/Files.vue b/src/views/Files/Files.vue index e1a746b..fc6bb54 100644 --- a/src/views/Files/Files.vue +++ b/src/views/Files/Files.vue @@ -235,7 +235,7 @@ import IconVector from '@/components/icons/IconVector.vue'; import IconList from '@/components/icons/IconList.vue'; import IconGrid from '@/components/icons/IconGrid.vue'; - import { renameModal, deleteFileModal, reallyDeldetInformation } from '@/module/alertModal.js'; + import { renameModal, deleteFileModal, reallyDeleteInformation } from '@/module/alertModal.js'; export default { data() { @@ -335,7 +335,7 @@ /** * Really deleted information */ - reallyDeldetData: function() { + reallyDeleteData: function() { let result = []; if(this.store.allFiles.length !== 0){ @@ -360,7 +360,7 @@ if(newValue != null) this.compareData = JSON.parse(JSON.stringify(newValue)); } }, - reallyDeldetData: { + reallyDeleteData: { handler(newValue, oldValue) { if(newValue.length !== 0 && oldValue.length === 0){ this.showReallyDeldet(); @@ -512,8 +512,8 @@ showReallyDeldet(){ let srt = ''; - if(this.reallyDeldetData.length !== 0) { - this.reallyDeldetData.forEach(file => { + if(this.reallyDeleteData.length !== 0) { + this.reallyDeleteData.forEach(file => { switch (file.type) { case 'log-check': case 'filter-check': @@ -526,7 +526,7 @@ srt += content; }); } - reallyDeldetInformation(srt, this.reallyDeldetData); + reallyDeleteInformation(srt, this.reallyDeleteData); srt = ''; }, /** diff --git a/src/views/MainContainer.vue b/src/views/MainContainer.vue index 8e1bc98..4bd8567 100644 --- a/src/views/MainContainer.vue +++ b/src/views/MainContainer.vue @@ -77,7 +77,7 @@ export default { methods: { ...mapActions(PageAdminStore, [ 'copyPendingPageToActivePage', - 'setPrevioiusPage', + 'setPreviousPage', 'clearShouldKeepPreviousPageBoolean', 'setActivePageComputedByRoute', ],), @@ -137,7 +137,7 @@ export default { }, // Remember, Swal modal handling is called before beforeRouteUpdate beforeRouteUpdate(to, from, next) { - this.setPrevioiusPage(from.name); + this.setPreviousPage(from.name); // 離開 Map 頁時判斷是否有無資料和需要存檔 if ((from.name === 'Map' || from.name === 'CheckMap') && this.tempFilterId) { diff --git a/tests/stores/allMapData.test.js b/tests/stores/allMapData.test.js index 300cc77..01970f7 100644 --- a/tests/stores/allMapData.test.js +++ b/tests/stores/allMapData.test.js @@ -173,20 +173,20 @@ describe('allMapDataStore', () => { }); }); - describe('updataFilter', () => { + describe('updateFilter', () => { it('updates filter and clears temp id', async () => { store.createFilterId = 88; store.tempFilterId = 77; store.postRuleData = [{ type: 'updated' }]; mockAxios.put.mockResolvedValue({ status: 200 }); - await store.updataFilter(); + await store.updateFilter(); expect(mockAxios.put).toHaveBeenCalledWith( '/api/filters/88', [{ type: 'updated' }], ); - expect(store.isUpdataFilter).toBe(true); + expect(store.isUpdateFilter).toBe(true); expect(store.tempFilterId).toBeNull(); }); }); diff --git a/tests/stores/conformance.test.js b/tests/stores/conformance.test.js index 2f56a09..8a8a5a9 100644 --- a/tests/stores/conformance.test.js +++ b/tests/stores/conformance.test.js @@ -147,19 +147,19 @@ describe('conformanceStore', () => { }); }); - describe('updataConformance', () => { + describe('updateConformance', () => { it('updates existing log check', async () => { store.conformanceLogCreateCheckId = 50; store.conformanceRuleData = { type: 'updated' }; mockAxios.put.mockResolvedValue({ status: 200 }); - await store.updataConformance(); + await store.updateConformance(); expect(mockAxios.put).toHaveBeenCalledWith( '/api/log-checks/50', { type: 'updated' }, ); - expect(store.isUpdataConformance).toBe(true); + expect(store.isUpdateConformance).toBe(true); }); }); diff --git a/tests/stores/pageAdmin.test.js b/tests/stores/pageAdmin.test.js index 37e7eec..22afaa7 100644 --- a/tests/stores/pageAdmin.test.js +++ b/tests/stores/pageAdmin.test.js @@ -24,14 +24,14 @@ describe('pageAdminStore', () => { expect(store.activePage).toBe('CONFORMANCE'); }); - it('setPrevioiusPage converts page name', () => { - store.setPrevioiusPage('CheckPerformance'); + it('setPreviousPage converts page name', () => { + store.setPreviousPage('CheckPerformance'); expect(store.previousPage).toBe('PERFORMANCE'); }); - it('setPrevioiusPageUsingActivePage copies activePage to previousPage', () => { + it('setPreviousPageUsingActivePage copies activePage to previousPage', () => { store.setActivePage('CONFORMANCE'); - store.setPrevioiusPageUsingActivePage(); + store.setPreviousPageUsingActivePage(); expect(store.previousPage).toBe('CONFORMANCE'); }); @@ -58,7 +58,7 @@ describe('pageAdminStore', () => { }); it('keepPreviousPage restores previous page', () => { - store.setPrevioiusPage('CONFORMANCE'); + store.setPreviousPage('CONFORMANCE'); store.setActivePage('PERFORMANCE'); store.keepPreviousPage(); expect(store.activePage).toBe('CONFORMANCE');