diff --git a/appinfo/routes.php b/appinfo/routes.php index b1ee012..98812d6 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -9,6 +9,7 @@ return [ ['name' => 'agency#show', 'url' => '/getagencydata', 'verb' => 'GET'], ['name' => 'agency#updateagencydata', 'url' => '/updateagencydata', 'verb' => 'PUT'], ['name' => 'agency#getagencycontributors', 'url' => '/getagencycontributors', 'verb' => 'GET'], + ['name' => 'agency#updateagencygroupcontributors', 'url' => '/updateagencygroupcontributors/{gid}', 'verb' => 'POST'], # GROUPS ['name' => 'group#getagencygroups', 'url' => '/getagencygroups', 'verb' => 'GET'], ['name' => 'group#addagencygroup', 'url' => '/addagencygroup', 'verb' => 'PUT'], diff --git a/lib/Agency/AgencyManager.php b/lib/Agency/AgencyManager.php index 02eef74..520658e 100644 --- a/lib/Agency/AgencyManager.php +++ b/lib/Agency/AgencyManager.php @@ -90,8 +90,7 @@ class AgencyManager { $return_users = array(); // Creating a nice User-JSON-Array foreach($users as $user){ - #array_push($return_users, array("displayName" => $user->getDisplayName(), "uid" => $user->getUID(), "lastLogin" => $user->getLastLogin())); - array_push($return_users, $user->getDisplayName()); + array_push($return_users, array("user" => $user->getUID(), "displayName" => $user->getDisplayName())); } return $return_users; } diff --git a/lib/Controller/AgencyController.php b/lib/Controller/AgencyController.php index 2f4edc6..5c18a8f 100644 --- a/lib/Controller/AgencyController.php +++ b/lib/Controller/AgencyController.php @@ -101,4 +101,16 @@ class AgencyController extends Controller { 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; + } + } \ No newline at end of file diff --git a/lib/Controller/GroupController.php b/lib/Controller/GroupController.php index eb636bc..bf9b772 100644 --- a/lib/Controller/GroupController.php +++ b/lib/Controller/GroupController.php @@ -54,7 +54,12 @@ class GroupController extends Controller { if(str_contains($group->getGId(), 'subgroup')){ $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 $keys = array_column($response_groups, 'name'); diff --git a/src/components/Group.vue b/src/components/Group.vue index 4d07718..0abbb71 100644 --- a/src/components/Group.vue +++ b/src/components/Group.vue @@ -26,9 +26,28 @@ Nicht default
- + :options="agencyContributor" + @input="updateContributor" />--> + + + @@ -38,13 +57,14 @@ import { generateUrl } from '@nextcloud/router' import axios from '@nextcloud/axios' import Permission from './Permission' -import { Multiselect } from '@nextcloud/vue' +import { Multiselect, ListItemIcon } from '@nextcloud/vue' export default { name: 'Group', components: { Permission, Multiselect, + ListItemIcon, }, // Properties of Group-Elements props: { @@ -61,21 +81,47 @@ export default { return { // Main Group-ID for all Accordions groupDefId: 'acc_groupele_', + value: [], contributors: [], + formattedContributors: [], } }, - computed: { - agencyContributor() { - return this.contributors - }, - }, - created() { - this.getAgencyContributor() + mounted() { + this.getAgencyContributors() }, 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')) 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 accordionToggle(ele) {