mirror of https://github.com/doccano/doccano.git
6 changed files with 222 additions and 45 deletions
Unified View
Diff Options
-
66frontend/components/containers/labels/LabelActionMenu.vue
-
30frontend/components/containers/labels/LabelCreationButton.vue
-
39frontend/components/containers/labels/LabelDeletionButton.vue
-
87frontend/components/organisms/labels/LabelImportForm.vue
-
10frontend/pages/projects/_id/labels/index.vue
-
35frontend/store/labels.js
@ -0,0 +1,66 @@ |
|||||
|
<template> |
||||
|
<div> |
||||
|
<action-menu |
||||
|
:items="menuItems" |
||||
|
@create="createDialog=true" |
||||
|
@upload="importDialog=true" |
||||
|
@download="handleDownload" |
||||
|
/> |
||||
|
<base-dialog :dialog="createDialog"> |
||||
|
<label-creation-form |
||||
|
:create-label="createLabel" |
||||
|
@close="createDialog=false" |
||||
|
/> |
||||
|
</base-dialog> |
||||
|
<base-dialog :dialog="importDialog"> |
||||
|
<label-import-form |
||||
|
:import-label="importLabels" |
||||
|
@close="importDialog=false" |
||||
|
/> |
||||
|
</base-dialog> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import { mapActions } from 'vuex' |
||||
|
import ActionMenu from '@/components/molecules/ActionMenu' |
||||
|
import BaseDialog from '@/components/molecules/BaseDialog' |
||||
|
import LabelCreationForm from '@/components/organisms/labels/LabelCreationForm' |
||||
|
import LabelImportForm from '@/components/organisms/labels/LabelImportForm' |
||||
|
|
||||
|
export default { |
||||
|
components: { |
||||
|
ActionMenu, |
||||
|
BaseDialog, |
||||
|
LabelCreationForm, |
||||
|
LabelImportForm |
||||
|
}, |
||||
|
|
||||
|
data() { |
||||
|
return { |
||||
|
createDialog: false, |
||||
|
importDialog: false, |
||||
|
menuItems: [ |
||||
|
{ title: 'Create a Label', icon: 'mdi-pencil', event: 'create' }, |
||||
|
{ title: 'Import Labels', icon: 'mdi-upload', event: 'upload' }, |
||||
|
{ title: 'Export Labels', icon: 'mdi-download', event: 'download' } |
||||
|
] |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
created() { |
||||
|
this.setCurrentProject(this.$route.params.id) |
||||
|
}, |
||||
|
|
||||
|
methods: { |
||||
|
...mapActions('labels', ['createLabel', 'importLabels', 'exportLabels']), |
||||
|
...mapActions('projects', ['setCurrentProject']), |
||||
|
|
||||
|
handleDownload() { |
||||
|
this.exportLabels({ |
||||
|
projectId: this.$route.params.id |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
@ -1,30 +0,0 @@ |
|||||
<template> |
|
||||
<base-modal |
|
||||
text="Create" |
|
||||
:is-create="true" |
|
||||
> |
|
||||
<template v-slot="slotProps"> |
|
||||
<label-creation-form |
|
||||
:create-label="createLabel" |
|
||||
@close="slotProps.close" |
|
||||
/> |
|
||||
</template> |
|
||||
</base-modal> |
|
||||
</template> |
|
||||
|
|
||||
<script> |
|
||||
import { mapActions } from 'vuex' |
|
||||
import BaseModal from '@/components/molecules/BaseModal' |
|
||||
import LabelCreationForm from '@/components/organisms/labels/LabelCreationForm' |
|
||||
|
|
||||
export default { |
|
||||
components: { |
|
||||
BaseModal, |
|
||||
LabelCreationForm |
|
||||
}, |
|
||||
|
|
||||
methods: { |
|
||||
...mapActions('labels', ['createLabel']) |
|
||||
} |
|
||||
} |
|
||||
</script> |
|
@ -0,0 +1,87 @@ |
|||||
|
<template> |
||||
|
<base-card |
||||
|
title="Upload Label" |
||||
|
agree-text="Upload" |
||||
|
cancel-text="Cancel" |
||||
|
:disabled="!valid" |
||||
|
@agree="create" |
||||
|
@cancel="cancel" |
||||
|
> |
||||
|
<template #content> |
||||
|
<v-form |
||||
|
ref="form" |
||||
|
v-model="valid" |
||||
|
> |
||||
|
<v-alert |
||||
|
v-show="showError" |
||||
|
v-model="showError" |
||||
|
type="error" |
||||
|
dismissible |
||||
|
> |
||||
|
The file could not be uploaded. Maybe invalid format. |
||||
|
Please check available formats carefully. |
||||
|
</v-alert> |
||||
|
<h2>Select a file</h2> |
||||
|
<v-file-input |
||||
|
v-model="file" |
||||
|
accept=".json" |
||||
|
:rules="uploadFileRules" |
||||
|
label="File input" |
||||
|
/> |
||||
|
</v-form> |
||||
|
</template> |
||||
|
</base-card> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import BaseCard from '@/components/molecules/BaseCard' |
||||
|
import { uploadFileRules } from '@/rules/index' |
||||
|
|
||||
|
export default { |
||||
|
components: { |
||||
|
BaseCard |
||||
|
}, |
||||
|
props: { |
||||
|
importLabel: { |
||||
|
type: Function, |
||||
|
default: () => {}, |
||||
|
required: true |
||||
|
} |
||||
|
}, |
||||
|
data() { |
||||
|
return { |
||||
|
valid: false, |
||||
|
file: null, |
||||
|
uploadFileRules, |
||||
|
showError: false |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
methods: { |
||||
|
cancel() { |
||||
|
this.$emit('close') |
||||
|
}, |
||||
|
validate() { |
||||
|
return this.$refs.form.validate() |
||||
|
}, |
||||
|
reset() { |
||||
|
this.$refs.form.reset() |
||||
|
}, |
||||
|
create() { |
||||
|
if (this.validate()) { |
||||
|
this.importLabel({ |
||||
|
projectId: this.$route.params.id, |
||||
|
file: this.file |
||||
|
}) |
||||
|
.then((response) => { |
||||
|
this.reset() |
||||
|
this.cancel() |
||||
|
}) |
||||
|
.catch(() => { |
||||
|
this.showError = true |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
Write
Preview
Loading…
Cancel
Save