Skip to content

Commit

Permalink
Implemented vuejs components
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Mar 8, 2023
1 parent 99e04b3 commit 41f2ebe
Show file tree
Hide file tree
Showing 13 changed files with 490 additions and 317 deletions.
11 changes: 7 additions & 4 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public function beforeFilter()
{
parent::beforeFilter();

$this->Security->unlockedActions = array('removeSubscriber', 'addSubscriber');

//Need to find which plugin instance choosing, if more than one from cm_co_grouper_lites
// table being used in COmanage.
$grouperConnData = $this->Session->read('Plugin.Grouper.Api');
Expand Down Expand Up @@ -766,16 +768,16 @@ function isAuthorized()

//TODO - This is needed for my dev enviro since I do not log in via I2 IdP
// BEGIN ===============================================
// if ($this->Session->check('Auth.User.username')) {
// $this->userId = $this->Session->read('Auth.User.username');
// }
if ($this->Session->check('Auth.User.username')) {
$this->userId = $this->Session->read('Auth.User.username');
}
// END ===============================================

//TODO - Need to make the following code configurable in getting the user ID. In this case the code is
// specific to the needs of I2.
// BEGIN ===============================================

$uid=$this->Session->read('Auth.User.co_person_id');
/*$uid=$this->Session->read('Auth.User.co_person_id');
$username=$this->Session->read('Auth.User.username');
error_log("HUBING ================ " . $username);
Expand Down Expand Up @@ -815,6 +817,7 @@ function isAuthorized()
$this->Session->write('Plugin.Grouper.UserId', $this->userId);
}
// END ===============================================
*/

// Determine what operations this user can perform
// Construct the permission set for this user, which will also be passed to the view.
Expand Down
2 changes: 1 addition & 1 deletion Lib/GrouperApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ private function useMembershipUrl(array $queryData)
{
$groupType = $queryData['groupType'];
$userId = $queryData['userId'];

if ($groupType == 'optins' || $groupType == 'optouts') {
$subjectId = "GrouperAll";
} elseif ($groupType == 'admin' || $groupType == 'update' || $groupType == 'stemAdmin') {
Expand Down
4 changes: 3 additions & 1 deletion Lib/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,7 @@
'pl.grouperlite.attributes.zero-state' => 'No Attributes Associated to this Group.',
'pl.grouperlite.groups.zero-state' => 'No groups found.',
'pl.grouperlite.working-groups.zero-state' => 'None.',
'pl.grouperlite.email-lists.zero-state' => 'No email lists found.'
'pl.grouperlite.email-lists.zero-state' => 'No email lists found.',
'pl.grouperlite.members.noaccess' => 'You do not have access to view memberships.',
'pl.grouperlite.members.empty' => 'This group has no members.'
);
8 changes: 0 additions & 8 deletions View/Elements/Components/subscriberList.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,12 @@
$("#addUser").val(ui.item.identifier);
// $("#CoGroupMemberCoPersonLabel").val(ui.item.label);
$("#addUserbutton").prop('disabled', false).focus();
$("#group-add-member-clear-button").show();
return false;
},
search: function(event, ui) {
$("#group-add-member-search-container .co-loading-mini").show();
},
focus: function(event, ui) {
event.preventDefault();
$("#group-add-member-search-container .co-loading-mini").hide();
$("#group-add-member").val(ui.item.label + " (" + ui.item.value + ")");
},
close: function(event, ui) {
$("#group-add-member-search-container .co-loading-mini").hide();
}
}).autocomplete("instance")._renderItem = formatCoPersonAutoselectItem;
}

Expand Down
118 changes: 118 additions & 0 deletions View/Elements/Components/vue-table.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<script type="module">
<?php if(Configure::read('debug') > 0): ?>
import GrouperGroupsView from '<?php print $this->webroot ?>grouper_lite/js/grouper-groups-view.js?time=<?php print time()?>';
<?php else: ?>
import GrouperGroupsView from '<?php print $this->webroot ?>grouper_lite/js/grouper-groups-view.js';
<?php endif; ?>

