Skip to content

Commit 0f6dd35

Browse files
committed
#39 #40 fix Enter key up functionality by validating cve id before look up, display reference url link instead of name, reset accordian to closed state when new cve id look up executes
1 parent fdb5b96 commit 0f6dd35

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

src/components/cveRecordLookupModule.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="field mt-1" style="">
33
<div class="field has-addons mb-1">
44
<div class="control is-expanded">
5-
<input v-model="cveId" @keyup.enter="lookupId" @keyup="validateCveId" @blur="removeHelpText" type="text" class="input cve-id-input"
5+
<input v-model="cveId" @keyup.enter="onKeyUpEnter" @keyup="validateCveId" @blur="removeHelpText" type="text" class="input cve-id-input"
66
placeholder="Enter CVE ID (CVE-YYYY-NNNN)"/>
77
</div>
88
<div class="control">
@@ -303,6 +303,11 @@ export default ({
303303
304304
this.formatCveRecord();
305305
},
306+
onKeyUpEnter() {
307+
this.validateCveId();
308+
309+
if (!this.disabled) this.lookupId();
310+
},
306311
},
307312
});
308313
</script>

src/views/CVERecord.vue

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,23 @@
3636
<section class="cve-accordian">
3737
<div class="message">
3838
<div class="message-header cve-base-light-gray-borders-bg">
39-
<p style="margin-top: auto !important; margin-bottom: auto !important">{{showRecord ? 'Hide' : 'View'}} full JSON 4.0 record</p>
40-
<button class="button" @click="toggleRecord" :aria-expanded="!true ? 'true' : 'false'" aria-controls="cve-id">
39+
<p style="margin-top: auto !important; margin-bottom: auto !important">
40+
{{this.$store.state.showJsonRecord ? 'Hide' : 'View'}} full JSON 4.0 record
41+
</p>
42+
<button class="button" @click="toggleRecord"
43+
:aria-expanded="!this.$store.state.showJsonRecord ? 'true' : 'false'" aria-controls="cve-id">
4144
<span class="icon is-small">
4245
<p id="cve-id-alttext" class="is-hidden">
4346
{{true ? 'collapse' : 'expand'}}
4447
</p>
45-
<font-awesome-icon :icon="showRecord ? 'minus' : 'plus'"
48+
<font-awesome-icon :icon="this.$store.state.showJsonRecord ? 'minus' : 'plus'"
4649
aria-hidden="false" focusable="true" aria-labelledby="cve-id-alttext"/>
4750
</span>
4851
</button>
4952
</div>
5053
<div class="message-body pb-0" :class="{'is-hidden': false}" id="cve-id">
51-
<pre :class="[{'is-hidden': !showRecord}]" v-html="$sanitize(JSON.stringify(this.$store.state.recordData, null, 2))"></pre>
54+
<pre :class="[{'is-hidden': !this.$store.state.showJsonRecord}]"
55+
v-html="$sanitize(JSON.stringify(this.$store.state.recordData, null, 2))"></pre>
5256
</div>
5357
</div>
5458
</section>
@@ -114,7 +118,7 @@
114118
<ul v-for="reference in this.$store.state.recordData.reference_data" :key="reference.index">
115119
<li v-if="reference.url !== undefined" class="cve-task-tile-list-item">
116120
<a :href="$sanitize(reference.url)" class="cve-word-wrap" target="_blank">
117-
{{reference.name === undefined ? $sanitize(reference.url) : $sanitize(reference.name)}}
121+
{{$sanitize(reference.url)}}
118122
</a>
119123
</li>
120124
</ul>
@@ -148,14 +152,9 @@
148152
<script>
149153
export default {
150154
name: 'CVERecord',
151-
data() {
152-
return {
153-
showRecord: false,
154-
};
155-
},
156155
methods: {
157156
toggleRecord() {
158-
this.showRecord = !this.showRecord;
157+
this.$store.commit('updateState', { showJsonRecord: !this.$store.state.showJsonRecord });
159158
},
160159
},
161160
};

0 commit comments

Comments
 (0)