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.

207 lines
5.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <v-toolbar class="toolbar-control" dense flat>
  3. <v-row no-gutters>
  4. <v-btn-toggle>
  5. <button-review :is-reviewd="isReviewd" @click:review="$emit('click:review')" />
  6. <button-filter :value="filterOption" @click:filter="changeFilter" />
  7. <button-order :value="orderOption" @click:order="changeOrder" />
  8. <button-guideline @click:guideline="dialogGuideline = true" />
  9. <v-dialog v-model="dialogGuideline">
  10. <form-guideline :guideline-text="guidelineText" @click:close="dialogGuideline = false" />
  11. </v-dialog>
  12. <button-comment @click:comment="dialogComment = true" />
  13. <v-dialog v-model="dialogComment">
  14. <form-comment :example-id="docId" @click:cancel="dialogComment = false" />
  15. </v-dialog>
  16. <button-auto-labeling @click:auto="dialogAutoLabeling = true" />
  17. <v-dialog v-model="dialogAutoLabeling">
  18. <form-auto-labeling
  19. :is-enabled="enableAutoLabeling"
  20. :error-message="errorMessage"
  21. @click:cancel="dialogAutoLabeling = false"
  22. @input="updateAutoLabeling"
  23. />
  24. </v-dialog>
  25. <button-clear @click:clear="dialogClear = true" />
  26. <v-dialog v-model="dialogClear">
  27. <form-clear-label
  28. @click:ok="
  29. $emit('click:clear-label')
  30. dialogClear = false
  31. "
  32. @click:cancel="dialogClear = false"
  33. />
  34. </v-dialog>
  35. <button-keyboard-shortcut @click:open="dialogShortcut = true" />
  36. <v-dialog v-model="dialogShortcut">
  37. <form-keyboard-shortcut @click:close="dialogShortcut = false" />
  38. </v-dialog>
  39. </v-btn-toggle>
  40. <slot />
  41. <v-spacer />
  42. <button-pagination
  43. :value="page"
  44. :total="total"
  45. @click:prev="updatePage(page - 1)"
  46. @click:next="updatePage(page + 1)"
  47. @click:first="updatePage(1)"
  48. @click:last="updatePage(total)"
  49. @click:jump="updatePage($event)"
  50. />
  51. </v-row>
  52. </v-toolbar>
  53. </template>
  54. <script lang="ts">
  55. import Vue from 'vue'
  56. import ButtonAutoLabeling from './buttons/ButtonAutoLabeling.vue'
  57. import ButtonClear from './buttons/ButtonClear.vue'
  58. import ButtonComment from './buttons/ButtonComment.vue'
  59. import ButtonFilter from './buttons/ButtonFilter.vue'
  60. import ButtonGuideline from './buttons/ButtonGuideline.vue'
  61. import ButtonOrder from './buttons/ButtonOrder.vue'
  62. import ButtonPagination from './buttons/ButtonPagination.vue'
  63. import ButtonReview from './buttons/ButtonReview.vue'
  64. import ButtonKeyboardShortcut from './buttons/ButtonKeyboardShortcut.vue'
  65. import FormAutoLabeling from './forms/FormAutoLabeling.vue'
  66. import FormClearLabel from './forms/FormClearLabel.vue'
  67. import FormComment from './forms/FormComment.vue'
  68. import FormGuideline from './forms/FormGuideline.vue'
  69. import FormKeyboardShortcut from './forms/FormKeyboardShortcut.vue'
  70. export default Vue.extend({
  71. components: {
  72. ButtonAutoLabeling,
  73. ButtonClear,
  74. ButtonComment,
  75. ButtonFilter,
  76. ButtonGuideline,
  77. ButtonOrder,
  78. ButtonKeyboardShortcut,
  79. ButtonPagination,
  80. ButtonReview,
  81. FormAutoLabeling,
  82. FormClearLabel,
  83. FormComment,
  84. FormGuideline,
  85. FormKeyboardShortcut
  86. },
  87. props: {
  88. docId: {
  89. type: Number,
  90. required: true
  91. },
  92. enableAutoLabeling: {
  93. type: Boolean,
  94. default: false,
  95. required: true
  96. },
  97. guidelineText: {
  98. type: String,
  99. default: '',
  100. required: true
  101. },
  102. isReviewd: {
  103. type: Boolean,
  104. default: false
  105. },
  106. total: {
  107. type: Number,
  108. default: 1
  109. }
  110. },
  111. data() {
  112. return {
  113. dialogAutoLabeling: false,
  114. dialogClear: false,
  115. dialogComment: false,
  116. dialogGuideline: false,
  117. dialogShortcut: false,
  118. errorMessage: ''
  119. }
  120. },
  121. computed: {
  122. page(): number {
  123. // @ts-ignore
  124. return parseInt(this.$route.query.page, 10)
  125. },
  126. filterOption(): string {
  127. // @ts-ignore
  128. return this.$route.query.isChecked
  129. },
  130. orderOption(): string {
  131. // @ts-ignore
  132. return this.$route.query.ordering
  133. }
  134. },
  135. methods: {
  136. updatePage(page: number) {
  137. this.$router.push({
  138. query: {
  139. page: page.toString(),
  140. isChecked: this.filterOption,
  141. ordering: this.$route.query.ordering,
  142. q: this.$route.query.q
  143. }
  144. })
  145. },
  146. changeFilter(isChecked: string) {
  147. this.$router.push({
  148. query: {
  149. page: '1',
  150. isChecked,
  151. ordering: this.$route.query.ordering,
  152. q: this.$route.query.q
  153. }
  154. })
  155. },
  156. changeOrder(ordering: string) {
  157. this.$router.push({
  158. query: {
  159. page: '1',
  160. isChecked: this.filterOption,
  161. q: this.$route.query.q,
  162. ordering
  163. }
  164. })
  165. },
  166. updateAutoLabeling(isEnable: boolean) {
  167. if (isEnable) {
  168. this.$emit('update:enable-auto-labeling', true)
  169. } else {
  170. this.$emit('update:enable-auto-labeling', false)
  171. }
  172. }
  173. }
  174. })
  175. </script>
  176. <style scoped>
  177. .toolbar-control {
  178. position: sticky;
  179. top: 68px;
  180. z-index: 100;
  181. }
  182. .toolbar-control >>> .v-toolbar__content {
  183. padding: 0px !important;
  184. }
  185. ::v-deep .v-dialog {
  186. width: 800px;
  187. }
  188. </style>