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.

41 lines
950 B

  1. import Vue from 'vue';
  2. import annotationMixin from './mixin';
  3. import HTTP from './http';
  4. Vue.use(require('vue-shortkey'), {
  5. prevent: ['input', 'textarea'],
  6. });
  7. const vm = new Vue({
  8. el: '#mail-app',
  9. delimiters: ['[[', ']]'],
  10. mixins: [annotationMixin],
  11. methods: {
  12. isIn(label) {
  13. for (let i = 0; i < this.annotations[this.pageNumber].length; i++) {
  14. const a = this.annotations[this.pageNumber][i];
  15. if (a.label === label.id) {
  16. return a;
  17. }
  18. }
  19. return false;
  20. },
  21. async addLabel(label) {
  22. const a = this.isIn(label);
  23. if (a) {
  24. this.removeLabel(a);
  25. } else {
  26. const docId = this.docs[this.pageNumber].id;
  27. const payload = {
  28. label: label.id,
  29. };
  30. await HTTP.post(`docs/${docId}/annotations/`, payload).then((response) => {
  31. this.annotations[this.pageNumber].push(response.data);
  32. });
  33. }
  34. },
  35. },
  36. });