Skip to content

Commit

Permalink
moved form to fields.inc file, updates to lang file
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Dec 17, 2020
1 parent 9f9a43d commit aceb8d0
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 322 deletions.
28 changes: 14 additions & 14 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function index() {

public function groupUser()
{
$this->set('title', 'Grouper Groups:');
$this->set('title', _txt('pl.grouperlite.title.root'));
//TODO - Change to get userid somehow
$this->set('groupergroupsmember', $this->GrouperGroup->optinGroups($this->userId));
}
Expand All @@ -31,13 +31,13 @@ public function groupInfo()
$details = $this->GrouperGroup->groupDescriptions($name);

$this->set('groupname', $name);
$this->set('title', 'Group configuration and attributes');
$this->set('title', _txt('pl.grouperlite.title.groupinfo'));
$this->set('groupergroupsdetail', $details[0]);
}

public function groupOwner()
{
$this->set('title', 'Grouper Groups I Manage:');
$this->set('title', _txt('pl.grouperlite.title.groupowner'));
if (isset($this->request->data['search'])){
$searchCriteria = urldecode($this->request->data['search']);
$this->set('groupergroupsowner', $this->GrouperGroup->getSearchedGroups($this->userId, $searchCriteria, 'groupOwner'));
Expand All @@ -49,7 +49,7 @@ public function groupOwner()

public function groupOptin()
{
$this->set('title', 'Grouper Groups I Can Join:');
$this->set('title', _txt('pl.grouperlite.title.groupoptin'));

if (isset($this->request->data['search'])){
$searchCriteria = urldecode($this->request->data['search']);
Expand All @@ -62,7 +62,7 @@ public function groupOptin()

public function emailListsOptin()
{
$this->set('title', 'Email lists');
$this->set('title', _txt('pl.grouperlite.title.emaillists'));
// mock data
$this->set('group', array(
'member' => true,
Expand All @@ -74,7 +74,7 @@ public function emailListsOptin()

public function emailListsManaged()
{
$this->set('title', 'Email lists I manage');
$this->set('title', _txt('pl.grouperlite.title.emaillistsmanaged'));
// mock data
$this->set('group', array(
'member' => true,
Expand All @@ -86,7 +86,7 @@ public function emailListsManaged()

public function emailListInfo()
{
$this->set('title', 'Email list configuration and attributes');
$this->set('title', _txt('pl.grouperlite.title.emaillistsinfo'));
// mock data
$this->set('groupergroupsdetail', array(
'member' => true,
Expand All @@ -103,7 +103,7 @@ public function emailListInfo()
}

public function groupCreateForm() {
$this->set('title', 'Create Grouper Group');
$this->set('title', _txt('pl.grouperlite.title.groupcreate'));
}

public function groupCreate()
Expand All @@ -120,13 +120,13 @@ public function joinGroup()
if ($this->request->is('post')) {
$name = $this->request->data['GroupName'];
if($this->GrouperGroup->joinGroup($this->userId, $name)) {
$this->Flash->success(__('You have been added to the group!'));
$this->Flash->success(__(_txt('You have been added to the group!')));
} else {
$this->Flash->error(__('You are unable to join the group!'));
$this->Flash->error(__(_txt('You are unable to join the group!')));
}
return $this->redirect(array('action' => 'groupoptin'));
}
$this->Flash->error(__('An error occurred in joining the group, please try again later.'));
$this->Flash->error(__(_txt('An error occurred in joining the group, please try again later.')));

}

Expand All @@ -135,13 +135,13 @@ public function leaveGroup()
if ($this->request->is('post')) {
$name = $this->request->data['GroupName'];
if($this->GrouperGroup->leaveGroup($this->userId, $name)) {
$this->Flash->success(__('You have been deleted from the group!'));
$this->Flash->success(__(_txt('You have been deleted from the group!')));
} else {
$this->Flash->error(__('You are unable to delete the group!'));
$this->Flash->error(__(_txt('You are unable to delete the group!')));
}
return $this->redirect(array('action' => 'groupoptin'));
}
$this->Flash->error(__('An error occurred in leaving the group, please try again later.'));
$this->Flash->error(__(_txt('An error occurred in leaving the group, please try again later.')));
}

/**
Expand Down
38 changes: 38 additions & 0 deletions Lib/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,30 @@

$cm_grouper_lite_texts['en_US'] = array(

'pl.grouperlite.crumb.root' => 'Grouper groups',
'pl.grouperlite.nav.groups' => 'Groups',
'pl.grouperlite.nav.groups-presided' => 'Groups I preside over',
'pl.grouperlite.nav.email-lists' => 'Email lists',
'pl.grouperlite.nav.email-lists-managed' => 'Email lists I manage',
'pl.grouperlite.nav.create-group' => 'Create group',

'pl.grouperlite.title.root' => 'Grouper Groups:',
'pl.grouperlite.title.groupinfo' => 'Group configuration and attributes',
'pl.grouperlite.title.groupowner' => 'Grouper Groups I Manage',
'pl.grouperlite.title.groupoptin' => 'Grouper Groups I Can Join',
'pl.grouperlite.title.emaillists' => 'Email lists',
'pl.grouperlite.title.emaillistsmanaged' => 'Email lists I manage',
'pl.grouperlite.title.emaillistsinfo' => 'Email list configuration and attributes',
'pl.grouperlite.title.groupcreate' => 'Create Grouper Group',

'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.leave-group-success' => 'You have been deleted from the group!',
'pl.grouperlite.message.flash.leave-group-failed' => 'You are unable to delete the group!',
'pl.grouperlite.message.flash.leave-group-error' => 'An error occurred in leaving the group, please try again later.',

'pl.grouperlite.table.name' => 'Name',
'pl.grouperlite.table.description' => 'Description',
'pl.grouperlite.table.status' => 'Status',
Expand All @@ -24,6 +42,26 @@
'pl.grouperlite.action.subscribe' => 'Subscribe',
'pl.grouperlite.action.unsubscribe' => 'Unsubscribe',
'pl.grouperlite.action.search' => 'Search',
'pl.grouperlite.action.remove' => 'Remove',

'pl.grouperlite.form.group.template.label' => 'Select a template',
'pl.grouperlite.form.group.template.empty' => '(choose one)',
'pl.grouperlite.form.group.name.label' => 'Display name',
'pl.grouperlite.form.group.name.help' => 'Name is the label that identifies this group, and might change.',
'pl.grouperlite.form.group.stem.label' => 'Create in this folder:',
'pl.grouperlite.form.group.stem.help' => 'Enter a folder name.',
'pl.grouperlite.form.group.description.label' => 'Description:',
'pl.grouperlite.form.group.description.help' => 'Description contains notes about the group, which could include: what the group represents, why it was created, etc.',
'pl.grouperlite.form.group.privs.label' => 'Privileges',
'pl.grouperlite.form.group.privs.label.READ' => 'READ',
'pl.grouperlite.form.group.privs.label.VIEW' => 'VIEW',
'pl.grouperlite.form.group.privs.label.OPTIN' => 'OPTIN',
'pl.grouperlite.form.group.privs.label.OPTOUT' => 'OPTOUT',
'pl.grouperlite.form.group.privs.label.ATTRIBUTE_READ' => 'ATTRIBUTE READ',
'pl.grouperlite.form.group.subs.label' => 'Subscribers:',
'pl.grouperlite.form.group.subs.help' => 'Select subscribers to add to the group.',
'pl.grouperlite.form.group.subs.placeholder' => 'Search subscribers',
'pl.grouperlite.form.group.action.save' => 'Save Group',

'pl.grouperlite.search.tags.text' => 'Search',
);
2 changes: 1 addition & 1 deletion View/Elements/Components/search.ctp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script type="text/javascript">
$(document).ready(function() {
$(function() {
var collapse = $(".collapse"),
btn = $(".adv-search-link"),
open = false;
Expand Down
4 changes: 2 additions & 2 deletions View/GrouperGroups/base.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ print $this->Html->css('GrouperLite.co-grouper-plugin') . "\n ";
print $this->Html->script('GrouperLite.bootstrap.bundle.js') . "\n ";
print $this->Html->script('GrouperLite.typeahead.bundle.js') . "\n ";

$this->Html->addCrumb('Grouper groups', array('controller' => 'groupergroups', 'action' => 'groupoptin'), array('prepend' => true));
$this->Html->addCrumb(_txt('pl.grouperlite.crumb.root'), array('controller' => 'groupergroups', 'action' => 'groupoptin'), array('prepend' => true));
?>

<div id="grouper-plugin" class="pt-2">
<div class="d-flex align-items-center">
<h2><?php echo($title); ?></h2>
<h2><?php echo $title; ?></h2>
</div>
<?php echo $this->fetch('content'); ?>
</div>
208 changes: 208 additions & 0 deletions View/GrouperGroups/fields.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
<?php
$PRIVELAGES = array('READ', 'VIEW', 'OPTIN', 'OPTOUT', 'ATTRIBUTE_READ');
?>

<script type="text/javascript">
$(function() {
var form = $('#form');
var selector = $('#template-select')
selector.on('change', function(ev) {
if (ev.target.value && ev.target.value !== '') {
form.removeClass('d-none');
} else {
form.addClass('d-none');
}
});

var users = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
// url points to a json file that contains an array of country names, see
// https://github.com/twitter/typeahead.js/blob/gh-pages/data/countries.json
remote: '/files/users.json',
identify: function(obj) {
return obj.email;
}
});

var subscribers = [];

// passing in `null` for the `options` arguments will result in the default
// options being used
var typeahead = $('#userselect .typeahead').typeahead({
hint: true,
highlight: true,
minLength: 1
}, {
name: 'users',
display: function(obj) {
return obj.name;
},
source: users
});

var list = $('#subscriber-list');

typeahead.on('typeahead:select', function(ev, selection) {
ev.preventDefault();
typeahead.typeahead('val', null);
addSubscriber(selection);
});

list.delegate('.typeahead-remove', 'click', function(ev) {
var email = $(ev.currentTarget).data('subscriber');
removeSubscriber(email);
});

function removeSubscriber(email) {
subscribers = subscribers.filter(function(s) {
return email !== s.email;
});
updateSubscriberList();
}

function addSubscriber(sub) {
subscribers.push(sub);
updateSubscriberList();
}

function updateSubscriberList() {
list.empty();
list.html(subscribers.map(function(s) {

var button = [
'<button class="btn btn-text btn-icon ml-2 typeahead-remove" type="button" data-subscriber="' + s.email + '">',
'<span class="sr-only">',
<?php echo _txt('pl.grouperlite.action.remove') ?>,
'</span>',
'<i class="fa fa-times"></i>',
'</button>'
].join('');

return [
'<span class="badge badge-pill badge-primary d-inline-flex align-items-center mr-2">',
s.name,
button,
'<input type="hidden" name="subscribers[]" value="' + s.email + '" />',
'</span>'
].join('');
}));
}

});
</script>

<div class="form-group row py-2 bg-lighter">
<?php echo $this->Form->label(false, _txt('pl.grouperlite.form.group.template.label'), array(
'for' => 'template-select',
'class' => "col-sm-3 col-form-label"
)); ?>
<div class="col-sm-9">
<?php echo $this->Form->input('grouptemplate', array(
'label' => false,
'class' => 'custom-select',
'id' => 'template-select',
'options' => array('1' => 'Template', '2' => 'Another template', '3' => 'Yet another template'),
'empty' => _txt('pl.grouperlite.form.group.template.empty')
)); ?>
</div>
</div>
<fieldset id="form" class="">
<div class="form-group row py-2 bg-light">
<?php echo $this->Form->label(false, _txt('pl.grouperlite.form.group.name.label'), array(
'for' => 'name',
'class' => "col-sm-3 col-form-label"
)); ?>
<div class="col-sm-9">
<?php echo $this->Form->input('name', array(
'label' => false,
'class' => 'form-control',
'id' => 'name'
)); ?>
<small id="nameHelp" class="form-text text-muted">
<?php echo _txt('pl.grouperlite.form.group.name.help'); ?>
</small>
</div>
</div>
<div class="form-group row py-2 bg-lighter">
<?php echo $this->Form->label(false, _txt('pl.grouperlite.form.group.stem.label'), array(
'for' => 'folder',
'class' => "col-sm-3 col-form-label"
)); ?>
<div class="col-sm-9">
<?php echo $this->Form->input('grouptemplate', array(
'label' => false,
'class' => 'form-control',
'id' => 'folder',
'default' => 'sandbox:org:unicon:',
'readonly' => true
)); ?>
<small id="folderHelp" class="form-text text-muted">
<?php echo _txt('pl.grouperlite.form.group.stem.help'); ?>
</small>
</div>
</div>
<div class="form-group row py-2 bg-light">
<?php echo $this->Form->label(false, 'Description:', array(
'for' => 'descr',
'class' => "col-sm-3 col-form-label"
)); ?>
<div class="col-sm-9">
<?php echo $this->Form->textarea('description', array(
'class' => 'form-control',
'id' => 'descr',
'rows' => 5
)); ?>
<small id="descrHelp" class="form-text text-muted">
Description contains notes about the group, which could include: what the group represents, why it was created, etc.
</small>
</div>
</div>
<div class="form-group row py-2 bg-lighter">
<legend class="col-form-label col-sm-3 pt-0">Privileges:</legend>
<div class="col-sm-9">
<div class="d-flex">
<?php foreach ($PRIVELAGES as $opt) : ?>
<div class="form-check mr-4">
<?php echo $this->Form->checkbox('privelages', array(
'value' => $OPT,
'class' => 'form-check-input',
'id' => 'assign-' . $opt,
'hiddenField' => false
)); ?>
<?php echo $this->Form->label(false, _txt('pl.grouperlite.form.group.privs.label.' . $opt), array(
'for' => 'assign-' . $opt,
'class' => "form-check-label"
)); ?>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<div class="form-group row py-2 bg-light">
<?php echo $this->Form->label(false, _txt('pl.grouperlite.form.group.subs.label'), array(
'for' => 'subscribers',
'class' => "col-sm-3 col-form-label"
)); ?>
<div class="col-sm-9" id="userselect">
<?php echo $this->Form->input('grouptemplate', array(
'label' => false,
'class' => 'typeahead form-control',
'id' => 'name',
'placeholder' => _txt('pl.grouperlite.form.group.subs.placeholder')
)); ?>
<small id="descrHelp" class="form-text text-muted">
<?php echo _txt('pl.grouperlite.form.group.subs.help'); ?>
</small>
<div id="subscriber-list" class="my-2"></div>
</div>
</div>
<div class="form-group row py-2 bg-lighter">
<div class="col-sm-9 offset-sm-3">
<?php echo $this->Form->button(_txt('pl.grouperlite.form.group.action.save'), array(
'type' => 'submit',
'class' => 'btn btn-primary btn-lg btn-raised'
)); ?>
</div>
</div>
</fieldset>
Loading

0 comments on commit aceb8d0

Please sign in to comment.