mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 16:24:08 -04:00
Refactor on/off table fields into component
There’s a lot of repeated code in our Jinja templates for the settings page. We already have a `boolean_field` component, but it’s not used anywhere (it was just lifted from Digital Marketplace). So this commit changes the `boolean_field` component to be useful for our on/off use case, and wires it into the settings page.
This commit is contained in:
@@ -105,10 +105,8 @@
|
|||||||
{% endcall %}
|
{% endcall %}
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
{% macro boolean_field(yes) -%}
|
{% macro boolean_field(value) -%}
|
||||||
{% call field(status='yes' if yes else 'no') %}
|
{{ text_field('On' if value else 'Off') }}
|
||||||
{{ "Yes" if yes else "No" }}
|
|
||||||
{% endcall %}
|
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
{% macro right_aligned_field_heading(text) %}
|
{% macro right_aligned_field_heading(text) %}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{% extends "withnav_template.html" %}
|
{% extends "withnav_template.html" %}
|
||||||
{% from "components/table.html" import list_table, row, field, boolean_field, hidden_field_heading %}
|
{% from "components/table.html" import list_table, row, field, hidden_field_heading %}
|
||||||
{% from "components/page-footer.html" import page_footer %}
|
{% from "components/page-footer.html" import page_footer %}
|
||||||
{% from "components/tick-cross.html" import tick_cross %}
|
{% from "components/tick-cross.html" import tick_cross %}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{% extends "withnav_template.html" %}
|
{% extends "withnav_template.html" %}
|
||||||
{% from "components/banner.html" import banner_wrapper %}
|
{% from "components/banner.html" import banner_wrapper %}
|
||||||
{% from "components/browse-list.html" import browse_list %}
|
{% from "components/browse-list.html" import browse_list %}
|
||||||
{% from "components/table.html" import mapping_table, row, text_field, edit_field, field %}
|
{% from "components/table.html" import mapping_table, row, text_field, edit_field, field, boolean_field %}
|
||||||
|
|
||||||
{% block service_page_title %}
|
{% block service_page_title %}
|
||||||
Settings
|
Settings
|
||||||
@@ -47,19 +47,19 @@
|
|||||||
|
|
||||||
{% call row() %}
|
{% call row() %}
|
||||||
{{ text_field('International text messages') }}
|
{{ text_field('International text messages') }}
|
||||||
{{ text_field('On' if current_service.can_send_international_sms else 'Off') }}
|
{{ boolean_field(current_service.can_send_international_sms) }}
|
||||||
{{ edit_field('Change', url_for('.service_set_international_sms', service_id=current_service.id)) }}
|
{{ edit_field('Change', url_for('.service_set_international_sms', service_id=current_service.id)) }}
|
||||||
{% endcall %}
|
{% endcall %}
|
||||||
|
|
||||||
{% call row() %}
|
{% call row() %}
|
||||||
{{ text_field('Receive text messages') }}
|
{{ text_field('Receive text messages') }}
|
||||||
{{ text_field('On' if 'inbound_sms' in current_service.permissions else 'Off') }}
|
{{ boolean_field('inbound_sms' in current_service.permissions) }}
|
||||||
{{ edit_field('Change', url_for('.service_set_inbound_sms', service_id=current_service.id)) }}
|
{{ edit_field('Change', url_for('.service_set_inbound_sms', service_id=current_service.id)) }}
|
||||||
{% endcall %}
|
{% endcall %}
|
||||||
|
|
||||||
{% call row() %}
|
{% call row() %}
|
||||||
{{ text_field('Letters') }}
|
{{ text_field('Letters') }}
|
||||||
{{ text_field('On' if current_service.can_send_letters else 'Off') }}
|
{{ boolean_field(current_service.can_send_letters) }}
|
||||||
{{ edit_field('Change', url_for('.service_set_letters', service_id=current_service.id)) }}
|
{{ edit_field('Change', url_for('.service_set_letters', service_id=current_service.id)) }}
|
||||||
{% endcall %}
|
{% endcall %}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user