const app = Vue.createApp({
data() {
return {
groups: <?php echo $groupData; ?>,
columns: <?php echo $columns; ?>,
config: {
adhocHeading: "<?php echo $config['adHocHeading'] ? $config['adHocHeading'] : 'Ad-hoc groups' ; ?>",
wgHeading: "<?php echo $config['wgHeading'] ? $config['wgHeading'] : 'Working groups' ; ?>",
collapsed: <?php print $collapsed ? 'true' : 'false'; ?>,
optAction: "<?php echo $optAction; ?>",
members: <?php echo $members ? 'true' : 'false' ?>,
add: <?php echo $addSubscribers ? 'true' : 'false' ?>
},
owner: <?php echo $treatAsOwner ? 'true' : 'false'; ?>,
url: "<?php echo $actionUrl; ?>",
}
},
provide: {
txt: {
groups: "<?php echo _txt('pl.grouperlite.dashboard.heading.groups'); ?>",
leave: "<?php echo _txt('pl.grouperlite.action.leave') ?>",
descrZeroState: "<?php echo _txt('pl.grouperlite.value.descr.zerostate') ?>",
members: "<?php echo _txt('pl.grouperlite.action.members') ?>",
email: "<?php echo _txt('pl.grouperlite.value.email') ?>",
close: "<?php echo _txt('pl.grouperlite.action.close') ?>",
remove: "<?php echo _txt('pl.grouperlite.action.remove-user') ?>",
addUser: "<?php echo _txt('pl.grouperlite.action.add-user') ?>",
search: "<?php echo _txt('pl.grouperlite.search.tags.text') ?>",
noaccess: "<?php echo _txt('pl.grouperlite.members.noaccess') ?>",
empty: "<?php echo _txt('pl.grouperlite.members.empty') ?>",
join: "<?php echo _txt('pl.grouperlite.action.join') ?>"
},
api: {
co: 1,
mode: "<?php echo PeoplePickerModeEnum::All ?>",
base: "<?php echo $this->webroot ?>grouper_lite/grouper_groups",
find: "<?php echo $this->Html->url(
array(
'controller' => 'grouper_groups',
'action' => 'findSubscriber'
)
); ?>",
remove: "<?php echo $this->webroot ?>grouper_lite/grouper_groups/removeSubscriber",
add: "<?php echo $this->webroot ?>grouper_lite/grouper_groups/addSubscriber",
group: "<?php echo $this->webroot ?>grouper_lite/grouper_groups/groupSubscribers",
},
},
mounted() {
if (!this.owner) {
this.columns = this.columns.filter(c => c.value !== 'role');
}
},
components: {
GrouperGroupsView
}
}).mount('#grouper-lite-widget');
</script>

<style>
.ui-autocomplete {
max-height: 220px;
overflow-y: auto;
overflow-x: hidden;
padding-right: 20px;
}
</style>

<div class="grouper-table">
<?php print $this->element("pagination", array(
'goto' => false,
'limit' => false,
'numbers' => false,
'counter' => true,
'class' => 'counter'
)); ?>
<div id="grouper-lite-widget">
<grouper-groups-view
:groups="groups"
:columns="columns"
:config="config"
:owner="owner"
:action="config.optAction"
:url="url"
>
<template v-slot:actionform="actionform">
<?php echo $this->Form->create(false, array(
'url' => array('controller' => 'grouper_groups', 'action' => $optAction),
'class' => 'd-flex justify-content-center',
'id' => 'group-action'
)); ?>
<input type="hidden" name="data[GroupName]" :value="actionform.groupname" />
<input type="hidden" name="data[GroupDisplayName]" :value="actionform.groupdisplayname" />
<button
:class="actionform.actiontype"
class="btn btn-sm btn-block text-nowrap m-1 btn-success" type="submit">
{{ actionform.actionlabel }}
&nbsp;
<em class="material-icons mt-0" aria-hidden="true">{{ actionform.actionicon }}</em>
</button>
<?php echo $this->Form->end(null); ?>
</template>
</grouper-groups-view>
</div>

<?php print $this->element("pagination", array(
'goto' => false,
'limit' => true,
'numbers' => true,
'counter' => false
)); ?>
</div>
4 changes: 1 addition & 3 deletions View/GrouperGroups/base.ctp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


<?php

