Skip to content

Commit

Permalink
Code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Apr 1, 2024
1 parent a0c059a commit 700f48c
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 77 deletions.
2 changes: 1 addition & 1 deletion Controller/CoGrouperLiteWidgetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function display($id) {
$cfg = $this->CoGrouperLiteWidget->getConfig();

$this->set('pl_grouperlite_index_url', Router::url([
'plugin' => "grouper_lite",
'plugin' => 'grouper_lite',
'controller' => 'grouper_groups',
'action' => 'index',
'co' => $this->cur_co['Co']['id'],
Expand Down
96 changes: 48 additions & 48 deletions View/CoGrouperLiteWidgets/display.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ $this->extend('/GrouperGroups/base');

// Figure out the widget ID so we can overwrite the dashboard's widget div
$divid = $vv_config['CoGrouperLiteWidget']['co_dashboard_widget_id'];
$plugin = filter_var($vv_codw['CoDashboardWidget']['plugin'], FILTER_SANITIZE_SPECIAL_CHARS);
$pl = Inflector::underscore($plugin);
$plcmodel = Inflector::pluralize($pl);
$pl = Inflector::underscore(filter_var($vv_codw['CoDashboardWidget']['plugin'], FILTER_SANITIZE_SPECIAL_CHARS));
$idsuffix = rand();

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

const app = Vue.createApp({
Expand All @@ -53,52 +51,52 @@ $idsuffix = rand();
glid: "<?= $glid ?>",
pages: [
{
label: "<?php echo _txt('pl.grouperlite.nav.memberships'); ?>",
url: "<?php print $this->Html->url(
array(
'plugin' => $pl,
'controller' => 'grouper_groups',
'action' => 'groupmember',
'co' => $coid,
'glid' => $glid
)
); ?>"
label: "<?= _txt('pl.grouperlite.nav.memberships') ?>",
url: "<?= $this->Html->url(
[
'plugin' => $pl,
'controller' => 'grouper_groups',
'action' => 'groupmember',
'co' => $coid,
'glid' => $glid
]
) ?>"
},
{
label: "<?php echo _txt('pl.grouperlite.nav.groups-can-join'); ?>",
url: "<?php print $this->Html->url(
array(
'plugin' => $pl,
'controller' => 'grouper_groups',
'action' => 'groupoptin',
'co' => $coid,
'glid' => $glid
)
); ?>"
label: "<?= _txt('pl.grouperlite.nav.groups-can-join') ?>",
url: "<?= $this->Html->url(
[
'plugin' => $pl,
'controller' => 'grouper_groups',
'action' => 'groupoptin',
'co' => $coid,
'glid' => $glid
]
) ?>"
},
{
label: "<?php echo _txt('pl.grouperlite.nav.groups-presided'); ?>",
url: "<?php print $this->Html->url(
array(
'plugin' => $pl,
'controller' => 'grouper_groups',
'action' => 'groupowner',
'co' => $coid,
'glid' => $glid
)
); ?>"
label: "<?= _txt('pl.grouperlite.nav.groups-presided') ?>",
url: "<?= $this->Html->url(
[
'plugin' => $pl,
'controller' => 'grouper_groups',
'action' => 'groupowner',
'co' => $coid,
'glid' => $glid
]
) ?>"
},
{
label: "<?php echo _txt('pl.grouperlite.nav.users-presided'); ?>",
url: "<?php print $this->Html->url(
array(
'plugin' => $pl,
'controller' => 'grouper_groups',
'action' => 'usermanager',
'co' => $coid,
'glid' => $glid
)
); ?>"
label: "<?= _txt('pl.grouperlite.nav.users-presided') ?>",
url: "<?= $this->Html->url(
[
'plugin' => $pl,
'controller' => 'grouper_groups',
'action' => 'usermanager',
'co' => $coid,
'glid' => $glid
]
) ?>"
}
]
}
Expand All @@ -109,11 +107,11 @@ $idsuffix = rand();
});

$(document).ready(function () {
app.mount('#grouper-lite-widget-<?php echo $idsuffix; ?>');
app.mount('#grouper-lite-widget-<?= $idsuffix ?>');
});
</script>

