-
Notifications
You must be signed in to change notification settings - Fork 1
Added recursivity for configuring moreoption by entity #3
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
Open
Lainow
wants to merge
33
commits into
main
Choose a base branch
from
fix-recursivity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+460
−41
Open
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
d2a048e
Fix header
Lainow da9563e
Add units tests and PR template
Lainow 5dcb974
Update tests/units/ConfigTest.php
Lainow 2b7ae74
Fix comments
Lainow 95f0cd3
Fix units tests
Lainow 4f2b093
Fix units tests
Lainow ca8b5c6
Fix phpstan
Lainow 746ad07
Fix phpstan
Lainow f53756f
Fix phpstan and gitignore
Lainow bb315c9
Fix phpstan
Lainow 4365e83
Fix phpstan
Lainow d51bbb3
Fix phpstan
Lainow 08be56e
Fix phpstan
Lainow 71ee797
Remove tests files
Lainow c84656d
Assign item group to technician group
Lainow f4e7aa4
Add mandatory field to change and problem
Lainow 1f0d0d9
Add index
Lainow 296e37e
Fix units tests
Lainow f12a2d2
Implement suggestions
Lainow f4becd5
Implement suggestions
Lainow 9db8fec
Update src/Controller.php
Lainow 298fa17
Implement assign technical group ans manager when category changed
Lainow f660911
Fix phpstan
Lainow 3fcee53
Add recursivity
Lainow d305879
Fix lints
Lainow 8e2674c
Fix php cs
Lainow 20bbe93
FIx php units
Lainow 4eec0e3
Merge branch 'main' into fix-recursivity
Lainow 2c83424
Fix lint
Lainow 7fb0d2e
Fix units tests
Lainow 4c90d0b
Apply suggestions from code review
Lainow 627def4
Fix units tests
Lainow 8022516
Use getConfig
Lainow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -112,6 +112,13 @@ public static function preItemUpdate(CommonDBTM $item): CommonDBTM | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| // Handle use_parent_entity field | ||||||||
| if (!isset($item->input['use_parent_entity'])) { | ||||||||
| $item->input['use_parent_entity'] = 0; | ||||||||
| } elseif ($item->input['use_parent_entity'] == 'on') { | ||||||||
| $item->input['use_parent_entity'] = 1; | ||||||||
| } | ||||||||
|
|
||||||||
| return $item; | ||||||||
| } | ||||||||
|
|
||||||||
|
|
@@ -169,31 +176,28 @@ public static function getSelectableActorGroup(): array | |||||||
|
|
||||||||
| public static function showForEntity(Entity $item): void | ||||||||
| { | ||||||||
| // $parents = getAncestorsOf(Entity::getTable(), $item->getID()); | ||||||||
| // if (!empty($parents)) { | ||||||||
| // foreach ($parents as $parent) { | ||||||||
| // $pconfig = new Config(); | ||||||||
| // $pconfig->getFromDBByCrit([ | ||||||||
| // 'entities_id' => $parent, | ||||||||
| // ]); | ||||||||
| // if ($pconfig->getField('is_active') == 1) { | ||||||||
| // $pentity = $parent; | ||||||||
| // } | ||||||||
| // } | ||||||||
| // $csconfig = new self(); | ||||||||
| // $csconfig->getFromDBByCrit([ | ||||||||
| // 'entities_id' => $pentity ?? 0, | ||||||||
| // ]); | ||||||||
| // } | ||||||||
| $moconfig = new self(); | ||||||||
| $moconfig->getFromDBByCrit([ | ||||||||
| 'entities_id' => $item->getID(), | ||||||||
| ]); | ||||||||
|
|
||||||||
| // Get effective configuration to show which entity's config is actually used | ||||||||
| $effectiveConfig = self::getEffectiveConfigForEntity($item->getID()); | ||||||||
| $parentEntityInfo = null; | ||||||||
|
|
||||||||
| if (isset($moconfig->fields['use_parent_entity']) && $moconfig->fields['use_parent_entity'] == 1 && $effectiveConfig->fields['entities_id'] != $item->getID()) { | ||||||||
Lainow marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
| $parentEntity = new Entity(); | ||||||||
| if ($parentEntity->getFromDB($effectiveConfig->fields['entities_id'])) { | ||||||||
| $parentEntityInfo = $parentEntity->getName(); | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| TemplateRenderer::getInstance()->display( | ||||||||
| '@moreoptions/config.html.twig', | ||||||||
| [ | ||||||||
| 'item' => $moconfig, | ||||||||
| 'dropdown_options' => self::getSelectableActorGroup(), | ||||||||
| 'parent_entity_info' => $parentEntityInfo, | ||||||||
| 'params' => [ | ||||||||
| 'canedit' => true, | ||||||||
| ], | ||||||||
|
|
@@ -224,6 +228,36 @@ public static function getCurrentConfig(): self | |||||||
| return $moconfig; | ||||||||
| } | ||||||||
|
|
||||||||
| /** | ||||||||
| * Get effective configuration for current entity, considering parent entity inheritance | ||||||||
| */ | ||||||||
| public static function getEffectiveConfig(): self | ||||||||
Lainow marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Lainow marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
| { | ||||||||
| return self::getEffectiveConfigForEntity(Session::getActiveEntity()); | ||||||||
| } | ||||||||
|
|
||||||||
| /** | ||||||||
| * Get effective configuration for a specific entity, considering parent entity inheritance | ||||||||
| */ | ||||||||
| public static function getEffectiveConfigForEntity(int $entityId): self | ||||||||
| { | ||||||||
| $moconfig = new self(); | ||||||||
| $moconfig->getFromDBByCrit([ | ||||||||
| 'entities_id' => $entityId, | ||||||||
| ]); | ||||||||
|
|
||||||||
| // If use_parent_entity is enabled and we're not at root entity | ||||||||
| if (isset($moconfig->fields['use_parent_entity']) && $moconfig->fields['use_parent_entity'] == 1 && $entityId > 0) { | ||||||||
Lainow marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
| $entity = new Entity(); | ||||||||
| if ($entity->getFromDB($entityId)) { | ||||||||
| $parentId = $entity->fields['entities_id']; | ||||||||
| return self::getEffectiveConfigForEntity($parentId); | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| return $moconfig; | ||||||||
| } | ||||||||
|
|
||||||||
| public static function install(Migration $migration): void | ||||||||
| { | ||||||||
| /** @var \DBmysql $DB */ | ||||||||
|
|
@@ -235,6 +269,7 @@ public static function install(Migration $migration): void | |||||||
| `id` int unsigned NOT NULL AUTO_INCREMENT, | ||||||||
| `is_active` tinyint NOT NULL DEFAULT '1', | ||||||||
| `entities_id` int unsigned NOT NULL DEFAULT '0', | ||||||||
| `use_parent_entity` tinyint NOT NULL DEFAULT '0', | ||||||||
| `take_item_group_ticket` tinyint NOT NULL DEFAULT '0', | ||||||||
|
Comment on lines
+258
to
259
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. Rather than adding a global inheritance option, I think we should follow the approach taken in the core (
Suggested change
|
||||||||
| `take_item_group_change` tinyint NOT NULL DEFAULT '0', | ||||||||
| `take_item_group_problem` tinyint NOT NULL DEFAULT '0', | ||||||||
|
|
||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.