Skip to content

Commit ac63d3f

Browse files
authored
Merge pull request #41 from socialblue/develop
Removes dependency
2 parents 7f5a24c + 87804ca commit ac63d3f

File tree

3 files changed

+47
-13
lines changed

3 files changed

+47
-13
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^7.1",
20-
"illuminate/support": "5.8.*"
19+
"php": "^7.0"
2120
},
2221
"require-dev": {
2322
"orchestra/testbench": "^3.8"

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
<div class="rows">
1111
<h3 class="subtitle">Order</h3>
1212
<div class="field">
13-
<input class="is-checkradio" id="exampleRadioInline1" type="radio" name="exampleRadioInline" checked="checked">
14-
<label for="exampleRadioInline1">Default</label>
13+
<input class="is-checkradio" id="default" type="radio" value="time" name="sortField" v-model="sortField">
14+
<label for="default">Default</label>
1515
</div>
1616
<div class="field">
17-
<input class="is-checkradio" id="exampleRadioInline2" type="radio" name="exampleRadioInline">
18-
<label for="exampleRadioInline2">QueryTime</label>
17+
<input class="is-checkradio" id="querytime" type="radio" value="queryTime" name="sortField" v-model="sortField">
18+
<label for="querytime">QueryTime</label>
1919
</div>
2020
<div class="field">
21-
<input class="is-checkradio" id="exampleRadioInline3" type="radio" name="exampleRadioInline">
22-
<label for="exampleRadioInline3">Grouped Amount</label>
21+
<input class="is-checkradio" id="amount" type="radio" value="amount" name="sortField" v-model="sortField">
22+
<label for="amount">Grouped Amount</label>
2323
</div>
2424
</div>
2525
</div>
@@ -39,6 +39,19 @@
3939
}
4040
},
4141
42+
computed: {
43+
sortField: {
44+
get() {
45+
return this.$attrs['sort-field'];
46+
},
47+
48+
set(field) {
49+
console.log(field);
50+
this.$emit('update:sort-field', field);
51+
}
52+
}
53+
},
54+
4255
beforeCreate() {
4356
window.EventBus.$on('show-filter-bar', () => {
4457
this.active = true;

resources/assets/js/view/index.vue

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@
3232
<span class="tag is-medium is-primary">Start</span>
3333
</header>
3434

35-
<div class="timeline-item is-primary" v-for="(queries, key) in dataList">
35+
<div class="timeline-item is-primary" v-for="key in dataListKey">
3636
<div class="timeline-marker is-icon button is-info">
3737
<span v-on:click="toggleQueryGroup(key)" class="material-icons" title="expand">
3838
<template v-if="!showQueryGroup(key)">expand_more</template>
3939
<template v-if="showQueryGroup(key)">expand_less</template>
4040
</span>
4141
</div>
4242
<div class="timeline-content">
43-
<p class="heading">{{groupTitle(key)}} ({{queries.length}})
43+
<p class="heading">{{groupTitle(key)}} ({{dataList[key].length}})
4444

4545
</p>
4646
<div>
4747
<div class="columns is-multiline" v-if="showQueryGroup(key)">
48-
<div class="column" v-for="(query) in queries" >
48+
<div class="column" v-for="query in dataList[key]" >
4949
<query-block
5050
:query="query"
5151
>
@@ -62,7 +62,7 @@
6262
</div>
6363
</main>
6464
</div>
65-
<side-panel />
65+
<side-panel :sort-field.sync="sortKey"/>
6666
<page-footer />
6767
<notification />
6868
</div>
@@ -87,6 +87,8 @@
8787
8888
data() {
8989
return {
90+
sortKey: 'time',
91+
sortDirection: 1,
9092
listType: 'time',
9193
cachedKeys: {},
9294
showTime: []
@@ -102,6 +104,19 @@
102104
return this.groupValuesByKey(this.listType);
103105
},
104106
107+
dataListKey() {
108+
let list = this.dataList;
109+
110+
return Object.keys(list).sort((a, b) => {
111+
if (list[a][0][this.sortKey] === list[b][0][this.sortKey]) {
112+
return 0;
113+
} else if(list[a][0][this.sortKey] > list[b][0][this.sortKey]) {
114+
return -1 * this.sortDirection
115+
}
116+
return this.sortDirection;
117+
});
118+
},
119+
105120
flattenedCachedKeys() {
106121
return Object.values(this.cachedKeys).flat();
107122
},
@@ -184,7 +199,14 @@
184199
groupValuesByKey(key) {
185200
let data = {};
186201
this.getUniqueValuesByKey(key).forEach((uniqueValue) => {
187-
data[uniqueValue] = this.flattenedCachedKeys.filter(row => row[key] === 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+
});
188210
});
189211
return data;
190212
}

0 commit comments

Comments
 (0)