diff --git a/flatisfy/web/js_src/components/flatstable.vue b/flatisfy/web/js_src/components/flatstable.vue
index 0512a6d..6eb03d1 100644
--- a/flatisfy/web/js_src/components/flatstable.vue
+++ b/flatisfy/web/js_src/components/flatstable.vue
@@ -2,10 +2,34 @@
- {{ $t("flatsDetails.Title") }} |
- {{ $t("flatsDetails.Area") }} |
- {{ $t("flatsDetails.Rooms") }} |
- {{ $t("flatsDetails.Cost") }} |
+
+ {{ $t("flatsDetails.Title") }}
+
+
+
+
+ |
+
+ {{ $t("flatsDetails.Area") }}
+
+
+
+
+ |
+
+ {{ $t("flatsDetails.Rooms") }}
+
+
+
+
+ |
+
+ {{ $t("flatsDetails.Cost") }}
+
+
+
+
+ |
{{ $t("common.Actions") }} |
@@ -55,17 +79,43 @@
import "font-awesome-webpack"
export default {
+ data () {
+ return {
+ sortBy: 'cost',
+ sortOrder: 'up'
+ }
+ },
+
props: ['flats'],
computed: {
sortedFlats () {
- return this.flats.sort((flat1, flat2) => flat1.cost - flat2.cost)
+ return this.flats.sort(
+ (flat1, flat2) => {
+ if (this.sortOrder === "up") {
+ return flat1[this.sortBy] > flat2[this.sortBy]
+ } else {
+ return flat1[this.sortBy] < flat2[this.sortBy]
+ }
+ }
+ )
}
},
methods: {
updateFlatStatus (id, status) {
this.$store.dispatch('updateFlatStatus', { flatId: id, newStatus: status })
+ },
+ updateSortBy (field) {
+ if (this.sortBy === field) {
+ if (this.sortOrder === "up") {
+ this.sortOrder = "down"
+ } else {
+ this.sortOrder = "up"
+ }
+ } else {
+ this.sortBy = field;
+ }
}
}
}
@@ -89,4 +139,8 @@ button {
font-size: 1em;
cursor: pointer;
}
+
+.pointer {
+ cursor: pointer;
+}