@mongoosejs/studio 0.0.14 → 0.0.15

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,6 +46,8 @@
46
46
 
47
47
  .modal-body {
48
48
  margin: 20px 0;
49
+ max-height: calc(100vh - 40px - 60px - 10px);
50
+ overflow: auto;
49
51
  }
50
52
 
51
53
  .modal__button--default {
@@ -80,4 +82,4 @@
80
82
  right: 0.25em;
81
83
  top: 0.25em;
82
84
  cursor: pointer;
83
- }
85
+ }
@@ -5,6 +5,11 @@
5
5
  min-height: calc(100% - 56px);
6
6
  }
7
7
 
8
+ .models button.gray {
9
+ color: black;
10
+ background-color: #eee;
11
+ }
12
+
8
13
  .models .model-selector {
9
14
  background-color: #eee;
10
15
  flex-grow: 0;
@@ -120,4 +125,14 @@
120
125
 
121
126
  .models .loader img {
122
127
  height: 4em;
128
+ }
129
+
130
+ .models .documents .buttons {
131
+ display: inline-flex;
132
+ justify-content: space-around;
133
+ align-items: baseline;
134
+ }
135
+
136
+ .models .documents .buttons button:not(:last-child) {
137
+ margin-right: 8px;
123
138
  }
@@ -19,13 +19,14 @@
19
19
  </div>
20
20
  <div class="buttons">
21
21
  <button @click="shouldShowExportModal = true">Export</button>
22
+ <button @click="shouldShowFieldModal = true">Fields</button>
22
23
  </div>
23
24
  </div>
24
25
  </div>
25
26
  <div class="documents-container">
26
27
  <table>
27
28
  <thead>
28
- <th v-for="path in schemaPaths">
29
+ <th v-for="path in filteredPaths">
29
30
  {{path.path}}
30
31
  <span class="path-type">
31
32
  ({{(path.instance || 'unknown')}})
@@ -36,7 +37,7 @@
36
37
  </thead>
37
38
  <tbody>
38
39
  <tr v-for="document in documents" @click="$router.push('/model/' + currentModel + '/document/' + document._id)" :key="document._id">
39
- <td v-for="schemaPath in schemaPaths">
40
+ <td v-for="schemaPath in filteredPaths">
40
41
  <component
41
42
  :is="getComponentForPath(schemaPath)"
42
43
  :value="getValueForPath(document, schemaPath.path)"
@@ -61,5 +62,20 @@
61
62
  </export-query-results>
62
63
  </template>
63
64
  </modal>
65
+ <modal v-if="shouldShowFieldModal">
66
+ <template v-slot:body>
67
+ <div class="modal-exit" @click="shouldShowFieldModal = false; selectedPaths = [...filteredPaths];">&times;</div>
68
+ <div v-for="(path, index) in schemaPaths" :key="index" style="margin-bottom: 0.5em">
69
+ <input type="checkbox" :id="'path.path'+index" @change="addOrRemove(path)" :value="path.path" :checked="isSelected(path.path)" />
70
+ <label :for="'path' + index">{{path.path}}</label>
71
+ </div>
72
+ <div style="margin-top: 1em">
73
+ <button type="submit" @click="filterDocuments()" style="color: black;margin-right: 0.5em">Filter Selection</button>
74
+ <button type="submit" @click="deselectAll()" class="gray" style="margin-right: 0.5em">Deselect All</button>
75
+ <button type="submit" @click="resetDocuments()" class="gray">Cancel</button>
76
+
77
+ </div>
78
+ </template>
79
+ </modal>
64
80
  </div>
65
81
  </div>
@@ -19,6 +19,8 @@ module.exports = app => app.component('models', {
19
19
  currentModel: null,
20
20
  documents: [],
21
21
  schemaPaths: [],
22
+ filteredPaths: [],
23
+ selectedPaths: [],
22
24
  numDocuments: 0,
23
25
  status: 'loading',
24
26
  loadedAllDocs: false,
@@ -27,6 +29,7 @@ module.exports = app => app.component('models', {
27
29
  filter: null,
28
30
  searchText: '',
29
31
  shouldShowExportModal: false,
32
+ shouldShowFieldModal: false,
30
33
  shouldExport: {},
31
34
  sortBy: {},
32
35
  query: {},
@@ -62,6 +65,16 @@ module.exports = app => app.component('models', {
62
65
  await this.getDocuments();
63
66
  }
64
67
 
68
+ const hashUrl = window.location.hash.replace(/^#/, '');
69
+ if (hashUrl.indexOf('?') !== -1) {
70
+ const searchParams = new URLSearchParams(
71
+ hashUrl.slice(hashUrl.indexOf('?') + 1)
72
+ );
73
+ if (searchParams.has('fields')) {
74
+ this.filteredPaths = searchParams.get('fields').split(',').map(path => ({ path }));
75
+ }
76
+ }
77
+
65
78
  this.status = 'loaded';
66
79
  },
67
80
  methods: {
@@ -79,7 +92,6 @@ module.exports = app => app.component('models', {
79
92
  skip: this.documents.length,
80
93
  limit
81
94
  });
82
- console.log('FX', docs.length, limit)
83
95
  if (docs.length < limit) {
84
96
  this.loadedAllDocs = true;
85
97
  }
@@ -143,6 +155,55 @@ module.exports = app => app.component('models', {
143
155
  for (const { path } of this.schemaPaths) {
144
156
  this.shouldExport[path] = true;
145
157
  }
158
+
159
+ this.filteredPaths = [...this.schemaPaths];
160
+ this.selectedPaths = [...this.schemaPaths];
161
+ },
162
+ addOrRemove(path) {
163
+ const exists = this.selectedPaths.findIndex(x => x.path == path.path);
164
+ if (exists > 0) { // remove
165
+ this.selectedPaths.splice(exists, 1);
166
+ } else { // add
167
+ this.selectedPaths.push(path);
168
+ this.selectedPaths = Object.keys(this.selectedPaths).sort((k1, k2) => {
169
+ if (k1 === '_id' && k2 !== '_id') {
170
+ return -1;
171
+ }
172
+ if (k1 !== '_id' && k2 === '_id') {
173
+ return 1;
174
+ }
175
+ return 0;
176
+ }).map(key => this.selectedPaths[key]);
177
+ }
178
+ },
179
+ filterDocuments() {
180
+ this.filteredPaths = [...this.selectedPaths];
181
+ this.shouldShowFieldModal = false;
182
+ const selectedParams = this.filteredPaths.map(x => x.path).join(',');
183
+
184
+ const hashUrl = window.location.hash.replace(/^#/, '');
185
+ if (hashUrl.indexOf('?') === -1) {
186
+ window.history.pushState({}, '', window.location.pathname + '#' + hashUrl + '?fields=' + selectedParams);
187
+ } else {
188
+ const searchParams = new URLSearchParams(
189
+ hashUrl.indexOf('?') === -1 ? '' : hashUrl.slice(hashUrl.indexOf('?') + 1)
190
+ );
191
+ const hashUrlWithoutSearchParams = hashUrl.slice(0, hashUrl.indexOf('?'));
192
+
193
+ searchParams.set('fields', selectedParams);
194
+ window.history.pushState({}, '', window.location.pathname + '#' + hashUrlWithoutSearchParams + '?' + searchParams);
195
+ }
196
+
197
+ },
198
+ resetDocuments() {
199
+ this.selectedPaths = [...this.filteredPaths];
200
+ this.shouldShowFieldModal = false;
201
+ },
202
+ deselectAll() {
203
+ this.selectedPaths = [];
204
+ },
205
+ isSelected(path) {
206
+ return this.selectedPaths.find(x => x.path == path);
146
207
  },
147
208
  getComponentForPath(schemaPath) {
148
209
  if (schemaPath.instance === 'Array') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongoosejs/studio",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "dependencies": {
5
5
  "archetype": "0.13.0",
6
6
  "csv-stringify": "6.3.0",