summaryrefslogblamecommitdiffstats
path: root/webapp/src/components/GroupModuleEdit.vue
blob: 4b91269d81efd3a4030bf92a6a13a07fce1e3e4c (plain) (tree)














































































                                                                                   
<i18n>
{
  "en": {
  },
  "de": {
  }
}
</i18n>

<template>
  <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>
</template>

<script>

export default {
  name: 'GroupModuleEdit',
  props: ['id', 'client'],
  data () {
    return {
      name: ''
    }
  },
  watch: {
    id () { this.loadData() }
  },
  methods: {
    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>