@mongoosejs/studio 0.0.7 → 0.0.8

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.
@@ -46,7 +46,7 @@
46
46
  </tr>
47
47
  </tbody>
48
48
  </table>
49
- <div v-if="true" class="loader">
49
+ <div v-if="status === 'loading'" class="loader">
50
50
  <img src="images/loader.gif">
51
51
  </div>
52
52
  </div>
@@ -9,6 +9,8 @@ const appendCSS = require('../appendCSS');
9
9
 
10
10
  appendCSS(require('./models.css'));
11
11
 
12
+ const limit = 50;
13
+
12
14
  module.exports = app => app.component('models', {
13
15
  template: template,
14
16
  props: ['model'],
@@ -18,7 +20,8 @@ module.exports = app => app.component('models', {
18
20
  documents: [],
19
21
  schemaPaths: [],
20
22
  numDocuments: 0,
21
- status: 'init',
23
+ status: 'loading',
24
+ loadedAllDocs: false,
22
25
  edittingDoc: null,
23
26
  docEdits: null,
24
27
  filter: null,
@@ -28,7 +31,6 @@ module.exports = app => app.component('models', {
28
31
  sortBy: {},
29
32
  query: {},
30
33
  scrollHeight: 0,
31
- limit: 50,
32
34
  interval: null
33
35
  }),
34
36
  created() {
@@ -64,14 +66,24 @@ module.exports = app => app.component('models', {
64
66
  },
65
67
  methods: {
66
68
  async onScroll() {
67
- if (this.status === 'loading') {
69
+ if (this.status === 'loading' || this.loadedAllDocs) {
68
70
  return;
69
71
  }
70
72
  const container = this.$refs.documentsList;
71
73
  if (container.scrollHeight - container.clientHeight - 100 < container.scrollTop) {
72
74
  this.status = 'loading';
73
- this.limit += 50;
74
- await this.getDocuments();
75
+ const { docs } = await api.Model.getDocuments({
76
+ model: this.currentModel,
77
+ filter: this.filter,
78
+ sort: this.sortBy,
79
+ skip: this.documents.length,
80
+ limit
81
+ });
82
+ console.log('FX', docs.length, limit)
83
+ if (docs.length < limit) {
84
+ this.loadedAllDocs = true;
85
+ }
86
+ this.documents.push(...docs);
75
87
  this.status = 'loaded';
76
88
  }
77
89
  },
@@ -110,9 +122,12 @@ module.exports = app => app.component('models', {
110
122
  model: this.currentModel,
111
123
  filter: this.filter,
112
124
  sort: this.sortBy,
113
- limit: this.limit
125
+ limit
114
126
  });
115
127
  this.documents = docs;
128
+ if (docs.length < limit) {
129
+ this.loadedAllDocs = true;
130
+ }
116
131
  this.schemaPaths = Object.keys(schemaPaths).sort((k1, k2) => {
117
132
  if (k1 === '_id' && k2 !== '_id') {
118
133
  return -1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongoosejs/studio",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "dependencies": {
5
5
  "archetype": "0.13.0",
6
6
  "csv-stringify": "6.3.0",