Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor method names and stores with camelCase #57 #62

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions components/DictEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
}>()

const GetDictEntry = async () => {
const getDictEntry = async () => {
const { $api } = useNuxtApp()
const id = String(props.params.sid)
const dict = String(props.params.dict)
Expand All @@ -26,12 +26,12 @@
}
}

htmlContents.value = await GetDictEntry()
htmlContents.value = await getDictEntry()

const domId = 'id-' + Math.floor(Math.random() * 1000000)
const WMStore = useWMStore()
const wmStore = useWMStore()
onMounted(() => {
WMStore.SanitizeLinks(domId)
wmStore.sanitizeLinks(domId)
})
</script>

Expand Down
28 changes: 14 additions & 14 deletions components/DictQuery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

const props = defineProps(['params'])

const DictStore = useDictStore()
const dictList = computed(() => DictStore.dictList)
const dictStore = useDictStore()
const dictList = computed(() => dictStore.dictList)
const dictSelector: Ref<{ [dictId: string]: boolean }> = ref({})
dictList.value.forEach(d => { dictSelector.value[d.coll_name] = (props.params?.dictId == d.coll_name) })
if (!Object.keys(dictSelector.value).some(d => dictSelector.value[d])) {
Expand All @@ -18,7 +18,7 @@
.join(",")
return newString
})
const dictCrossQueryXslt = computed(() => DictStore.dictCrossQueryXslt)
const dictCrossQueryXslt = computed(() => dictStore.dictCrossQueryXslt)

const queryString: Ref<string> = ref('')
const normalizedQueryString = computed(() => {
Expand All @@ -36,7 +36,7 @@
return newString
})

const QueryDictionaries = async () => {
const queryDictionaries = async () => {
const { $api } = useNuxtApp()
$api.baseUrl = ("" + import.meta.env.VITE_APIBASEURL);
try {
Expand All @@ -46,11 +46,11 @@
xslt: dictCrossQueryXslt.value
})).text()
} catch (error) {
LogError(error)
logError(error)
}
}

