mann mann

This commit is contained in:
holger.trampe 2021-07-01 11:48:23 +02:00
parent 3b2544e7ac
commit e8fbc6dfcc
5 changed files with 77 additions and 14 deletions

View File

@ -9,6 +9,7 @@ return [
['name' => 'agency#show', 'url' => '/getagencydata', 'verb' => 'GET'], ['name' => 'agency#show', 'url' => '/getagencydata', 'verb' => 'GET'],
['name' => 'agency#updateagencydata', 'url' => '/updateagencydata', 'verb' => 'PUT'], ['name' => 'agency#updateagencydata', 'url' => '/updateagencydata', 'verb' => 'PUT'],
['name' => 'agency#getagencycontributors', 'url' => '/getagencycontributors', 'verb' => 'GET'], ['name' => 'agency#getagencycontributors', 'url' => '/getagencycontributors', 'verb' => 'GET'],
['name' => 'agency#updateagencygroupcontributors', 'url' => '/updateagencygroupcontributors/{gid}', 'verb' => 'POST'],
# GROUPS # GROUPS
['name' => 'group#getagencygroups', 'url' => '/getagencygroups', 'verb' => 'GET'], ['name' => 'group#getagencygroups', 'url' => '/getagencygroups', 'verb' => 'GET'],
['name' => 'group#addagencygroup', 'url' => '/addagencygroup', 'verb' => 'PUT'], ['name' => 'group#addagencygroup', 'url' => '/addagencygroup', 'verb' => 'PUT'],

View File

@ -90,8 +90,7 @@ class AgencyManager {
$return_users = array(); $return_users = array();
// Creating a nice User-JSON-Array // Creating a nice User-JSON-Array
foreach($users as $user){ foreach($users as $user){
#array_push($return_users, array("displayName" => $user->getDisplayName(), "uid" => $user->getUID(), "lastLogin" => $user->getLastLogin())); array_push($return_users, array("user" => $user->getUID(), "displayName" => $user->getDisplayName()));
array_push($return_users, $user->getDisplayName());
} }
return $return_users; return $return_users;
} }

View File

@ -101,4 +101,16 @@ class AgencyController extends Controller {
return $this->agencyManager->getagencycontributors(); return $this->agencyManager->getagencycontributors();
} }
/**
* @NoAdminRequired
*
* Update the Group-Members
*
*
*/
# TODO: Noch prüfen, OB der Nutzer das überhautp darf und Agenturcheck usw.
public function updateagencygroupcontributors(string $gid){
return $_POST;
}
} }

View File

@ -54,7 +54,12 @@ class GroupController extends Controller {
if(str_contains($group->getGId(), 'subgroup')){ if(str_contains($group->getGId(), 'subgroup')){
$isDefault = false; $isDefault = false;
} }
array_push($response_groups, array('name' => $group->getDisplayName(), 'gid' => $group->getGid(), 'isDefault' => $isDefault)); // Adding current Users to the Group
$user_groups = [];
foreach($group->getUsers() as $groupuser){
array_push($user_groups, array("user" => $groupuser->getUID(), "displayName" => $groupuser->getDisplayName()));
}
array_push($response_groups, array('name' => $group->getDisplayName(), 'gid' => $group->getGid(), 'isDefault' => $isDefault, 'users' => $user_groups));
} }
//Sorting the Array A-Z by GroupDisplayName //Sorting the Array A-Z by GroupDisplayName
$keys = array_column($response_groups, 'name'); $keys = array_column($response_groups, 'name');

View File

@ -26,9 +26,28 @@
<span v-else>Nicht default</span> <span v-else>Nicht default</span>
<hr> <hr>
<!-- SHAREING --> <!-- SHAREING -->
<Multiselect <!--<Multiselect
:v-model="contributors"
:multiple="true"
placeholder="Suche" placeholder="Suche"
:options="agencyContributor" /> :options="agencyContributor"
@input="updateContributor" />-->
<Multiselect v-model="value"
:options="formattedContributors"
label="displayName"
placeholder="Mitarbeiter der Gruppe hinzufügen"
track-by="user"
:multiple="true"
:user-select="true"
style="width: 350px"
@input="updateContributorsValue()">
<template #singleLabel="{ option }">
<ListItemIcon v-bind="option"
:title="option.displayName"
:avatar-size="24"
:no-margin="true" />
</template>
</Multiselect>
</b-card-body> </b-card-body>
</b-collapse> </b-collapse>
</b-card> </b-card>
@ -38,13 +57,14 @@
import { generateUrl } from '@nextcloud/router' import { generateUrl } from '@nextcloud/router'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import Permission from './Permission' import Permission from './Permission'
import { Multiselect } from '@nextcloud/vue' import { Multiselect, ListItemIcon } from '@nextcloud/vue'
export default { export default {
name: 'Group', name: 'Group',
components: { components: {
Permission, Permission,
Multiselect, Multiselect,
ListItemIcon,
}, },
// Properties of Group-Elements // Properties of Group-Elements
props: { props: {
@ -61,21 +81,47 @@ export default {
return { return {
// Main Group-ID for all Accordions // Main Group-ID for all Accordions
groupDefId: 'acc_groupele_', groupDefId: 'acc_groupele_',
value: [],
contributors: [], contributors: [],
formattedContributors: [],
} }
}, },
computed: { mounted() {
agencyContributor() { this.getAgencyContributors()
return this.contributors
},
},
created() {
this.getAgencyContributor()
}, },
methods: { methods: {
async getAgencyContributor() { async updateContributorsValue() {
let valueData = ''
this.value.forEach((item) => {
valueData += item.user + '___'
})
const r = await axios.post(generateUrl('/apps/agency/updateagencygroupcontributors/' + this.group.gid), valueData)
console.log(r)
},
// Contributors changed, update the formattedContributors for the Field
updateContributors() {
this.formattedContributors = this.contributors.map(item => {
return {
user: item.user,
displayName: item.displayName,
icon: 'icon-user',
}
})
},
// Loading the Contributors for the Agency
async getAgencyContributors() {
const response = await axios.get(generateUrl('/apps/agency/getagencycontributors')) const response = await axios.get(generateUrl('/apps/agency/getagencycontributors'))
this.contributors = response.data this.contributors = response.data
// Contributors loaded, now update formattedContributors to see the result in the field
this.updateContributors()
// After Updating the Users in that group, add current users of the group
this.value = this.group.users.map(item => {
return {
user: item.user,
displayName: item.displayName,
icon: 'icon-user',
}
})
}, },
// Toggle the Group-Accordion-Element // Toggle the Group-Accordion-Element
accordionToggle(ele) { accordionToggle(ele) {