From f8574c5157196c1d3080231b11f1156d2e00f78a Mon Sep 17 00:00:00 2001 From: khansadaoudi Date: Mon, 29 Jul 2024 16:56:49 +0200 Subject: [PATCH] fix the problem of samples loading when we access the project from url --- src/pages/Project.vue | 12 +++++++----- src/pinia/modules/project/defaultState.ts | 2 ++ src/router/index.ts | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/pages/Project.vue b/src/pages/Project.vue index a6946b61..3ad58f97 100644 --- a/src/pages/Project.vue +++ b/src/pages/Project.vue @@ -550,8 +550,9 @@ export default defineComponent({ 'isAllowdedToSync', 'canExportTrees', 'language', + 'reloadSamples' ]), - ...mapWritableState(useProjectStore, ['freezed']), + ...mapWritableState(useProjectStore, ['freezed', 'reloadSamples']), ...mapState(useUserStore, ['isSuperAdmin']), ...mapState(useGithubStore, ['reloadCommits']), projectName(): string { @@ -589,6 +590,9 @@ export default defineComponent({ reloadCommits(newVal) { if (newVal > 0) this.loadProjectData(); }, + reloadSamples(newVal) { + if (newVal > 0) this.loadProjectData(); + } }, created() { window.addEventListener('resize', this.handleResize); @@ -638,10 +642,8 @@ export default defineComponent({ api.getProjectSamples(this.projectName as string).then((response) => { this.samples = response.data; this.samplesNumber = this.samples.length; - this.sampleNames = []; - for (const sample of this.samples) { - this.sampleNames.push(sample.sample_name); - } + this.sampleNames = this.samples.map(sample => sample.sample_name); + this.reloadSamples = false; }); }, diff --git a/src/pinia/modules/project/defaultState.ts b/src/pinia/modules/project/defaultState.ts index 7512c335..645b566e 100644 --- a/src/pinia/modules/project/defaultState.ts +++ b/src/pinia/modules/project/defaultState.ts @@ -17,6 +17,7 @@ interface configState { diffMode: boolean; diffUserId: string; reloadProjects: boolean; + reloadSamples: boolean; shownFeatures: string[]; shownMeta: string[]; annotationFeatures: annotationFeatures_t; @@ -45,6 +46,7 @@ export default function defaultState(): configState { diffMode: false, diffUserId: '', reloadProjects: false, + reloadSamples: false, shownFeatures: ['FORM', 'UPOS', 'LEMMA', 'MISC.Gloss'], shownMeta: ['text_en'], languagesList: languages, diff --git a/src/router/index.ts b/src/router/index.ts index 84500188..590a0e7a 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -49,8 +49,8 @@ export default route((/* { store, ssrContext } */) => { const configStore = useProjectStore(); const klangStore = useKlangStore(); if (to.params.projectname && to.params.projectname !== from.params.projectname) { - // store.dispatch('config/fetchProjectConlluSchema', {projectname: to.params.projectname}) configStore.fetchProjectSettings({ projectname: to.params.projectname } as { projectname: string }); + configStore.reloadSamples = true; } if (to.params.kprojectname) { klangStore.fetchKlangProjectSettings({