From dc1eabf876a484892e503b986c1e93da5476cfed Mon Sep 17 00:00:00 2001 From: Ryan Mathis Date: Mon, 5 Jun 2023 14:42:48 -0700 Subject: [PATCH] Implemented tabs, pagination, search --- Controller/GrouperGroupsController.php | 24 +- Lib/lang.php | 13 +- View/CoGrouperLites/display.ctp | 148 +- View/GrouperGroups/base.ctp | 8 +- View/GrouperGroups/index.ctp | 76 +- webroot/js/dashboard.js | 15 + webroot/js/grouper-groups-view.js | 95 +- webroot/js/groups-table.js | 99 +- webroot/js/groups.js | 80 +- webroot/js/members.js | 5 + webroot/js/nested-table.js | 70 + webroot/js/page/GroupMember.js | 86 + webroot/js/page/GroupOptin.js | 30 + webroot/js/page/GroupOwner.js | 38 + webroot/js/pagination.js | 20 +- webroot/js/params.js | 24 + webroot/js/table.js | 39 + webroot/js/tabs/tabs.js | 6 +- webroot/js/vue-router.js | 3806 ++++++++++++++++++++++++ 19 files changed, 4448 insertions(+), 234 deletions(-) create mode 100644 webroot/js/dashboard.js create mode 100644 webroot/js/nested-table.js create mode 100644 webroot/js/page/GroupMember.js create mode 100644 webroot/js/page/GroupOptin.js create mode 100644 webroot/js/page/GroupOwner.js create mode 100644 webroot/js/params.js create mode 100644 webroot/js/table.js create mode 100644 webroot/js/vue-router.js diff --git a/Controller/GrouperGroupsController.php b/Controller/GrouperGroupsController.php index fd621c5..09458bc 100644 --- a/Controller/GrouperGroupsController.php +++ b/Controller/GrouperGroupsController.php @@ -112,7 +112,7 @@ private function setConnection() $this->Session->write('Plugin.Grouper.Api.defaultCollapse', $connectionInfo['CoGrouperLite']['default_collapse']); } - private function getConfig() + private function getConfig($page = 'groupmember') { $this->set('title', _txt('pl.grouperlite.title.groupmember')); @@ -125,7 +125,8 @@ private function getConfig() "adHocHeading" => CakeSession::read('Plugin.Grouper.Api.adHocHeading'), "wgHeading" => CakeSession::read('Plugin.Grouper.Api.wgHeading'), 'co' => CakeSession::read('Plugin.Grouper.Api.co'), - 'glid' => isset($this->passedArgs['glid']), + 'glid' => $this->Session->read('Plugin.Grouper.Api.id'), + 'view' => $page ]; return $config; @@ -138,27 +139,24 @@ private function getConfig() */ public function index() { - $this->set('config', $this->getConfig()); + $this->set('config', $this->getConfig('groupmember')); } public function groupMember() { - $this->set('config', $this->getConfig()); - $this->set('page', 'groupmember'); + $this->set('config', $this->getConfig('groupmember')); $this->render('index'); } public function groupOptin() { - $this->set('config', $this->getConfig()); - $this->set('page', 'groupoptin'); + $this->set('config', $this->getConfig('groupoptin')); $this->render('index'); } public function groupOwner() { - $this->set('config', $this->getConfig()); - $this->set('page', 'groupowner'); + $this->set('config', $this->getConfig('groupowner')); $this->render('index'); } @@ -248,7 +246,7 @@ public function addSubscriber() CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true)); $subscribers = 'ERROR'; - $this->Flash->set(_txt('pl.grouperlite.message.flash.group-detail-members-failed'), array('key' => 'error')); + // $this->Flash->set(_txt('pl.grouperlite.message.flash.group-detail-members-failed'), array('key' => 'error')); } if ($resultAdd == 'SUCCESS') { @@ -420,7 +418,7 @@ public function removeSubscriber() } catch (Exception $e) { CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true)); - $this->Flash->set(_txt('pl.grouperlite.message.flash.group-detail-members-failed'), array('key' => 'error')); + //$this->Flash->set(_txt('pl.grouperlite.message.flash.group-detail-members-failed'), array('key' => 'error')); } if ($resultRemove == 'SUCCESS') { @@ -669,10 +667,10 @@ public function joinGroup() try { if ($this->GrouperGroup->joinGroup($this->userId, $name)) { - $this->Flash->set( + /*$this->Flash->set( _txt('pl.grouperlite.message.flash.join-group-success', array(filter_var($display, FILTER_SANITIZE_SPECIAL_CHARS))), array('key' => 'success') - ); + );*/ $resultAdd = "Success"; } else { $this->response->type('json'); diff --git a/Lib/lang.php b/Lib/lang.php index cc33a8d..7e581b3 100644 --- a/Lib/lang.php +++ b/Lib/lang.php @@ -44,13 +44,13 @@ 'pl.grouperlite.title.groupcreate' => 'Create a group', 'pl.grouperlite.title.templatecreate' => 'Create a working group', - 'pl.grouperlite.message.flash.join-group-success' => 'You have been added to the group: %1$s', - 'pl.grouperlite.message.flash.join-group-failed' => 'You are unable to join the group: %1$s', + 'pl.grouperlite.message.flash.join-group-success' => 'You have been added to the group:', + 'pl.grouperlite.message.flash.join-group-failed' => 'You are unable to join the group:', 'pl.grouperlite.message.flash.join-group-error' => 'An error occurred in joining the group, please try again later.', 'pl.grouperlite.message.flash.info-group-failed' => 'Error in viewing group info, please try again later.', - 'pl.grouperlite.message.flash.leave-group-success' => 'You have been deleted from the group: %1$s', - 'pl.grouperlite.message.flash.leave-group-failed' => 'You are unable to be removed from the group: %1$s', + 'pl.grouperlite.message.flash.leave-group-success' => 'You have been deleted from the group:', + 'pl.grouperlite.message.flash.leave-group-failed' => 'You are unable to be removed from the group:', 'pl.grouperlite.message.flash.leave-group-error' => 'An error occurred in leaving the group, please try again later.', 'pl.grouperlite.message.flash.owner-group-failed' => 'Error occurred in viewing groups you manage, please try again later.', 'pl.grouperlite.message.flash.member-group-failed' => 'Error occurred in viewing groups you are a member, please try again later.', @@ -58,6 +58,11 @@ 'pl.grouperlite.message.flash.group-detail-members-failed' => 'Error in viewing the members of this group, please try again later.', + 'pl.grouperlite.message.flash.add-subscriber-success' => 'Added subscriber.', + 'pl.grouperlite.message.flash.add-subscriber-failed' => 'Error in adding subscriber.', + 'pl.grouperlite.message.flash.remove-subscriber-success' => 'Removed subscriber.', + 'pl.grouperlite.message.flash.remove-subscriber-failed' => 'Error in removing subscriber.', + 'pl.grouperlite.table.name' => 'Name', 'pl.grouperlite.table.description' => 'Description', 'pl.grouperlite.table.role' => 'Role', diff --git a/View/CoGrouperLites/display.ctp b/View/CoGrouperLites/display.ctp index 53dd633..480ee25 100644 --- a/View/CoGrouperLites/display.ctp +++ b/View/CoGrouperLites/display.ctp @@ -33,11 +33,78 @@ $divid = $vv_config['CoGrouperLite']['co_dashboard_widget_id']; +// $coid = $config['co']; +// $glid = $config['glid']; + +$this->extend('/GrouperGroups/base'); echo $this->element('GrouperLite.base-styles'); +$idsuffix = rand(); + ?> + + +
diff --git a/View/GrouperGroups/base.ctp b/View/GrouperGroups/base.ctp index 8038bc6..d1b2780 100644 --- a/View/GrouperGroups/base.ctp +++ b/View/GrouperGroups/base.ctp @@ -18,7 +18,7 @@ echo $this->Html->meta( print $this->element('GrouperLite.base-styles'); print $this->Html->css('GrouperLite.co-grouper-plugin') . "\n "; -print $this->Html->script('vue/vue-3.2.31.global.prod.js'); + ?> @@ -29,11 +29,5 @@ $this->Html->addCrumb(_txt('pl.grouperlite.crumb.root'), array('controller' => '
-
- Html->image('GrouperLite.Grouper.jpg', array('class' => 'img-fluid mr-2', 'style' => 'height: 50px')); ?> -

- -
- fetch('content'); ?>
\ No newline at end of file diff --git a/View/GrouperGroups/index.ctp b/View/GrouperGroups/index.ctp index 7e5553e..f696efe 100644 --- a/View/GrouperGroups/index.ctp +++ b/View/GrouperGroups/index.ctp @@ -1,15 +1,28 @@ extend('/GrouperGroups/base'); ?> +Html->script('GrouperLite.vue-router.js'); ?> Html->addCrumb(_txt('pl.grouperlite.nav.memberships')); ?> + +
+ Html->image('GrouperLite.Grouper.jpg', array('class' => 'img-fluid mr-2', 'style' => 'height: 50px')); ?> +

+
+ @@ -106,7 +172,7 @@
- +
+ + {{ page.label }} + + + ` +} \ No newline at end of file diff --git a/webroot/js/grouper-groups-view.js b/webroot/js/grouper-groups-view.js index 855b736..2975c20 100644 --- a/webroot/js/grouper-groups-view.js +++ b/webroot/js/grouper-groups-view.js @@ -1,40 +1,36 @@ import Collapse from './collapse.js'; -import Popover from './popover.js'; -import Members from './members.js'; -import Groups from './groups.js'; -import PageCount from './pagecount.js'; -import Pagination from './pagination.js'; -import Tab from './tabs/tab.js'; -import Tabs from './tabs/tabs.js'; -import GroupsTable from './groups-table.js'; export default { - directives: { - Popover - }, props: {}, - inject: ['api', 'txt', 'tabs', 'columns', 'allowAddSubscribers', 'page'], + inject: ['api', 'txt', 'tabs', 'columns', 'allowAddSubscribers'], data() { return { - active: 'groupmember', keyword: '', loading: false, error: null, groups: { adhoc: [], working: [] - } + }, + newText: '', + tabs: [ + { + path: `/groupmember/co:${this.api.co}/glid:${this.api.glid}`, + label: this.txt.tabs.memberships + }, + { + path: `/groupoptin/co:${this.api.co}/glid:${this.api.glid}`, + label: this.txt.tabs.optin + }, + { + path: `/groupowner/co:${this.api.co}/glid:${this.api.glid}`, + label: this.txt.tabs.owner + } + ] } }, components: { - Collapse, - Members, - Groups, - PageCount, - Pagination, - Tabs, - Tab, - GroupsTable + Collapse }, computed: { cols() { @@ -54,45 +50,34 @@ export default { return this.columns.some(c => c.value === 'status'); }, tab() { - return this.tabs.find(t => t.id === this.active); + return this.tabs.find(t => t.id === this.controller); } }, methods: { - search(query) { - this.keyword = query; - }, - showSubscribers(group) { - this.$refs.members.show(group); - }, - updateHistory(controller) { - // const history = window.history; - history.replaceState(null, null, `../../${controller}/co:${this.api.co}/glid:${this.api.gl}`); + setPage(controller) { + this.controller = controller; } }, - mounted() { - // this.loadGroups(this.tab.api); - }, template: /*html*/` - + + + ` +} + +/* + + - - - + - +