From d7b54bf6dbc56b53bcc4d8f08831d431d9efab25 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Fri, 9 Dec 2022 11:59:09 +0100 Subject: [PATCH] Skill: Interface improvements between skill levels and skill level profiles - refs BT#20381 --- main/admin/skill.php | 2 +- main/admin/skill_level.php | 21 +++++++++++++++++-- main/admin/skill_profile.php | 2 +- main/template/default/admin/skill.tpl | 4 ++-- main/template/default/admin/skill_profile.tpl | 11 +++++----- 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/main/admin/skill.php b/main/admin/skill.php index dfb4fd5b8a..a6e0225830 100644 --- a/main/admin/skill.php +++ b/main/admin/skill.php @@ -21,7 +21,7 @@ if (isset($_GET['action']) && in_array($_GET['action'], ['add', 'edit', 'delete' $action = $_GET['action']; } -$id = isset($_GET['id']) ? $_GET['id'] : ''; +$id = isset($_GET['id']) ? (int) $_GET['id'] : ''; $item = null; if (!empty($id)) { diff --git a/main/admin/skill_level.php b/main/admin/skill_level.php index e7b06c3640..dfa629d70f 100644 --- a/main/admin/skill_level.php +++ b/main/admin/skill_level.php @@ -25,6 +25,8 @@ if (isset($_GET['action']) && in_array($_GET['action'], ['add', 'edit', 'delete' $id = isset($_GET['id']) ? $_GET['id'] : ''; +$profileId = !empty($_GET['profile_id']) ? (int) $_GET['profile_id'] : 0; + $item = null; if (!empty($id)) { /** @var Level $item */ @@ -40,7 +42,14 @@ $form->addText('short_name', get_lang('ShortName')); $form->addSelectFromCollection('profile_id', get_lang('Profile'), $profiles); $form->addHidden('action', $action); $form->addHidden('id', $id); -$form->addButtonSave(get_lang('Save')); +// Submit buttons +if ($action == 'edit') { + $form->addButtonSave(get_lang('Save')); +} elseif ($action == 'add') { + $html_results_enabled[] = $form->createElement('button', 'submit', get_lang('Add'), 'plus', 'primary'); + $html_results_enabled[] = $form->createElement('button', 'submit_plus', get_lang('Add').'+', 'plus', 'primary'); + $form->addGroup($html_results_enabled); +} if (!empty($item)) { $form->setDefaults([ @@ -48,13 +57,17 @@ if (!empty($item)) { 'short_name' => $item->getShortName(), 'profile_id' => $item->getProfile()->getId(), ]); +} elseif (!empty($profileId)) { + $form->setDefaults([ + 'profile_id' => $profileId + ]); } $formToDisplay = ''; $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('PlatformAdmin')]; $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/skill.php', 'name' => get_lang('ManageSkillsLevels')]; -$interbreadcrumb[] = ['url' => api_get_self(), 'name' => get_lang('SkillLevel')]; +$interbreadcrumb[] = ['url' => api_get_self(), 'name' => get_lang('SkillLevels')]; switch ($action) { case 'add': @@ -77,6 +90,10 @@ switch ($action) { } else { Display::addFlash(Display::return_message(get_lang('YouNeedToCreateASkillProfile'))); } + if (isset($values['submit_plus'])) { + header('Location: '.$listAction.'?action=add'); + exit; + } header('Location: '.$listAction); exit; } diff --git a/main/admin/skill_profile.php b/main/admin/skill_profile.php index 382089b95f..64a10077dd 100644 --- a/main/admin/skill_profile.php +++ b/main/admin/skill_profile.php @@ -46,7 +46,7 @@ $formToDisplay = $form->returnForm(); $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('PlatformAdmin')]; $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/skill.php', 'name' => get_lang('ManageSkillsLevels')]; -$interbreadcrumb[] = ['url' => api_get_self(), 'name' => get_lang('SkillProfile')]; +$interbreadcrumb[] = ['url' => api_get_self(), 'name' => get_lang('SkillLevelProfiles')]; $toolbar = null; diff --git a/main/template/default/admin/skill.tpl b/main/template/default/admin/skill.tpl index 6983e35d13..0f2ffe9018 100644 --- a/main/template/default/admin/skill.tpl +++ b/main/template/default/admin/skill.tpl @@ -2,12 +2,12 @@ diff --git a/main/template/default/admin/skill_profile.tpl b/main/template/default/admin/skill_profile.tpl index c1cd10b369..4a8879d213 100644 --- a/main/template/default/admin/skill_profile.tpl +++ b/main/template/default/admin/skill_profile.tpl @@ -10,9 +10,6 @@ {{ item.name }} - {##} - {##} - {##}