Skip to content

Commit

Permalink
Added subscriber modal
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Sep 27, 2021
1 parent 37a0623 commit 7c001d8
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 52 deletions.
2 changes: 2 additions & 0 deletions Lib/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
'pl.grouperlite.action.edit' => 'Edit',
'pl.grouperlite.action.view-in-grouper' => 'View in Grouper',
'pl.grouperlite.action.view-members' => 'View members',
'pl.grouperlite.action.grouper' => 'Grouper',
'pl.grouperlite.action.members' => 'Members',
'pl.grouperlite.action.close' => 'Close',
'pl.grouperlite.action.clear' => 'Clear',

Expand Down
2 changes: 1 addition & 1 deletion View/Elements/Components/optAction.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'id' => 'join-group.' . $idx
)); ?>
<?php print $this->Form->hidden('GroupName', array('default' => $group, 'id' => 'groupName.' . $idx)); ?>
<button class="btn btn-sm btn-<?php echo $member ? 'danger' : 'success'; ?>" type="submit">
<button class="btn btn-sm btn-<?php echo $member ? 'danger' : 'success'; ?> btn-block text-nowrap" type="submit">
<?php echo $member ? _txt('pl.grouperlite.action.leave') : _txt('pl.grouperlite.action.join') ?> &nbsp;
<i class="fa fa-<?php echo $member ? 'user-times' : 'users'; ?> fa-sm"></i>
</button>
Expand Down
75 changes: 65 additions & 10 deletions View/Elements/Components/subscriberList.ctp
Original file line number Diff line number Diff line change
@@ -1,11 +1,66 @@
<div class="modal modal-members modal-primary fade" tabindex="-1" id="subscribers" aria-labelledby="modal-title">
<div class="modal-dialog modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modal-title"><?php echo _txt('pl.grouperlite.group.info.members-heading'); ?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
</div>
<div class="modal-body loader text-center">
<i class="fa fa-spinner fa-pulse fa-3x fa-fw" aria-hidden="true"></i>
<p class="sr-only">Loading...</p>
</div>
<div class="modal-body msg">
<p>There was an error retrieving the subscribers.</p>
</div>
<div class="modal-body subs">
<table class="table table-striped">
<tbody>
<?php foreach ($subscribers as $sub) : ?>
<tr>
<td><?php echo $sub['name']; ?></td>
<td><?php echo $sub['id']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-grouper btn-link" data-dismiss="modal"><?php echo _txt('pl.grouperlite.action.close'); ?></button>
</div>
</div>
</div>
</div>
<script>
var url = '<?php print $this->Html->url(
array(
'plugin' => "grouper_lite",
'controller' => 'grouper_groups',
'action' => 'groupSubscribers'
)
); ?>';
$('.members-btn').click(function(ev) {
var $this = $(this);
var id = $this.data('id');
var modal = $('#subscribers');
modal.addClass('loading');
modal.modal('toggle');

<table class="table table-striped">
<tbody>
<?php foreach ($subscribers as $sub) : ?>
<tr>
<td><?php echo $sub['name']; ?></td>
<td><?php echo $sub['id']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
$.ajax({
url: url + '?groupname=' + id,
dataType: 'json',
success: function(data) {
console.log(data);

},
error: function() {
modal.addClass('error');
},
complete: function() {
modal.removeClass('loading');
}
})
});
</script>
18 changes: 18 additions & 0 deletions View/Elements/base-styles.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,22 @@
.grouper a:not(.btn):hover {
color: var(--link-hover);
}

#subscribers.loading .loader {
display: block;
}

#subscribers.loading .subs,
#subscribers.error .subs {
display: none;
}

#subscribers.error .msg {
display: block;
}

#subscribers .loader,
#subscribers .msg {
display: none;
}
</style>
29 changes: 1 addition & 28 deletions View/GrouperGroups/groupinfo.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ $attrUrlBase = $baseUrl . $path . $attrOperation;
<div class="border-bottom py-4 mb-4 d-flex justify-content-between">
<h2><strong><?php echo _txt('pl.grouperlite.group.info.page-heading'); ?></strong> <?php echo $groupergroupsdetail['friendlyName']; ?></h2>
<div class="d-flex align-items-center">
<?php if ($isuserowner === 'T') : ?>
<button class="btn btn-grouper btn btn-primary mr-2" data-toggle="modal" data-target="#subscribers"><?php echo _txt('pl.grouperlite.action.view-members'); ?> <i class="fa fa-group"></i></button>
<?php endif ?>
<a href="<?php echo $groupUrlBase . $groupergroupsdetail['uuid']; ?>" class="btn btn-grouper btn btn-success mt-0" target="_blank" role="button">
<?php echo _txt('pl.grouperlite.action.view-in-grouper'); ?> &nbsp;
<i class="fa fa-external-link"></i>
</a>

