Skip to content

Commit 5ced4d0

Browse files
committed
Change how first time validation is handled and what is displayed and when.
It's not nice code, but it will do till it all gets refactored
1 parent 350cbee commit 5ced4d0

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/App.vue

+29-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,26 @@
4141
/>
4242
</b-collapse>
4343

44+
<b-row v-if="!firstEvaluation && !loadingData" align-h="center" justify-content-md-center>
45+
<b-col lg="4" sm="6">
46+
<b-alert v-if="allJSONValid === false" show variant="danger">
47+
Invalid JSON. Scroll for errors.
48+
</b-alert>
49+
<b-alert v-else-if="ajvSchemaError.length !== 0" show variant="danger">
50+
JSON Schema invalid. Scroll for errors.
51+
</b-alert>
52+
<b-alert v-else-if="ajvValidationSuccess === null" show variant="info">
53+
Checking validation
54+
</b-alert>
55+
<b-alert v-if="ajvValidationSuccess === true" show variant="success">
56+
Instance Validation Successful
57+
</b-alert>
58+
<b-alert v-if="ajvValidationSuccess === false" show variant="danger">
59+
Instance Validation Failed. Scroll for errors.
60+
</b-alert>
61+
</b-col>
62+
</b-row>
63+
4464
<b-row class="mb-3 no-gutters vld-parent">
4565
<loading
4666
:active="loadingData"
@@ -135,6 +155,7 @@ export default {
135155
errorMessage: null,
136156
infoMessage: null,
137157
loadingData: true,
158+
firstEvaluation: true,
138159
checkingValidation: false,
139160
schema: null,
140161
primarySchemaText: defaultPrimarySchemaText,
@@ -146,6 +167,8 @@ export default {
146167
editorTheme: 'default',
147168
showFeatures: false,
148169
showSettings: false,
170+
// Expect this will be determined using a computed at some point
171+
numberOfEditors: 2,
149172
};
150173
},
151174
computed: {
@@ -185,6 +208,10 @@ export default {
185208
handler: function() {
186209
this.ajvValidationSuccess = null;
187210
this.validateIfPossible();
211+
const lintResults = Object.values(this.jsonLintValid);
212+
if(lintResults.length === this.numberOfEditors && lintResults.every(v => v !== null)){
213+
this.$set(this, 'firstEvaluation', false);
214+
}
188215
},
189216
deep: true,
190217
},
@@ -260,11 +287,10 @@ export default {
260287
Vue.set(this, 'instanceText', localStorage.getItem('instanceText'));
261288
}
262289
},
263-
validate: function() {
290+
validate: async function() {
264291
if(this.loadingData){
265292
return;
266293
}
267-
this.checkingValidation = true;
268294
this.ajvValidationSuccess = null;
269295
this.ajvSchemaError = [];
270296
this.ajvValidationErrors = [];
@@ -303,6 +329,7 @@ export default {
303329
},
304330
validateIfPossible: _.debounce(function() {
305331
if (this.allJSONValid) {
332+
this.$set(this, 'checkingValidation', true);
306333
this.validate();
307334
}
308335
}, 300),

src/components/Results.vue

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
<b-alert show variant="success">
3333
<h5>
3434
<icon
35-
v-if="ajvValidationSuccess === true"
3635
:icon="['far', 'check-circle']"
3736
size="2x"
3837
class="align-middle"

0 commit comments

Comments
 (0)