Skip to content

Commit e16aae6

Browse files
committed
add Buefy package; ReportRequestForNonCNAs: add auto-complete CNA search box
1 parent f3df288 commit e16aae6

File tree

4 files changed

+49
-10
lines changed

4 files changed

+49
-10
lines changed

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@fortawesome/free-solid-svg-icons": "^6.5.1",
2323
"@fortawesome/vue-fontawesome": "^3.0.5",
2424
"axios": "^1.6.5",
25+
"buefy": "npm:@ntohq/buefy-next@^0.1.4",
2526
"bulma": "^0.9.4",
2627
"bulma-timeline": "^3.0.5",
2728
"lodash": "^4.17.21",

src/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22
import { createApp } from 'vue';
3+
import Buefy from 'buefy';
4+
import 'buefy/dist/buefy.css';
35
import { createPinia } from 'pinia';
46
import VueGtag from 'vue-gtag';
57
import LoadScript from 'vue-plugin-load-script';
@@ -31,6 +33,7 @@ library.add(
3133

3234

3335
const app = createApp(App);
36+
app.use(Buefy);
3437
const pinia = createPinia();
3538
pinia.use(({ store }) => {
3639
store.router = router;

src/views/ReportRequest/ReportRequestForNonCNAs.vue

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
<h4 class="title">Find the CVE Numbering Authority (CNA)</h4>
3232
<p>
3333
Find the CNA partner whose scope includes the product affected by the vulnerability on the
34-
<router-link to="/PartnerInformation/ListofPartners">List of Partners</router-link> page or in the search box below.
34+
<router-link to="/PartnerInformation/ListofPartners">List of Partners</router-link>
35+
page or in the search box below.
3536
</p>
3637
<b-field>
3738
<b-autocomplete
@@ -188,17 +189,34 @@ export default {
188189
},
189190
computed: {
190191
filteredDataObj() {
191-
const results = this.data.filter((option) => (
192-
option.organizationName
193-
.toString()
194-
.toLowerCase()
195-
.indexOf(this.name.toLowerCase()) >= 0
196-
));
192+
const normalizedName = this.name.toLowerCase();
193+
if (!normalizedName.length)
194+
return;
197195
198-
if (results.length > 10) {
199-
return results.splice(0, 10);
196+
let results = this.data.filter((option) => (
197+
option.organizationName.toLowerCase()
198+
.indexOf(normalizedName) >= 0));
199+
200+
function cmp(cna1, cna2) {
201+
// Sorts the list of organization names based on the characters
202+
// entered by the user in the search box. For example, if the user
203+
// has entered "br", then "Brocade Communications" is listed before
204+
// "Jetbrains" because "br" is closest to the beginning of the
205+
// string in "Brocade Communications".
206+
207+
const cna1NormalName = cna1.organizationName.toLowerCase();
208+
const cna2NormalName = cna2.organizationName.toLowerCase()
209+
const cna1Index = cna1NormalName.indexOf(normalizedName);
210+
const cna2Index = cna2NormalName.indexOf(normalizedName);
211+
212+
return cna1Index < cna2Index ? -1 : cna1Index > cna2Index ? 1 :
213+
cna1NormalName.localeCompare(cna2NormalName);
200214
}
201-
return results;
215+
216+
// Limit the choices presented to the user to the first 10 organizations
217+
// in the list.
218+
219+
return results.sort(cmp).slice(0, 10);
202220
},
203221
},
204222
methods: {

0 commit comments

Comments
 (0)