forked from strictdoc-project/strictdoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request strictdoc-project#1451 from strictdoc-project/mett…
…ta/_#1271_UID_autogeneration export/html: 'UID reset button' on the requirement form
- Loading branch information
Showing
18 changed files
with
303 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<svg class="svg_icon" width="16px" height="16px" viewBox="0 0 16 16"> | ||
<path d="M11,12 C7.5,14.5 3,12 3,7"/> | ||
<path d="M5,4 C8.5,1.5 13,4 13,9"/> | ||
<polyline points="5 8 3 6 1 8" /> | ||
<polyline points="11 8 13 10 15 8" /> | ||
</svg> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...port/html/templates/components/requirement_form/frame_row_with_uid_with_reset_field.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{%- extends "components/form/row.jinja" %} | ||
|
||
{% assert text_field_row_context is defined, "row_with_text: row_context must be defined." %} | ||
|
||
{% assert text_field_row_context.errors is defined, "row_with_text: errors must be defined." %} | ||
{% assert text_field_row_context.field is defined, "row_with_text: field must be defined." %} | ||
{% assert text_field_row_context.field_type is defined, "row_with_text: field_type must be defined." %} | ||
{% assert text_field_row_context.field_type in ("singleline", "multiline"), "row_with_text: field_type must be singleline or multiline." %} | ||
{% assert text_field_row_context.reference_mid is defined, "row_with_text: reference_mid must be defined." %} | ||
|
||
{%- set row_context = text_field_row_context -%} | ||
|
||
{% block row_form_attributes %} | ||
{# Explicitly no attributes. #} | ||
{% endblock row_form_attributes %} | ||
|
||
{% block row_left %} | ||
{# Explicitly nothing. #} | ||
{% endblock row_left %} | ||
|
||
{% block row_content scoped %} | ||
{%- set placeholder_name = text_field_row_context.field.field_name %} | ||
|
||
{%- with | ||
mid = text_field_row_context.field.field_mid, | ||
field_class_name = none, | ||
field_input_name = text_field_row_context.field.get_input_field_name(), | ||
field_label = text_field_row_context.field.field_name, | ||
field_placeholder = "Enter "~placeholder_name~" here...", | ||
field_type = text_field_row_context.field_type, | ||
field_value = text_field_row_context.field.field_escaped_value, | ||
testid_postfix = "requirement-field-"~text_field_row_context.field.field_name | ||
%} | ||
{%- include "components/form/field/contenteditable/index.jinja" %} | ||
{%- endwith -%} | ||
|
||
<input | ||
type="hidden" | ||
name="{{ text_field_row_context.field.get_input_field_type_name() }}" | ||
value="{{ text_field_row_context.field.field_name }}" | ||
/> | ||
{% endblock row_content %} | ||
|
||
{% block row_right scoped %} | ||
<a | ||
class="field_action" | ||
href="/reset_uid?reference_mid={{ text_field_row_context.reference_mid }}" | ||
mid="{{ text_field_row_context.field.field_mid }}" | ||
title="Reset UID to default" | ||
data-action-type="reset" | ||
data-turbo-action="replace" | ||
data-turbo="true" | ||
data-testid="reset-uid-field-action" | ||
>{% include "_res/svg_ico16_reset.jinja" %}</a> | ||
{% endblock row_right %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...ort/html/templates/components/requirement_form/stream_row_with_uid_with_reset_field.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{% assert uid_form_field is defined %} | ||
|
||
{% set text_field_row_context = namespace() %} | ||
{% set row_context = text_field_row_context %} | ||
|
||
{# | ||
When called in the template: | ||
"strictdoc/export/html/templates/components/requirement_form/index.jinja", | ||
the following parameters are passed: | ||
{% set text_field_row_context.errors=form_object.get_errors(field_.field_name) %} | ||
{% set text_field_row_context.field = field_ %} | ||
{% set text_field_row_context.field_type = "singleline" %} | ||
{% set text_field_row_context.reference_mid = form_object.requirement_mid %} | ||
There's no form_object here in Stream. | ||
And we also create a field in the router "/reset_uid", | ||
which we will pass here (instead of the field from the form_object, as in a normal form). | ||
#} | ||
{# So we redefine the parameters like this: #} | ||
{% set text_field_row_context.errors=[] %} | ||
{% set text_field_row_context.field = uid_form_field %} | ||
{% set text_field_row_context.field_type = "singleline" %} | ||
{% set text_field_row_context.reference_mid = uid_form_field.field_mid %} | ||
|
||
<turbo-stream action="replace" target="uid_with_reset-{{ reference_mid }}"> | ||
{# this template is turbo-frame and has a button to reset to the default value: #} | ||
<template> | ||
{%- include "components/requirement_form/frame_row_with_uid_with_reset_field.jinja" %} | ||
</template> | ||
</turbo-stream> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
18 changes: 18 additions & 0 deletions
18
...ment/update_requirement/update_requirement_uid_reset_button/expected_output/document.sdoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[DOCUMENT] | ||
TITLE: Document 1 | ||
|
||
[FREETEXT] | ||
Hello world! | ||
[/FREETEXT] | ||
|
||
[REQUIREMENT] | ||
UID: REQ-1 | ||
STATEMENT: >>> | ||
Requirement statement. | ||
<<< | ||
|
||
[REQUIREMENT] | ||
UID: REQ-2 | ||
STATEMENT: >>> | ||
Requirement statement. | ||
<<< |
17 changes: 17 additions & 0 deletions
17
...reens/document/update_requirement/update_requirement_uid_reset_button/input/document.sdoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[DOCUMENT] | ||
TITLE: Document 1 | ||
|
||
[FREETEXT] | ||
Hello world! | ||
[/FREETEXT] | ||
|
||
[REQUIREMENT] | ||
UID: REQ-1 | ||
STATEMENT: >>> | ||
Requirement statement. | ||
<<< | ||
|
||
[REQUIREMENT] | ||
STATEMENT: >>> | ||
Requirement statement. | ||
<<< |
73 changes: 73 additions & 0 deletions
73
...2end/screens/document/update_requirement/update_requirement_uid_reset_button/test_case.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
from tests.end2end.e2e_case import E2ECase | ||
from tests.end2end.end2end_test_setup import End2EndTestSetup | ||
from tests.end2end.helpers.screens.document.form_edit_requirement import ( | ||
Form_EditRequirement, | ||
) | ||
from tests.end2end.helpers.screens.project_index.screen_project_index import ( | ||
Screen_ProjectIndex, | ||
) | ||
from tests.end2end.server import SDocTestServer | ||
|
||
|
||
class Test(E2ECase): | ||
def test(self): | ||
test_setup = End2EndTestSetup(path_to_test_file=__file__) | ||
|
||
with SDocTestServer( | ||
input_path=test_setup.path_to_sandbox | ||
) as test_server: | ||
self.open(test_server.get_host_and_port()) | ||
|
||
screen_project_index = Screen_ProjectIndex(self) | ||
|
||
screen_project_index.assert_on_screen() | ||
screen_project_index.assert_contains_document("Document 1") | ||
|
||
screen_document = screen_project_index.do_click_on_first_document() | ||
|
||
screen_document.assert_on_screen_document() | ||
screen_document.assert_header_document_title("Document 1") | ||
screen_document.assert_text("Hello world!") | ||
|
||
# Requirement 1 has UID. | ||
# It shouldn't have a reset button. | ||
requirement1 = screen_document.get_requirement(1) | ||
requirement1.assert_requirement_uid_contains("REQ-1") | ||
form_edit_requirement1: Form_EditRequirement = ( | ||
requirement1.do_open_form_edit_requirement() | ||
) | ||
form_edit_requirement1.assert_on_form() | ||
form_edit_requirement1.assert_uid_field_contains("REQ-1") | ||
form_edit_requirement1.assert_uid_field_has_not_reset_button() | ||
form_edit_requirement1.do_form_cancel() | ||
|
||
# New requirement form shouldn't have a reset button, | ||
# but must have the correct UID entered in the field. | ||
node_menu = requirement1.do_open_node_menu() | ||
form_add_requirement: Form_EditRequirement = ( | ||
node_menu.do_node_add_requirement_above() | ||
) | ||
form_add_requirement.assert_on_form() | ||
form_add_requirement.assert_uid_field_has_not_reset_button() | ||
form_add_requirement.assert_uid_field_contains("REQ-2") | ||
form_add_requirement.do_form_cancel() | ||
|
||
# Requirement 2 has UID. | ||
# It shouldn't have a reset button. | ||
requirement2 = screen_document.get_requirement(2) | ||
requirement2.assert_requirement_has_no_uid() | ||
form_edit_requirement2: Form_EditRequirement = ( | ||
requirement2.do_open_form_edit_requirement() | ||
) | ||
form_edit_requirement2.assert_on_form() | ||
form_edit_requirement2.assert_uid_field_has_reset_button() | ||
form_edit_requirement2.assert_uid_field_does_not_contain("REQ-2") | ||
# Use the reset button. | ||
form_edit_requirement2.do_reset_uid_field() | ||
form_edit_requirement2.assert_uid_field_contains("REQ-2") | ||
form_edit_requirement2.do_form_submit() | ||
|
||
# Checking the success of the button. | ||
requirement2.assert_requirement_uid_contains("REQ-2") | ||
|
||
assert test_setup.compare_sandbox_and_expected_output() |