Files
dougal-software/lib/www/client/source/src/components/app-bar-extension-project-list.vue
D. Berge c8b2047483 Refactor client-side access checks.
Go from a Vuex based to a mixin based approach.
2025-07-12 11:31:38 +02:00

87 lines
2.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<v-dialog
v-model="dialogOpen"
@input="(e) => $emit('input', e)"
max-width="600"
>
<template v-slot:activator="{ on, attrs }">
<v-btn v-if="adminaccess()"
title="Create a new project from scratch. Generally, it's preferable to clone an existing project (right-click → Clone)"
small
outlined
color="warning"
v-bind="attrs"
v-on="on"
>
<span>Create new project</span>
<v-icon right small>mdi-file-document-plus-outline</v-icon>
</v-btn>
</template>
<dougal-project-settings-name-id-geodetics
:value="newProjectDetails"
@input="save"
@close="dialogOpen = false"
>
</dougal-project-settings-name-id-geodetics>
</v-dialog>
</template>
<script>
import { mapActions, mapGetters } from 'vuex';
import DougalProjectSettingsNameIdGeodetics from '@/components/project-settings/name-id-geodetics'
import AccessMixin from '@/mixins/access';
export default {
name: 'DougalAppBarExtensionProjectList',
components: {
DougalProjectSettingsNameIdGeodetics
},
mixins: [
AccessMixin
],
data() {
return {
dialogOpen: false,
newProjectDetails: {
name: null,
id: null,
epsg: null
}
};
},
methods: {
async save (data) {
this.dialogOpen = false;
data.archived = true; // Make the project inactive to start with
console.log("POST the new project data");
console.log(data);
const init = {
method: "POST",
body: data
};
const cb = (err, res) => {
if (!err && res) {
console.log(res);
if (res.status == "201") {
// Redirect to new project settings page
const settingsUrl = `/projects/${data.id.toLowerCase()}/configuration`;
this.$router.push(settingsUrl);
}
}
};
await this.api(["/project", init, cb]);
},
...mapActions(["api"])
}
}
</script>