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.

75 lines
2.1 KiB

  1. <template lang="pug">
  2. extends ./annotation.pug
  3. block annotation-area
  4. div.card
  5. header.card-header
  6. div.card-header-title.has-background-royalblue
  7. div.field.is-grouped.is-grouped-multiline
  8. div.control(v-for="label in labels")
  9. div.tags.has-addons
  10. a.tag.is-medium(
  11. v-shortkey.once="replaceNull(shortcutKey(label))"
  12. v-bind:style="{ \
  13. color: label.text_color, \
  14. backgroundColor: label.background_color \
  15. }"
  16. v-on:click="annotate(label.id)"
  17. v-on:shortkey="annotate(label.id)"
  18. ) {{ label.text }}
  19. span.tag.is-medium
  20. kbd {{ shortcutKey(label) | simpleShortcut }}
  21. div.card-content
  22. div.content.scrollable(v-if="docs[pageNumber] && annotations[pageNumber]", ref="textbox")
  23. annotator(
  24. v-bind:labels="labels"
  25. v-bind:entity-positions="annotations[pageNumber]"
  26. v-bind:search-query="searchQuery"
  27. v-bind:text="docs[pageNumber].text"
  28. v-on:remove-label="removeLabel"
  29. v-on:add-label="addLabel"
  30. ref="annotator"
  31. )
  32. </template>
  33. <style scoped>
  34. .card-header-title {
  35. padding: 1.5rem;
  36. }
  37. </style>
  38. <script>
  39. import annotationMixin from './annotationMixin';
  40. import Annotator from './annotator.vue';
  41. import HTTP from './http';
  42. import { simpleShortcut } from './filter';
  43. export default {
  44. filters: { simpleShortcut },
  45. components: { Annotator },
  46. mixins: [annotationMixin],
  47. methods: {
  48. annotate(labelId) {
  49. this.$refs.annotator.addLabel(labelId);
  50. },
  51. addLabel(annotation) {
  52. const docId = this.docs[this.pageNumber].id;
  53. HTTP.post(`docs/${docId}/annotations`, annotation).then((response) => {
  54. this.annotations[this.pageNumber].push(response.data);
  55. });
  56. },
  57. async submit() {
  58. const state = this.getState();
  59. this.url = `docs?q=${this.searchQuery}&seq_annotations__isnull=${state}&offset=${this.offset}&ordering=${this.ordering}`;
  60. await this.search();
  61. this.pageNumber = 0;
  62. },
  63. },
  64. };
  65. </script>