From 41818d7955635d54ee852f1dad42dc8a5b706ffa Mon Sep 17 00:00:00 2001 From: Montana Date: Wed, 8 May 2019 09:40:02 -0400 Subject: [PATCH 1/8] Toggle on click - New copy to the translations file - CSS is not updated --- atst/routes/applications/settings.py | 13 ++++++++ .../applications/add_new_environment.html | 33 +++++++++++++++++++ .../portfolios/applications/settings.html | 4 +++ translations.yaml | 3 ++ 4 files changed, 53 insertions(+) create mode 100644 templates/fragments/applications/add_new_environment.html diff --git a/atst/routes/applications/settings.py b/atst/routes/applications/settings.py index 586e6d3d..07b08fd5 100644 --- a/atst/routes/applications/settings.py +++ b/atst/routes/applications/settings.py @@ -169,6 +169,19 @@ def update(application_id): environments_obj=get_environments_obj_for_app(application=application), ) +@applications_bp.route("/applications//add_environment", methods=["POST"]) +@user_can(Permissions.EDIT_APPLICATION, message="add application environment") +def add_environment(application_id): + application = Applications.get(application_id) + form = ApplicationForm(http_request.form) + + return render_template( + "portfolios/applications/settings.html", + application=application, + form=form, + environments_obj=get_environments_obj_for_app(application=application), + ) + @applications_bp.route("/environments//roles", methods=["POST"]) @user_can(Permissions.ASSIGN_ENVIRONMENT_MEMBER, message="update environment roles") diff --git a/templates/fragments/applications/add_new_environment.html b/templates/fragments/applications/add_new_environment.html new file mode 100644 index 00000000..9adf1e7e --- /dev/null +++ b/templates/fragments/applications/add_new_environment.html @@ -0,0 +1,33 @@ +{% from "components/toggle_list.html" import ToggleButton, ToggleSection %} + +
+ {{ form.csrf_token }} + + +
+ {% set add_env_link %} + + {{ "portfolios.applications.add_environment" | translate }} + {{ Icon('plus') }} + + {% endset %} + + {% call ToggleSection(section_name="add-new-environment") %} +
+ {{ "portfolios.applications.create_new_env" | translate }} +
{{ "portfolios.applications.create_new_env_info" | translate }}
+ {{ "portfolios.applications.enter_env_name" | translate }} +
+ {% endcall %} + + {{ + ToggleButton( + open_html=add_env_link, + close_html=add_env_link, + section_name="add-new-environment" + ) + }} +
+
+ +
diff --git a/templates/portfolios/applications/settings.html b/templates/portfolios/applications/settings.html index efa44f0f..b21710ec 100644 --- a/templates/portfolios/applications/settings.html +++ b/templates/portfolios/applications/settings.html @@ -69,6 +69,10 @@ {% if user_can(permissions.EDIT_APPLICATION) %} {% include "fragments/applications/edit_environments.html" %} + {% if user_can(permissions.CREATE_ENVIRONMENT) %} + {% include "fragments/applications/add_new_environment.html" %} + {% endif %} + {% elif user_can(permissions.VIEW_ENVIRONMENT) %} {% include "fragments/applications/read_only_environments.html" %} {% endif %} diff --git a/translations.yaml b/translations.yaml index 449bd585..d7161885 100644 --- a/translations.yaml +++ b/translations.yaml @@ -420,6 +420,8 @@ portfolios: add_another_environment: Add another environment app_settings_text: App settings create_button_text: Create + create_new_env: Create a new environment. + create_new_env_info: Creating an environment gives you access to the Cloud Service Provider. This environment will function within the constraints of the task order, and any costs will be billed against the portfolio. csp_console_text: CSP console delete: alert: @@ -427,6 +429,7 @@ portfolios: title: Warning! This action is permanent. button: Delete application header: Are you sure you want to delete this application? + enter_env_name: "Enter environment name:" environments: name: Name delete: From f07ea38b9bad62bbf608b07f2c3abe05539b0a92 Mon Sep 17 00:00:00 2001 From: Montana Date: Wed, 8 May 2019 13:53:56 -0400 Subject: [PATCH 2/8] Functionality for adding an env - uses two route functions - one for update app, another for add environment - uses a second form for the app settings page - uses the /environments/new url naming convention --- atst/routes/applications/settings.py | 60 ++++++++++++++----- .../applications/add_new_environment.html | 8 ++- .../applications/edit_environments.html | 5 +- tests/routes/applications/test_settings.py | 34 ++++++++++- 4 files changed, 85 insertions(+), 22 deletions(-) diff --git a/atst/routes/applications/settings.py b/atst/routes/applications/settings.py index 07b08fd5..44b04d90 100644 --- a/atst/routes/applications/settings.py +++ b/atst/routes/applications/settings.py @@ -101,6 +101,7 @@ def settings(application_id): members_form=members_form, active_toggler=http_request.args.get("active_toggler"), active_toggler_section=http_request.args.get("active_toggler_section"), + new_env_form=EditEnvironmentForm(), ) @@ -135,12 +136,52 @@ def update_environment(environment_id): form=ApplicationForm( name=application.name, description=application.description ), + new_env_form=EditEnvironmentForm(), + members_form=AppEnvRolesForm( + data=data_for_app_env_roles_form(application) + ), + environments_obj=get_environments_obj_for_app(application=application), + active_toggler=environment.id, + active_toggler_section="edit", + ), + 400, + ) + + +@applications_bp.route( + "/applications//environments/new", methods=["POST"] +) +@user_can(Permissions.CREATE_ENVIRONMENT, message="create application environment") +def new_environment(application_id): + application = Applications.get(application_id) + env_form = EditEnvironmentForm(formdata=http_request.form) + + if env_form.validate(): + Environments.create(application=application, name=env_form.name.data) + + flash("application_environments_updated") + + return redirect( + url_for( + "applications.settings", + application_id=application.id, + fragment="application-environments", + _anchor="application-environments", + ) + ) + else: + return ( + render_template( + "portfolios/applications/settings.html", + application=application, + form=ApplicationForm( + name=application.name, description=application.description + ), + new_env_form=env_form, environments_obj=get_environments_obj_for_app(application=application), members_form=AppEnvRolesForm( data=data_for_app_env_roles_form(application) ), - active_toggler=environment.id, - active_toggler_section="edit", ), 400, ) @@ -166,22 +207,10 @@ def update(application_id): "portfolios/applications/settings.html", application=application, form=form, + new_env_form=EditEnvironmentForm(), environments_obj=get_environments_obj_for_app(application=application), ) -@applications_bp.route("/applications//add_environment", methods=["POST"]) -@user_can(Permissions.EDIT_APPLICATION, message="add application environment") -def add_environment(application_id): - application = Applications.get(application_id) - form = ApplicationForm(http_request.form) - - return render_template( - "portfolios/applications/settings.html", - application=application, - form=form, - environments_obj=get_environments_obj_for_app(application=application), - ) - @applications_bp.route("/environments//roles", methods=["POST"]) @user_can(Permissions.ASSIGN_ENVIRONMENT_MEMBER, message="update environment roles") @@ -233,6 +262,7 @@ def update_env_roles(environment_id): form=ApplicationForm( name=application.name, description=application.description ), + new_env_form=EditEnvironmentForm(), environments_obj=get_environments_obj_for_app(application=application), active_toggler=environment.id, active_toggler_section="edit", diff --git a/templates/fragments/applications/add_new_environment.html b/templates/fragments/applications/add_new_environment.html index 9adf1e7e..ddf6a5bb 100644 --- a/templates/fragments/applications/add_new_environment.html +++ b/templates/fragments/applications/add_new_environment.html @@ -1,7 +1,9 @@ +{% from 'components/save_button.html' import SaveButton %} +{% from "components/text_input.html" import TextInput %} {% from "components/toggle_list.html" import ToggleButton, ToggleSection %} -
- {{ form.csrf_token }} + + {{ new_env_form.csrf_token }}
@@ -17,7 +19,9 @@ {{ "portfolios.applications.create_new_env" | translate }}
{{ "portfolios.applications.create_new_env_info" | translate }}
{{ "portfolios.applications.enter_env_name" | translate }} + {{ TextInput(new_env_form.name) }}
+ {{ SaveButton(text=('common.save' | translate), element="input", form="add-new-env") }} {% endcall %} {{ diff --git a/templates/fragments/applications/edit_environments.html b/templates/fragments/applications/edit_environments.html index 7852ae7d..299c8f6c 100644 --- a/templates/fragments/applications/edit_environments.html +++ b/templates/fragments/applications/edit_environments.html @@ -128,9 +128,6 @@ diff --git a/tests/routes/applications/test_settings.py b/tests/routes/applications/test_settings.py index 1e5bfb02..a658107a 100644 --- a/tests/routes/applications/test_settings.py +++ b/tests/routes/applications/test_settings.py @@ -54,7 +54,7 @@ def test_updating_application_environments_success(client, user_session): assert environment.name == "new name a" -def test_updating_application_environments_failure(client, user_session): +def test_update_environment_failure(client, user_session): portfolio = PortfolioFactory.create() application = ApplicationFactory.create(portfolio=portfolio) environment = EnvironmentFactory.create( @@ -391,6 +391,38 @@ def test_delete_application(client, user_session): assert len(application.environments) == 0 +def test_new_environment(client, user_session): + user = UserFactory.create() + portfolio = PortfolioFactory(owner=user) + application = ApplicationFactory.create(portfolio=portfolio) + num_envs = len(application.environments) + + user_session(user) + response = client.post( + url_for("applications.new_environment", application_id=application.id), + data={"name": "dabea"}, + ) + + assert response.status_code == 302 + assert len(application.environments) == num_envs + 1 + + +def test_new_environment_with_bad_data(client, user_session): + user = UserFactory.create() + portfolio = PortfolioFactory(owner=user) + application = ApplicationFactory.create(portfolio=portfolio) + num_envs = len(application.environments) + + user_session(user) + response = client.post( + url_for("applications.new_environment", application_id=application.id), + data={"name": None}, + ) + + assert response.status_code == 400 + assert len(application.environments) == num_envs + + def test_delete_environment(client, user_session): user = UserFactory.create() portfolio = PortfolioFactory(owner=user) From b2989e99c94fd88dbeee48baa4965590d8883a58 Mon Sep 17 00:00:00 2001 From: Montana Date: Thu, 9 May 2019 08:18:06 -0400 Subject: [PATCH 3/8] Styling --- styles/components/_accordion_table.scss | 18 +++++++++ .../applications/add_new_environment.html | 38 +++++++++++++------ .../applications/edit_environments.html | 5 --- 3 files changed, 45 insertions(+), 16 deletions(-) diff --git a/styles/components/_accordion_table.scss b/styles/components/_accordion_table.scss index 28cd08de..9fcf9938 100644 --- a/styles/components/_accordion_table.scss +++ b/styles/components/_accordion_table.scss @@ -42,6 +42,19 @@ .usa-input { margin: 0; + + .icon-validation { + left: 135%; + } + } + + #name { + max-width: none; + border-color: black; + } + + .usa-alert { + margin: 2.5rem 0; } select { @@ -50,6 +63,11 @@ } } + .new-env { + margin-top: 5rem; + padding: 0 5rem;; + } + .accordion-table__items { margin: 0; diff --git a/templates/fragments/applications/add_new_environment.html b/templates/fragments/applications/add_new_environment.html index ddf6a5bb..2d051edd 100644 --- a/templates/fragments/applications/add_new_environment.html +++ b/templates/fragments/applications/add_new_environment.html @@ -1,3 +1,4 @@ +{% from "components/alert.html" import Alert %} {% from 'components/save_button.html' import SaveButton %} {% from "components/text_input.html" import TextInput %} {% from "components/toggle_list.html" import ToggleButton, ToggleSection %} @@ -8,26 +9,41 @@
{% set add_env_link %} - - {{ "portfolios.applications.add_environment" | translate }} - {{ Icon('plus') }} - + {% endset %} {% call ToggleSection(section_name="add-new-environment") %} -
- {{ "portfolios.applications.create_new_env" | translate }} -
{{ "portfolios.applications.create_new_env_info" | translate }}
- {{ "portfolios.applications.enter_env_name" | translate }} - {{ TextInput(new_env_form.name) }} +
+
{{ "portfolios.applications.create_new_env" | translate }}
+ {{ Alert('', + message=("portfolios.applications.create_new_env_info" | translate ) + ) }} +
{{ "portfolios.applications.enter_env_name" | translate }}
+ {{ TextInput(new_env_form.name, label="") }} +
+ - {{ SaveButton(text=('common.save' | translate), element="input", form="add-new-env") }} {% endcall %} {{ ToggleButton( open_html=add_env_link, - close_html=add_env_link, + close_html="", section_name="add-new-environment" ) }} diff --git a/templates/fragments/applications/edit_environments.html b/templates/fragments/applications/edit_environments.html index 299c8f6c..ee4643f9 100644 --- a/templates/fragments/applications/edit_environments.html +++ b/templates/fragments/applications/edit_environments.html @@ -126,8 +126,3 @@
- From caf3a47c68b233a2827ab2a49ade8747711aa0e0 Mon Sep 17 00:00:00 2001 From: Montana Date: Mon, 13 May 2019 11:33:05 -0400 Subject: [PATCH 4/8] Update banners - Adds "Create a new environment" title to info banner - Adds a new "environment added" success banner --- atst/routes/applications/settings.py | 2 +- atst/utils/flash.py | 9 ++++++++- styles/components/_accordion_table.scss | 2 +- .../fragments/applications/add_new_environment.html | 4 ++-- translations.yaml | 1 + 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/atst/routes/applications/settings.py b/atst/routes/applications/settings.py index 44b04d90..430095e0 100644 --- a/atst/routes/applications/settings.py +++ b/atst/routes/applications/settings.py @@ -159,7 +159,7 @@ def new_environment(application_id): if env_form.validate(): Environments.create(application=application, name=env_form.name.data) - flash("application_environments_updated") + flash("environment_added", environment_name=env_form.data["name"]) return redirect( url_for( diff --git a/atst/utils/flash.py b/atst/utils/flash.py index c411e22e..60574430 100644 --- a/atst/utils/flash.py +++ b/atst/utils/flash.py @@ -12,6 +12,13 @@ MESSAGES = { "message_template": "Application environment members have been updated", "category": "success", }, + "environment_added": { + "title_template": translate("flash.success"), + "message_template": """ + {{ "flash.environment_added" | translate({ "env_name": environment_name }) }} + """, + "category": "success", + }, "application_environments_updated": { "title_template": "Application environments updated", "message_template": "Application environments have been updated", @@ -24,7 +31,7 @@ MESSAGES = { }, "invitation_resent": { "title_template": "Invitation resent", - "message_template": "The {{ officer_type }} has been resent instructions to join this portfolio.", + "message_template": "The {{ officer_type }} has been resent instructions to join this portfolio.", "category": "success", }, "task_order_draft": { diff --git a/styles/components/_accordion_table.scss b/styles/components/_accordion_table.scss index 9fcf9938..1bcf3331 100644 --- a/styles/components/_accordion_table.scss +++ b/styles/components/_accordion_table.scss @@ -65,7 +65,7 @@ .new-env { margin-top: 5rem; - padding: 0 5rem;; + padding: 0 5rem; } .accordion-table__items { diff --git a/templates/fragments/applications/add_new_environment.html b/templates/fragments/applications/add_new_environment.html index 2d051edd..c28921b9 100644 --- a/templates/fragments/applications/add_new_environment.html +++ b/templates/fragments/applications/add_new_environment.html @@ -21,8 +21,8 @@ {% call ToggleSection(section_name="add-new-environment") %}
-
{{ "portfolios.applications.create_new_env" | translate }}
- {{ Alert('', + {{ Alert( + title=("portfolios.applications.create_new_env" | translate), message=("portfolios.applications.create_new_env_info" | translate ) ) }}
{{ "portfolios.applications.enter_env_name" | translate }}
diff --git a/translations.yaml b/translations.yaml index d7161885..3ea6721f 100644 --- a/translations.yaml +++ b/translations.yaml @@ -69,6 +69,7 @@ flash: congrats: Congrats! delete_member_success: 'You have successfully deleted {member_name} from the portfolio.' deleted_member: Portfolio member deleted + environment_added: 'The environment "{env_name}" has been added to the application.' login_required_message: After you log in, you will be redirected to your destination page. login_required_title: Log in required new_portfolio: You've created a new JEDI portfolio and jump-started your first task order! From 53d09deb2210e0c2d36fc03d4646e37157f13caf Mon Sep 17 00:00:00 2001 From: Montana Date: Wed, 8 May 2019 08:48:51 -0400 Subject: [PATCH 5/8] Clean up imports --- atst/utils/context_processors.py | 1 + templates/fragments/applications/edit_team.html | 1 + templates/portfolios/applications/team.html | 4 +--- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/atst/utils/context_processors.py b/atst/utils/context_processors.py index 243de728..f3794899 100644 --- a/atst/utils/context_processors.py +++ b/atst/utils/context_processors.py @@ -5,6 +5,7 @@ from sqlalchemy.orm.exc import NoResultFound from atst.database import db from atst.domain.authz import Authorization +from atst.domain.exceptions import NotFoundError from atst.domain.portfolios.scopes import ScopedPortfolio from atst.models import ( Application, diff --git a/templates/fragments/applications/edit_team.html b/templates/fragments/applications/edit_team.html index d5d9f300..9f38e9c5 100644 --- a/templates/fragments/applications/edit_team.html +++ b/templates/fragments/applications/edit_team.html @@ -1,4 +1,5 @@ {% from "components/options_input.html" import OptionsInput %} +{% from "components/toggle_list.html" import ToggleButton, ToggleSection %} {{ team_form.csrf_token }} diff --git a/templates/portfolios/applications/team.html b/templates/portfolios/applications/team.html index c7270c05..686a70de 100644 --- a/templates/portfolios/applications/team.html +++ b/templates/portfolios/applications/team.html @@ -1,10 +1,8 @@ {% extends "portfolios/applications/base.html" %} -{% from "components/empty_state.html" import EmptyState %} {% from "components/icon.html" import Icon %} -{% from 'components/save_button.html' import SaveButton %} -{% from "components/toggle_list.html" import ToggleButton, ToggleSection %} {% from "components/multi_step_modal_form.html" import MultiStepModalForm %} +{% from 'components/save_button.html' import SaveButton %} {% import "fragments/applications/new_member_modal_content.html" as member_steps %} {% set secondary_breadcrumb = 'portfolios.applications.team_settings.title' | translate({ "application_name": application.name }) %} From 1c506b995a2c13943f78e3c381db56d8a29b4b08 Mon Sep 17 00:00:00 2001 From: Montana Date: Tue, 14 May 2019 14:05:13 -0400 Subject: [PATCH 6/8] Use helper function to render settings page - use front end for validation testing - change "form" to "application_form" --- atst/routes/applications/settings.py | 69 +++++++------------ .../portfolios/applications/settings.html | 8 +-- 2 files changed, 27 insertions(+), 50 deletions(-) diff --git a/atst/routes/applications/settings.py b/atst/routes/applications/settings.py index 430095e0..b3077b77 100644 --- a/atst/routes/applications/settings.py +++ b/atst/routes/applications/settings.py @@ -85,23 +85,35 @@ def check_users_are_in_application(user_ids, application): return True -@applications_bp.route("/applications//settings") -@user_can(Permissions.VIEW_APPLICATION, message="view application edit form") -def settings(application_id): - application = Applications.get(application_id) - form = ApplicationForm(name=application.name, description=application.description) +def render_settings_page(application, **kwargs): environments_obj = get_environments_obj_for_app(application=application) members_form = AppEnvRolesForm(data=data_for_app_env_roles_form(application)) + new_env_form = EditEnvironmentForm() + + if "application_form" not in kwargs: + kwargs["application_form"] = ApplicationForm( + name=application.name, description=application.description + ) return render_template( "portfolios/applications/settings.html", application=application, - form=form, environments_obj=environments_obj, members_form=members_form, + new_env_form=new_env_form, + **kwargs, + ) + + +@applications_bp.route("/applications//settings") +@user_can(Permissions.VIEW_APPLICATION, message="view application edit form") +def settings(application_id): + application = Applications.get(application_id) + + return render_settings_page( + application=application, active_toggler=http_request.args.get("active_toggler"), active_toggler_section=http_request.args.get("active_toggler_section"), - new_env_form=EditEnvironmentForm(), ) @@ -130,17 +142,8 @@ def update_environment(environment_id): ) else: return ( - render_template( - "portfolios/applications/settings.html", + render_settings_page( application=application, - form=ApplicationForm( - name=application.name, description=application.description - ), - new_env_form=EditEnvironmentForm(), - members_form=AppEnvRolesForm( - data=data_for_app_env_roles_form(application) - ), - environments_obj=get_environments_obj_for_app(application=application), active_toggler=environment.id, active_toggler_section="edit", ), @@ -170,21 +173,7 @@ def new_environment(application_id): ) ) else: - return ( - render_template( - "portfolios/applications/settings.html", - application=application, - form=ApplicationForm( - name=application.name, description=application.description - ), - new_env_form=env_form, - environments_obj=get_environments_obj_for_app(application=application), - members_form=AppEnvRolesForm( - data=data_for_app_env_roles_form(application) - ), - ), - 400, - ) + return (render_settings_page(application=application), 400) @applications_bp.route("/applications//edit", methods=["POST"]) @@ -203,13 +192,7 @@ def update(application_id): ) ) else: - return render_template( - "portfolios/applications/settings.html", - application=application, - form=form, - new_env_form=EditEnvironmentForm(), - environments_obj=get_environments_obj_for_app(application=application), - ) + return render_settings_page(application=application, application_form=form) @applications_bp.route("/environments//roles", methods=["POST"]) @@ -256,14 +239,8 @@ def update_env_roles(environment_id): ) else: return ( - render_template( - "portfolios/applications/settings.html", + render_settings_page( application=application, - form=ApplicationForm( - name=application.name, description=application.description - ), - new_env_form=EditEnvironmentForm(), - environments_obj=get_environments_obj_for_app(application=application), active_toggler=environment.id, active_toggler_section="edit", ), diff --git a/templates/portfolios/applications/settings.html b/templates/portfolios/applications/settings.html index b21710ec..79062961 100644 --- a/templates/portfolios/applications/settings.html +++ b/templates/portfolios/applications/settings.html @@ -16,13 +16,13 @@
- {{ form.csrf_token }} + {{ application_form.csrf_token }}

{{ "fragments.edit_application_form.explain" | translate }}

- {{ TextInput(form.name) }} + {{ TextInput(application_form.name) }}
{% if user_can(permissions.DELETE_APPLICATION) %} @@ -45,7 +45,7 @@
- {{ TextInput(form.description, paragraph=True) }} + {{ TextInput(application_form.description, paragraph=True) }}
  @@ -96,7 +96,7 @@ modal_id=delete_modal_environment_id, delete_text=('portfolios.applications.delete.button' | translate), delete_action= url_for('applications.delete', application_id=application.id), - form=form + form=application_form ) }} {% endcall %} From 408fa4e618680f8c0e9b6964c20128324001e63e Mon Sep 17 00:00:00 2001 From: Montana Date: Tue, 14 May 2019 14:36:01 -0400 Subject: [PATCH 7/8] Fix DeleteConfirmation component modal id --- templates/components/delete_confirmation.html | 2 +- templates/fragments/applications/edit_environments.html | 4 ++-- templates/portfolios/applications/settings.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/components/delete_confirmation.html b/templates/components/delete_confirmation.html index e5e9bfc5..ac2d250b 100644 --- a/templates/components/delete_confirmation.html +++ b/templates/components/delete_confirmation.html @@ -17,7 +17,7 @@
diff --git a/templates/fragments/applications/edit_environments.html b/templates/fragments/applications/edit_environments.html index ee4643f9..4d401eef 100644 --- a/templates/fragments/applications/edit_environments.html +++ b/templates/fragments/applications/edit_environments.html @@ -115,10 +115,10 @@ {{ DeleteConfirmation( - modal_id=delete_modal_environment_id, + modal_id=delete_environment_modal_id, delete_text=('portfolios.applications.environments.delete.button' | translate), delete_action= url_for('applications.delete_environment', environment_id=env['id']), - form=form + form=edit_form ) }} {% endcall %} diff --git a/templates/portfolios/applications/settings.html b/templates/portfolios/applications/settings.html index 79062961..b5587a24 100644 --- a/templates/portfolios/applications/settings.html +++ b/templates/portfolios/applications/settings.html @@ -93,7 +93,7 @@ {{ DeleteConfirmation( - modal_id=delete_modal_environment_id, + modal_id="delete_application", delete_text=('portfolios.applications.delete.button' | translate), delete_action= url_for('applications.delete', application_id=application.id), form=application_form From ab874a06f85c74b55065d6281c9d44a6a1a184d2 Mon Sep 17 00:00:00 2001 From: Montana Date: Tue, 14 May 2019 15:11:10 -0400 Subject: [PATCH 8/8] Use new-environment component to toggle - Moves the form to the innermost place it can go --- js/components/forms/new_environment.js | 24 +++++++++ js/index.js | 2 + .../applications/add_new_environment.html | 49 +++++++------------ 3 files changed, 45 insertions(+), 30 deletions(-) create mode 100644 js/components/forms/new_environment.js diff --git a/js/components/forms/new_environment.js b/js/components/forms/new_environment.js new file mode 100644 index 00000000..9b075bc0 --- /dev/null +++ b/js/components/forms/new_environment.js @@ -0,0 +1,24 @@ +import FormMixin from '../../mixins/form' +import textinput from '../text_input' + +export default { + name: 'new-environment', + + mixins: [FormMixin], + + components: { + textinput, + }, + + data: function() { + return { + open: false, + } + }, + + methods: { + toggle: function() { + this.open = !this.open + }, + }, +} diff --git a/js/index.js b/js/index.js index 478f9b39..02a9b404 100644 --- a/js/index.js +++ b/js/index.js @@ -38,6 +38,7 @@ import SidenavToggler from './components/sidenav_toggler' import KoReview from './components/forms/ko_review' import BaseForm from './components/forms/base_form' import DeleteConfirmation from './components/delete_confirmation' +import NewEnvironment from './components/forms/new_environment' Vue.config.productionTip = false @@ -78,6 +79,7 @@ const app = new Vue({ BaseForm, DeleteConfirmation, nestedcheckboxinput, + NewEnvironment, }, mounted: function() { diff --git a/templates/fragments/applications/add_new_environment.html b/templates/fragments/applications/add_new_environment.html index c28921b9..f1e72e4f 100644 --- a/templates/fragments/applications/add_new_environment.html +++ b/templates/fragments/applications/add_new_environment.html @@ -1,53 +1,42 @@ {% from "components/alert.html" import Alert %} {% from 'components/save_button.html' import SaveButton %} {% from "components/text_input.html" import TextInput %} -{% from "components/toggle_list.html" import ToggleButton, ToggleSection %} -
- {{ new_env_form.csrf_token }} + +
+
+ + {{ new_env_form.csrf_token }} - -
- {% set add_env_link %} - - {% endset %} - - {% call ToggleSection(section_name="add-new-environment") %}
{{ Alert( title=("portfolios.applications.create_new_env" | translate), message=("portfolios.applications.create_new_env_info" | translate ) ) }}
{{ "portfolios.applications.enter_env_name" | translate }}
- {{ TextInput(new_env_form.name, label="") }} + {{ TextInput(new_env_form.name, label="", validation="requiredField") }}
- {% endcall %} - - {{ - ToggleButton( - open_html=add_env_link, - close_html="", - section_name="add-new-environment" - ) - }} +
-
- + +
+ +