1 | /*
|
2 | |--------------------------------------------------------------------------
|
3 | | Config
|
4 | |--------------------------------------------------------------------------
|
5 | |
|
6 | */
|
7 | // import { VuexGetters } from '@fernandoherlo/vue-core-store'
|
8 | // import { VuexActions } from '@fernandoherlo/vue-core-store'
|
9 | // import { VuexMutations } from '@fernandoherlo/vue-core-store'
|
10 |
|
11 | import { globalButtonsName } from '@/config/button'
|
12 | import { globalTableConfig } from '@/config/table'
|
13 | import { globalTableColumns } from '@/config/table'
|
14 |
|
15 | /*
|
16 | |--------------------------------------------------------------------------
|
17 | | Component
|
18 | |--------------------------------------------------------------------------
|
19 | |
|
20 | */
|
21 | export const createPlugin = function (options, table, form, buttons, menu_links, routes, VuexGetters, VuexActions, VuexMutations)
|
22 | {
|
23 | let config = {
|
24 | 'options': options,
|
25 | 'table': Object.assign({},
|
26 | globalTableConfig,
|
27 | {
|
28 | columns: table.columns.concat([globalTableColumns])
|
29 | },
|
30 | table.options
|
31 | ),
|
32 | 'form': form,
|
33 | 'buttons': Object.assign({},
|
34 | globalButtonsName,
|
35 | buttons
|
36 | ),
|
37 | 'menu_links': menu_links,
|
38 | 'routes': routes
|
39 | }
|
40 |
|
41 | // Override
|
42 | if (config.options.dataOverrideName) {
|
43 | config.options.nameVuex = config.options.dataOverrideName
|
44 | config.options.nameSingleVuex = config.options.dataOverrideName + '-single'
|
45 | } else {
|
46 | config.options.nameVuex = config.options.name
|
47 | config.options.nameSingleVuex = config.options.nameSingle
|
48 | }
|
49 |
|
50 | /*
|
51 | |--------------------------------------------------------------------------
|
52 | | State
|
53 | |--------------------------------------------------------------------------
|
54 | |
|
55 | */
|
56 | let state = {}
|
57 | if (!config.options.dataOverrideName) {
|
58 | state = {
|
59 | all: [],
|
60 | allByParent: [],
|
61 | item: {},
|
62 | clone: {}
|
63 | }
|
64 | }
|
65 |
|
66 | /*
|
67 | |--------------------------------------------------------------------------
|
68 | | Getters
|
69 | |--------------------------------------------------------------------------
|
70 | |
|
71 | */
|
72 | let getters = null
|
73 | if (!config.options.dataOverrideName) {
|
74 | getters = VuexGetters.core(state, config)
|
75 | }
|
76 |
|
77 | /*
|
78 | |--------------------------------------------------------------------------
|
79 | | Actions
|
80 | |--------------------------------------------------------------------------
|
81 | |
|
82 | */
|
83 | const actions = VuexActions.core(config)
|
84 |
|
85 | /*
|
86 | |--------------------------------------------------------------------------
|
87 | | Mutations
|
88 | |--------------------------------------------------------------------------
|
89 | |
|
90 | */
|
91 | let mutations = null
|
92 | if (!config.options.dataOverrideName) {
|
93 | mutations = VuexMutations.core(state, config)
|
94 | }
|
95 |
|
96 | /*
|
97 | |--------------------------------------------------------------------------
|
98 | | Store
|
99 | |--------------------------------------------------------------------------
|
100 | |
|
101 | */
|
102 | let store = {
|
103 | state,
|
104 | getters,
|
105 | actions,
|
106 | mutations
|
107 | }
|
108 |
|
109 | return [config, store]
|
110 | }
|