summaryrefslogtreecommitdiffstats
path: root/webapp/src/components/GroupModuleEditDialog.vue
blob: 8eab1e1839948b303411f2d2baf4bfb94dbbfb21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<i18n>
{
  "en": {
  },
  "de": {
  }
}
</i18n>

<template>
  <v-dialog :value="editDialog" @input="setEditDialog" max-width="600px">
    <v-card>
      <div class="input-fields">
        <v-text-field v-model="name" label="Name" box color="primary"></v-text-field>
      </div>
      <div class="action-buttons text-xs-right">
        <v-btn flat @click="$emit('close')">Cancel</v-btn>
        <v-btn color="primary" @click="saveData">Save</v-btn>
      </div>
    </v-card>
  </v-dialog>
</template>

<script>
import { mapState, mapMutations } from 'vuex'

export default {
  name: 'GroupModuleEditDialog',
  props: ['id', 'client'],
  data () {
    return {
      name: ''
    }
  },
  computed: {
    ...mapState('groups', ['editDialog'])
  },
  methods: {
    ...mapMutations('groups', ['setEditDialog']),
    loadData () {
      if (!this.id) return
      if (this.client) {
        // TODO
      } else {
        this.$http('/api/groups?action=getInfo&id=' + this.id).then(response => {
          this.name = response.data.name
        })
      }
    },
    saveData () {
      if (this.client) {
        // TODO
      } else {
        this.$http.post('/api/groups', {
          action: 'setInfo',
          id: this.id,
          name: this.name
        }).then(response => {
          console.log(response)
        })
      }
      this.$emit('close')
      this.$emit('reload')
    }
  },
  created () {
    this.loadData()
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.input-fields {
  padding: 40px;
  padding-bottom: 0;
}

.action-buttons {
  padding: 10px;
}

</style>