</div>
</div>
<div class="row">
Expand Down Expand Up @@ -48,24 +42,3 @@ $attrUrlBase = $baseUrl . $path . $attrOperation;
</div>
</div>
</div>

<?php if ($isuserowner === 'T') : ?>
<div class="modal modal-primary fade" tabindex="-1" id="subscribers" aria-labelledby="modal-title">
<div class="modal-dialog modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modal-title"><?php echo _txt('pl.grouperlite.group.info.members-heading'); ?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<?php echo $this->element('Components/subscriberList', array('subscribers' => $groupergroupssubscribers)); ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-grouper btn btn-link" data-dismiss="modal"><?php echo _txt('pl.grouperlite.action.close'); ?></button>
</div>
</div>
</div>
</div>
<?php endif; ?>
56 changes: 43 additions & 13 deletions View/GrouperGroups/groupmember.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,21 @@ $numColumns = count($columns);
<?php } ?>
<td><?php echo $group['description'] ?? _txt('pl.grouperlite.value.descr.zerostate'); ?></td>
<td>
<?php echo $group['optOut'] ? $this->element('GrouperLite.Components/optAction', array(
'member' => $group['optOut'],
'action' => 'leavegroup',
'group' => $group['name'],
'idx' => $key
)) : ''; ?>
<span class="btn-group d-flex flex-row justify-content-center align-items-center">
<?php echo $group['optOut'] ? $this->element('GrouperLite.Components/optAction', array(
'member' => $group['optOut'],
'action' => 'leavegroup',
'group' => $group['name'],
'idx' => $key
)) : ''; ?>
<button class="btn btn-grouper btn-block btn-primary btn-sm my-1 text-nowrap" data-toggle="modal" data-target="#subscribers"><?php echo _txt('pl.grouperlite.action.members'); ?> <i class="fa fa-group"></i></button>
<?php if ($isuserowner === 'T') : ?>
<a href="<?php echo $groupUrlBase . $groupergroupsdetail['uuid']; ?>" class="btn btn-grouper btn-block btn-sm btn-success mt-0 text-nowrap" target="_blank" role="button">
<?php echo _txt('pl.grouperlite.action.grouper'); ?> &nbsp;
<i class="fa fa-external-link"></i>
</a>
<?php endif ?>
</span>
</td>
</tr>
<?php endforeach; ?>
Expand All @@ -91,12 +100,32 @@ $numColumns = count($columns);
<?php echo $wggroup['workingDesc'] ?? " "; ?>
</td>
<td>
<?php echo $wggroup['optOut'] ? $this->element('GrouperLite.Components/optAction', array(
'member' => $wggroup['optOut'],
'action' => 'leavegroup',
'group' => $wggroup['workingGroupId'],
'idx' => $key
)) : ''; ?>
<span class="btn-group d-flex flex-row justify-content-center align-items-center">
<?php echo $wggroup['optOut'] ? $this->element('GrouperLite.Components/optAction', array(
'member' => $wggroup['optOut'],
'action' => 'leavegroup',
'group' => $wggroup['workingGroupId'],
'idx' => $key
)) : ''; ?>
<button class="btn btn-grouper btn-block btn-primary btn-sm my-1 text-nowrap members-btn"
data-id="<?php echo $wggroup['WGName']; ?>">
<?php echo _txt('pl.grouperlite.action.members'); ?> <i class="fa fa-group"></i>
</button>
<?php if ($isuserowner === 'T') : ?>
<?php
$baseUrl = $grouperbaseurl;
$path = '/grouper/grouperUi/app/UiV2Main.index';
$groupOperation = '?operation=UiV2Group.viewGroup&groupId=';
$groupUrlBase = $baseUrl . $path . $groupOperation;
$attrOperation = '?operation=UiV2AttributeDefName.viewAttributeDefName&attributeDefNameId=';
$attrUrlBase = $baseUrl . $path . $attrOperation;
?>
<a href="<?php echo $groupUrlBase . $groupergroupsdetail['uuid']; ?>" class="btn btn-grouper btn-block btn-sm btn-success mt-0 text-nowrap" target="_blank" role="button">
<?php echo _txt('pl.grouperlite.action.grouper'); ?> &nbsp;
<i class="fa fa-external-link"></i>
</a>
<?php endif ?>
</span>
</td>
</tr>
<?php foreach ($wggroup['Groups'] as $key => $group) : ?>
Expand Down Expand Up @@ -139,4 +168,5 @@ $numColumns = count($columns);
<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 endif; ?>
<?php echo $this->element('Components/subscriberList', array('subscribers' => $groupergroupssubscribers)); ?>

0 comments on commit 7c001d8

Please sign in to comment.