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

Adding the option to group/sort controls by SrG ID #566

Merged
merged 1 commit into from
Apr 27, 2023
Merged
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
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