|
@@ -7,10 +7,11 @@
|
|
|
<h3 class="question">- {{ element.text }}</h3>
|
|
<h3 class="question">- {{ element.text }}</h3>
|
|
|
<span v-if="element.optional"> (Optional)</span>
|
|
<span v-if="element.optional"> (Optional)</span>
|
|
|
<br>
|
|
<br>
|
|
|
- <ApplicationInputSwitch class="textfield" :highlight="highlight" :type="element.type" :options="element.options"></ApplicationInputSwitch>
|
|
|
|
|
|
|
+ <ApplicationInputSwitch class="textfield" :highlight="highlight" :type="element.type" :options="element.options" :ref="index"></ApplicationInputSwitch>
|
|
|
<span class="hint">{{ element.hint }}</span>
|
|
<span class="hint">{{ element.hint }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
<button @click="update">Create/Update</button>
|
|
<button @click="update">Create/Update</button>
|
|
|
|
|
+ <span class="error"> {{ error }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
<span v-else>You are not logged in.</span>
|
|
<span v-else>You are not logged in.</span>
|
|
|
</div>
|
|
</div>
|
|
@@ -25,6 +26,7 @@
|
|
|
instruction: '',
|
|
instruction: '',
|
|
|
pattern: null,
|
|
pattern: null,
|
|
|
highlight: false,
|
|
highlight: false,
|
|
|
|
|
+ error: '',
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
created () {
|
|
created () {
|
|
@@ -39,8 +41,43 @@
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ isReady() {
|
|
|
|
|
+ for(let key in this.$refs) {
|
|
|
|
|
+ //TBI What is that 0
|
|
|
|
|
+ let el = this.$refs[key][0]
|
|
|
|
|
+
|
|
|
|
|
+ if(!el.isOkay) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return true
|
|
|
|
|
+ },
|
|
|
|
|
+ getContent() {
|
|
|
|
|
+ let answers = []
|
|
|
|
|
+ for(let key in this.$refs) {
|
|
|
|
|
+ //TBI What is that 0
|
|
|
|
|
+ answers.push(this.$refs[key][0].getContent())
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return answers
|
|
|
|
|
+ },
|
|
|
update() {
|
|
update() {
|
|
|
- this.highlight = true
|
|
|
|
|
|
|
+ if(this.isReady()) {
|
|
|
|
|
+ this.core.post('/application', {
|
|
|
|
|
+ //TODO: Pattern, User-token
|
|
|
|
|
+ answers: this.getContent(),
|
|
|
|
|
+ creator: this.user.username,
|
|
|
|
|
+ }).then((response) => {
|
|
|
|
|
+
|
|
|
|
|
+ console.log('Response: ', response.data);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ this.error = ''
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.highlight = true
|
|
|
|
|
+ this.error = 'Please fill the required fields'
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
components: {
|
|
components: {
|
|
@@ -62,4 +99,8 @@
|
|
|
.hint {
|
|
.hint {
|
|
|
font-size: 0.8em;
|
|
font-size: 0.8em;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ .error {
|
|
|
|
|
+ color: red;
|
|
|
|
|
+ }
|
|
|
</style>
|
|
</style>
|