2019-05-13 21:44:02 +00:00
|
|
|
<template>
|
|
|
|
|
<div>
|
2019-05-21 10:13:21 +00:00
|
|
|
<h4 class="mb-4 text-xl font-bold">New Organization</h4>
|
2019-05-13 21:44:02 +00:00
|
|
|
<div class="field">
|
|
|
|
|
<div class="control">
|
2019-05-21 10:13:21 +00:00
|
|
|
<input
|
|
|
|
|
class="mb-4 appearance-none border rounded py-2 px-3 leading-tight focus:outline-none focus:shadow-outline"
|
|
|
|
|
type="text"
|
|
|
|
|
placeholder="Organization name"
|
|
|
|
|
v-model="orgName"
|
2022-02-23 15:13:44 +00:00
|
|
|
/>
|
2019-05-13 21:44:02 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2019-05-21 10:13:21 +00:00
|
|
|
<div class="mb-4">
|
|
|
|
|
<label>
|
2022-02-23 15:13:44 +00:00
|
|
|
<input type="checkbox" v-model="orgIsPrivate" />
|
2019-05-21 10:13:21 +00:00
|
|
|
Private
|
|
|
|
|
</label>
|
2019-05-13 21:44:02 +00:00
|
|
|
</div>
|
2019-05-21 10:13:21 +00:00
|
|
|
<button
|
|
|
|
|
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
|
|
|
|
|
@click="createOrg()"
|
2022-02-23 15:13:44 +00:00
|
|
|
>
|
|
|
|
|
Create Organization
|
|
|
|
|
</button>
|
2019-05-21 10:13:21 +00:00
|
|
|
<div
|
|
|
|
|
v-if="createOrgError"
|
|
|
|
|
class="mb-10 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative"
|
|
|
|
|
role="alert"
|
|
|
|
|
>
|
|
|
|
|
<span class="block sm:inline">{{ createOrgError }}</span>
|
2019-05-13 21:44:02 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-02-23 15:13:44 +00:00
|
|
|
import { createOrganization } from '@/util/data.js';
|
2019-05-13 21:44:02 +00:00
|
|
|
|
2022-02-23 15:13:44 +00:00
|
|
|
import { ownerLink } from '@/util/link.js';
|
2019-05-13 21:44:02 +00:00
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
components: {},
|
2022-02-23 15:13:44 +00:00
|
|
|
name: 'createorganization',
|
2019-05-13 21:44:02 +00:00
|
|
|
props: {},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
createOrgError: null,
|
|
|
|
|
orgIsPrivate: false,
|
2022-02-23 15:13:44 +00:00
|
|
|
orgName: null,
|
2019-05-13 21:44:02 +00:00
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
resetErrors() {
|
|
|
|
|
this.createOrgError = null;
|
|
|
|
|
},
|
|
|
|
|
async createOrg() {
|
|
|
|
|
this.resetErrors();
|
|
|
|
|
|
2022-02-23 15:13:44 +00:00
|
|
|
let visibility = 'public';
|
2019-05-13 21:44:02 +00:00
|
|
|
if (this.orgIsPrivate) {
|
2022-02-23 15:13:44 +00:00
|
|
|
visibility = 'private';
|
2019-05-13 21:44:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let { error } = await createOrganization(this.orgName, visibility);
|
|
|
|
|
if (error) {
|
|
|
|
|
this.createOrgError = error;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-23 15:13:44 +00:00
|
|
|
this.$router.push(ownerLink('org', this.orgName));
|
|
|
|
|
},
|
2019-05-13 21:44:02 +00:00
|
|
|
},
|
2022-02-23 15:13:44 +00:00
|
|
|
created: async function () {},
|
2019-05-13 21:44:02 +00:00
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
2022-02-23 15:13:44 +00:00
|
|
|
<style scoped lang="scss"></style>
|