Skip to content

Commit

Permalink
feat(targetticket,targetchange): assign a group from the technician g…
Browse files Browse the repository at this point in the history
…roup of an objec

Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Jan 29, 2020
1 parent 3bf78ff commit 24c365c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 35 deletions.
22 changes: 12 additions & 10 deletions inc/target_actor.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ abstract class PluginFormcreatorTarget_Actor extends CommonDBChild implements Pl
const ACTOR_TYPE_QUESTION_SUPPLIER = 8;
const ACTOR_TYPE_QUESTION_ACTORS = 9;
const ACTOR_TYPE_GROUP_FROM_OBJECT = 10;
const ACTOR_TYPE_TECH_GROUP_FROM_OBJECT = 11;

const ACTOR_ROLE_REQUESTER = 1;
const ACTOR_ROLE_OBSERVER = 2;
Expand All @@ -55,16 +56,17 @@ abstract class PluginFormcreatorTarget_Actor extends CommonDBChild implements Pl

static function getEnumActorType() {
return [
self::ACTOR_TYPE_CREATOR => __('Form requester', 'formcreator'),
self::ACTOR_TYPE_VALIDATOR => __('Form validator', 'formcreator'),
self::ACTOR_TYPE_PERSON => __('Specific person', 'formcreator'),
self::ACTOR_TYPE_QUESTION_PERSON => __('Person from the question', 'formcreator'),
self::ACTOR_TYPE_GROUP => __('Specific group', 'formcreator'),
self::ACTOR_TYPE_QUESTION_GROUP => __('Group from the question', 'formcreator'),
self::ACTOR_TYPE_GROUP_FROM_OBJECT => __('Group from an object', 'formcreator'),
self::ACTOR_TYPE_SUPPLIER => __('Specific supplier', 'formcreator'),
self::ACTOR_TYPE_QUESTION_SUPPLIER => __('Supplier from the question', 'formcreator'),
self::ACTOR_TYPE_QUESTION_ACTORS => __('Actors from the question', 'formcreator'),
self::ACTOR_TYPE_CREATOR => __('Form requester', 'formcreator'),
self::ACTOR_TYPE_VALIDATOR => __('Form validator', 'formcreator'),
self::ACTOR_TYPE_PERSON => __('Specific person', 'formcreator'),
self::ACTOR_TYPE_QUESTION_PERSON => __('Person from the question', 'formcreator'),
self::ACTOR_TYPE_GROUP => __('Specific group', 'formcreator'),
self::ACTOR_TYPE_QUESTION_GROUP => __('Group from the question', 'formcreator'),
self::ACTOR_TYPE_GROUP_FROM_OBJECT => __('Group from an object', 'formcreator'),
self::ACTOR_TYPE_TECH_GROUP_FROM_OBJECT => __('Tech group from an object', 'formcreator'),
self::ACTOR_TYPE_SUPPLIER => __('Specific supplier', 'formcreator'),
self::ACTOR_TYPE_QUESTION_SUPPLIER => __('Supplier from the question', 'formcreator'),
self::ACTOR_TYPE_QUESTION_ACTORS => __('Actors from the question', 'formcreator'),
];
}

