@@ -3,20 +3,20 @@ import router from '@/router'
33
44let actions = {
55 // table data
6- getItems ( { commit, state} ) {
6+ getItems ( { commit, state, getters } ) {
77 commit ( 'setLoadingStatus' , true )
8- Vue . http . get ( state . prefix + '/' + state . path )
8+ Vue . http . get ( getters . path )
99 . then ( ( response ) => {
1010 commit ( 'setItems' , response . body )
1111 commit ( 'setLoadingStatus' , false )
1212 } , error => {
1313 commit ( 'alertError' , error . statusText , { root : true } )
1414 } ) ;
1515 } ,
16- getItemsServerSide ( { commit, state} , [ params ] ) {
16+ getItemsServerSide ( { commit, state, getters } , [ params ] ) {
1717 return new Promise ( ( resolve , reject ) => {
1818 commit ( 'setLoadingStatus' , true )
19- Vue . http . post ( state . prefix + '/' + state . path + '/search' , params )
19+ Vue . http . post ( getters . path + '/search' , params )
2020 . then ( ( response ) => {
2121 commit ( 'setItemsServerSide' , response . body )
2222 resolve ( )
@@ -26,10 +26,10 @@ let actions = {
2626 } )
2727 } ,
2828 // item details
29- getItem ( { commit, state} , [ id ] ) {
29+ getItem ( { commit, state, getters } , [ id ] ) {
3030 return new Promise ( ( resolve , reject ) => {
3131 commit ( 'setDetailsLoader' , true )
32- Vue . http . get ( state . prefix + '/' + state . path + '/' + id )
32+ Vue . http . get ( getters . path + '/' + id )
3333 . then ( ( response ) => {
3434 commit ( 'setItem' , response . body )
3535 commit ( 'setDetailsLoader' , false )
@@ -39,9 +39,9 @@ let actions = {
3939 }
4040 } )
4141 } ,
42- updateItem ( { commit, dispatch, state} , [ id , params , successText , errorText ] ) {
42+ updateItem ( { commit, dispatch, state, getters } , [ id , params , successText , errorText ] ) {
4343 return new Promise ( ( resolve , reject ) => {
44- Vue . http . put ( state . prefix + '/' + state . path + '/' + id , params )
44+ Vue . http . put ( getters . path + '/' + id , params )
4545 . then ( ( response ) => {
4646 if ( response . body . status == 0 ) {
4747 commit ( 'alertSuccess' , successText , { root : true } )
@@ -59,9 +59,9 @@ let actions = {
5959 } )
6060 } )
6161 } ,
62- storeItem ( { commit, dispatch, state} , [ params , successText , errorText ] ) {
62+ storeItem ( { commit, dispatch, state, getters } , [ params , successText , errorText ] ) {
6363 return new Promise ( ( resolve , reject ) => {
64- Vue . http . post ( state . prefix + '/' + state . path , params )
64+ Vue . http . post ( getters . path , params )
6565 . then ( ( response ) => {
6666 if ( response . body . status == 0 ) {
6767 commit ( 'alertSuccess' , successText , { root : true } )
@@ -82,26 +82,26 @@ let actions = {
8282 } ) ;
8383 } )
8484 } ,
85- deleteItem ( { commit, dispatch, state} , [ id , successText , errorText ] ) {
86- Vue . http . delete ( state . prefix + '/' + state . path + '/' + id )
85+ deleteItem ( { commit, dispatch, state, getters } , [ id , successText , errorText ] ) {
86+ Vue . http . delete ( getters . path + '/' + id )
8787 . then ( ( response ) => {
8888 commit ( 'alertSuccess' , successText , { root : true } )
8989 commit ( 'refreshTable' )
9090 } , error => {
9191 commit ( 'alertError' , error . statusText , { root : true } )
9292 } ) ;
9393 } ,
94- mulitipleItemsUpdate ( { commit, dispatch, state} , [ params , successText , errorText ] ) {
95- Vue . http . post ( state . prefix + '/' + state . path + '/multiple-update' , params )
94+ mulitipleItemsUpdate ( { commit, dispatch, state, getters } , [ params , successText , errorText ] ) {
95+ Vue . http . post ( getters . path + '/multiple-update' , params )
9696 . then ( ( response ) => {
9797 commit ( 'alertSuccess' , successText , { root : true } )
9898 commit ( 'refreshTable' )
9999 } , error => {
100100 commit ( 'alertError' , error . statusText , { root : true } )
101101 } ) ;
102102 } ,
103- mulitipleItemsDelete ( { commit, dispatch, state} , [ ids , successText , errorText ] ) {
104- Vue . http . post ( state . prefix + '/' + state . path + '/multiple-delete' , ids )
103+ mulitipleItemsDelete ( { commit, dispatch, state, getters } , [ ids , successText , errorText ] ) {
104+ Vue . http . post ( getters . path + '/multiple-delete' , ids )
105105 . then ( ( response ) => {
106106 commit ( 'alertSuccess' , successText , { root : true } )
107107 commit ( 'refreshTable' )
@@ -110,12 +110,12 @@ let actions = {
110110 } ) ;
111111 } ,
112112 // item elements
113- getItemElements ( { commit, state} ) {
114- let url = state . itemElements . url . replace ( '{id}' , state . itemElements . id ) ;
113+ getItemElements ( { commit, state, getters } ) {
114+ let url = state . itemElements . url . replace ( '{id}' , state , getters . itemElements . id ) ;
115115 Vue . http . get ( url )
116116 . then ( ( response ) => commit ( 'setItemElements' , response . body ) )
117117 } ,
118- addItemElement ( { commit, dispatch, state} , [ params , successText , errorText ] ) {
118+ addItemElement ( { commit, dispatch, state, getters } , [ params , successText , errorText ] ) {
119119 Vue . http . post ( state . itemElements . controller , params )
120120 . then ( ( response ) => {
121121 commit ( 'alertSuccess' , successText , { root : true } )
@@ -124,7 +124,7 @@ let actions = {
124124 commit ( 'alertError' , error . statusText , { root : true } )
125125 } ) ;
126126 } ,
127- removeItemElement ( { commit, dispatch, state} , [ id , successText , errorText ] ) {
127+ removeItemElement ( { commit, dispatch, state, getters } , [ id , successText , errorText ] ) {
128128 Vue . http . delete ( state . itemElements . controller + '/' + id )
129129 . then ( ( response ) => {
130130 commit ( 'alertSuccess' , successText , { root : true } )
@@ -133,7 +133,7 @@ let actions = {
133133 commit ( 'alertError' , error . statusText , { root : true } )
134134 } ) ;
135135 } ,
136- addManyItemElements ( { commit, dispatch, state} , [ params , successText , errorText ] ) {
136+ addManyItemElements ( { commit, dispatch, state, getters } , [ params , successText , errorText ] ) {
137137 Vue . http . post ( state . itemElements . controller + '/multiple-add' , params )
138138 . then ( ( response ) => {
139139 commit ( 'alertSuccess' , successText , { root : true } )
@@ -142,7 +142,7 @@ let actions = {
142142 commit ( 'alertError' , error . statusText , { root : true } )
143143 } ) ;
144144 } ,
145- removeManyItemElements ( { commit, dispatch, state} , [ ids , successText , errorText ] ) {
145+ removeManyItemElements ( { commit, dispatch, state, getters } , [ ids , successText , errorText ] ) {
146146 Vue . http . post ( state . itemElements . controller + '/multiple-delete' , ids )
147147 . then ( ( response ) => {
148148 commit ( 'alertSuccess' , successText , { root : true } )
@@ -152,10 +152,10 @@ let actions = {
152152 } ) ;
153153 } ,
154154 // extented details
155- getItemDetails ( { commit, state} , [ id ] ) {
155+ getItemDetails ( { commit, state, getters } , [ id ] ) {
156156 return new Promise ( ( resolve , reject ) => {
157157 commit ( 'setDetailsLoader' , true )
158- Vue . http . get ( state . prefix + '/' + state . path + '/' + id )
158+ Vue . http . get ( getters . path + '/' + id )
159159 . then ( ( response ) => {
160160 commit ( 'itemDetails' , response . body )
161161 commit ( 'setDetailsLoader' , false )
@@ -165,8 +165,8 @@ let actions = {
165165 }
166166 } )
167167 } ,
168- updateItemDetail ( { commit, dispatch, state} , [ id , params , successText ] ) {
169- Vue . http . put ( state . prefix + '/' + state . path + '/' + id , params )
168+ updateItemDetail ( { commit, dispatch, state, getters } , [ id , params , successText ] ) {
169+ Vue . http . put ( getters . path + '/' + id , params )
170170 . then ( ( response ) => {
171171 if ( response . body . status == 0 ) {
172172 commit ( 'alertSuccess' , successText , { root : true } )
@@ -183,7 +183,7 @@ let actions = {
183183 } ) ;
184184 } ,
185185 // child details
186- updateChild ( { commit, dispatch, state} , [ id , params , successText , path ] ) {
186+ updateChild ( { commit, dispatch, state, getters } , [ id , params , successText , path ] ) {
187187 return new Promise ( ( resolve , reject ) => {
188188 Vue . http . put ( path + '/' + id , params )
189189 . then ( ( response ) => {
@@ -203,7 +203,7 @@ let actions = {
203203 } )
204204 } )
205205 } ,
206- deleteChild ( { commit, dispatch, state} , [ id , successText , errorText , path ] ) {
206+ deleteChild ( { commit, dispatch, state, getters } , [ id , successText , errorText , path ] ) {
207207 Vue . http . delete ( path + '/' + id )
208208 . then ( ( response ) => {
209209 if ( response . body . status == 0 ) {
@@ -220,7 +220,7 @@ let actions = {
220220 commit ( 'alertError' , error . statusText , { root : true } )
221221 } ) ;
222222 } ,
223- storeChild ( { commit, dispatch, state} , [ params , successText , path ] ) {
223+ storeChild ( { commit, dispatch, state, getters } , [ params , successText , path ] ) {
224224 return new Promise ( ( resolve , reject ) => {
225225 Vue . http . post ( path , params )
226226 . then ( ( response ) => {
@@ -240,7 +240,7 @@ let actions = {
240240 } )
241241 } )
242242 } ,
243- getChild ( { commit, state} , [ id , path , childItemName ] ) {
243+ getChild ( { commit, state, getters } , [ id , path , childItemName ] ) {
244244 return new Promise ( ( resolve , reject ) => {
245245 Vue . http . get ( path + '/' + id )
246246 . then ( ( response ) => {
0 commit comments