OU.vue 4.26 KB
Newer Older
janis.streib's avatar
janis.streib committed
1
2
3
<template>
  <div class="oe-overview">
    <h1>Organisationseinheiten</h1>
janis.streib's avatar
janis.streib committed
4
    <b-checkbox :value="true" :unchecked-value="false" v-model="only_own_oe" switch>Nur eigene Organisationseinheiten anzeigen
janis.streib's avatar
janis.streib committed
5
6
7
8
9
10
11
    </b-checkbox>
    <hr/>
    <Loading :data="[ous, mgrs]">
      <template v-for="ou in ous">
        <b-card no-body :key="'card-account-' + ou.short_name" class="mb-4 shadow">
          <template v-slot:header>
            <b-row>
janis.streib's avatar
janis.streib committed
12
              <b-col>
janis.streib's avatar
janis.streib committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
                <h4>
                  {{ ou.name }} ({{ ou.short_name }})
                </h4>
                <p class="text-muted">Organisationseinheit</p>
              </b-col>
            </b-row>
          </template>
          <b-button block squared variant="outline-secondary" v-b-toggle="ou.short_name + '-collapse'">
            OE-Betreuer<br/>
            <font-awesome-icon class="collapse-icon" :icon="['fas','chevron-down']"/>
          </b-button>
          <b-collapse :id="ou.short_name + '-collapse'">
            <b-table :items="mgrs2ou[ou.short_name]" :fields="ou_list_fields">
              <template v-slot:cell(first_name)="data">
                {{ mgrs[data.item.mgr_login_name].first_name }}
              </template>
              <template v-slot:cell(last_name)="data">
                {{ mgrs[data.item.mgr_login_name].last_name }}
              </template>
              <template v-slot:cell(email)="data">
                <b-link :href="'mailto:'+mgrs[data.item.mgr_login_name].email">
                  {{ mgrs[data.item.mgr_login_name].email }}
                </b-link>
              </template>
janis.streib's avatar
janis.streib committed
37
38
39
40
41
42
43
44
45
46
              <template v-slot:head(actions)>
                <b-button @click="assign_mgr(ou.short_name)" block variant="outline-success"
                          :id="'button-assign-mgr-' +  ou.short_name">
                  <font-awesome-icon :icon="['fas', 'plus']"/>
                </b-button>
                <b-tooltip :target="'button-assign-mgr-' +  ou.short_name" triggers="hover"
                           variant="success" placement="left">
                  Neuen Account zuordnen
                </b-tooltip>
              </template>
janis.streib's avatar
janis.streib committed
47
48
49
50
            </b-table>
          </b-collapse>
        </b-card>
      </template>
51
52
53
54
      <div v-if="!ous || ous.length === 0"
           class="font-italic text-center mb-3">
        Keine Organisationseinheiten vorhanden
      </div>
janis.streib's avatar
janis.streib committed
55
    </Loading>
janis.streib's avatar
janis.streib committed
56
    <DBEditor modal_id="assign_user_to_oe" object_function="create" object_fq_name="cntl.mgr2ou" :presets="db_editor_presets"
janis.streib's avatar
janis.streib committed
57
    :non_optionals_order="['ou_short_name', 'mgr_login_name']" object_title="Konto-zu-Organisationseinheits-Zuordnung"></DBEditor>
janis.streib's avatar
janis.streib committed
58
59
60
61
62
63
64
  </div>
</template>

<script>
import OUService from '@/api-services/ou.service'
import Loading from '@/components/Loading'
import apiutil from '@/util/apiutil'
janis.streib's avatar
janis.streib committed
65
import DBEditor from '@/components/DBEditor'
janis.streib's avatar
janis.streib committed
66
67
68

export default {
  name: 'OE',
janis.streib's avatar
janis.streib committed
69
  components: {DBEditor, Loading},
janis.streib's avatar
janis.streib committed
70
71
72
73
74
75
76
77
78
79
80
81
82
83
  watch: {
    only_own_oe: {
      immediate: true,
      async handler() {
        await this.refresh()
      }
    }
  },
  data() {
    return {
      only_own_oe: true,
      mgrs2ou: null,
      mgrs: null,
      ous: null,
janis.streib's avatar
janis.streib committed
84
      db_editor_presets: {},
janis.streib's avatar
janis.streib committed
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
      ou_list_fields: [
        {
          key: 'mgr_login_name',
          label: 'Login Name',
          sortable: false
        },
        {
          key: 'first_name',
          label: 'Vorname',
          sortable: false
        },
        {
          key: 'last_name',
          label: 'Nachname',
          sortable: false
        },
        {
          key: 'email',
          label: 'E-Mail',
          sortable: false
        },
        {
          key: 'actions',
          label: 'Aktionen',
          sortable: false
        }
      ]
    }
  },
  methods: {
    async refresh() {
      this.mgrs = this.mgrs2ou = this.ous = null
      const res = (await OUService.list(this.$store.state.netdb_axios_config, this.only_own_oe)).data
      this.mgrs2ou = apiutil.dict_of_lists_by_value_of_array(res[2], 'ou_short_name')
      this.mgrs = apiutil.dict_by_value_of_array(res[3], 'login_name')
      this.ous = res[1]
janis.streib's avatar
janis.streib committed
121
122
123
124
    },
    assign_mgr(oe) {
      this.db_editor_presets = { ou_short_name: oe }
      this.$root.$emit('bv::show::modal', 'assign_user_to_oe')
janis.streib's avatar
janis.streib committed
125
126
127
128
129
130
131
132
133
134
135
    }
  },
  async mounted() {
    await this.refresh()
  }
}
</script>

<style scoped>

</style>