Skip to content

Commit

Permalink
Refactor: Refactor payroll toggle to use same payroll permissions as …
Browse files Browse the repository at this point in the history
…page (#571)
  • Loading branch information
CaitBarnard authored Dec 9, 2024
1 parent 0fe4dea commit 2e62ef1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion forecast/templates/forecast/edit/edit.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends "forecast/edit/forecast_base.html" %}
{% load payroll_permissions %}
{% load util vite %}
{% load breadcrumbs %}

Expand Down Expand Up @@ -41,14 +42,15 @@
{% endblock %}
{% block scripts %}
{{ view.get_payroll_forecast_report|json_script:'payroll_forecast_data' }}
{% can_edit_payroll user as can_edit_payroll %}
<script>
window.actuals = {{ actuals|safe }};
window.period_display = {{ period_display|safe }};
window.table_data = {{ forecast_dump|safe }};
window.cost_centre = {{ view.cost_centre_details.cost_centre_code|safe }};
window.financial_year = {{ view.financial_year|safe }};
window.payroll_forecast_data = JSON.parse(document.getElementById("payroll_forecast_data").textContent);
window.can_toggle_payroll = "{{ can_toggle_payroll }}";
window.can_edit_payroll = "{{ can_edit_payroll }}";
</script>
{% vite_dev_client %}
{% vite_js 'src/index.jsx' %}
Expand Down
1 change: 0 additions & 1 deletion forecast/views/edit_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,6 @@ def get_context_data(self, **kwargs):
context["forecast_dump"] = forecast_dump
context["actuals"] = actual_data
context["period_display"] = period_display
context["can_toggle_payroll"] = self.request.user.is_superuser

return context

Expand Down
2 changes: 1 addition & 1 deletion front_end/src/Components/EditForecast/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ function EditForecast() {

return (
<Fragment>
{window.can_toggle_payroll === "True" && <ToggleCheckbox toggle={isPayrollEnabled} handler={handleIsPayrollEnabled} id="payroll-forecast" value="payroll" label="Toggle payroll forecast rows" />}
{window.can_edit_payroll === "True" && <ToggleCheckbox toggle={isPayrollEnabled} handler={handleIsPayrollEnabled} id="payroll-forecast" value="payroll" label="Toggle payroll forecast rows" />}
{errorMessage != null &&
<div className="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabIndex="-1" data-module="govuk-error-summary">
<h2 className="govuk-error-summary__title" id="error-summary-title">
Expand Down

0 comments on commit 2e62ef1

Please sign in to comment.