-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
899bc2e
commit 3e1088e
Showing
4 changed files
with
106 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<template> | ||
<q-card style="min-width: 50vw"> | ||
<q-bar class="bg-primary text-white"> | ||
<q-space /> | ||
<q-btn v-close-popup flat dense icon="close" /> | ||
</q-bar> | ||
<q-card-section> | ||
<div class="text-h6 text-left">Rename Sample</div> | ||
</q-card-section> | ||
<q-separator /> | ||
<q-card-section> | ||
<q-input | ||
outlined | ||
v-model="newSampleName" | ||
label="Rename sample" | ||
lazy-rules | ||
:rules="[ | ||
(val) => (val && val.length > 0) || 'Sample name must not be empty', | ||
(val) => (val && !val.endsWith(' ')) || 'Sample must not end with white space', | ||
]" | ||
/> | ||
<div class="flex flex-center"> | ||
<q-btn v-close-popup :disable="disableBtn" color="primary" label="Rename sample" @click="renameSample()" /> | ||
</div> | ||
</q-card-section> | ||
</q-card> | ||
</template> | ||
<script lang="ts"> | ||
import { api } from 'src/boot/axios'; | ||
import { mapWritableState, mapState } from 'pinia'; | ||
import { useProjectStore } from 'src/pinia/modules/project'; | ||
import { notifyError, notifyMessage } from 'src/utils/notify'; | ||
import { defineComponent, PropType } from 'vue'; | ||
export default defineComponent({ | ||
name: 'RenameSample', | ||
props: { | ||
sampleName: { | ||
type: String as PropType<string>, | ||
required: true, | ||
} | ||
}, | ||
data() { | ||
return { | ||
newSampleName: '', | ||
} | ||
}, | ||
computed: { | ||
...mapState(useProjectStore, ['name']), | ||
...mapWritableState(useProjectStore, ['reloadSamples']), | ||
disableBtn() { | ||
return this.newSampleName === '' && this.newSampleName.endsWith(' '); | ||
} | ||
}, | ||
methods: { | ||
renameSample() { | ||
const data = { newSampleName: this.newSampleName }; | ||
api | ||
.renameSample(this.name, this.sampleName, data) | ||
.then(() => { | ||
notifyMessage({ message: 'The sample name is modified' }); | ||
this.reloadSamples = true; | ||
}) | ||
.catch((error) => { | ||
notifyError({ error: error }); | ||
}); | ||
}, | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters