-
-
Notifications
You must be signed in to change notification settings - Fork 6
Add History Logging for Family Merge and Detach Operations #790
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
vahidbazzaz
wants to merge
5
commits into
master
Choose a base branch
from
feat/beneficiary-family-history-logging
base: master
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.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1033e58
Add history log for beneficiaries merged to family via action button
vahidbazzaz 45b28b1
Add history log for beneficiaries detached from family via action button
vahidbazzaz c79f24d
Add history log for beneficiary added to family via drag & drop
vahidbazzaz 03aa43c
Add history log for beneficiary removed from family via drag & drop
vahidbazzaz e6f068a
Add Cypress tests to verify family operation history logging
vahidbazzaz 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -439,6 +439,7 @@ function () use ($cmsmain, $data) { | |
| } | ||
| } | ||
| }); | ||
| simpleBulkSaveChangeHistory('people', $ids, 'merged to family (head: '.$oldest.')'); | ||
| $success = true; | ||
| $message = 'The merge has be successfully applied'; | ||
| $redirect = true; | ||
|
|
@@ -464,6 +465,7 @@ function () use ($cmsmain, $data) { | |
| db_query('UPDATE people SET parent_id = NULL WHERE id = :id', ['id' => $id]); | ||
| } | ||
| }); | ||
| simpleBulkSaveChangeHistory('people', $ids, 'detached from family'); | ||
|
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. this should maybe be simpleBulkSaveChangeHistory('people', $ids, 'parent_id; detached from family', ['int'=> <parent_id>, []); |
||
| $redirect = true; | ||
| $success = true; | ||
| $message = ($success) ? 'Selected people have been detached' : 'Something went wrong'; | ||
|
|
@@ -482,7 +484,30 @@ function () use ($cmsmain, $data) { | |
| $ids = json_decode((string) $_POST['ids']); | ||
| // list($success, $message, $redirect, $aftermove) = listMove($table, $ids, true, 'correctdrops'); | ||
| // Refactored list move method to use a transaction block and bulk insert for the correctdrops method | ||
| [$success, $message, $redirect, $aftermove] = listBulkMove($table, $ids, true, 'bulkcorrectdrops', true); | ||
| [$success, $message, $redirect, $aftermove, $parentChanges] = listBulkMove($table, $ids, true, 'bulkcorrectdrops', true); | ||
|
|
||
| // Log history for drag & drop family operations | ||
| if (!empty($parentChanges)) { | ||
| $addedToFamily = []; | ||
| $removedFromFamily = []; | ||
|
|
||
| foreach ($parentChanges as $change) { | ||
| if (is_null($change['old_parent_id']) && !is_null($change['new_parent_id'])) { | ||
| // Added to family | ||
| $addedToFamily[] = $change['id']; | ||
| } elseif (!is_null($change['old_parent_id']) && is_null($change['new_parent_id'])) { | ||
| // Removed from family | ||
| $removedFromFamily[] = $change['id']; | ||
| } | ||
| } | ||
|
|
||
| if (!empty($addedToFamily)) { | ||
| simpleBulkSaveChangeHistory('people', $addedToFamily, 'added to family via drag & drop'); | ||
| } | ||
| if (!empty($removedFromFamily)) { | ||
| simpleBulkSaveChangeHistory('people', $removedFromFamily, 'removed from family via drag & drop'); | ||
| } | ||
| } | ||
|
|
||
| break; | ||
|
|
||
|
|
||
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 |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <?php | ||
|
|
||
| // allowed databases | ||
| $devdbs = ['dropapp_dev', 'dropapp_staging']; | ||
| // confirmed testusers | ||
| $testusers = ['admin@admin.co', 'madmin@admin.co', 'coordinator@coordinator.co', 'user@user.co']; | ||
|
|
||
| $return = []; | ||
|
|
||
| // Test if user is a testusers and the database is a dev database | ||
| if (!(in_array($settings['db_database'], $devdbs) && in_array($_SESSION['user']['email'], $testusers))) { | ||
| $msg = 'You do not have access to check test data!'; | ||
| trigger_error($msg, E_USER_ERROR); | ||
|
|
||
| echo json_encode(['error' => 'No permission']); | ||
| } else { | ||
| $recordId = $_POST['record_id']; | ||
| $tablename = $_POST['tablename']; | ||
| $expectedChange = $_POST['expected_change']; | ||
|
|
||
| // Query history table for matching record | ||
| $historyEntries = db_array( | ||
| 'SELECT * FROM history WHERE tablename = :tablename AND record_id = :record_id AND changes LIKE :changes ORDER BY changedate DESC', | ||
| [ | ||
| 'tablename' => $tablename, | ||
| 'record_id' => $recordId, | ||
| 'changes' => '%'.$expectedChange.'%', | ||
| ] | ||
| ); | ||
|
|
||
| if (count($historyEntries) > 0) { | ||
| echo json_encode(['found' => true, 'count' => count($historyEntries), 'entries' => $historyEntries]); | ||
| } else { | ||
| echo json_encode(['found' => false, 'count' => 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
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.
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.
this should maybe be
simpleBulkSaveChangeHistory('people', $ids, 'parent_id; merged to family', [], ['int'=> <parent_id>);