summaryrefslogtreecommitdiffstats
path: root/webapp/src/components/RegistrationModule.vue
diff options
context:
space:
mode:
authorUdo Walter2018-11-12 05:59:16 +0100
committerUdo Walter2018-11-12 05:59:16 +0100
commit5a15373dcd76ed7371dbbee88104dd0c4384a889 (patch)
tree1d2c798f7602e17c007d67d279a7cb1ee754b053 /webapp/src/components/RegistrationModule.vue
parent[iDoIT] Rework the import method to use batch requests (diff)
downloadbas-5a15373dcd76ed7371dbbee88104dd0c4384a889.tar.gz
bas-5a15373dcd76ed7371dbbee88104dd0c4384a889.tar.xz
bas-5a15373dcd76ed7371dbbee88104dd0c4384a889.zip
[registration] add configurator for registration hooks
Diffstat (limited to 'webapp/src/components/RegistrationModule.vue')
-rw-r--r--webapp/src/components/RegistrationModule.vue137
1 files changed, 137 insertions, 0 deletions
diff --git a/webapp/src/components/RegistrationModule.vue b/webapp/src/components/RegistrationModule.vue
new file mode 100644
index 0000000..f9b857f
--- /dev/null
+++ b/webapp/src/components/RegistrationModule.vue
@@ -0,0 +1,137 @@
+<i18n>
+{
+ "en": {
+ "hooks": "Registration hooks",
+ "createHook": "Create hook"
+ },
+ "de": {
+ "hooks": "Registrierungs Hooks ",
+ "createHook": "Hook erstellen"
+ }
+}
+</i18n>
+
+<template>
+ <v-container fill-height>
+ <v-layout>
+ <v-flex class="tabs-wrapper" xl10 offset-xl1 lg12>
+ <v-card>
+ <v-tabs v-model="tabs" centered :dark="tabsDark" :color="tabsColor" :slider-color="tabsSliderColor">
+ <v-tab>{{ $t('hooks') }}</v-tab>
+ </v-tabs>
+ </v-card>
+ <v-tabs-items v-model="tabs" style="padding-bottom: 20px">
+ <v-tab-item>
+ <v-subheader>{{ $t('hooks') }}</v-subheader>
+ <v-card v-if="hooks.length > 0">
+ <v-list two-line>
+ <draggable :value="hooks" @input="setHooks($event)" :options="{ handle:'.handle' }">
+ <v-list-tile v-for="hook in hooks" :key="hook.id" @click.stop @dblclick="editHook(hook)">
+ <v-list-tile-action class="handle">
+ <v-icon>drag_handle</v-icon>
+ </v-list-tile-action>
+ <v-list-tile-content>
+ <v-list-tile-title>{{ hook.name }}<small class="type">{{ hook.type }}</small></v-list-tile-title>
+ <v-list-tile-sub-title>{{ hook.description }}</v-list-tile-sub-title>
+ </v-list-tile-content>
+ <v-icon v-if="hook.groups.length > 0">device_hub</v-icon>
+ <v-list-tile-action>
+ <v-btn @click="editHook(hook)" icon><v-icon color="primary">edit</v-icon></v-btn>
+ </v-list-tile-action>
+ <v-list-tile-action class="delete">
+ <v-btn @click="deleteHook(hook)" icon><v-icon color="error">delete</v-icon></v-btn>
+ </v-list-tile-action>
+ </v-list-tile>
+ </draggable>
+ </v-list>
+ </v-card>
+ <div class="text-xs-right">
+ <v-btn flat color="success" @click="createHook"><v-icon left>create</v-icon>{{ $t('createHook') }}</v-btn>
+ </div>
+ </v-tab-item>
+ </v-tabs-items>
+ </v-flex>
+ </v-layout>
+ <v-dialog
+ :value="dialog.show"
+ @input="setDialog({ show: $event })"
+ :max-width="dialog.type === 'delete' ? '500px' : '1000px'"
+ scrollable
+ :persistent="dialog.type !== 'delete'"
+ >
+ <registration-module-delete v-if="dialog.type === 'delete'" />
+ <registration-module-edit v-else-if="dialog.type === 'edit'"/>
+ </v-dialog>
+ </v-container>
+</template>
+
+<script>
+import draggable from 'vuedraggable'
+import RegistrationModuleDelete from '@/components/RegistrationModuleDelete'
+import RegistrationModuleEdit from '@/components/RegistrationModuleEdit'
+import { mapState, mapGetters, mapMutations, mapActions } from 'vuex'
+
+export default {
+ name: 'RegistrationModule',
+ components: {
+ draggable,
+ RegistrationModuleDelete,
+ RegistrationModuleEdit
+ },
+ data () {
+ return {
+ tabs: 0
+ }
+ },
+ computed: {
+ ...mapGetters(['tabsDark', 'tabsColor', 'tabsSliderColor']),
+ ...mapState('registration', ['hooks', 'dialog'])
+ },
+ methods: {
+ ...mapMutations('registration', ['setDialog']),
+ ...mapActions('registration', ['setHooks']),
+ deleteHook (hook) {
+ this.setDialog({ show: true, type: 'delete', info: hook })
+ },
+ editHook (hook) {
+ this.setDialog({ show: true, type: 'edit', info: hook })
+ },
+ createHook () {
+ this.setDialog({ show: true, type: 'edit', info: {} })
+ }
+ },
+ created () {
+ this.$store.dispatch('registration/loadGroupList')
+ this.$store.dispatch('registration/loadHooks')
+ }
+}
+</script>
+
+<!-- Add "scoped" attribute to limit CSS to this component only -->
+<style scoped>
+.handle {
+ margin-left: 12px;
+}
+.delete {
+ margin-right: 12px;
+}
+.type {
+ margin-left: 24px;
+}
+.hook-info {
+ display: flex;
+ flex-direction: row;
+ width: 100%;
+}
+.hook-info > .hook-type {
+ min-width: 60px;
+}
+.hook-info > .hook-name {
+ white-space: nowrap;
+}
+.hook-info > .hook-description {
+ margin-left: 40px;
+ overflow: hidden;
+ white-space: nowrap;
+}
+</style>