-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Admin to Update Project Description (#632)
allow updating project description Signed-off-by: Vanessa Fotso <[email protected]>
- Loading branch information
1 parent
509ff27
commit 0d8e583
Showing
5 changed files
with
103 additions
and
76 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
This file was deleted.
Oops, something went wrong.
85 changes: 85 additions & 0 deletions
85
app/javascript/components/projects/UpdateProjectDetailsModal.vue
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,85 @@ | ||
<template> | ||
<span> | ||
<b-button | ||
class="px-2 m-2" | ||
:variant="is_project_table ? 'primary' : 'success'" | ||
@click="showModal()" | ||
> | ||
<i v-if="is_project_table" class="mdi mdi-wrench" aria-hidden="true" /> | ||
{{ is_project_table ? "Update" : "Update Details" }} | ||
</b-button> | ||
<b-modal | ||
ref="updateProjectDetailsModal" | ||
title="Update Project Details" | ||
size="lg" | ||
ok-title="Update Project Details" | ||
@show="resetModal()" | ||
@ok="updateProjectDetails()" | ||
> | ||
<b-form @submit="updateProjectDetails()"> | ||
<!-- Name of the project --> | ||
<b-form-group label="Name"> | ||
<b-form-input v-model="name" placeholder="Project Name" required autocomplete="off" /> | ||
</b-form-group> | ||
<!-- Description --> | ||
<b-form-group label="Description"> | ||
<b-form-textarea v-model="description" placeholder="" rows="3" /> | ||
</b-form-group> | ||
|
||
<!-- Allow the enter button to submit the form --> | ||
<b-btn type="submit" class="d-none" @click.prevent="updateProjectDetails()" /> | ||
</b-form> | ||
</b-modal> | ||
</span> | ||
</template> | ||
|
||
<script> | ||
import axios from "axios"; | ||
import FormMixinVue from "../../mixins/FormMixin.vue"; | ||
import AlertMixinVue from "../../mixins/AlertMixin.vue"; | ||
export default { | ||
name: "UpdateProjectDetailsModal", | ||
mixins: [AlertMixinVue, FormMixinVue], | ||
props: { | ||
project: { | ||
type: Object, | ||
required: true, | ||
}, | ||
is_project_table: { | ||
type: Boolean, | ||
required: false, | ||
default: false, | ||
}, | ||
}, | ||
data: function () { | ||
return { | ||
name: this.project.name, | ||
description: this.project.description, | ||
}; | ||
}, | ||
methods: { | ||
resetModal: function () { | ||
this.name = this.project.name; | ||
this.description = this.project.description; | ||
}, | ||
showModal: function () { | ||
this.$refs["updateProjectDetailsModal"].show(); | ||
}, | ||
updateProjectDetails: function () { | ||
this.$refs["updateProjectDetailsModal"].hide(); | ||
let payload = { project: { name: this["name"], description: this["description"] } }; | ||
axios | ||
.put(`/projects/${this.project.id}`, payload) | ||
.then(this.editProjectSuccess) | ||
.catch(this.alertOrNotifyResponse); | ||
}, | ||
editProjectSuccess: function (response) { | ||
this.alertOrNotifyResponse(response); | ||
this.$emit("projectUpdated"); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped></style> |