From 4baed47b18297e6ff452504658600397f82683d2 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Tue, 5 Jun 2018 13:12:02 +0900 Subject: [PATCH] Update label definition --- doccano/app/server/static/project_admin.js | 161 +++++------------- doccano/app/server/templates/base.html | 1 + .../app/server/templates/project_admin.html | 121 ++++++------- 3 files changed, 95 insertions(+), 188 deletions(-) diff --git a/doccano/app/server/static/project_admin.js b/doccano/app/server/static/project_admin.js index 243c5a91..860c1e3c 100644 --- a/doccano/app/server/static/project_admin.js +++ b/doccano/app/server/static/project_admin.js @@ -11,76 +11,6 @@ function swap(values) { return ret; }; - -Vue.component('tabs', { - template: ` -
-
- -
- -
- -
-
- `, - - data() { - return { - tabs: [] - }; - }, - - created() { - this.tabs = this.$children; - }, - - methods: { - selectTab(selectedTab) { - this.tabs.forEach(tab => { - tab.isActive = (tab.name == selectedTab.name); - }); - } - } - -}); - -Vue.component('tab', { - template: ` -
- `, - - props: { - name: { - required: true - }, - selected: { - default: false - }, - }, - - data() { - return { - isActive: false - } - }, - - computed: { - href() { - return '#' + this.name.toLowerCase().replace(/ /g, '-') - } - }, - - mounted() { - this.isActive = this.selected - } - -}); - var vm = new Vue({ el: '#root', delimiters: ['[[', ']]'], @@ -94,16 +24,17 @@ var vm = new Vue({ }], "text": 'document' }], + todos: [], labels: [], file: null, file_name: '', + newTodo: '', + editedTodo: null, }, methods: { handleFileUpload() { this.file = this.$refs.file.files[0]; - console.log(this.file); - console.log(this.file.name); this.file_name = this.file.name; }, submitFile() { @@ -122,67 +53,55 @@ var vm = new Vue({ console.log('FAILURE!!'); }); }, - addLabel: function (label) { - var label = { - 'text': label, - 'prob': null - }; - this.items[this.cur]['labels'].push(label); - - var label2id = swap(this.labels); - var data = { - 'id': this.items[this.cur]['id'], - 'label_id': label2id[label['text']] - }; - - axios.post('/' + base_url + '/apis/data', data) - .then(function (response) { - console.log('post data'); - }) - .catch(function (error) { - console.log('ERROR!! happend by Backend.') - }); + addTodo: function () { + var value = this.newTodo && this.newTodo.trim(); + if (!value) { + return + } + this.todos.push({ + title: value, + }) + this.newTodo = '' + }, + removeTodo: function (todo) { + this.todos.splice(this.todos.indexOf(todo), 1) }, - deleteLabel: function (index) { - var label2id = swap(this.labels); - var label = this.items[this.cur]['labels'][index]; - var payload = { - 'id': this.items[this.cur]['id'], - 'label_id': label2id[label['text']] - }; - axios.delete('/' + base_url + '/apis/data', { - data: payload - }) - .then(function (response) { - console.log('delete data'); - }) - .catch(function (error) { - console.log('ERROR!! happend by Backend.') - }); - this.items[this.cur]['labels'].splice(index, 1) + editTodo: function (todo) { + this.beforeEditCache = todo.title + this.editedTodo = todo + }, + doneEdit: function (todo) { + if (!this.editedTodo) { + return + } + this.editedTodo = null + todo.title = todo.title.trim() + if (!todo.title) { + this.removeTodo(todo) + } + }, + cancelEdit: function (todo) { + this.editedTodo = null + todo.title = this.beforeEditCache }, - submit: function () { - console.log('submit' + this.searchQuery); - var self = this; - axios.get('/' + base_url + '/apis/search?keyword=' + this.searchQuery) - .then(function (response) { - console.log('search response'); - self.history = response.data['data']; - }) - .catch(function (error) { - console.log('ERROR!! happend by Backend.') - }); - } }, created: function () { var self = this; axios.get('/' + base_url + '/apis/labels') .then(function (response) { self.labels = response.data['labels']; + console.log(self.labels); }) .catch(function (error) { console.log('ERROR!! happend by Backend.') }); + }, + directives: { + 'todo-focus': function (el, binding) { + if (binding.value) { + el.focus() + } + } } }); \ No newline at end of file diff --git a/doccano/app/server/templates/base.html b/doccano/app/server/templates/base.html index cea9d4cc..0f1c134e 100644 --- a/doccano/app/server/templates/base.html +++ b/doccano/app/server/templates/base.html @@ -17,6 +17,7 @@ + {% block header %}{% endblock %} diff --git a/doccano/app/server/templates/project_admin.html b/doccano/app/server/templates/project_admin.html index fcfb6780..ca145b9a 100644 --- a/doccano/app/server/templates/project_admin.html +++ b/doccano/app/server/templates/project_admin.html @@ -1,81 +1,68 @@ -{% extends "base.html" %} {% load static %} {% block content %} +{% extends "base.html" %} {% load static %} +{% block header %} + +{% endblock %} +{% block content %}
- - -
-
-

Project Dataset

-
-
-

- -

+
+
+

Project Dataset

+
+
+
+
+
-
-
-
- -
-
-
- -
-
+
+
+
-
- - 1 -
-
-
-
- - -
-
-

Label Definition

-
-
-

- -

-
-
-
-

Label definition

-

- @jsmith created at {{ object.created_at|date }}   - Question -

-
-
-
- - 1 + + + +
+
+

Label Settings

+ +
+
+
    +
  • +
    + + +
    + +
  • +
+
+
-
+
- - +
+