Skip to content

Commit 15ede2a

Browse files
authored
Merge pull request #46 from socialblue/develop
introduces filter menu
2 parents a9f2e1b + bb4a2ef commit 15ede2a

File tree

4 files changed

+48
-21
lines changed

4 files changed

+48
-21
lines changed

public/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/mix-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"/app.js": "/app.js?id=d4940b332a8dd5bf2b6c",
2+
"/app.js": "/app.js?id=ae99c59e7b5fdd663bc0",
33
"/app.css": "/app.css?id=f844fdaf3875177afce4"
44
}

resources/assets/js/components/side-panel.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
<h3 class="subtitle">Order</h3>
1212
<div class="field">
1313
<input class="is-checkradio" id="default" type="radio" value="time" name="sortField" v-model="sortField">
14-
<label for="default">Default</label>
14+
<label for="default">Last inserted first</label>
1515
</div>
1616
<div class="field">
1717
<input class="is-checkradio" id="querytime" type="radio" value="queryTime" name="sortField" v-model="sortField">
18-
<label for="querytime">QueryTime</label>
18+
<label for="querytime">Slowest query first</label>
1919
</div>
2020
<div class="field">
2121
<input class="is-checkradio" id="amount" type="radio" value="amount" name="sortField" v-model="sortField">
@@ -46,7 +46,6 @@
4646
},
4747
4848
set(field) {
49-
console.log(field);
5049
this.$emit('update:sort-field', field);
5150
}
5251
}

resources/assets/js/view/index.vue

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<span>
1212
Queries
1313
</span>
14+
<span class="material-icons button is-pulled-right" title="show filter menu" v-on:click="showFilterMenu">
15+
filter_list
16+
</span>
1417
<span class="material-icons button is-pulled-right" title="clear query cache" v-on:click="clearQueryCache">
1518
eject
1619
</span>
@@ -66,8 +69,6 @@
6669
<page-footer />
6770
<notification />
6871
</div>
69-
70-
7172
</template>
7273

7374
<script>
@@ -97,24 +98,33 @@
9798
9899
computed: {
99100
dataList() {
100-
if (this.listType === 'time') {
101-
return this.cachedKeys;
102-
}
103-
104101
return this.groupValuesByKey(this.listType);
105102
},
106103
107104
dataListKey() {
108105
let list = this.dataList;
109106
110-
return Object.keys(list).sort((a, b) => {
107+
let sortClosure = (a, b) => {
111108
if (list[a][0][this.sortKey] === list[b][0][this.sortKey]) {
112109
return 0;
113110
} else if(list[a][0][this.sortKey] > list[b][0][this.sortKey]) {
114111
return -1 * this.sortDirection
115112
}
116113
return this.sortDirection;
117-
});
114+
};
115+
116+
if (this.sortKey === 'amount') {
117+
sortClosure = (a, b) => {
118+
if (list[a].length === list[b].length) {
119+
return 0;
120+
} else if(list[a].length > list[b].length) {
121+
return -1 * this.sortDirection;
122+
}
123+
return this.sortDirection;
124+
}
125+
}
126+
127+
return Object.keys(list).sort(sortClosure);
118128
},
119129
120130
flattenedCachedKeys() {
@@ -197,18 +207,36 @@
197207
},
198208
199209
groupValuesByKey(key) {
210+
211+
let sortClosure = (a, b) => {
212+
if (a[this.sortKey] === b[this.sortKey]) {
213+
return 0;
214+
} else if(a[this.sortKey] > b[this.sortKey]) {
215+
return -1 * this.sortDirection
216+
}
217+
return this.sortDirection;
218+
};
219+
220+
if (this.sortKey === 'amount') {
221+
sortClosure = (a, b) => {
222+
return 0;
223+
}
224+
}
225+
200226
let data = {};
201227
this.getUniqueValuesByKey(key).forEach((uniqueValue) => {
202-
data[uniqueValue] = this.flattenedCachedKeys.filter(row => row[key] === uniqueValue).sort((a, b) => {
203-
if (a[this.sortKey] === b[this.sortKey]) {
204-
return 0;
205-
} else if(a[this.sortKey] > b[this.sortKey]) {
206-
return -1 * this.sortDirection
207-
}
208-
return this.sortDirection;
209-
});
228+
data[uniqueValue] = this.flattenedCachedKeys
229+
.filter(row => row[key] === uniqueValue)
230+
.sort(
231+
sortClosure
232+
);
210233
});
234+
211235
return data;
236+
},
237+
238+
showFilterMenu() {
239+
window.EventBus.$emit('show-filter-bar');
212240
}
213241
},
214242

0 commit comments

Comments
 (0)