Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
feat(ui): create invitations without mass action; enhance menu
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Jun 8, 2017
1 parent c3046ae commit 8ce8d74
Show file tree
Hide file tree
Showing 18 changed files with 116 additions and 17 deletions.
13 changes: 13 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@
padding: 8px 10px 8px 10px;
}

#plugin_flyvemdm_menu li li div {
position: relative;
}

#plugin_flyvemdm_menu li li img {
position: absolute;
height: 20px;
margin: auto 0;
top: 0;
left: 4px;
bottom: 0;
}

#plugin_flyvemdm_menu li div::before, #plugin_flyvemdm_menu li div::after {
content: url(../../../pics/deplier_down.png);
margin: 3px;
Expand Down
6 changes: 6 additions & 0 deletions front/invitation.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
$invitation = new PluginFlyvemdmInvitation();
if (isset($_POST['add'])) {
$invitation->check(-1, CREATE, $_POST);
if ($newID = $invitation->add($_POST)) {
if ($_SESSION['glpibackcreated']) {
Html::redirect($invitation->getFormURL() . "?id=" . $newID);
}
}
Html::back();
} else {
$invitation->check($_GET['id'], READ);
Html::header(
Expand Down
4 changes: 4 additions & 0 deletions inc/agent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public static function getTypeName($nb=0) {
return _n('Agent', 'Agents', $nb, "flyvemdm");
}

public static function getMenuPicture() {
return '../pics/picto-agent.png';
}

/**
* @since version 0.1.0
* @see commonDBTM::getRights()
Expand Down
4 changes: 4 additions & 0 deletions inc/file.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public static function getTypeName($nb=0) {
return _n('File', 'Files', $nb, "flyvemdm");
}

public static function getMenuPicture() {
return '../pics/picto-file.png';
}

/**
*
* @see CommonDBTM::addNeededInfoToInput()
Expand Down
5 changes: 4 additions & 1 deletion inc/fleet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public static function getTypeName($nb = 0) {
return _n('Fleet', 'Fleets', $nb, "flyvemdm");
}

public static function getMenuPicture() {
return '../pics/picto-fleet.png';
}

/**
* @see CommonGLPI::defineTabs()
*/
Expand Down Expand Up @@ -115,7 +119,6 @@ public function showForm($ID, $options = array()) {
echo $twig->render('fleet.html', $data);

$this->showFormButtons($options);

}

/**
Expand Down
16 changes: 16 additions & 0 deletions inc/geolocation.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,22 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtempl
*/
public function getRights($interface='central') {
$rights = parent::getRights();
//$values = array(READ => __('Read'),
// PURGE => array('short' => __('Purge'),
// 'long' => _x('button', 'Delete permanently')));

//$values += ObjectLock::getRightsToAdd( get_class($this), $interface ) ;

//if ($this->maybeDeleted()) {
// $values[DELETE] = array('short' => __('Delete'),
// 'long' => _x('button', 'Put in dustbin'));
//}
//if ($this->usenotepad) {
// $values[READNOTE] = array('short' => __('Read notes'),
// 'long' => __("Read the item's notes"));
// $values[UPDATENOTE] = array('short' => __('Update notes'),
// 'long' => __("Update the item's notes"));
//}

return $rights;
}
Expand Down
25 changes: 23 additions & 2 deletions inc/invitation.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public static function getTypeName($nb=0) {
return _n('Invitation', 'Invitations', $nb, "flyvemdm");
}

public static function getMenuPicture() {
return '../pics/picto-invitation.png';
}

/**
* @since version 0.1.0
* @see commonDBTM::getRights()
Expand Down Expand Up @@ -191,7 +195,7 @@ public function prepareInputForUpdate($input) {
]
);
if (count($forbidden)) {
// An attempt to edit te item by a registered use
// An attempt to edit the item by a registered use
return false;
}
}
Expand Down Expand Up @@ -319,7 +323,7 @@ protected function createQRCodeDocument(User $user, $învitationToken) {
$document = new Document();
$input['entities_id'] = $this->input['entities_id'];
$input['is_recursive'] = '0';
$input['name'] = __('Enrollment QR code', 'flyvemdm');
$input['name'] = addslashes(__('Enrollment QR code', 'flyvemdm'));
$input['_filename'] = array($tmpFile);
$input['_only_if_upload_succeed'] = true;
$documentId = $document->add($input);
Expand Down Expand Up @@ -396,7 +400,24 @@ public function showForm($ID, $options = array()) {

$this->initForm($ID, $options);
$this->showFormHeader();
$twig = plugin_flyvemdm_getTemplateEngine();
$fields = $this->fields;
$user = new User();
$user->getFromDB($fields['users_id']);
$fields['_useremails'] = $user->getDefaultEmail();
$data = [
'withTemplate' => (isset($options['withtemplate']) && $options['withtemplate'] ? "*" : ""),
'canUpdate' => (!$this->isNewID($ID)) && ($this->canUpdate() > 0) || $this->isNewID($ID),
'isNewID' => $this->isNewID($ID),
'invitation' => $fields,
'resendButton' => Html::submit(_x('button', 'Re-send'), array('name' => 'resend')),
];
echo $twig->render('invitation.html', $data);

if (!$this->isNewID($ID)) {
$options['canedit'] = false;
}
$this->showFormButtons($options);
}

protected function showMassiveActionInviteUser() {
Expand Down
22 changes: 14 additions & 8 deletions inc/menu.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,33 +79,38 @@ public function displayMenu() {

$pluralNumber = Session::getPluralNumber();

$graph = new PluginFlyvemdmGraph();

$twig = plugin_flyvemdm_getTemplateEngine();
$data = [
'menu' => [
__('General', 'flyvemdm') => [
PluginFlyvemdmInvitation::getTypeName($pluralNumber) => [
'link' =>Toolbox::getItemTypeSearchURL(PluginFlyvemdmInvitation::class)
'link' =>Toolbox::getItemTypeSearchURL(PluginFlyvemdmInvitation::class),
'pic' => PluginFlyvemdmInvitation::getMenuPicture(),
],
PluginFlyvemdmAgent::getTypeName($pluralNumber) => [
'link' => Toolbox::getItemTypeSearchURL(PluginFlyvemdmAgent::class)
'link' => Toolbox::getItemTypeSearchURL(PluginFlyvemdmAgent::class),
'pic' => PluginFlyvemdmAgent::getMenuPicture(),
],
PluginFlyvemdmFleet::getTypeName($pluralNumber) => [
'link' =>Toolbox::getItemTypeSearchURL(PluginFlyvemdmFleet::class)
'link' =>Toolbox::getItemTypeSearchURL(PluginFlyvemdmFleet::class),
'pic' => PluginFlyvemdmFleet::getMenuPicture(),
],
PluginFlyvemdmPackage::getTypeName($pluralNumber) => [
'link' => Toolbox::getItemTypeSearchURL(PluginFlyvemdmPackage::class)
'link' => Toolbox::getItemTypeSearchURL(PluginFlyvemdmPackage::class),
'pic' => PluginFlyvemdmPackage::getMenuPicture(),
],
PluginFlyvemdmFile::getTypeName($pluralNumber) => [
'link' =>Toolbox::getItemTypeSearchURL(PluginFlyvemdmFile::class)
'link' =>Toolbox::getItemTypeSearchURL(PluginFlyvemdmFile::class),
'pic' => PluginFlyvemdmFile::getMenuPicture(),
],
],
/*
__('Board', 'flyvemdm') => [
PluginFlyvemdmFleet::getTypeName($pluralNumber) => [
'link' => Toolbox::getItemTypeSearchURL(PluginFlyvemdmFleet::class)
]
]
*/
],
];
echo $twig->render('menu.html', $data);
Expand All @@ -131,8 +136,9 @@ public static function getMenuContent() {
'PluginFlyvemdmInvitation' => 'invitation',
);

