-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Saved Custom Report Templates #15714
Conversation
can the save templates be used to automate weekly reports? |
@mcarasso-PPD not in this first version of the feature but it's something we're exploring for a future release. |
static::created(function (ReportTemplate $reportTemplate) { | ||
$logAction = new Actionlog([ | ||
'item_type' => ReportTemplate::class, | ||
'item_id' => $reportTemplate->id, | ||
'created_by' => auth()->id(), | ||
]); | ||
|
||
$logAction->logaction('create'); | ||
}); | ||
|
||
static::updated(function (ReportTemplate $reportTemplate) { | ||
$changed = []; | ||
|
||
foreach ($reportTemplate->getDirty() as $key => $value) { | ||
$changed[$key] = [ | ||
'old' => $reportTemplate->getOriginal($key), | ||
'new' => $reportTemplate->getAttribute($key), | ||
]; | ||
} | ||
|
||
$logAction = new Actionlog(); | ||
$logAction->item_type = ReportTemplate::class; | ||
$logAction->item_id = $reportTemplate->id; | ||
$logAction->created_by = auth()->id(); | ||
$logAction->log_meta = json_encode($changed); | ||
$logAction->logaction('update'); | ||
}); | ||
|
||
static::deleted(function (ReportTemplate $reportTemplate) { | ||
$logAction = new Actionlog([ | ||
'item_type' => ReportTemplate::class, | ||
'item_id' => $reportTemplate->id, | ||
'created_by' => auth()->id(), | ||
]); | ||
|
||
$logAction->logaction('delete'); | ||
}); |
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.
Understandable if we want to move these to an observer.
@snipe friendly ping on this PR. I know it's a lot of changes but it is mostly additions for the new feature so hopefully it is easier to review. |
Description
This PR introduces the concept of Saved Custom Asset Report Templates so users that frequently run Custom Asset Reports can load a customized pre-defined template instead of having to select all of the options they want each time.
Overview of Feature
New Custom Asset Report page with new options to open saved template or created a new one with the selected options
So if you select some options, enter a name and hit save
You'll be redirected to the saved template and can hit
Generate
like normal at the bottom of the pageYou can select existing saved templates upon returning the Custom Asset Report page in the future from the menu on the top left of the page
Templates can be updated by clicking the yellow pencil icon, updating selections, and hitting the Save button at the bottom of the page
Templates can also be (soft) deleted by clicking the red trash icon
Technical Details / Decisions
Here are some decisions that were made in this PR that we might want to change before merging:
ReportTemplate
booted()
method.ReportTemplate
model's name field does not have a unique constraint on it. This will make it easier to handle any duplicate names issues when reports are eventually sharable.reports.view
permission was re-used for managing saved templates.ReportTemplate
) was used to simplify changes to the view (avoid adding a bunch ofif
checks to see if the user is working with a saved template or generating a report on the fly). This is seen in the modifications to the existingReportsController
.(Potential) Future Improvements
Big shoutout to @akemidx for kicking this off and pairing throughout!
Fixes #4616
Type of change