From 10f81d5d161ddf5e740613c604219fea29473031 Mon Sep 17 00:00:00 2001
From: Chris Hill-Scott
Date: Fri, 28 Jul 2017 15:07:08 +0100
Subject: [PATCH] Make pricing table searchable
uses the same pattern as searching templates by name.
---
app/main/views/index.py | 4 ++-
app/templates/views/pricing.html | 45 +++++++++++++++++++++-----------
2 files changed, 33 insertions(+), 16 deletions(-)
diff --git a/app/main/views/index.py b/app/main/views/index.py
index c0264c62e..596527769 100644
--- a/app/main/views/index.py
+++ b/app/main/views/index.py
@@ -1,6 +1,7 @@
from flask import (render_template, url_for, redirect, request, abort)
from app.main import main
from app import convert_to_boolean
+from app.main.forms import SearchTemplatesForm
from flask_login import (login_required, current_user)
from notifications_utils.template import HTMLEmailTemplate
@@ -38,7 +39,8 @@ def pricing():
international_sms_rates=sorted([
(cc, country['names'], country['billable_units'])
for cc, country in INTERNATIONAL_BILLING_RATES.items()
- ], key=lambda x: x[0])
+ ], key=lambda x: x[0]),
+ search_form=SearchTemplatesForm(),
)
diff --git a/app/templates/views/pricing.html b/app/templates/views/pricing.html
index 9b202cc82..90418b19b 100644
--- a/app/templates/views/pricing.html
+++ b/app/templates/views/pricing.html
@@ -1,4 +1,5 @@
-{% from "components/table.html" import mapping_table, row, text_field, row_heading %}
+{% from "components/table.html" import mapping_table, row, text_field, field, row_heading %}
+{% from "components/textbox.html" import textbox %}
{% extends "withoutnav_template.html" %}
@@ -60,20 +61,34 @@
times the cost of messages to UK mobile numbers.
- {% call mapping_table(
- caption='Letter pricing',
- field_headings=['Country code', 'Country', 'Cost multipler'],
- field_headings_visible=True,
- caption_visible=False
- ) %}
- {% for cc, names, billable_units in international_sms_rates %}
- {% call row() %}
- {{ text_field('+ '|safe + cc) }}
- {{ text_field(names[0]) }}
- {{ text_field('{} ×'.format(billable_units)|safe) }}
- {% endcall %}
- {% endfor %}
- {% endcall %}
+
+ {{ textbox(
+ search_form.search,
+ width='1-1',
+ label='Search by country name or code'
+ ) }}
+
+
+
+ {% call mapping_table(
+ caption='Letter pricing',
+ field_headings=['Country code', 'Country', 'Cost multipler'],
+ field_headings_visible=True,
+ caption_visible=False
+ ) %}
+ {% for cc, names, billable_units in international_sms_rates %}
+ {% call row() %}
+ {{ text_field('+' + cc) }}
+ {% call field() %}
+ {% for name in names %}
+ {{ name }}
+ {% endfor %}
+ {% endcall %}
+ {{ text_field('{} ×'.format(billable_units)|safe) }}
+ {% endcall %}
+ {% endfor %}
+ {% endcall %}
+
Letters