Skip to content

Commit

Permalink
sort projects by name
Browse files Browse the repository at this point in the history
  • Loading branch information
jsawo committed Nov 14, 2022
1 parent da0fa13 commit bd98547
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview",
"tsc": "npx vue-tsc --noEmit"
"tsc": "vue-tsc --noEmit"
},
"dependencies": {
"@guolao/vue-monaco-editor": "^0.0.5",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const clearMessages = () => data.messages = []
const currentProject = computed<Project>(function () {
return data.appConfig.Projects
? data.appConfig.Projects[data.appConfig.Currentproject]
: {}
: {} as Project
})
const currentColor = computed<string>(function() {
Expand Down
20 changes: 18 additions & 2 deletions frontend/src/components/pages/ProjectSettings.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { reactive } from 'vue'
import { reactive, computed } from 'vue'
import Button from 'primevue/button'
import InputText from 'primevue/inputtext'
import Dropdown from 'primevue/dropdown'
Expand Down Expand Up @@ -53,6 +53,22 @@ data.commandPresets = [...new Set(data.commandPresets)]
setFormDefaults()
const sortedProjects = computed(function () {
const keys = Object.keys(props.appConfig.Projects).sort((a, b) => {
return props.appConfig.Projects[a].Name.localeCompare(props.appConfig.Projects[b].Name)
})
const sorted: Record<string, Project> = {}
keys.forEach(key => {
sorted[key] = props.appConfig.Projects[key]
})
return sorted
})
console.log(props.appConfig.Projects)
const setCurrentProject = (id: string) => {
SetCurrentProject(id).then(() => setFormDefaults())
}
Expand Down Expand Up @@ -104,7 +120,7 @@ const commandPresetSelected = (event) => {
<div class="text-right">
<Button label="New" class="p-button-sm" icon="pi pi-plus" @click="createProject" />
</div>
<div v-for="project in appConfig.Projects"
<div v-for="project in sortedProjects"
class="project" :class="currentProject?.Id === project.Id ? 'active' : ''"
@click="() => setCurrentProject(project.Id)"
:key="project.Id"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/types/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
interface AppConfig {
Currentproject: string,
Projects: Array<Project>,
Projects: Record<string, Project>,
Tags: Array<Tag>,
}

Expand Down

0 comments on commit bd98547

Please sign in to comment.