Skip to content

Commit

Permalink
minor fixes for lexicon
Browse files Browse the repository at this point in the history
  • Loading branch information
khansadaoudi committed Sep 20, 2024
1 parent 92ea517 commit 8814a22
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 106 deletions.
140 changes: 37 additions & 103 deletions src/components/lexicon/LexiconMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,7 @@
<q-card-section>
<div class="text-h6 q-mb-md">{{ $t('lexicon.lexiconTitle') }}</div>
<div class="row q-gutter-md">
<div class="col-3">
<q-select
dense
v-model="selectedSamples"
outlined
multiple
:options="sampleIds"
use-chips
stack-label
:label="$t('lexicon.selectSample')"
/>
</div>
<div class="col-3">
<div class="col">
<q-select
dense
v-model="principalFeatures"
Expand All @@ -27,7 +15,7 @@
:label="$t('lexicon.similarFeatures')"
/>
</div>
<div class="col-3">
<div class="col">
<q-select
dense
:disable="!principalFeatures.length"
Expand All @@ -40,82 +28,18 @@
:label="$t('lexicon.ambiguousFeatures')"
/>
</div>
<div>
<q-tooltip content-class="bg-white text-primary">{{ $t('lexicon.selectTreeType') }}</q-tooltip>
<q-btn-dropdown
:disable="!principalFeatures.length"
class="float-right"
size="md"
outline
color="primary"
label=" get Lexicon"
>
<q-list>
<q-item v-if="canSaveTreeInProject && collaborativeMode" v-close-popup clickable @click="fetchLexicon_('user')">
<q-item-section avatar>
<q-avatar v-if="isLoggedIn" size="1.2rem">
<img :src="avatar" alt="avatar" />
</q-avatar>
<q-icon v-else name="account_circle" />
</q-item-section>
<q-item-section>
<q-item-label>{{ $t('lexicon.lexiconOptions[0]') }}</q-item-label>
</q-item-section>
</q-item>

<q-item
v-close-popup
v-if="canSeeOtherUsersTrees && canSaveTreeInProject && collaborativeMode"
clickable
@click="fetchLexicon_('user_recent')"
>
<q-item-section avatar>
<q-avatar v-if="isLoggedIn" size="1.2rem">
<img :src="avatar" alt="avatar" />
<q-badge floating transparent color="principal">+</q-badge>
</q-avatar>
<q-icon v-else name="account_circle" />
</q-item-section>
<q-item-section>
<q-item-label>{{ $t('lexicon.lexiconOptions[1]') }}</q-item-label>
</q-item-section>
</q-item>

<q-item v-if="canSeeOtherUsersTrees && collaborativeMode" v-close-popup clickable @click="fetchLexicon_('all')">
<q-item-section avatar>
<q-icon name="groups" />
</q-item-section>
<q-item-section>
<q-item-label>{{ $t('lexicon.lexiconOptions[2]') }}</q-item-label>
</q-item-section>
</q-item>

<q-item v-if="canSeeOtherUsersTrees && collaborativeMode" v-close-popup clickable @click="fetchLexicon_('recent')">
<q-item-section avatar>
<q-icon name="schedule" />
</q-item-section>
<q-item-section>
<q-item-label>{{ $t('lexicon.lexiconOptions[3]') }}</q-item-label>
</q-item-section>
</q-item>

