Browse Source

Remove headers from stores to components

pull/341/head
Hironsan 5 years ago
parent
commit
dad35fbcaa
8 changed files with 70 additions and 110 deletions
  1. 23
      frontend/components/containers/documents/DocumentList.vue
  2. 19
      frontend/components/containers/labels/LabelList.vue
  3. 17
      frontend/components/containers/members/MemberList.vue
  4. 22
      frontend/components/containers/projects/ProjectList.vue
  5. 50
      frontend/store/documents.js
  6. 18
      frontend/store/labels.js
  7. 14
      frontend/store/members.js
  8. 17
      frontend/store/projects.js

23
frontend/components/containers/documents/DocumentList.vue

@ -58,13 +58,32 @@ export default {
data() {
return {
search: '',
options: {}
options: {},
headers: [
{
text: 'Text',
align: 'left',
value: 'text',
sortable: false
},
{
text: 'Metadata',
align: 'left',
value: 'meta',
sortable: false
},
{
text: 'Action',
align: 'left',
value: 'action',
sortable: false
}
]
}
},
computed: {
...mapState('documents', ['items', 'selected', 'loading', 'total']),
...mapGetters('documents', ['headers']),
...mapGetters('projects', ['getLink'])
},

19
frontend/components/containers/labels/LabelList.vue

@ -74,7 +74,7 @@
</template>
<script>
import { mapState, mapActions, mapMutations, mapGetters } from 'vuex'
import { mapState, mapActions, mapMutations } from 'vuex'
import { colorRules, labelNameRules } from '@/rules/index'
import { idealColor } from '~/plugins/utils'
@ -82,6 +82,22 @@ export default {
data() {
return {
search: '',
headers: [
{
text: 'Name',
align: 'left',
value: 'text'
},
{
text: 'Shortkey',
value: 'suffix_key'
},
{
text: 'Color',
sortable: false,
value: 'background_color'
}
],
colorRules,
labelNameRules
}
@ -89,7 +105,6 @@ export default {
computed: {
...mapState('labels', ['items', 'selected', 'loading']),
...mapGetters('labels', ['headers']),
keys() {
return 'abcdefghijklmnopqrstuvwxyz'.split('')

17
frontend/components/containers/members/MemberList.vue

@ -48,7 +48,7 @@
</template>
<script>
import { mapState, mapActions, mapMutations, mapGetters } from 'vuex'
import { mapState, mapActions, mapMutations } from 'vuex'
import { roleRules } from '@/rules/index'
export default {
@ -58,6 +58,18 @@ export default {
'Admin',
'Member'
],
headers: [
{
text: 'Name',
align: 'left',
sortable: false,
value: 'username'
},
{
text: 'Role',
value: 'role'
}
],
search: '',
newRole: null,
roleRules
@ -65,8 +77,7 @@ export default {
},
computed: {
...mapState('members', ['items', 'selected', 'loading']),
...mapGetters('members', ['headers'])
...mapState('members', ['items', 'selected', 'loading'])
},
created() {

22
frontend/components/containers/projects/ProjectList.vue

@ -29,18 +29,32 @@
</template>
<script>
import { mapState, mapActions, mapMutations, mapGetters } from 'vuex'
import { mapState, mapActions, mapMutations } from 'vuex'
export default {
data() {
return {
search: ''
search: '',
headers: [
{
text: 'Name',
align: 'left',
value: 'name'
},
{
text: 'Description',
value: 'description'
},
{
text: 'Type',
value: 'project_type'
}
]
}
},
computed: {
...mapState('projects', ['projects', 'selected', 'loading']),
...mapGetters('projects', ['headers'])
...mapState('projects', ['projects', 'selected', 'loading'])
},
async created() {

50
frontend/store/documents.js

@ -1,13 +1,10 @@
import DocumentService from '@/services/document.service'
import AnnotationService from '@/services/annotation.service'
import CSVParser from '@/services/parsers/csv.service'
export const state = () => ({
items: [],
selected: [],
loading: false,
selectedFormat: null,
parsed: {},
current: 0,
total: 0,
searchOptions: {
@ -23,38 +20,9 @@ export const getters = {
isDocumentSelected(state) {
return state.selected.length > 0
},
headers() {
return [
{
text: 'Text',
align: 'left',
value: 'text',
sortable: false
},
{
text: 'Metadata',
align: 'left',
value: 'meta',
sortable: false
},
{
text: 'Action',
align: 'left',
value: 'action',
sortable: false
}
]
},
approved(state) {
return state.items[state.current].annotation_approver !== null
},
parsedDoc(state) {
if ('data' in state.parsed) {
return state.parsed.data
} else {
return []
}
},
currentDoc(state) {
return state.items[state.current]
}
@ -89,10 +57,6 @@ export const mutations = {
setTotalItems(state, payload) {
state.total = payload
},
parseFile(state, text) {
const parser = new CSVParser()
state.parsed = parser.parse(text)
},
addAnnotation(state, payload) {
state.items[state.current].annotations.push(payload)
},
@ -193,20 +157,6 @@ export const actions = {
}
commit('resetSelected')
},
nextPage({ commit }) {
},
prevPage({ commit }) {
},
parseFile({ commit }, data) {
const reader = new FileReader()
reader.readAsText(data, 'UTF-8')
reader.onload = (e) => {
commit('parseFile', e.target.result)
}
reader.onerror = (e) => {
alert(e)
}
},
addAnnotation({ commit, state }, payload) {
const documentId = state.items[state.current].id
AnnotationService.addAnnotation(payload.projectId, documentId, payload)

18
frontend/store/labels.js

@ -9,24 +9,6 @@ export const state = () => ({
export const getters = {
isLabelSelected(state) {
return state.selected.length > 0
},
headers() {
return [
{
text: 'Name',
align: 'left',
value: 'text'
},
{
text: 'Shortkey',
value: 'suffix_key'
},
{
text: 'Color',
sortable: false,
value: 'background_color'
}
]
}
}

14
frontend/store/members.js

@ -9,20 +9,6 @@ export const state = () => ({
export const getters = {
isMemberSelected(state) {
return state.selected.length > 0
},
headers() {
return [
{
text: 'Name',
align: 'left',
sortable: false,
value: 'username'
},
{
text: 'Role',
value: 'role'
}
]
}
}

17
frontend/store/projects.js

@ -14,23 +14,6 @@ export const getters = {
currentProject(state) {
return state.current
},
headers() {
return [
{
text: 'Name',
align: 'left',
value: 'name'
},
{
text: 'Description',
value: 'description'
},
{
text: 'Type',
value: 'project_type'
}
]
},
getFilterOption(state) {
if (state.current.project_type === 'DocumentClassification') {
return 'doc_annotations__isnull'

Loading…
Cancel
Save