Expand Down
6 changes: 5 additions & 1 deletion inc/targetbase.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,9 @@ protected function prepareActors(PluginFormcreatorForm $form, PluginFormcreatorF

// Check the object has a group FK
$groupFk = Group::getForeignKeyField();
if ($actor['actor_type'] == PluginFormcreatorTarget_Actor::ACTOR_TYPE_TECH_GROUP_FROM_OBJECT) {
$groupFk = $groupFk . '_tech';
}
$object = new $itemtype();
if (!$DB->fieldExists($object->getTable(), $groupFk)) {
continue 2;
Expand Down Expand Up @@ -547,7 +550,8 @@ protected function prepareActors(PluginFormcreatorForm $form, PluginFormcreatorF
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_GROUP :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_GROUP :
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_GROUP_FROM_OBJECT:
foreach ($userIds as $groupId) {
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_TECH_GROUP_FROM_OBJECT:
foreach ($userIds as $groupId) {
$this->addGroupActor($actor['actor_role'], $groupId);
}
break;
Expand Down
56 changes: 32 additions & 24 deletions js/scripts.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -715,19 +715,21 @@ function plugin_formcreator_ChangeActorRequester(value) {
$('#block_requester_group').hide();
$('#block_requester_question_group').hide();
$('#block_requester_group_from_object').hide();
$('#block_requester_tech_group_from_object').hide();
$('#block_requester_question_actors').hide();
$('#block_requester_supplier').hide();
$('#block_requester_question_supplier').hide();

switch (value) {
case '3' : $('#block_requester_user').show(); break;
case '4' : $('#block_requester_question_user').show(); break;
case '5' : $('#block_requester_group').show(); break;
case '6' : $('#block_requester_question_group').show(); break;
case '10': $('#block_requester_group_from_object').show(); break;
case '9' : $('#block_requester_question_actors').show(); break;
case '7' : $('#block_requester_supplier').show(); break;
case '8' : $('#block_requester_question_supplier').show(); break;
case '3' : $('#block_requester_user').show(); break;
case '4' : $('#block_requester_question_user').show(); break;
case '5' : $('#block_requester_group').show(); break;
case '6' : $('#block_requester_question_group').show(); break;
case '10': $('#block_requester_group_from_object').show(); break;
case '11': $('#block_requester_tech_group_from_object').show(); break;
case '9' : $('#block_requester_question_actors').show(); break;
case '7' : $('#block_requester_supplier').show(); break;
case '8' : $('#block_requester_question_supplier').show(); break;
}
}

Expand All @@ -737,19 +739,22 @@ function plugin_formcreator_ChangeActorWatcher(value) {
$('#block_watcher_group').hide();
$('#block_watcher_question_group').hide();
$('#block_watcher_group_from_object').hide();
$('#block_watcher_tech_group_from_object').hide();
$('#block_watcher_question_actors').hide();
$('#block_watcher_supplier').hide();
$('#block_watcher_question_supplier').hide();

switch (value) {
case '3' : $('#block_watcher_user').show(); break;
case '4' : $('#block_watcher_question_user').show(); break;
case '5' : $('#block_watcher_group').show(); break;
case '6' : $('#block_watcher_question_group').show(); break;
case '9' : $('#block_watcher_question_actors').show(); break;
case '10': $('#block_watcher_group_from_object').show(); break;
case '7' : $('#block_watcher_supplier').show(); break;
case '8' : $('#block_watcher_question_supplier').show(); break;
case '3' : $('#block_watcher_user').show(); break;
case '4' : $('#block_watcher_question_user').show(); break;
case '5' : $('#block_watcher_group').show(); break;
case '6' : $('#block_watcher_question_group').show(); break;
case '9' : $('#block_watcher_question_actors').show(); break;
case '10': $('#block_watcher_group_from_object').show(); break;
case '11': $('#block_watcher_tech_group_from_object').show(); break;
case '9' : $('#block_watcher_question_actors').show(); break;
case '7' : $('#block_watcher_supplier').show(); break;
case '8' : $('#block_watcher_question_supplier').show(); break;
}
}

Expand All @@ -759,20 +764,23 @@ function plugin_formcreator_ChangeActorAssigned(value) {
$('#block_assigned_group').hide();
$('#block_assigned_question_group').hide();
$('#block_assigned_group_from_object').hide();
$('#block_assigned_tech_group_from_object').hide();
$('#block_assigned_question_actors').hide();
$('#block_assigned_supplier').hide();
$('#block_assigned_question_supplier').hide();

// The numbers match PluginFormcreatorTarget_Actor::ACTOR_TYPE_* constants
switch (value) {
case '3' : $('#block_assigned_user').show(); break;
case '4' : $('#block_assigned_question_user').show(); break;
case '5' : $('#block_assigned_group').show(); break;
case '6' : $('#block_assigned_question_group').show(); break;
case '9' : $('#block_assigned_question_actors').show(); break;
case '10': $('#block_assigned_group_from_object').show(); break;
case '7' : $('#block_assigned_supplier').show(); break;
case '8' : $('#block_assigned_question_supplier').show(); break;
case '3' : $('#block_assigned_user').show(); break;
case '4' : $('#block_assigned_question_user').show(); break;
case '5' : $('#block_assigned_group').show(); break;
case '6' : $('#block_assigned_question_group').show(); break;
case '9' : $('#block_assigned_question_actors').show(); break;
case '10': $('#block_assigned_group_from_object').show(); break;
case '11': $('#block_assigned_tech_group_from_object').show(); break;
case '9' : $('#block_assigned_question_actors').show(); break;
case '7' : $('#block_assigned_supplier').show(); break;
case '8' : $('#block_assigned_question_supplier').show(); break;
}
}

Expand Down

0 comments on commit 24c365c

Please sign in to comment.