<q-item v-if="canSeeOtherUsersTrees" v-close-popup clickable @click="fetchLexicon_('validated')">
<q-item-section avatar>
<q-icon name="verified" />
</q-item-section>
<q-item-section>
<q-item-label>{{ $t('lexicon.lexiconOptions[4]') }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
<div class="col-6">
<TreesTypeSelect grew-option="REWRITE" :samples="samples" @selected-value="getSelectedValues" />
</div>
<div class="col">
<q-btn :disable="!principalFeatures.length" color="primary" label="Generate lexicon" @click="fetchLexicon_"></q-btn>
</div>
</div>
</q-card-section>
<q-card-section v-if="isShowLexiconTable" class="q-gutter-md">
<LexiconModificationDialog :features="features" v-if="lexiconItems.length >= 1" />
<div v-if="lexiconItemsModified.length >= 1">
<q-btn outline color="primary" icon="refresh" @click="fetchLexicon_(lexiconType)"> reload</q-btn>
<q-btn outline color="primary" icon="refresh" @click="fetchLexicon_()">reload</q-btn>
</div>
<LexiconTableBase
v-show="lexiconItemsModified.length >= 1"
Expand All @@ -124,9 +48,8 @@
:passed-lexicon-items="lexiconItemsModified"
:lexicon-loading="false"
:features="features"
:key="lexiconItemsModified.length"
:lexicon-type="lexiconType"
:sample-ids="sampleIds"
:lexicon-type="data.treeType"
:sample-ids="sampleNames"
></LexiconTableBase>
<LexiconTableBase
title="Lexicon"
Expand All @@ -135,50 +58,50 @@
:lexicon-loading="lexiconLoading"
:features="features"
:key="features.length"
:lexicon-type="lexiconType"
:sample-ids="sampleIds"
:lexicon-type="data.treeType"
:sample-ids="sampleNames"
>
</LexiconTableBase>
</q-card-section>
</q-card>
</template>

<script lang="ts">
import LexiconModificationDialog from './LexiconModificationDialog.vue';
import LexiconTableBase from './LexiconTableBase.vue';
import TreesTypeSelect from '../shared/TreesTypeSelect.vue';
import { mapActions, mapState, mapWritableState } from 'pinia';
import { useLexiconStore } from 'src/pinia/modules/lexicon';
import { useProjectStore } from 'src/pinia/modules/project';
import { useUserStore } from 'src/pinia/modules/user';
import { PropType, defineComponent } from 'vue';
import LexiconModificationDialog from './LexiconModificationDialog.vue';
import LexiconTableBase from './LexiconTableBase.vue';
import { sample_t } from 'src/api/backend-types';
import { notifyMessage } from 'src/utils/notify';
export default defineComponent({
name: 'LexiconMain',
props: {
sampleIds: {
type: Object as PropType<string[]>,
samples: {
type: Object as PropType<sample_t[]>,
default: [],
},
},
components: {
LexiconTableBase,
LexiconModificationDialog,
TreesTypeSelect,
},
data() {
const features: string[] = [];
const selectedSamples: string[] = [];
const data: { selectedSamples: string[]; treeType: string; otherUser: string } = { selectedSamples: [], treeType: 'recent', otherUser: '' };
return {
lexiconType: '',
features,
selectedSamples,
isShowLexiconTable: false,
data,
};
},
computed: {
...mapState(useProjectStore, ['name', 'annotationFeatures', 'canSeeOtherUsersTrees', 'canSaveTreeInProject', 'collaborativeMode']),
...mapState(useUserStore, ['isLoggedIn', 'isSuperAdmin', 'avatar']),
...mapState(useProjectStore, ['name', 'annotationFeatures']),
...mapState(useLexiconStore, ['lexiconItems', 'lexiconLoading', 'lexiconItemsModified', 'principalFeatures', 'secondaryFeatures']),
...mapWritableState(useLexiconStore, ['principalFeatures', 'secondaryFeatures']),
principalFeatureOptions() {
Expand All @@ -187,10 +110,13 @@ export default defineComponent({
secondaryFeatureOptions() {
return this.principalFeatureOptions.filter((value) => !this.principalFeatures.includes(value));
},
sampleNames() {
return this.samples.map((sample) => sample.sampleName);
}
},
methods: {
...mapActions(useLexiconStore, ['fetchLexicon']),
fetchLexicon_(lexiconType: string) {
fetchLexicon_() {
let prune: number;
this.features = this.principalFeatures.concat(this.secondaryFeatures);
Expand All @@ -200,10 +126,18 @@ export default defineComponent({
} else {
prune = 0;
}
const data = { samplenames: this.selectedSamples, lexiconType: lexiconType, features: this.features, prune: prune };
const data = {
sampleNames: this.data.selectedSamples,
lexiconType: this.data.treeType,
otherUser: this.data.otherUser,
features: this.features,
prune: prune
};
this.fetchLexicon(this.name, data);
this.isShowLexiconTable = true;
this.lexiconType = lexiconType;
},
getSelectedValues(val: any) {
this.data = val;
},
displayMessage() {
let message = 'We search all lexicon entries that have the same ';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<ParsingPanel :samples="samples" :parentGetProjectSamples="getProjectSamples"></ParsingPanel>
</q-tab-panel>
<q-tab-panel class="q-pa-none" name="lexicon">
<LexiconMain :sample-ids="sampleNames"></LexiconMain>
<LexiconMain :samples="samples"></LexiconMain>
</q-tab-panel>
<q-tab-panel class="q-pa-none" name="relation_table">
<RelationTable :samples="samples"></RelationTable>
Expand Down
4 changes: 2 additions & 2 deletions src/pinia/modules/lexicon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export const useLexiconStore = defineStore('lexicon', {
this.isShowLexiconModification = false;
this.couplesLexiconItemsBeforeAfter = [];
},
fetchLexicon(projectname: string, data: any) {
fetchLexicon(projectName: string, data: any) {
this.lexiconLoading = true;
this.purgeCurrentState();
api
.getLexicon(projectname, data)
.getLexicon(projectName, data)
.then((response) => {
this.lexiconLoading = false;
const lexiconItems = [];
Expand Down

0 comments on commit 8814a22

Please sign in to comment.