File tree Expand file tree Collapse file tree 6 files changed +35
-44
lines changed Expand file tree Collapse file tree 6 files changed +35
-44
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
import Vue from 'vue'
2
2
import Vuex from 'vuex'
3
3
4
- import * as actions from './actions'
5
- import * as getters from './getters'
6
4
import index from './modules/index'
7
5
import entity from './modules/entity'
8
- import converter from './modules/converter '
6
+ import relation from './modules/relation '
9
7
10
8
Vue . use ( Vuex )
11
9
12
10
export default new Vuex . Store ( {
13
- actions,
14
- getters,
15
11
modules : {
16
12
index,
17
13
entity,
18
- converter
14
+ relation
19
15
} ,
20
16
strict : process . env . NODE_ENV !== 'production'
21
17
} )
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ const mutations = {
20
20
state . records . push ( record )
21
21
} ,
22
22
[ types . ADD_AMOUNT ] ( state ) {
23
- state . amount ++
23
+ state . amount ++
24
24
} ,
25
25
[ types . REMOVE_ALL_RECORDS ] ( state ) {
26
26
let records = state . records
@@ -35,7 +35,31 @@ const mutations = {
35
35
}
36
36
}
37
37
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
+
38
60
export default {
61
+ namespaced : true ,
39
62
state,
63
+ actions,
40
64
mutations
41
65
}
Original file line number Diff line number Diff line change 1
1
import * as types from '../mutation-types'
2
2
import { LIST } from '../../utils/constant'
3
+ import { isRangeValid } from '../../utils/utils'
3
4
4
5
const state = {
5
6
items : LIST . INIT
6
7
}
7
8
8
9
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 )
11
12
}
12
13
}
13
14
14
15
const actions = {
15
16
addItem : ( { commit, state } , item ) => {
16
17
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 )
19
22
}
20
23
}
21
24
}
22
25
23
26
export default {
27
+ namespaced : true ,
24
28
state,
25
29
mutations,
26
30
actions
You can’t perform that action at this time.
0 commit comments