8000 alter to modules · supercoderhawk/emr-processor@6fd37bf · GitHub
[go: up one dir, main page]

Skip to content

Commit 6fd37bf

Browse files
alter to modules
1 parent b5a30ec commit 6fd37bf

File tree

6 files changed

+35
-44
lines changed

6 files changed

+35
-44
lines changed

app/src/renderer/store/actions.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

app/src/renderer/store/getters.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

app/src/renderer/store/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
import Vue from 'vue'
22
import Vuex from 'vuex'
33

4-
import * as actions from './actions'
5-
import * as getters from './getters'
64
import index from './modules/index'
75
import entity from './modules/entity'
8-
import converter from './modules/converter'
6+
import relation from './modules/relation'
97

108
Vue.use(Vuex)
119

1210
export default new Vuex.Store({
13-
actions,
14-
getters,
1511
modules: {
1612
index,
1713
entity,
18-
converter
14+
relation
1915
},
2016
strict: process.env.NODE_ENV !== 'production'
2117
})

app/src/renderer/store/modules/converter.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const mutations = {
2020
state.records.push(record)
2121
},
2222
[types.ADD_AMOUNT] (state) {
23-
state.amount ++
23+
state.amount++
2424
},
2525
[types.REMOVE_ALL_RECORDS] (state) {
2626
let records = state.records
@@ -35,7 +35,31 @@ const mutations = {
3535
}
3636
}
3737

38+
const actions = {
39+
addRecord: ({ commit, state }, recItem) => {
40+
let record = {
41+
id: state.converter.amount,
42+
hash: recItem.hash,
43+
name: recItem.name,
44+
plainText: recItem.plainText,
45+
jsonText: recItem.jsonText
46+
}
47+
48+
commit(types.ADD_RECORD, record)
49+
commit(types.ADD_AMOUNT)
50+
},
51+
removeAllRecords: ({commit}) => {
52+
commit(types.REMOVE_ALL_RECORDS)
53+
},
54+
modifyText: ({commit}, {plainText, jsonText}) => {
55+
commit(types.MODIFY_PLAIN_IN_DISPLAY, plainText)
56+
commit(types.MODIFY_JSON_IN_DISPLAY, jsonText)
57+
}
58+
}
59+
3860
export default {
61+
namespaced: true,
3962
state,
63+
actions,
4064
mutations
4165
}

app/src/renderer/store/modules/entity.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
import * as types from '../mutation-types'
22
import {LIST} from '../../utils/constant'
3+
import {isRangeValid} from '../../utils/utils'
34

45
const state = {
56
items: LIST.INIT
67
}
78

89
const mutations = {
9-
[types.ADD_ITEM] (state, item) {
10-
state.items.push(item)
10+
[types.ADD_ITEM] (state, item, index) {
11+
state.items.splice(index, 0, item)
1112
}
1213
}
1314

1415
const actions = {
1516
addItem: ({ commit, state }, item) => {
1617
let items = state.items
17-
if (item.start > items[items.length - 1].end) {
18-
commit(types.ADD_ITEM, item)
18+
if (isRangeValid(item.start, item.end, items)) {
19+
let itemCount = items.length
20+
let insertIndex = itemCount > 0 ? items.filter(curItem => { return curItem.end <= item.start }).length : 0
21+
commit(types.ADD_ITEM, item, insertIndex)
1922
}
2023
}
2124
}
2225

2326
export default {
27+
namespaced: true,
2428
state,
2529
mutations,
2630
actions

app/src/renderer/store/modules/relation.js

Whitespace-only changes.

0 commit comments

Comments
 (0)
0