From 99f34fe45a84560aff2f222091c9328125a915c2 Mon Sep 17 00:00:00 2001 From: George Drummond Date: Thu, 3 Jan 2019 15:12:51 -0500 Subject: [PATCH] Disable CLIN fields via a config option --- atst/app.py | 1 + atst/forms/task_order.py | 5 +++++ atst/routes/task_orders/new.py | 20 +++++++++++++++++--- config/base.ini | 1 + styles/elements/_inputs.scss | 23 +++++++++++++++++++++++ templates/components/text_input.html | 12 ++++++++++-- templates/task_orders/new/funding.html | 4 ++-- 7 files changed, 59 insertions(+), 7 deletions(-) diff --git a/atst/app.py b/atst/app.py index 444f7032..f064a820 100644 --- a/atst/app.py +++ b/atst/app.py @@ -121,6 +121,7 @@ def map_config(config): **config["default"], "ENV": config["default"]["ENVIRONMENT"], "DEBUG": config["default"].getboolean("DEBUG"), + "CLASSIFIED": config["default"].getboolean("CLASSIFIED"), "PORT": int(config["default"]["PORT"]), "SQLALCHEMY_DATABASE_URI": config["default"]["DATABASE_URI"], "SQLALCHEMY_TRACK_MODIFICATIONS": False, diff --git a/atst/forms/task_order.py b/atst/forms/task_order.py index b63ce7b0..28063a5c 100644 --- a/atst/forms/task_order.py +++ b/atst/forms/task_order.py @@ -77,6 +77,11 @@ class FundingForm(CacheableForm): clin_04 = IntegerField("CLIN 04: Classified") +class UnclassifiedFundingForm(FundingForm): + clin_02 = IntegerField("CLIN 02: Classified (available soon)") + clin_04 = IntegerField("CLIN 04: Classified (available soon)") + + class OversightForm(CacheableForm): ko_first_name = StringField("First Name") ko_last_name = StringField("Last Name") diff --git a/atst/routes/task_orders/new.py b/atst/routes/task_orders/new.py index 9f0b38b4..c4d68e5a 100644 --- a/atst/routes/task_orders/new.py +++ b/atst/routes/task_orders/new.py @@ -1,4 +1,11 @@ -from flask import request as http_request, render_template, g, redirect, url_for +from flask import ( + request as http_request, + render_template, + g, + redirect, + url_for, + current_app as app, +) from . import task_orders_bp from atst.domain.task_orders import TaskOrders @@ -18,6 +25,7 @@ TASK_ORDER_SECTIONS = [ "title": "Funding", "template": "task_orders/new/funding.html", "form": task_order_form.FundingForm, + "unclassified_form": task_order_form.UnclassifiedFundingForm, }, { "section": "oversight", @@ -59,12 +67,18 @@ class ShowTaskOrderWorkflow: @property def form(self): + form_type = ( + "unclassified_form" + if "unclassified_form" in self._section and not app.config.get("CLASSIFIED") + else "form" + ) + if self._form: pass elif self.task_order: - self._form = self._section["form"](formdata=self.task_order_formdata) + self._form = self._section[form_type](formdata=self.task_order_formdata) else: - self._form = self._section["form"]() + self._form = self._section[form_type]() return self._form diff --git a/config/base.ini b/config/base.ini index ab075e1d..45cc2308 100644 --- a/config/base.ini +++ b/config/base.ini @@ -1,6 +1,7 @@ [default] CAC_URL = http://localhost:8000/login-redirect CA_CHAIN = ssl/server-certs/ca-chain.pem +CLASSIFIED = false COOKIE_SECRET = some-secret-please-replace CRL_DIRECTORY = crl DEBUG = true diff --git a/styles/elements/_inputs.scss b/styles/elements/_inputs.scss index c7cda5ec..418fde41 100644 --- a/styles/elements/_inputs.scss +++ b/styles/elements/_inputs.scss @@ -108,6 +108,15 @@ } } + .usa-input__coming-soon { + @include h5; + font-weight: normal; + + @include line-max; + + color: $color-gray-medium; + } + input, textarea, select, @@ -348,3 +357,17 @@ select { } } } + +.input--disabled { + color: $color-gray-lighter; + + input[disabled] { + border-color: $color-gray-lighter; + cursor: not-allowed; + + &:hover { + border-color: $color-gray-lighter !important; + box-shadow: none; + } + } +} diff --git a/templates/components/text_input.html b/templates/components/text_input.html index b48f3bad..baf04b44 100644 --- a/templates/components/text_input.html +++ b/templates/components/text_input.html @@ -9,6 +9,7 @@ placeholder='', validation='anything', paragraph=False, + disabled=False, initial_value='', noMaxWidth=False) -%} @@ -23,10 +24,14 @@ inline-template>
+ {% if disabled %}class="input--disabled"{% endif %} + v-bind:class="['usa-input usa-input--validation--' + validation, { 'usa-input--error': showError, 'usa-input--success': showValid, 'usa-input--validation--paragraph': paragraph, 'no-max-width': noMaxWidth, 'disabled-available-soon': disabled_available_soon }]">