Skip to content

Commit f48e3fd

Browse files
author
Vinayak Kulkarni
committed
Cleaned up the code heavily
1 parent eb10d6c commit f48e3fd

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

src/index.js

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module.exports = {
22

33
template: '<div>\
4-
<router-link v-if="data.sorttype === \'desc\'" :to="{ name: routeName, query: { sort: data.sort, sorttype: data.sorttype }}" @click.native="sortData(data.sort, data.sorttype)">\
5-
{{ label }} <i class="down black icon" :class="icon" v-if="data.sort === this.$route.query.sort"></i>\
4+
<router-link v-show="toRoute.query.sorttype === \'desc\'" :to="toRoute" @click.native="sortData(toRoute.query.sort, toRoute.query.sorttype)">\
5+
{{ label }} <i class="down black icon" :class="icon" v-if="toRoute.query.sort === this.$route.query.sort"></i>\
66
</router-link>\
7-
<router-link v-if="data.sorttype === \'asc\'" :to="{ name: routeName, query: { sort: data.sort, sorttype: data.sorttype }}" @click.native="sortData(data.sort, data.sorttype)">\
8-
{{ label }} <i class="up black icon" :class="icon" v-if="data.sort === this.$route.query.sort"></i>\
7+
<router-link v-show="toRoute.query.sorttype === \'asc\'" :to="toRoute" @click.native="sortData(toRoute.query.sort, toRoute.query.sorttype)">\
8+
{{ label }} <i class="up black icon" :class="icon" v-if="toRoute.query.sort === this.$route.query.sort"></i>\
99
</router-link>\
1010
</div>',
1111

@@ -20,24 +20,19 @@ module.exports = {
2020
default: 'chevron',
2121
required: false
2222
},
23-
routeName: {
24-
type: String,
25-
required: true
26-
},
27-
data: {
23+
toRoute: {
2824
type: Object,
29-
default: function() {
30-
return {
31-
sort: null,
32-
sorttype: null,
33-
}
34-
},
35-
required: true
36-
}
25+
default: function() {
26+
return {
27+
name: 'example.index',
28+
query: { sort: 1, sorttype: 'asc' }
29+
}
30+
}
31+
},
3732
},
3833
methods: {
3934
sortData(sort, direction) {
4035
this.$emit('sort-data', sort, direction);
4136
},
4237
}
43-
}
38+
}

0 commit comments

Comments
 (0)