echo $this->Html->meta(
Expand All @@ -23,7 +21,7 @@ print $this->Html->css('GrouperLite.co-grouper-plugin') . "\n ";
print $this->Html->script('vue/vue-3.2.31.global.prod.js');

?>

<?php echo $this->element('GrouperLite.Components/plugins'); ?>

<?php
$this->Html->addCrumb(_txt('pl.grouperlite.crumb.root'), array('controller' => 'grouper_groups', 'action' => 'groupmember'), array('prepend' => true));
Expand Down
128 changes: 20 additions & 108 deletions View/GrouperGroups/groupmember.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -3,119 +3,31 @@
<?php $this->Html->addCrumb(_txt('pl.grouperlite.nav.memberships')); ?>
<?php echo $this->element('GrouperLite.Components/navigation-groups', array('active' => 'groupmember')); ?>
<?php echo $this->element('GrouperLite.Components/search', array('active' => 'groupmember')); ?>
<?php

$collapsed = $config['defaultCollapse'] === 'collapsed' ? true : false;

$collapsed = false;

?>


<script type="module">
<?php if(Configure::read('debug') > 0): ?>
import GrouperGroupsView from '<?php print $this->webroot ?>grouper_lite/js/grouper-groups-view.js?time=<?php print time()?>';
<?php else: ?>
import GrouperGroupsView from '<?php print $this->webroot ?>grouper_lite/js/grouper-groups-view.js';
<?php endif; ?>

const app = Vue.createApp({
data() {
return {
groups: <?php echo json_encode(array(
'adhoc' => $groupmemberships,
'working' => $wgmemberships
)) ?>,
columns: [
{value: 'name', label: "<?php print _txt('pl.grouperlite.table.name'); ?>"},
{value: 'role', label: "<?php print _txt('pl.grouperlite.table.role'); ?>"},
{value: 'description', label: "<?php print _txt('pl.grouperlite.table.description'); ?>"},
{value: 'action', label: "<?php print _txt('pl.grouperlite.table.action'); ?>"},
],
config: {
adhocHeading: "<?php echo $config['adHocHeading'] ? $config['adHocHeading'] : 'Ad-hoc groups' ; ?>",
collapsed: <?php print $collapsed ? 'true' : 'false'; ?>
},
owner: <?php echo $isuserowner === 'T' ? 'true' : 'false'; ?>,
url: "<?php echo $this->Html->url([
'controller' => 'grouper_groups', 'action' => 'leavegroup'
]) ?>",
txt: {
groups: "<?php echo _txt('pl.grouperlite.dashboard.heading.groups'); ?>",
leave: "<?php echo _txt('pl.grouperlite.action.leave') ?>",
descrZeroState: "<?php echo _txt('pl.grouperlite.value.descr.zerostate') ?>",
members: "<?php echo _txt('pl.grouperlite.action.members') ?>",
email: "<?php echo _txt('pl.grouperlite.value.email') ?>"
}
}
},
mounted() {
if (!this.owner) {
this.columns = this.columns.filter(c => c.value !== 'role');
}
},
components: {
GrouperGroupsView
}
}).mount('#grouper-lite-widget');
</script>

<div class="grouper-table">
<?php print $this->element("pagination", array(
'goto' => false,
'limit' => false,
'numbers' => false,
'counter' => true,
'class' => 'counter'
)); ?>
<div id="grouper-lite-widget">
<grouper-groups-view
:groups="groups"
:columns="columns"
:config="config"
:owner="owner"
action="leavegroup"
:url="url"
:txt="txt"
>
<template v-slot:actionform="actionform">
<?php echo $this->Form->create(false, array(
'url' => array('controller' => 'grouper_groups', 'action' => 'leavegroup'),
'class' => 'd-flex justify-content-center',
'id' => 'join-group'
)); ?>
<input type="hidden" name="data[GroupName]" :value="actionform.groupname" />
<input type="hidden" name="data[GroupDisplayName]" :value="actionform.groupdisplayname" />
<button
class="btn btn-sm btn-block text-nowrap m-1 btn-danger" type="submit">
{{ txt.leave }}
&nbsp;
<em class="material-icons mt-0" aria-hidden="true">{{ 'person_off' }}</em>
</button>
<?php echo $this->Form->end(null); ?>
</template>
</grouper-groups-view>
</div>

<?php print $this->element("pagination", array(
'goto' => false,
'limit' => true,
'numbers' => true,
'counter' => false
)); ?>
</div>
<script>
$('.grpr-popover-toggle').popover({
placement: 'top',
trigger: 'hover'
});
</script>
<?php echo $this->element('GrouperLite.Components/vue-table', array(
'groupData' => json_encode(array(
'adhoc' => $groupmemberships,
'working' => $wgmemberships
)),
'treatAsOwner' => $isuserowner === 'T' ? 'true' : 'false',
'columns' => json_encode(array(
array('value' => 'name', 'label' => _txt('pl.grouperlite.table.name')),
array('value' => 'role', 'label' => _txt('pl.grouperlite.table.role')),
array('value' => 'description', 'label' => _txt('pl.grouperlite.table.description')),
array('value' => 'action', 'label' => _txt('pl.grouperlite.table.action')),
)),
'collapsed' => $config['defaultCollapse'] === 'collapsed' ? true : false,
'optAction' => "leavegroup",
'actionUrl' => $this->Html->url([
'controller' => 'grouper_groups', 'action' => 'leavegroup'
]),
'members' => true,
'addSubscribers' => true,
)); ?>
<?php if (count($groupmemberships) < 1 && count($wgmemberships) < 1) : ?>
<div class="alert alert-info">
<p class="lead mb-0 text-center"><?php echo _txt('pl.grouperlite.groups.zero-state'); ?></p>
</div>
<?php endif; ?>

<?php echo $this->element('Components/subscriberList', array('addSubscribers' => false)); ?>

<!--/nocache-->
Loading

0 comments on commit 41f2ebe

Please sign in to comment.