Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ge/data grid question #1667

Merged
merged 3 commits into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
GovReady-Q Release Notes
========================

v0.9.6-dev (July XX, 2021)

v0.9.7-dev (July xx, 2021)
--------------------------

**UI changes**

* Display datagrid question wider and with smaller fonts.
* Display existance of legacy statement in project system's selected controls.

**Developer changes**

* Support datagrid specifying select type cell.

**Bug fixes**

* Fix count on project system's components associated with a control (avoid double counting).


v0.9.6 (July 15, 2021)
----------------------

**UI changes**
Expand Down
3 changes: 1 addition & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
v0.9.6-dev

v0.9.7-dev
18 changes: 12 additions & 6 deletions controls/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,20 @@ def controls_selected(request, system_id):
# sort controls
controls = list(controls)
controls.sort(key=lambda control: control.get_flattened_oscal_control_as_dict()['sort_id'])
# controls.sort(key = lambda control:list(reversed(control.get_flattened_oscal_control_as_dict()['sort_id'])))

impl_smts_count = {}
# Determine if a legacy statement exists for the control
impl_smts_legacy = Statement.objects.filter(consumer_element=system.root_element, statement_type=StatementTypeEnum.CONTROL_IMPLEMENTATION_LEGACY.name)
impl_smts_legacy_dict = {}
for legacy_smt in impl_smts_legacy:
impl_smts_legacy_dict[legacy_smt.sid] = legacy_smt

# Get count of componentes (e.g., producer_elements) associated with a control
impl_smts_cmpts_count = {}
ikeys = system.smts_control_implementation_as_dict.keys()
for c in controls:
impl_smts_count[c.oscal_ctl_id] = 0
impl_smts_cmpts_count[c.oscal_ctl_id] = 0
if c.oscal_ctl_id in ikeys:
impl_smts_count[c.oscal_ctl_id] = len(
system.smts_control_implementation_as_dict[c.oscal_ctl_id]['control_impl_smts'])
impl_smts_cmpts_count[c.oscal_ctl_id] = len(set([s.producer_element for s in system.smts_control_implementation_as_dict[c.oscal_ctl_id]['control_impl_smts']]))

# Get list of catalog objects
catalog_list = Catalogs().list_catalogs()
Expand All @@ -184,7 +189,8 @@ def controls_selected(request, system_id):
"project": project,
"controls": controls,
"external_catalogs": external_catalogs,
"impl_smts_count": impl_smts_count,
"impl_smts_cmpts_count": impl_smts_cmpts_count,
"impl_smts_legacy_dict": impl_smts_legacy_dict,
"enable_experimental_opencontrol": SystemSettings.enable_experimental_opencontrol,
}
return render(request, "systems/controls_selected.html", context)
Expand Down
31 changes: 20 additions & 11 deletions templates/question.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@
/* on mobile, space between columns */
margin-bottom: 30px;
}

.datagrid-text {
font-size: 0.8em;
}
.datagrid-text-select {
font-size: 1.0em;
}

</style>
{% endblock %}

Expand All @@ -140,7 +148,6 @@
{{block.super}}

<div class="row" style="padding-left: 22px;">

<div id="focus-area-wrapper" class="col-xs-12 col-sm-9 col-md-7 col-lg-7 col-xl-6">
{% if source_invitation %}
<div class="question-source-invitation">
Expand Down Expand Up @@ -583,7 +590,7 @@ <h1>{{title|safe}}</h1>
&nbsp;
</div>

<div id="progress-project-area-wrapper" class="col-xs-8 col-sm-6 col-md-3 col-lg-3 col-xl-2 question-progress-project">
<div id="progress-project-area-wrapper" class="col-xs-6 col-sm-4 col-md-1 col-lg-2 col-xl-2 question-progress-project">
{% include "task-progress-project-list.html" with previous="question" %}
</div>

Expand Down Expand Up @@ -1088,11 +1095,10 @@ <h1>{{title|safe}}</h1>
<script>
// Render datagrid question type
// Make focus-area-wrapper wider when question type is datagrid
$("#col-spacer").removeClass("col-spacer hidden-xs col-sm-1 col-md-1 col-lg-3 col-xl-2");
$("#col-spacer").addClass("col-spacer hidden-xs col-sm-1 col-md-1 col-lg-1 col-xl-2");
$("#focus-area-wrapper").removeClass("col-xs-12 col-sm-9 col-md-7 col-lg-6 col-xl-5");
$("#focus-area-wrapper").addClass("col-xs-12 col-sm-9 col-md-8 col-lg-8 col-xl-7");

$("#col-spacer").removeClass("col-spacer hidden-xs col-sm-1 col-md-1 col-lg-2 col-xl-1");
$("#col-spacer").addClass("hidden-xs hidden-sm hidden-md hidden-lg hidden-xl");
$("#focus-area-wrapper").removeClass("col-xs-12 col-sm-9 col-md-7 col-lg-7 col-xl-6");
$("#focus-area-wrapper").addClass("col-xs-12 col-sm-12 col-md-10 col-lg-10 col-xl-10");

// Prepare data for jsGrid data grid
var entries = [
Expand All @@ -1103,21 +1109,24 @@ <h1>{{title|safe}}</h1>

var datagrid_fields = [
{% for field in q.spec.fields %}
{ name: "{{field.key}}", type: "text", width: 100, validate: "required" },
{% if field.type == 'select' %}
{ name: "{{field.key}}", type: "select", items: [""{% for item in field.choices %},"{{ item.key }}"{% endfor %}], width: 100, validate: "required", headercss: "datagrid-text", insertcss: "datagrid-text-select" },
{% else %}
{ name: "{{field.key}}", type: "text", width: 100, validate: "required", css: "datagrid-text" },
{% endif %}

{% endfor %}
{ type: "control" }
];

$("#jsGrid").jsGrid({
width: "98%",

inserting: true,
editing: true,
sorting: true,
paging: true,

data: entries,

noDataContent: "Click the '+' button to add new row of data.<br>Click the row's '+' to add row of data to answer.",
fields: datagrid_fields
});
</script>
Expand Down
25 changes: 16 additions & 9 deletions templates/systems/controls_selected.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,22 @@
{{ control.get_flattened_oscal_control_as_dict.title }}
</div>
<div id="" class="col-xs-2 col-sm-2 col-md-2 col-lg-2 col-xl-2">
{% with total=impl_smts_count|get_item:control.oscal_ctl_id %}
{% if total > 0%}
{{ total }} component{{ total|pluralize }}
{% else %}
<div class="center-text">
&mdash;
</div>
{% endif %}
{% endwith %}
<div class="center-text">
{% with total=impl_smts_cmpts_count|get_item:control.oscal_ctl_id %}
{% if total > 0 %}
{{ total }} component{{ total|pluralize }}
{% else %}
&mdash;
{% endif %}
{% endwith %}
</div>
<div class="center-text">
{% with total=impl_smts_legacy_dict|get_item:control.oscal_ctl_id %}
{% if total %}
1 legacy statement{{ total|pluralize }}
{% endif %}
{% endwith %}
</div>
</div>
{% get_obj_perms request.user for system as "system_perms" %}
{% if "view_system" in system_perms %}
Expand Down