Browse Source

Extract form button

pull/341/head
Hironsan 5 years ago
parent
commit
4bded490cf
5 changed files with 82 additions and 86 deletions
  1. 42
      frontend/components/molecules/BaseCard.vue
  2. 41
      frontend/components/organisms/MemberAdditionForm.vue
  3. 27
      frontend/components/organisms/MemberDeletionForm.vue
  4. 31
      frontend/components/organisms/ProjectCreationForm.vue
  5. 27
      frontend/components/organisms/ProjectDeletionForm.vue

42
frontend/components/molecules/BaseCard.vue

@ -12,7 +12,24 @@
</v-container> </v-container>
<v-card-actions> <v-card-actions>
<v-spacer /> <v-spacer />
<slot name="actions" />
<v-btn
class="text-capitalize"
text
color="primary"
data-test="cancel-button"
@click="cancel"
>
{{ cancelText }}
</v-btn>
<v-btn
class="text-none"
text
:disabled="disabled"
data-test="delete-button"
@click="agree"
>
{{ agreeText }}
</v-btn>
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</template> </template>
@ -24,6 +41,29 @@ export default {
type: String, type: String,
default: '', default: '',
required: true required: true
},
cancelText: {
type: String,
default: '',
required: true
},
agreeText: {
type: String,
default: '',
required: true
},
disabled: {
type: Boolean,
default: false
}
},
methods: {
agree() {
this.$emit('agree')
},
cancel() {
this.$emit('cancel')
} }
} }
} }

41
frontend/components/organisms/MemberAdditionForm.vue

@ -1,5 +1,12 @@
<template> <template>
<base-card title="Add Member">
<base-card
title="Add Member"
agree-text="Add"
cancel-text="Cancel"
:disabled="!valid"
@agree="create"
@cancel="cancel"
>
<template #content> <template #content>
<v-form <v-form
ref="form" ref="form"
@ -10,6 +17,7 @@
:items="items" :items="items"
:loading="isLoading" :loading="isLoading"
:search-input.sync="username" :search-input.sync="username"
:rules="userRules"
color="white" color="white"
hide-no-data hide-no-data
hide-selected hide-selected
@ -22,31 +30,12 @@
<v-select <v-select
v-model="role" v-model="role"
:items="roles" :items="roles"
:rules="roleRules"
label="Role" label="Role"
prepend-icon="mdi-account-card-details-outline" prepend-icon="mdi-account-card-details-outline"
/> />
</v-form> </v-form>
</template> </template>
<template #actions>
<v-btn
class="text-capitalize"
text
color="primary"
data-test="cancel-button"
@click="cancel"
>
Cancel
</v-btn>
<v-btn
:disabled="!valid"
class="text-none"
text
data-test="create-button"
@click="create"
>
Add
</v-btn>
</template>
</base-card> </base-card>
</template> </template>
@ -71,12 +60,18 @@ export default {
}, },
data() { data() {
return { return {
valid: true,
valid: false,
username: '', username: '',
role: null, role: null,
isLoading: false, isLoading: false,
selectedUser: null, selectedUser: null,
roles: ['Admin', 'Member']
roles: ['Admin', 'Member'],
userRules: [
v => !!v || 'User is required'
],
roleRules: [
v => !!v || 'Role is required'
]
} }
}, },

27
frontend/components/organisms/MemberDeletionForm.vue

@ -1,5 +1,11 @@
<template> <template>
<base-card title="Remove Member">
<base-card
title="Remove Member"
agree-text="Yes, remove"
cancel-text="Cancel"
@agree="removeMember"
@cancel="cancel"
>
<template #content> <template #content>
Are you sure you want to remove these members? Are you sure you want to remove these members?
<v-list dense> <v-list dense>
@ -10,25 +16,6 @@
</v-list-item> </v-list-item>
</v-list> </v-list>
</template> </template>
<template #actions>
<v-btn
class="text-capitalize"
text
color="primary"
data-test="cancel-button"
@click="cancel"
>
Cancel
</v-btn>
<v-btn
class="text-none"
text
data-test="delete-button"
@click="removeMember"
>
Yes, remove
</v-btn>
</template>
</base-card> </base-card>
</template> </template>

31
frontend/components/organisms/ProjectCreationForm.vue

@ -1,5 +1,12 @@
<template> <template>
<base-card title="Add Project">
<base-card
title="Add Project"
agree-text="Create"
cancel-text="Cancel"
:disabled="!valid"
@agree="create"
@cancel="cancel"
>
<template #content> <template #content>
<v-form <v-form
ref="form" ref="form"
@ -33,26 +40,6 @@
/> />
</v-form> </v-form>
</template> </template>
<template #actions>
<v-btn
class="text-capitalize"
text
color="primary"
data-test="cancel-button"
@click="cancel"
>
Cancel
</v-btn>
<v-btn
:disabled="!valid"
class="text-none"
text
data-test="create-button"
@click="create"
>
Create
</v-btn>
</template>
</base-card> </base-card>
</template> </template>
@ -80,7 +67,7 @@ export default {
}, },
data() { data() {
return { return {
valid: true,
valid: false,
name: '', name: '',
description: '', description: '',
projectType: null, projectType: null,

27
frontend/components/organisms/ProjectDeletionForm.vue

@ -1,5 +1,11 @@
<template> <template>
<base-card title="Delete Project">
<base-card
title="Delete Project"
agree-text="Yes, delete"
cancel-text="Cancel"
@agree="deleteProject"
@cancel="cancel"
>
<template #content> <template #content>
Are you sure you want to delete these projects? Are you sure you want to delete these projects?
<v-list dense> <v-list dense>
@ -10,25 +16,6 @@
</v-list-item> </v-list-item>
</v-list> </v-list>
</template> </template>
<template #actions>
<v-btn
class="text-capitalize"
text
color="primary"
data-test="cancel-button"
@click="cancel"
>
Cancel
</v-btn>
<v-btn
class="text-none"
text
data-test="delete-button"
@click="deleteProject"
>
Yes, delete
</v-btn>
</template>
</base-card> </base-card>
</template> </template>

Loading…
Cancel
Save