@benjy2976/pmsg 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Model.js +5 -6
- package/src/useModelStore.js +7 -5
package/package.json
CHANGED
package/src/Model.js
CHANGED
|
@@ -23,10 +23,7 @@ export default class Model {
|
|
|
23
23
|
params : { modeljs: true },// Aquí se configuran parámetros adicionales a enviar en los request excepto DELETE
|
|
24
24
|
modelGetters : {},// Aquí se configuran parámetros adicionales a enviar en los request excepto DELETE
|
|
25
25
|
paginate : false,// Condicional para definir si el modelo tiene paginación
|
|
26
|
-
pagination : {
|
|
27
|
-
current_page : 1,
|
|
28
|
-
per_page : 10
|
|
29
|
-
}
|
|
26
|
+
pagination : {current_page: 1, per_page: 10},// Configuración de paginación
|
|
30
27
|
}
|
|
31
28
|
//config.hasKey=config.hasKey!=undefined?config.hasKey:config.key!=undefined
|
|
32
29
|
defaultValues = Object.assign(defaultValues, config)
|
|
@@ -50,7 +47,7 @@ export default class Model {
|
|
|
50
47
|
this.params = defaultValues.params
|
|
51
48
|
this.modelGetters = defaultValues.modelGetters
|
|
52
49
|
this.paginate = defaultValues.paginate
|
|
53
|
-
this.pagination =
|
|
50
|
+
this.pagination = defaultValues.pagination
|
|
54
51
|
this.state = {}
|
|
55
52
|
this.getters = {}
|
|
56
53
|
this.actions = {}
|
|
@@ -193,7 +190,9 @@ export default class Model {
|
|
|
193
190
|
|
|
194
191
|
}
|
|
195
192
|
}),
|
|
196
|
-
sync
|
|
193
|
+
sync : this.sync,
|
|
194
|
+
paginate : this.paginate,
|
|
195
|
+
pagination : this.pagination,
|
|
197
196
|
}
|
|
198
197
|
}
|
|
199
198
|
|
package/src/useModelStore.js
CHANGED
|
@@ -34,7 +34,8 @@ export default function createModelStore (model, state = {}, getters = {}, actio
|
|
|
34
34
|
maxRelationsResolve : config.maxRelationsResolve,
|
|
35
35
|
relations : config.relations,
|
|
36
36
|
syncStatus : config.sync,
|
|
37
|
-
|
|
37
|
+
paginate : config.paginate,
|
|
38
|
+
pagination : config.pagination,
|
|
38
39
|
selectedStatus : false,
|
|
39
40
|
timeOutAsinc : null,
|
|
40
41
|
check : check,
|
|
@@ -132,7 +133,7 @@ export default function createModelStore (model, state = {}, getters = {}, actio
|
|
|
132
133
|
async get (params = {}, pagination={}) {
|
|
133
134
|
//var commit = store.commit
|
|
134
135
|
const action = this.syncStatus ? 'sync' : 'setItems';
|
|
135
|
-
|
|
136
|
+
|
|
136
137
|
if (model.paginate) {
|
|
137
138
|
params = {...params, ...Object.assign({
|
|
138
139
|
page : this.pagination.current_page, per_page : this.pagination.per_page
|
|
@@ -143,11 +144,12 @@ export default function createModelStore (model, state = {}, getters = {}, actio
|
|
|
143
144
|
model.getAll(params).then(response => {
|
|
144
145
|
const data = response.data;
|
|
145
146
|
model.save(data.data);
|
|
146
|
-
this[action](data.data);
|
|
147
|
-
|
|
147
|
+
this[action](data.data);
|
|
148
|
+
// eslint-disable-next-line no-unused-vars
|
|
149
|
+
const { data: _, ...pagination } = data.meta;
|
|
148
150
|
this.pagination = Object.assign(this.pagination, pagination);
|
|
149
|
-
//console.log('get', this.pagination)
|
|
150
151
|
this.afterGet();
|
|
152
|
+
console.log('get', this)
|
|
151
153
|
resolve(response);
|
|
152
154
|
}).catch(reject);
|
|
153
155
|
})
|