-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
FIX / Improve project creation via template with read-only preview of project tabs #22293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 11.0/bugfixes
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -314,6 +314,14 @@ | |||||
| return false; | ||||||
| } | ||||||
|
|
||||||
| // If we are creating a project from a template, show read-only warning | ||||||
| if ($withtemplate == 2 && $item instanceof Project) { | ||||||
| echo '<div class="alert alert-info mb-3">'; | ||||||
| echo '<i class="ti ti-info-circle me-2"></i>'; | ||||||
| echo __('You are viewing documents from the template. Save the project first to be able to add or modify documents.'); | ||||||
|
Check failure on line 321 in src/Document_Item.php
|
||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| echo '</div>'; | ||||||
| } | ||||||
|
|
||||||
| if ($item instanceof Document && $tabnum === 1) { | ||||||
| return self::showForDocument($item); | ||||||
| } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -86,10 +86,11 @@ | |||||
| * Print the HTML array for Items linked to a project | ||||||
| * | ||||||
| * @param Project $project | ||||||
| * @param int $withtemplate (default 0) | ||||||
| * | ||||||
| * @return bool | ||||||
| **/ | ||||||
| public static function showForProject(Project $project): bool | ||||||
| public static function showForProject(Project $project, int $withtemplate = 0): bool | ||||||
| { | ||||||
| $instID = $project->getID(); | ||||||
|
|
||||||
|
|
@@ -169,7 +170,8 @@ | |||||
|
|
||||||
| TemplateRenderer::getInstance()->display('pages/tools/item_project.html.twig', [ | ||||||
| 'item' => $project, | ||||||
| 'can_edit' => $canedit, | ||||||
| 'can_edit' => $canedit && $withtemplate != 2, | ||||||
| 'withtemplate' => $withtemplate, | ||||||
| 'used' => $used, | ||||||
| 'datatable_params' => [ | ||||||
| 'is_tab' => true, | ||||||
|
|
@@ -245,8 +247,16 @@ | |||||
| return false; | ||||||
| } | ||||||
|
|
||||||
| // If we are creating a project from a template, show read-only warning | ||||||
| if ($withtemplate == 2 && $item instanceof Project) { | ||||||
| echo '<div class="alert alert-info mb-3">'; | ||||||
| echo '<i class="ti ti-info-circle me-2"></i>'; | ||||||
| echo __('You are viewing items from the template. Save the project first to be able to add or modify linked items.'); | ||||||
|
Check failure on line 254 in src/Item_Project.php
|
||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| echo '</div>'; | ||||||
| } | ||||||
|
|
||||||
| if ($item instanceof Project) { | ||||||
| return self::showForProject($item); | ||||||
| return self::showForProject($item, $withtemplate); | ||||||
| } | ||||||
|
|
||||||
| if ( | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -103,26 +103,35 @@ | |||||
|
|
||||||
| public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) | ||||||
| { | ||||||
| // If we are creating a project from a template, show read-only warning | ||||||
| if ($withtemplate == 2 && $item instanceof Project) { | ||||||
| echo '<div class="alert alert-info mb-3">'; | ||||||
| echo '<i class="ti ti-info-circle me-2"></i>'; | ||||||
| echo __('You are viewing ITIL objects from the template. Save the project first to be able to add or modify linked tickets, problems or changes.'); | ||||||
|
Check failure on line 110 in src/Itil_Project.php
|
||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| echo '</div>'; | ||||||
| } | ||||||
|
|
||||||
| switch ($item::class) { | ||||||
| case Change::class: | ||||||
| case Problem::class: | ||||||
| case Ticket::class: | ||||||
| return self::showForItil($item); | ||||||
|
|
||||||
| case Project::class: | ||||||
| return self::showForProject($item); | ||||||
| return self::showForProject($item, $withtemplate); | ||||||
| } | ||||||
| return false; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Show ITIL items for a project. | ||||||
| * ITIL items for a project. | ||||||
| * | ||||||
| * @param Project $project | ||||||
| * @param int $withtemplate (default 0) | ||||||
| * | ||||||
| * @return bool | ||||||
| **/ | ||||||
| public static function showForProject(Project $project): bool | ||||||
| public static function showForProject(Project $project, int $withtemplate = 0): bool | ||||||
| { | ||||||
| global $DB, $CFG_GLPI; | ||||||
|
|
||||||
|
|
@@ -177,7 +186,7 @@ | |||||
| ]; | ||||||
| } | ||||||
|
|
||||||
| if ($canedit) { | ||||||
| if ($canedit && $withtemplate != 2) { | ||||||
| $twig_params = [ | ||||||
| 'btn_msg' => _x('button', 'Add'), | ||||||
| 'used' => $used, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -83,6 +83,15 @@ | |||||
| if (!$item instanceof CommonDBTM) { | ||||||
| return false; | ||||||
| } | ||||||
|
|
||||||
| // If we are creating a project from a template, show read-only warning | ||||||
| if ($withtemplate == 2 && $item instanceof Project) { | ||||||
| echo '<div class="alert alert-info mb-3">'; | ||||||
| echo '<i class="ti ti-info-circle me-2"></i>'; | ||||||
| echo __('You are viewing knowledge base items from the template. Save the project first to be able to add or modify linked articles.'); | ||||||
|
Check failure on line 91 in src/KnowbaseItem_Item.php
|
||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| echo '</div>'; | ||||||
| } | ||||||
|
|
||||||
| self::showForItem($item, $withtemplate); | ||||||
| return true; | ||||||
| } | ||||||
|
|
@@ -118,7 +127,7 @@ | |||||
| } | ||||||
|
|
||||||
| $rand = mt_rand(); | ||||||
| if ($canedit && $ok_state) { | ||||||
| if ($canedit && $ok_state && $withtemplate != 2) { | ||||||
| if ($item::class !== KnowbaseItem::class) { | ||||||
| $visibility = KnowbaseItem::getVisibilityCriteria(); | ||||||
| $condition = (isset($visibility['WHERE']) && count($visibility['WHERE'])) ? $visibility['WHERE'] : []; | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -133,6 +133,14 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $ | |||||
| return false; | ||||||
| } | ||||||
|
|
||||||
| // If we are creating a project from a template, show read-only warning | ||||||
| if ($withtemplate == 2 && $item instanceof Project) { | ||||||
| echo '<div class="alert alert-info mb-3">'; | ||||||
| echo '<i class="ti ti-info-circle me-2"></i>'; | ||||||
| echo __('You are viewing notes from the template. Save the project first to be able to add or modify notes.'); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| echo '</div>'; | ||||||
| } | ||||||
|
|
||||||
| static::showForItem($item, $withtemplate); | ||||||
| return true; | ||||||
| } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -95,7 +95,14 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) | |||||
| public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) | ||||||
| { | ||||||
| if ($item instanceof Project) { | ||||||
| return self::showForProject($item); | ||||||
| // If we are creating from a template, show read-only view with explanation | ||||||
| if ($withtemplate == 2) { | ||||||
| echo '<div class="alert alert-info mb-3">'; | ||||||
| echo '<i class="ti ti-info-circle me-2"></i>'; | ||||||
| echo __('You are viewing costs from the template. Save the project first to be able to add or modify costs.'); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| echo '</div>'; | ||||||
| } | ||||||
| return self::showForProject($item, $withtemplate); | ||||||
| } | ||||||
| return false; | ||||||
| } | ||||||
|
|
@@ -317,7 +324,7 @@ public static function showForProject(Project $project, $withtemplate = 0): bool | |||||
|
|
||||||
| $rand = mt_rand(); | ||||||
|
|
||||||
| if ($canedit) { | ||||||
| if ($canedit && $withtemplate != 2) { | ||||||
| echo "<div id='viewcost" . $ID . "_$rand'></div>\n"; | ||||||
| echo "<script type='text/javascript' >\n"; | ||||||
| echo "function viewAddCost" . $ID . "_$rand() {\n"; | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1211,7 +1211,7 @@ public function rawSearchOptions() | |||||
| * | ||||||
| * @return void|false | ||||||
| **/ | ||||||
| public static function showFor($item) | ||||||
| public static function showFor($item, $withtemplate = 0) | ||||||
| { | ||||||
| global $DB; | ||||||
|
|
||||||
|
|
@@ -1288,7 +1288,7 @@ public static function showFor($item) | |||||
| return; | ||||||
| } | ||||||
|
|
||||||
| if ($canedit) { | ||||||
| if ($canedit && $withtemplate != 2) { | ||||||
| // language=Twig | ||||||
| echo TemplateRenderer::getInstance()->renderFromStringTemplate(<<<TWIG | ||||||
| <div class="mb-3"> | ||||||
|
|
@@ -1297,7 +1297,7 @@ public static function showFor($item) | |||||
| TWIG, ['projects_id' => $ID, 'btn_label' => _x('button', 'Add a task')]); | ||||||
| } | ||||||
|
|
||||||
| if ($item::class === self::class && $item->can($ID, UPDATE)) { | ||||||
| if ($item::class === self::class && $item->can($ID, UPDATE) && $withtemplate != 2) { | ||||||
| $twig_params = [ | ||||||
| 'projects_id' => $item->fields['projects_id'], | ||||||
| 'projecttasks_id' => $ID, | ||||||
|
|
@@ -1444,10 +1444,18 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) | |||||
|
|
||||||
| public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) | ||||||
| { | ||||||
| // If we are creating from a template, show read-only view with explanation | ||||||
| if ($withtemplate == 2) { | ||||||
| echo '<div class="alert alert-info mb-3">'; | ||||||
| echo '<i class="ti ti-info-circle me-2"></i>'; | ||||||
| echo __('You are viewing tasks from the template. Save the project first to be able to add or modify tasks.'); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| echo '</div>'; | ||||||
| } | ||||||
|
|
||||||
| switch ($item::class) { | ||||||
| case Project::class: | ||||||
| case self::class: | ||||||
| self::showFor($item); | ||||||
| self::showFor($item, $withtemplate); | ||||||
| break; | ||||||
| } | ||||||
| return true; | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -108,10 +108,17 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) | |||||
|
|
||||||
| public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) | ||||||
| { | ||||||
| // If we are creating from a template, show read-only view with explanation | ||||||
| if ($withtemplate == 2) { | ||||||
| echo '<div class="alert alert-info mb-3">'; | ||||||
| echo '<i class="ti ti-info-circle me-2"></i>'; | ||||||
| echo __('You are viewing team members from the template. Save the project first to be able to add or modify team members.'); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| echo '</div>'; | ||||||
| } | ||||||
|
|
||||||
| switch (get_class($item)) { | ||||||
| case Project::class: | ||||||
| $item->showTeam($item); | ||||||
| $item->showTeam($item, $withtemplate); | ||||||
| } | ||||||
| return true; | ||||||
| } | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.