mirror of https://github.com/doccano/doccano.git
4 changed files with 69 additions and 67 deletions
Unified View
Diff Options
-
BINapp/db.sqlite3
-
2app/server/static/bundle/seq2seq.js
-
124app/server/static/js/seq2seq.js
-
10app/server/templates/annotation/seq2seq.html
@ -1,73 +1,75 @@ |
|||||
import Vue from 'vue'; |
import Vue from 'vue'; |
||||
|
import annotationMixin from './mixin'; |
||||
|
import HTTP from './http'; |
||||
|
|
||||
Vue.use(require('vue-shortkey')); |
Vue.use(require('vue-shortkey')); |
||||
import annotationMixin from './mixin.js'; |
|
||||
import HTTP from './http.js'; |
|
||||
|
|
||||
|
|
||||
var vm = new Vue({ |
|
||||
el: '#mail-app', |
|
||||
delimiters: ['[[', ']]'], |
|
||||
data: { |
|
||||
newTodo: '', |
|
||||
editedTodo: null |
|
||||
}, |
|
||||
mixins: [annotationMixin], |
|
||||
directives: { |
|
||||
'todo-focus': function (el, binding) { |
|
||||
if (binding.value) { |
|
||||
el.focus() |
|
||||
} |
|
||||
} |
|
||||
|
const vm = new Vue({ |
||||
|
el: '#mail-app', |
||||
|
delimiters: ['[[', ']]'], |
||||
|
data: { |
||||
|
newTodo: '', |
||||
|
editedTodo: null, |
||||
|
}, |
||||
|
mixins: [annotationMixin], |
||||
|
directives: { |
||||
|
'todo-focus': function(el, binding) { |
||||
|
if (binding.value) { |
||||
|
el.focus(); |
||||
|
} |
||||
}, |
}, |
||||
methods: { |
|
||||
addTodo: function () { |
|
||||
var value = this.newTodo && this.newTodo.trim() |
|
||||
if (!value) { |
|
||||
return |
|
||||
} |
|
||||
|
}, |
||||
|
|
||||
var doc_id = this.items[this.cur].id; |
|
||||
var payload = {text: value} |
|
||||
HTTP.post(`docs/${doc_id}/annotations/`, payload).then(response => { |
|
||||
this.items[this.cur]['labels'].push(response.data) |
|
||||
}) |
|
||||
|
methods: { |
||||
|
addTodo() { |
||||
|
const value = this.newTodo && this.newTodo.trim(); |
||||
|
if (!value) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
this.newTodo = '' |
|
||||
}, |
|
||||
|
const docId = this.docs[this.pageNumber].id; |
||||
|
const payload = { |
||||
|
text: value, |
||||
|
}; |
||||
|
HTTP.post(`docs/${docId}/annotations/`, payload).then((response) => { |
||||
|
this.annotations[this.pageNumber].push(response.data); |
||||
|
}); |
||||
|
|
||||
removeTodo: function (todo) { |
|
||||
var doc_id = this.items[this.cur].id; |
|
||||
HTTP.delete(`docs/${doc_id}/annotations/${todo.id}`).then(response => { |
|
||||
this.items[this.cur]['labels'].splice(this.items[this.cur]['labels'].indexOf(todo), 1) |
|
||||
}); |
|
||||
}, |
|
||||
|
this.newTodo = ''; |
||||
|
}, |
||||
|
|
||||
editTodo: function (todo) { |
|
||||
this.beforeEditCache = todo.text |
|
||||
this.editedTodo = todo |
|
||||
}, |
|
||||
|
removeTodo(todo) { |
||||
|
const docId = this.docs[this.pageNumber].id; |
||||
|
HTTP.delete(`docs/${docId}/annotations/${todo.id}`).then((response) => { |
||||
|
const index = this.annotations[this.pageNumber].indexOf(todo); |
||||
|
this.annotations[this.pageNumber].splice(index, 1); |
||||
|
}); |
||||
|
}, |
||||
|
|
||||
doneEdit: function (todo) { |
|
||||
if (!this.editedTodo) { |
|
||||
return |
|
||||
} |
|
||||
this.editedTodo = null |
|
||||
todo.text = todo.text.trim() |
|
||||
if (!todo.text) { |
|
||||
this.removeTodo(todo) |
|
||||
} |
|
||||
var doc_id = this.items[this.cur].id; |
|
||||
HTTP.put(`docs/${doc_id}/annotations/${todo.id}`, todo).then(response => { |
|
||||
console.log(response) |
|
||||
}); |
|
||||
}, |
|
||||
|
editTodo(todo) { |
||||
|
this.beforeEditCache = todo.text; |
||||
|
this.editedTodo = todo; |
||||
|
}, |
||||
|
|
||||
|
doneEdit(todo) { |
||||
|
if (!this.editedTodo) { |
||||
|
return; |
||||
|
} |
||||
|
this.editedTodo = null; |
||||
|
todo.text = todo.text.trim(); |
||||
|
if (!todo.text) { |
||||
|
this.removeTodo(todo); |
||||
|
} |
||||
|
const docId = this.docs[this.pageNumber].id; |
||||
|
HTTP.put(`docs/${docId}/annotations/${todo.id}`, todo).then((response) => { |
||||
|
console.log(response); |
||||
|
}); |
||||
|
}, |
||||
|
|
||||
cancelEdit: function (todo) { |
|
||||
this.editedTodo = null |
|
||||
todo.text = this.beforeEditCache |
|
||||
} |
|
||||
|
cancelEdit(todo) { |
||||
|
this.editedTodo = null; |
||||
|
todo.text = this.beforeEditCache; |
||||
}, |
}, |
||||
created: function () { |
|
||||
this.submit(); |
|
||||
} |
|
||||
}); |
|
||||
|
}, |
||||
|
}); |
Write
Preview
Loading…
Cancel
Save