mirror of https://github.com/doccano/doccano.git
Hironsan
5 years ago
13 changed files with 275 additions and 190 deletions
Unified View
Diff Options
-
1frontend/api/routes/labels.js
-
30frontend/components/containers/LabelCreationButton.vue
-
35frontend/components/containers/LabelDeletionButton.vue
-
2frontend/components/containers/MemberAdditionButton.vue
-
24frontend/components/containers/MemberDeletionButton.vue
-
2frontend/components/containers/ProjectCreationButton.vue
-
24frontend/components/containers/ProjectDeletionButton.vue
-
80frontend/components/organisms/ConfirmDialog.vue
-
99frontend/components/organisms/LabelCreationForm.vue
-
47frontend/components/organisms/MemberDeletionForm.vue
-
47frontend/components/organisms/ProjectDeletionForm.vue
-
68frontend/pages/projects/_id/labels/index.vue
-
6frontend/store/labels.js
@ -0,0 +1,30 @@ |
|||||
|
<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/LabelCreationForm' |
||||
|
|
||||
|
export default { |
||||
|
components: { |
||||
|
BaseModal, |
||||
|
LabelCreationForm |
||||
|
}, |
||||
|
|
||||
|
methods: { |
||||
|
...mapActions('labels', ['createLabel']) |
||||
|
} |
||||
|
} |
||||
|
</script> |
@ -0,0 +1,35 @@ |
|||||
|
<template> |
||||
|
<confirm-dialog |
||||
|
title="Delete Label" |
||||
|
message="Are you sure you want to remove these labels from this project?" |
||||
|
item-key="text" |
||||
|
:disabled="!isLabelSelected" |
||||
|
:items="selected" |
||||
|
@ok="handleDeleteLabel()" |
||||
|
/> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import { mapState, mapGetters, mapActions } from 'vuex' |
||||
|
import ConfirmDialog from '@/components/organisms/ConfirmDialog' |
||||
|
|
||||
|
export default { |
||||
|
components: { |
||||
|
ConfirmDialog |
||||
|
}, |
||||
|
|
||||
|
computed: { |
||||
|
...mapState('labels', ['selected']), |
||||
|
...mapGetters('labels', ['isLabelSelected']) |
||||
|
}, |
||||
|
|
||||
|
methods: { |
||||
|
...mapActions('labels', ['deleteLabel']), |
||||
|
|
||||
|
handleDeleteLabel() { |
||||
|
const projectId = this.$route.params.id |
||||
|
this.deleteLabel(projectId) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
@ -0,0 +1,80 @@ |
|||||
|
<template> |
||||
|
<base-modal |
||||
|
text="Delete" |
||||
|
:disabled="disabled" |
||||
|
> |
||||
|
<template v-slot="slotProps"> |
||||
|
<base-card |
||||
|
:title="title" |
||||
|
:agree-text="buttonTrueText" |
||||
|
:cancel-text="buttonFalseText" |
||||
|
@agree="ok(); slotProps.close()" |
||||
|
@cancel="slotProps.close" |
||||
|
> |
||||
|
<template #content> |
||||
|
{{ message }} |
||||
|
<v-list dense> |
||||
|
<v-list-item v-for="(item, i) in items" :key="i"> |
||||
|
<v-list-item-content> |
||||
|
<v-list-item-title>{{ item[itemKey] }}</v-list-item-title> |
||||
|
</v-list-item-content> |
||||
|
</v-list-item> |
||||
|
</v-list> |
||||
|
</template> |
||||
|
</base-card> |
||||
|
</template> |
||||
|
</base-modal> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import BaseCard from '@/components/molecules/BaseCard' |
||||
|
import BaseModal from '@/components/molecules/BaseModal' |
||||
|
|
||||
|
export default { |
||||
|
components: { |
||||
|
BaseCard, |
||||
|
BaseModal |
||||
|
}, |
||||
|
|
||||
|
props: { |
||||
|
title: { |
||||
|
type: String, |
||||
|
default: '', |
||||
|
required: true |
||||
|
}, |
||||
|
message: { |
||||
|
type: String, |
||||
|
default: '', |
||||
|
required: true |
||||
|
}, |
||||
|
items: { |
||||
|
type: Array, |
||||
|
default: () => [], |
||||
|
required: true |
||||
|
}, |
||||
|
itemKey: { |
||||
|
type: String, |
||||
|
default: '', |
||||
|
required: true |
||||
|
}, |
||||
|
disabled: { |
||||
|
type: Boolean, |
||||
|
default: false |
||||
|
}, |
||||
|
buttonTrueText: { |
||||
|
type: String, |
||||
|
default: 'Yes' |
||||
|
}, |
||||
|
buttonFalseText: { |
||||
|
type: String, |
||||
|
default: 'Cancel' |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
methods: { |
||||
|
ok() { |
||||
|
this.$emit('ok') |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
@ -0,0 +1,99 @@ |
|||||
|
<template> |
||||
|
<base-card |
||||
|
title="Create Label" |
||||
|
agree-text="Create" |
||||
|
cancel-text="Cancel" |
||||
|
:disabled="!valid" |
||||
|
@agree="create" |
||||
|
@cancel="cancel" |
||||
|
> |
||||
|
<template #content> |
||||
|
<v-form |
||||
|
ref="form" |
||||
|
v-model="valid" |
||||
|
> |
||||
|
<v-text-field |
||||
|
v-model="labelName" |
||||
|
:rules="nameRules" |
||||
|
label="Label name" |
||||
|
prepend-icon="label" |
||||
|
/> |
||||
|
<v-select |
||||
|
v-model="suffixKey" |
||||
|
:items="keys" |
||||
|
label="Key" |
||||
|
prepend-icon="mdi-keyboard" |
||||
|
/> |
||||
|
<v-color-picker |
||||
|
v-model="color" |
||||
|
:rules="colorRules" |
||||
|
show-swatches |
||||
|
hide-mode-switch |
||||
|
width="800" |
||||
|
mode="hexa" |
||||
|
class="ma-2" |
||||
|
/> |
||||
|
</v-form> |
||||
|
</template> |
||||
|
</base-card> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import BaseCard from '@/components/molecules/BaseCard' |
||||
|
|
||||
|
export default { |
||||
|
components: { |
||||
|
BaseCard |
||||
|
}, |
||||
|
props: { |
||||
|
createLabel: { |
||||
|
type: Function, |
||||
|
default: () => {}, |
||||
|
required: true |
||||
|
}, |
||||
|
keys: { |
||||
|
type: Array, |
||||
|
default: () => 'abcdefghijklmnopqrstuvwxyz'.split('') |
||||
|
} |
||||
|
}, |
||||
|
data() { |
||||
|
return { |
||||
|
valid: false, |
||||
|
labelName: '', |
||||
|
suffixKey: '', |
||||
|
color: '', |
||||
|
nameRules: [ |
||||
|
v => !!v || 'Label name is required', |
||||
|
v => |
||||
|
(v && v.length <= 30) || 'Label name must be less than 30 characters' |
||||
|
], |
||||
|
colorRules: [ |
||||
|
v => !!v || 'Color is required' |
||||
|
] |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
methods: { |
||||
|
cancel() { |
||||
|
this.$emit('close') |
||||
|
}, |
||||
|
validate() { |
||||
|
return this.$refs.form.validate() |
||||
|
}, |
||||
|
reset() { |
||||
|
this.$refs.form.reset() |
||||
|
}, |
||||
|
create() { |
||||
|
if (this.validate()) { |
||||
|
this.createLabel({ |
||||
|
text: this.labelName, |
||||
|
suffix_key: this.suffixKey, |
||||
|
background_color: this.color |
||||
|
}) |
||||
|
this.reset() |
||||
|
this.cancel() |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
@ -1,47 +0,0 @@ |
|||||
<template> |
|
||||
<base-card |
|
||||
title="Remove Member" |
|
||||
agree-text="Yes, remove" |
|
||||
cancel-text="Cancel" |
|
||||
@agree="removeMember" |
|
||||
@cancel="cancel" |
|
||||
> |
|
||||
<template #content> |
|
||||
Are you sure you want to remove these members? |
|
||||
<v-list dense> |
|
||||
<v-list-item v-for="(item, i) in selected" :key="i"> |
|
||||
<v-list-item-content> |
|
||||
<v-list-item-title>{{ item.username }}</v-list-item-title> |
|
||||
</v-list-item-content> |
|
||||
</v-list-item> |
|
||||
</v-list> |
|
||||
</template> |
|
||||
</base-card> |
|
||||
</template> |
|
||||
|
|
||||
<script> |
|
||||
import BaseCard from '@/components/molecules/BaseCard' |
|
||||
|
|
||||
export default { |
|
||||
components: { |
|
||||
BaseCard |
|
||||
}, |
|
||||
|
|
||||
props: { |
|
||||
selected: { |
|
||||
type: Array, |
|
||||
default: () => [], |
|
||||
required: true |
|
||||
} |
|
||||
}, |
|
||||
|
|
||||
methods: { |
|
||||
cancel() { |
|
||||
this.$emit('close') |
|
||||
}, |
|
||||
removeMember() { |
|
||||
this.$emit('remove') |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
</script> |
|
@ -1,47 +0,0 @@ |
|||||
<template> |
|
||||
<base-card |
|
||||
title="Delete Project" |
|
||||
agree-text="Yes, delete" |
|
||||
cancel-text="Cancel" |
|
||||
@agree="deleteProject" |
|
||||
@cancel="cancel" |
|
||||
> |
|
||||
<template #content> |
|
||||
Are you sure you want to delete these projects? |
|
||||
<v-list dense> |
|
||||
<v-list-item v-for="(item, i) in selected" :key="i"> |
|
||||
<v-list-item-content> |
|
||||
<v-list-item-title>{{ item.name }}</v-list-item-title> |
|
||||
</v-list-item-content> |
|
||||
</v-list-item> |
|
||||
</v-list> |
|
||||
</template> |
|
||||
</base-card> |
|
||||
</template> |
|
||||
|
|
||||
<script> |
|
||||
import BaseCard from '@/components/molecules/BaseCard' |
|
||||
|
|
||||
export default { |
|
||||
components: { |
|
||||
BaseCard |
|
||||
}, |
|
||||
|
|
||||
props: { |
|
||||
selected: { |
|
||||
type: Array, |
|
||||
default: () => [], |
|
||||
required: true |
|
||||
} |
|
||||
}, |
|
||||
|
|
||||
methods: { |
|
||||
cancel() { |
|
||||
this.$emit('close') |
|
||||
}, |
|
||||
deleteProject() { |
|
||||
this.$emit('delete') |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
</script> |
|
Write
Preview
Loading…
Cancel
Save