<div class="container-fluid p-0 grouper" id="grouper-lite-widget-<?php echo $idsuffix; ?>">
<div class="container-fluid p-0 grouper" id="grouper-lite-widget-<?= $idsuffix ?>">
<div class="row no-gutters">
<div class="col-xl-6 col-lg-8 col-xs-12">
<div class="border rounded container ml-0 mr-auto">
Expand All @@ -124,7 +122,9 @@ $idsuffix = rand();
</div>
</div>
<div class="col-xs-12 col-md-6">
<h3 class="text-center mb-2 mt-2 h6"><em class="material-icons text-grouper" aria-hidden="true">group</em>&nbsp; <?php echo _txt('pl.grouperlite.dashboard.heading.groups'); ?></h3>
<h3 class="text-center mb-2 mt-2 h6"><em class="material-icons text-grouper" aria-hidden="true">group</em>&nbsp; <?= _txt(
'pl.grouperlite.dashboard.heading.groups'
) ?></h3>
<div>
<dashboard :pages="pages"></dashboard>
</div>
Expand Down
19 changes: 12 additions & 7 deletions View/GrouperGroups/base.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ print $this->Html->script('GrouperLiteWidget.autocomplete.grouperplugin') . PHP_
print $this->Html->css('GrouperLiteWidget.co-grouper-base') . PHP_EOL;
print $this->Html->css('GrouperLiteWidget.co-grouper-plugin') . PHP_EOL;

$this->Html->addCrumb(_txt('pl.grouperlite.crumb.root'),
[
'controller' => 'grouper_groups',
'action' => 'groupmember'
],
['prepend' => true]
);
if(isset($this->viewVars['vv_coid'])) {
$this->Html->addCrumb(_txt('pl.grouperlite.crumb.root'),
[
'plugin' => Inflector::underscore(filter_var($this->plugin, FILTER_SANITIZE_SPECIAL_CHARS)),
'controller' => 'grouper_groups',
'action' => 'groupmember',
'co' => $this->viewVars['vv_coid'],
'glid' => $this->viewVars['vv_config']['CoGrouperLiteWidget']['id']
],
['prepend' => true]
);
}
?>

<!-- Load JavaScript -->
Expand Down
37 changes: 17 additions & 20 deletions View/GrouperGroups/index.ctp
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<!--nocache-->
<?php $this->extend('/GrouperGroups/base'); ?>
<?= $this->Html->script('GrouperLiteWidget.vue-router.js') ?>
<?php $this->Html->addCrumb(_txt('pl.grouperlite.nav.memberships')); ?>
<?php
$this->extend('/GrouperGroups/base');

// Add javascript
print $this->Html->script('GrouperLiteWidget.vue-router.js');

// Add Breadcrumb
$this->Html->addCrumb(_txt('pl.grouperlite.nav.memberships'));

?>
<!--/nocache-->
<div class="d-flex align-items-center mb-4">
<?php print $this->Html->image('GrouperLiteWidget.Grouper.jpg', array('class' => 'img-fluid mr-2', 'style' => 'height: 50px')); ?>
<?= $this->Html->image('GrouperLiteWidget.Grouper.jpg', ['class' => 'img-fluid mr-2', 'style' => 'height: 50px']) ?>
<h1 class="h2"><?= $title; ?></h1>
</div>

Expand Down Expand Up @@ -109,13 +116,12 @@
owner: "<?= _txt('pl.grouperlite.nav.groups-presided') ?>",
manager: "<?= _txt('pl.grouperlite.nav.users-presided') ?>",
},
columns: <?php print_r(json_encode(array(
'name' => _txt('pl.grouperlite.table.name'),
'role' => _txt('pl.grouperlite.table.role'),
'description' => _txt('pl.grouperlite.table.description'),
'status' => _txt('pl.grouperlite.table.status'),
'action' => _txt('pl.grouperlite.table.action'),
))) ?>,
columns: <?= json_encode(['name' => _txt('pl.grouperlite.table.name'),
'role' => _txt('pl.grouperlite.table.role'),
'description' => _txt('pl.grouperlite.table.description'),
'status' => _txt('pl.grouperlite.table.status'),
'action' => _txt('pl.grouperlite.table.action')],
JSON_THROW_ON_ERROR) ?>,
},

api: {
Expand Down Expand Up @@ -146,15 +152,6 @@
app.mount('#grouper-lite-widget');
</script>

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

<div class="grouper-table">
<div id="grouper-lite-widget">
<router-view></router-view>
Expand Down
7 changes: 7 additions & 0 deletions webroot/css/co-grouper-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@
max-width: 400px;
}

.ui-autocomplete {
max-height: 240px;
overflow-y: auto;
overflow-x: hidden;
padding-right: 20px;
}

@keyframes fadeInHalf {
from {
opacity: 0.5;
Expand Down
2 changes: 1 addition & 1 deletion webroot/css/co-grouper-plugin.css
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,4 @@ a.list-group-item-action:hover .fa {
animation: 1.2s linear infinite both loading;
background-color: var(--teal);
display: inline-block;
}
}

0 comments on commit 700f48c

Please sign in to comment.