const LogError = async (error: any) => {
const logError = async (error: any) => {
let errorXml = (new DOMParser()).parseFromString(await error.text(), 'text/xml')
console.error(errorXml)
alert(
Expand All @@ -64,19 +64,19 @@
const resultHtml: Ref<string | undefined> = ref('')

const domId = 'id-' + Math.floor(Math.random() * 1000000)
const WMStore = useWMStore()
const wmStore = useWMStore()

const QueryButtonClicked = async (e: Event) => {
const queryButtonClicked = async (e: Event) => {
e.preventDefault()
resultHtml.value = await QueryDictionaries()
resultHtml.value = await queryDictionaries()
nextTick(() => {
WMStore.SanitizeLinks(domId)
wmStore.sanitizeLinks(domId)
})
}

const OpenExamples = (e: Event) => {
const openExamples = (e: Event) => {
e.preventDefault()
WMStore.Open('Text', 'textQuery: TUNICO DICTIONARY', { id: 'dictFrontPage_Tunis', customClass: 'vicav-cover-page' })
wmStore.open('Text', 'textQuery: TUNICO DICTIONARY', { id: 'dictFrontPage_Tunis', customClass: 'vicav-cover-page' })
}
</script>

Expand All @@ -91,7 +91,7 @@
placeholder="Search in dictionaries ..."
aria-label="Search"
/>
<button class="crossDictQueryBtn" @click="QueryButtonClicked" :disabled="queryString === '' || !Object.keys(dictSelector).some(d => dictSelector[d])">
<button class="crossDictQueryBtn" @click="queryButtonClicked" :disabled="queryString === '' || !Object.keys(dictSelector).some(d => dictSelector[d])">
Query</button
><br />
</form>
Expand All @@ -105,7 +105,7 @@
</ul>
<p>
For details as to how to formulate meaningful dictionary queries consult the
<a class="aVicText" href="" @click="OpenExamples">examples of the TUNICO dictionary</a>.
<a class="aVicText" href="" @click="openExamples">examples of the TUNICO dictionary</a>.
</p>
<div v-html="resultHtml" :id="domId"></div>
</div>
Expand Down
14 changes: 7 additions & 7 deletions components/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
AppDataStore.isMobileMenuOpen = !AppDataStore.isMobileMenuOpen
}

const WMStore = useWMStore()
const wmStore = useWMStore()
const windowList = computed(() => {
return WMStore.windowList.map(w => { return {
return wmStore.windowList.map(w => { return {
id: w.id,
name: w.id?.toString() + ': ' + w.winBoxOptions?.title
}})
})
function SelectWindow(windowId: number | null) {
if (windowId != null) {
WMStore.Focus(windowId);
wmStore.focus(windowId);
}
}

Expand All @@ -32,7 +32,7 @@
onMounted(() => {
windowListDropdown = new $bootstrap.Dropdown(windowListTogglerRef.value)
let menuBarHeight = menuBarRef.value.offsetHeight
WMStore.SetTopMargin(menuBarHeight)
wmStore.setTopMargin(menuBarHeight)
})
function ToggleWindowListCollapse(e) {
AppDataStore.isMobileMenuOpen = false
Expand Down Expand Up @@ -109,14 +109,14 @@
<li>
<div class="dropdown-divider"></div>
</li>
<li v-for="wam in WMStore.desktopArrangeMethods" :key="wam.id">
<li v-for="wam in wmStore.desktopArrangeMethods" :key="wam.id">
<a
class="dropdown-item"
href="#"
@mousedown="WMStore.SelectDesktopArrangeMethod(wam)"
@mousedown="wmStore.SelectDesktopArrangeMethod(wam)"
>
<span class="vv-navbar-wam-checkmark">
{{ wam.id == WMStore.selectedDesktopArrangeMethodId ? '✓' : '' }}
{{ wam.id == wmStore.selectedDesktopArrangeMethodId ? '✓' : '' }}
</span>
{{ wam.name }}
</a>
Expand Down
8 changes: 4 additions & 4 deletions components/Text.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
const htmlContents: Ref<string | undefined> = ref("")
const props = defineProps(['params'])

const GetText = async () => {
const getText = async () => {
const { $api } = useNuxtApp()
const id = String(props.params.id)
$api.baseUrl = ("" + import.meta.env.VITE_APIBASEURL);
Expand All @@ -19,12 +19,12 @@
console.error(error)
}
}
htmlContents.value = await GetText()
htmlContents.value = await getText()

const domId = 'id-' + Math.floor(Math.random() * 1000000)
const WMStore = useWMStore()
const wmStore = useWMStore()
onMounted(() => {
WMStore.SanitizeLinks(domId)
wmStore.sanitizeLinks(domId)
})
</script>

Expand Down
12 changes: 5 additions & 7 deletions components/VicavMenuItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,26 @@
<a
class="dropdown-item"
href="#"
@mousedown="ClickMenu(menuNode)"
@mousedown="clickMenu(menuNode)"
>
{{ menuNode.name }}
</a>
</div>
</template>

<script setup lang="ts">
import { useAppDataStore } from '~~/store/appData';
import { IMenuItem } from "~/store/appData";
import { useWMStore } from '~~/store/wm';

const AppDataStore = useAppDataStore()
const WMStore = useWMStore()
const wmStore = useWMStore()

const props = defineProps<{
defineProps<{
menuNode: IMenuItem;
}>();

function ClickMenu(menuNode: IMenuItem) {
function clickMenu(menuNode: IMenuItem) {
if (menuNode.type === 'item') {
WMStore.Open(menuNode.windowTypeId, menuNode.name, menuNode.params)
wmStore.open(menuNode.windowTypeId, menuNode.name, menuNode.params)
}
}
</script>
4 changes: 2 additions & 2 deletions components/VicavMenuSubmenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<a
:id="menuNode.id"
ref="buttonRef"
@click="ToggleMenu(dropdown)"
@click="toggleMenu(dropdown)"
class="nav-link dropdown-toggle"
role="button"
data-bs-toggle="dropdown"
Expand Down Expand Up @@ -39,7 +39,7 @@

let dropdown: Dropdown | null = null;

function ToggleMenu(dropdown: Dropdown | null) {
function toggleMenu(dropdown: Dropdown | null) {
if (dropdown == null) {
return
}
Expand Down
40 changes: 20 additions & 20 deletions components/WindowManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { useWMStore, INewWindow, IWindow, IWindowType } from '~~/store/wm'
import { VicavWinBox } from "./VicavWinBox.client"

const WMStore = useWMStore()
const windowList = computed(() => WMStore.windowList)
const wmStore = useWMStore()
const windowList = computed(() => wmStore.windowList)
const windowTypes = {
Text: {
component: resolveComponent('Text'),
Expand All @@ -20,20 +20,20 @@
} as IWindowType,
}

const newWindow = computed(() => WMStore.newWindow)
const newWindow = computed(() => wmStore.newWindow)
watch(newWindow, (window) => {
if (window != null) {
NewWindow(window)
createNewWindow(window)
}
})
function NewWindow(newWindow: INewWindow) {
function createNewWindow(newWindow: INewWindow) {
let windowType = windowTypes[newWindow.windowTypeId as keyof typeof windowTypes]
if (windowType === undefined) {
ConsoleWarning("Window type undefined", newWindow)
consoleWarning("Window type undefined", newWindow)
return false
}
if (typeof windowType.component === "string") {
ConsoleWarning("Window type '" + windowType + "' was not resolved", newWindow)
consoleWarning("Window type '" + windowType + "' was not resolved", newWindow)
return false
}

Expand All @@ -47,33 +47,33 @@
type: windowType as IWindowType,
winBoxOptions: {
title: '[' + newWindow.windowTypeId + '] ' + newWindow.title,
top: WMStore.topMargin,
top: wmStore.topMargin,
class: windowClasses,
},
params: newWindow.params,
}

WMStore.AddWindowToList(window)
wmStore.addWindowToList(window)
}
function ConsoleWarning(text: string, data: Object) {
function consoleWarning(text: string, data: Object) {
console.warn("WindowManager:", text, data);
}

function RegisterWindowRef(i: number, ref: any) {
WMStore.RegisterWindowRef(i, ref)
function registerWindowRef(i: number, ref: any) {
wmStore.registerWindowRef(i, ref)
}

function RemoveWindowRef(i: number, ref: any) {
WMStore.RemoveWindowRef(i, ref)
function removeWindowRef(i: number, ref: any) {
wmStore.removeWindowRef(i, ref)
}

function RegisterClientSize() {
WMStore.RegisterClientSize(document.documentElement.clientWidth, document.documentElement.clientHeight)
function registerClientSize() {
wmStore.registerClientSize(document.documentElement.clientWidth, document.documentElement.clientHeight)
}

onMounted(() =>{
RegisterClientSize()
window.addEventListener('resize', RegisterClientSize, true)
registerClientSize()
window.addEventListener('resize', registerClientSize, true)
})
</script>

Expand All @@ -83,8 +83,8 @@
v-for="(window, i) in windowList"
:key="window.id?.toString()"
:options="window.winBoxOptions"
@open="RegisterWindowRef(i, $event)"
@close="RemoveWindowRef(i, $event)"
@open="registerWindowRef(i, $event)"
@close="removeWindowRef(i, $event)"
>
<component
:is="{...window.type.component}"
Expand Down
4 changes: 2 additions & 2 deletions store/appData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const useAppDataStore = defineStore(
{"id": "subNavVicavDictMarkers", "icon": "fa fa-map", "title": "VICAV Dictionaries"}] as IMapBarItem[]);


const GetProjectData = async () => {
const getProjectData = async () => {
const { $api } = useNuxtApp();
$api.baseUrl = ("" + import.meta.env.VITE_APIBASEURL);
try {
Expand Down Expand Up @@ -59,7 +59,7 @@ export const useAppDataStore = defineStore(
}
}

GetProjectData()
getProjectData()

const isMobileMenuOpen = ref(false);
const isMobile = ref(false);
Expand Down
Loading
Loading