-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ : organization creation & deletion
resolves #107
- Loading branch information
Showing
7 changed files
with
185 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<template> | ||
<div> | ||
<b-modal | ||
id="new-organization-modal" | ||
title="New Organization" | ||
ok-title="Create" | ||
auto-focus-button="ok" | ||
@ok="createOrg" | ||
@cancel="newOrganizationName = ''" | ||
@close="newOrganizationName = ''" | ||
> | ||
<b-input | ||
v-model="newOrganizationName" | ||
autofocus | ||
/> | ||
</b-modal> | ||
|
||
<b-button | ||
v-b-modal.new-organization-modal | ||
variant="primary" | ||
> | ||
<font-awesome-icon | ||
icon="plus" | ||
class="icon" | ||
/> | ||
Create new organization | ||
</b-button> | ||
|
||
<div class="block mt-3"> | ||
<b-table | ||
:items="teams" | ||
:fields="fields" | ||
striped | ||
fixed | ||
outlined | ||
> | ||
<template v-slot:cell(edit)="row"> | ||
<b-button | ||
variant="outline-danger" | ||
class="ml-1" | ||
@click="deleteOrg(row.item)" | ||
> | ||
<font-awesome-icon | ||
:icon="['far', 'trash-alt']" | ||
class="icon" | ||
/> | ||
</b-button> | ||
</template> | ||
</b-table> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { createOrganization, deleteOrganization, getTeams } from '@/shared/api/teams-api'; | ||
import { displayNotification } from '@/shared/services/modal-service'; | ||
export default { | ||
name: 'AppOrganizations', | ||
data: () => ({ | ||
teams: [], | ||
newOrganizationName: '', | ||
fields: [ | ||
{ key: 'id', label: 'Name', sortable: true }, | ||
{ key: 'edit' }, | ||
], | ||
}), | ||
async created() { | ||
await this.refresh(); | ||
}, | ||
methods: { | ||
async refresh() { | ||
this.teams = await getTeams(); | ||
}, | ||
async createOrg() { | ||
await createOrganization({ id: this.newOrganizationName }) | ||
.then(() => displayNotification(this, { message: 'Organization created', variant: 'success' })) | ||
.then(this.refresh) | ||
.catch(({ error, message }) => displayNotification(this, { title: error, message, variant: 'danger' })); | ||
}, | ||
async deleteOrg(organization) { | ||
await deleteOrganization(organization.id) | ||
.then(() => displayNotification(this, { message: 'Organization deleted', variant: 'success' })) | ||
.then(this.refresh) | ||
.catch(({ error, message }) => displayNotification(this, { title: error, message, variant: 'danger' })); | ||
}, | ||
}, | ||
}; | ||
</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
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
import axios from 'axios'; | ||
|
||
export const getTeams = async () => axios.get('/api/teams'); | ||
|
||
export const deleteOrganization = async (organizationId) => axios.delete(`/api/teams/${organizationId}`); | ||
|
||
export const createOrganization = async (organization) => axios.post('/api/teams', organization); |
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 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