Add dropdown menu to autocomplete email field from project members
This commit is contained in:
@@ -5,6 +5,7 @@ New features:
|
|||||||
|
|
||||||
* Automatic action to assign tasks to its creator
|
* Automatic action to assign tasks to its creator
|
||||||
* Add the possibility to create a comment when a task is sent by email
|
* Add the possibility to create a comment when a task is sent by email
|
||||||
|
* Add dropdown menu to autocomplete email field from project members
|
||||||
|
|
||||||
Version 1.0.44 (May 28, 2017)
|
Version 1.0.44 (May 28, 2017)
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class TaskMailController extends BaseController
|
|||||||
'errors' => $errors,
|
'errors' => $errors,
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
'project' => $project,
|
'project' => $project,
|
||||||
|
'members' => $this->projectPermissionModel->getMembersWithEmail($project['id']),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,13 @@ class ProjectGroupRoleModel extends Base
|
|||||||
public function getUsers($project_id)
|
public function getUsers($project_id)
|
||||||
{
|
{
|
||||||
return $this->db->table(self::TABLE)
|
return $this->db->table(self::TABLE)
|
||||||
->columns(UserModel::TABLE.'.id', UserModel::TABLE.'.username', UserModel::TABLE.'.name', self::TABLE.'.role')
|
->columns(
|
||||||
|
UserModel::TABLE.'.id',
|
||||||
|
UserModel::TABLE.'.username',
|
||||||
|
UserModel::TABLE.'.name',
|
||||||
|
UserModel::TABLE.'.email',
|
||||||
|
self::TABLE.'.role'
|
||||||
|
)
|
||||||
->join(GroupMemberModel::TABLE, 'group_id', 'group_id', self::TABLE)
|
->join(GroupMemberModel::TABLE, 'group_id', 'group_id', self::TABLE)
|
||||||
->join(UserModel::TABLE, 'id', 'user_id', GroupMemberModel::TABLE)
|
->join(UserModel::TABLE, 'id', 'user_id', GroupMemberModel::TABLE)
|
||||||
->eq(self::TABLE.'.project_id', $project_id)
|
->eq(self::TABLE.'.project_id', $project_id)
|
||||||
|
|||||||
@@ -93,6 +93,24 @@ class ProjectPermissionModel extends Base
|
|||||||
return $members;
|
return $members;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMembers($project_id)
|
||||||
|
{
|
||||||
|
$userMembers = $this->projectUserRoleModel->getUsers($project_id);
|
||||||
|
$groupMembers = $this->projectGroupRoleModel->getUsers($project_id);
|
||||||
|
|
||||||
|
$userMembers = array_column_index_unique($userMembers, 'username');
|
||||||
|
$groupMembers = array_column_index_unique($groupMembers, 'username');
|
||||||
|
return array_merge($userMembers, $groupMembers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMembersWithEmail($project_id)
|
||||||
|
{
|
||||||
|
$members = $this->getMembers($project_id);
|
||||||
|
return array_filter($members, function (array $user) {
|
||||||
|
return ! empty($user['email']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if everybody is allowed for the project
|
* Return true if everybody is allowed for the project
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -98,7 +98,13 @@ class ProjectUserRoleModel extends Base
|
|||||||
public function getUsers($project_id)
|
public function getUsers($project_id)
|
||||||
{
|
{
|
||||||
return $this->db->table(self::TABLE)
|
return $this->db->table(self::TABLE)
|
||||||
->columns(UserModel::TABLE.'.id', UserModel::TABLE.'.username', UserModel::TABLE.'.name', self::TABLE.'.role')
|
->columns(
|
||||||
|
UserModel::TABLE.'.id',
|
||||||
|
UserModel::TABLE.'.username',
|
||||||
|
UserModel::TABLE.'.name',
|
||||||
|
UserModel::TABLE.'.email',
|
||||||
|
self::TABLE.'.role'
|
||||||
|
)
|
||||||
->join(UserModel::TABLE, 'id', 'user_id')
|
->join(UserModel::TABLE, 'id', 'user_id')
|
||||||
->eq('project_id', $project_id)
|
->eq('project_id', $project_id)
|
||||||
->asc(UserModel::TABLE.'.username')
|
->asc(UserModel::TABLE.'.username')
|
||||||
|
|||||||
@@ -1,12 +1,25 @@
|
|||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2><?= $this->text->e($task['title']) ?> > <?= t('Send by email') ?></h2>
|
<h2><?= $this->text->e($task['title']) ?> > <?= t('Send by email') ?></h2>
|
||||||
</div>
|
</div>
|
||||||
<form method="post" action="<?= $this->url->href('TaskMailController', 'send', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off">
|
<form method="post" action="<?= $this->url->href('TaskMailController', 'send', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off" class="js-task-mail-form">
|
||||||
<?= $this->form->csrf() ?>
|
<?= $this->form->csrf() ?>
|
||||||
|
|
||||||
<?= $this->form->label(t('Email'), 'email') ?>
|
<?= $this->form->label(t('Email'), 'email') ?>
|
||||||
<?= $this->form->email('email', $values, $errors, array('autofocus', 'required', 'tabindex="1"')) ?>
|
<?= $this->form->email('email', $values, $errors, array('autofocus', 'required', 'tabindex="1"')) ?>
|
||||||
|
|
||||||
|
<?php if (! empty($members)): ?>
|
||||||
|
<div class="dropdown">
|
||||||
|
<a href="#" class="dropdown-menu dropdown-menu-link-icon"><i class="fa fa-address-card-o"></i><i class="fa fa-caret-down"></i></a>
|
||||||
|
<ul>
|
||||||
|
<?php foreach ($members as $member): ?>
|
||||||
|
<li data-email="<?= $this->text->e($member['email']) ?>" class="js-autocomplete-email">
|
||||||
|
<?= $this->text->e($this->user->getFullname($member)) ?>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
<?= $this->form->label(t('Subject'), 'subject') ?>
|
<?= $this->form->label(t('Subject'), 'subject') ?>
|
||||||
<?= $this->form->text('subject', $values, $errors, array('required', 'tabindex="2"')) ?>
|
<?= $this->form->text('subject', $values, $errors, array('required', 'tabindex="2"')) ?>
|
||||||
|
|
||||||
|
|||||||
4
assets/js/app.min.js
vendored
4
assets/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
12
assets/js/components/autocomplete-email.js
Normal file
12
assets/js/components/autocomplete-email.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
KB.onClick('.js-autocomplete-email', function (e) {
|
||||||
|
var email = KB.dom(e.target).data('email');
|
||||||
|
|
||||||
|
if (email) {
|
||||||
|
var emailField = KB.find('.js-task-mail-form input[type="email"]');
|
||||||
|
|
||||||
|
if (emailField) {
|
||||||
|
emailField.attr('value', email);
|
||||||
|
_KB.controllers['Dropdown'].close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user