$pluralNumber = Session::getPluralNumber();
foreach ($itemtypes as $itemtype => $option) {
$menu['options'][$option]['title'] = $itemtype::getTypeName(2);
$menu['options'][$option]['title'] = $itemtype::getTypeName($pluralNumber);
$menu['options'][$option]['page'] = $itemtype::getSearchURL(false);
$menu['options'][$option]['links']['search'] = $itemtype::getSearchURL(false);
if ($itemtype::canCreate()) {
Expand Down
4 changes: 4 additions & 0 deletions inc/package.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public static function getTypeName($nb=0) {
return _n('Package', 'Packages', $nb, "flyvemdm");
}

public static function getMenuPicture() {
return '../pics/picto-package.png';
}

/**
* @see CommonGLPI::defineTabs()
*/
Expand Down
4 changes: 2 additions & 2 deletions install/installer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ protected function createFirstAccess() {

$newRights = array(
PluginFlyvemdmProfile::$rightname => PluginFlyvemdmProfile::RIGHT_FLYVEMDM_USE,
PluginFlyvemdmInvitation::$rightname => CREATE | READ | UPDATE | DELETE | PURGE,
PluginFlyvemdmAgent::$rightname => READ | UPDATE | READNOTE | UPDATENOTE,
PluginFlyvemdmInvitation::$rightname => CREATE | READ | DELETE | PURGE,
PluginFlyvemdmAgent::$rightname => READ | UPDATE | PURGE | READNOTE | UPDATENOTE,
PluginFlyvemdmFleet::$rightname => ALLSTANDARDRIGHT | READNOTE | UPDATENOTE,
PluginFlyvemdmPackage::$rightname => ALLSTANDARDRIGHT | READNOTE | UPDATENOTE,
PluginFlyvemdmFile::$rightname => ALLSTANDARDRIGHT | READNOTE | UPDATENOTE,
Expand Down
Binary file added pics/picto-agent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/picto-file.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/picto-fleet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/picto-invitation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/picto-package.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion tests/0010_Integration/SuperAdminProfileIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function testGetRights() {
PluginFlyvemdmPolicyCategory::$rightname,
PluginFlyvemdmProfile::$rightname,
PluginFlyvemdmEntityconfig::$rightname,
PluginFlyvemdmInvitation::$rightname,
PluginFlyvemdmInvitationLog::$rightname,
User::$rightname,
Profile::$rightname,
Expand All @@ -70,7 +71,7 @@ public function testGetRights() {
* @param array $rights
*/
public function testSuperAdminProfileAgentRight($rights) {
$this->assertEquals(READ | UPDATE | READNOTE | UPDATENOTE, $rights[PluginFlyvemdmAgent::$rightname]);
$this->assertEquals(READ | UPDATE | PURGE | READNOTE | UPDATENOTE, $rights[PluginFlyvemdmAgent::$rightname]);
}

/**
Expand Down Expand Up @@ -150,6 +151,14 @@ public function testSuperAdminProfilePluginProfileEntityconfigRight($rights) {
$rights[PluginFlyvemdmEntityconfig::$rightname]);
}

/**
* @depends testGetRights
* @param array $rights
*/
public function testSuperAdminProfilePluginProfileInvitationRight($rights) {
$this->assertEquals(CREATE | READ | DELETE | PURGE, $rights[PluginFlyvemdmInvitation::$rightname]);
}

/**
* @depends testGetRights
* @param array $rights
Expand Down
17 changes: 15 additions & 2 deletions tpl/invitation.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
{% if isNewID == true %}
<tr>
<td>
{{ email.label }}
{{ __('Email') }}
</td>
<td>
<input name="email">
<input name="_useremails" value="{{ invitation._useremails }}">
</td>
</tr>
{% else %}
<tr>
<td>
{{ __('There is nothing to change in an invitation. You may only need to re-send it.') }}
</td>
</tr>
<tr>
<td>
{{ resendButton|raw }}
</td>
</tr>
{% endif %}
2 changes: 1 addition & 1 deletion tpl/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<li><a href="#"><div>{{ menuName }}</div></a>
<ul>
{% for subMenuName, subMenu in menuItem %}
<li><a href="{{ subMenu.link }}"><div>{{ subMenuName }}</div></a></li>
<li><a href="{{ subMenu.link }}"><div><img src="{{ subMenu.pic }}" /><span>{{ subMenuName }}</span></div></a></li>
{% endfor %}
</ul>
</li>
Expand Down

0 comments on commit 8ce8d74

Please sign in to comment.