Skip to content

Commit

Permalink
Adding the option to group/sort controls by SrG ID (#566)
Browse files Browse the repository at this point in the history
Addig the option to group/sort controls by SrG ID

Signed-off-by: Vanessa Fotso <vfotso@mitre.org>
  • Loading branch information
vanessuniq authored Apr 27, 2023
1 parent f8e0b5c commit e9a63bb
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion app/javascript/components/rules/RuleNavigator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@
</b-form-checkbox>
</b-form-group>

<!-- Toggle Sort by SRG ID -->
<b-form-group class="mt-3">
<b-form-checkbox
id="sortBySRGIdChecked"
v-model="filters.sortBySRGIdChecked"
class="mb-1 unselectable"
switch
name="sortBySRGIdChecked-fitler"
>
Sort by SRG ID
</b-form-checkbox>
</b-form-group>

<!-- Find & Replace -->
<FindAndReplace :component-id="componentId" :project-prefix="projectPrefix" :rules="rules" />

Expand Down Expand Up @@ -323,6 +336,7 @@ export default {
lckFilterChecked: true, // Locked
showDuplicatesChecked: false, // Show duplicates
showSRGIdChecked: false, // Show SRG ID instead of STIG ID
sortBySRGIdChecked: false, // Sort by SRG ID
},
};
},
Expand Down Expand Up @@ -475,7 +489,12 @@ export default {
// Helper to filter & search a group of rules
filterRules: function (rules) {
let downcaseSearch = this.filters.search.toLowerCase();
return rules.filter((rule) => {
let sortedRules = [...rules];
if (this.filters.sortBySRGIdChecked) {
sortedRules.sort((a, b) => a.version.localeCompare(b.version));
}
return sortedRules.filter((rule) => {
return (
this.searchTextForRule(rule).includes(downcaseSearch) &&
this.doesRuleHaveFilteredStatus(rule) &&
Expand Down Expand Up @@ -572,6 +591,7 @@ export default {
lckFilterChecked: true, // Locked
showDuplicatesChecked: false, // Show duplicates
showSRGIdChecked: false, // Show SRG ID instead of STIG ID
sortBySRGIdChecked: false, // Sort by SRG ID
};
},
handleScroll: function () {
Expand Down

0 comments on commit e9a63bb

Please sign in to comment.