You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
3.2 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <v-stepper-content step="2">
  3. <v-card>
  4. <v-card-text class="pa-0">
  5. <v-form>
  6. <h4 class="text-h6">Set parameters</h4>
  7. <p class="font-weight-regular body-1">
  8. You can set parameters to fetch API response.
  9. </p>
  10. <template v-for="item in value">
  11. <v-text-field
  12. v-if="item.type === 'textField'"
  13. :key="item.name"
  14. v-model="item.value"
  15. :label="item.name"
  16. outlined
  17. />
  18. <v-select
  19. v-if="item.type === 'selectField'"
  20. :key="item.name"
  21. v-model="item.value"
  22. :items="item.items"
  23. :label="item.name"
  24. outlined
  25. />
  26. <object-field
  27. v-if="item.type === 'objectField'"
  28. :key="item.name"
  29. v-model="item.value"
  30. :title="item.name"
  31. />
  32. </template>
  33. <h4 class="text-h6">Test the parameters</h4>
  34. <p class="font-weight-regular body-1">
  35. Before proceeding, you need to test the parameters whether they can fetch API response.
  36. Please input sample text and press the <strong>Test</strong> button.
  37. </p>
  38. <v-text-field
  39. v-model="sampleText"
  40. outlined
  41. label="Sample Text"
  42. />
  43. <v-alert
  44. v-for="(error, index) in errorMessages"
  45. :key="index"
  46. prominent
  47. type="error"
  48. >
  49. <v-row align="center">
  50. <v-col class="grow">
  51. {{ error }}
  52. </v-col>
  53. </v-row>
  54. </v-alert>
  55. <h4 class="text-h6">
  56. Response
  57. </h4>
  58. <v-sheet
  59. :dark="!$vuetify.theme.dark"
  60. :light="$vuetify.theme.dark"
  61. class="mb-5 pa-5"
  62. >
  63. <pre>{{ JSON.stringify(response, null, 4) }}</pre>
  64. </v-sheet>
  65. </v-form>
  66. </v-card-text>
  67. <v-card-actions class="pa-0">
  68. <v-spacer />
  69. <v-btn
  70. text
  71. class="text-capitalize"
  72. @click="$emit('prev')"
  73. >
  74. Prev
  75. </v-btn>
  76. <v-btn
  77. v-show="!isPassed"
  78. color="primary"
  79. class="text-capitalize"
  80. @click="$emit('onTest', sampleText)"
  81. >
  82. Test
  83. </v-btn>
  84. <v-btn
  85. v-show="isPassed"
  86. color="primary"
  87. class="text-capitalize"
  88. @click="$emit('next')"
  89. >
  90. Next
  91. </v-btn>
  92. </v-card-actions>
  93. </v-card>
  94. </v-stepper-content>
  95. </template>
  96. <script lang="ts">
  97. import Vue from 'vue'
  98. import ObjectField from './ObjectField.vue'
  99. export default Vue.extend({
  100. components: {
  101. ObjectField
  102. },
  103. props: {
  104. value: {
  105. type: Array,
  106. default: () => [],
  107. required: true
  108. },
  109. errorMessages: {
  110. type: Array,
  111. default: () => [],
  112. required: true
  113. },
  114. isPassed: {
  115. type: Boolean,
  116. default: false,
  117. required: true
  118. },
  119. response: {
  120. type: [String, Array, Object],
  121. default: () => [],
  122. required: true
  123. }
  124. },
  125. data() {
  126. return {
  127. sampleText: ''
  128. }
  129. }
  130. })
  131. </script>