diff --git a/src/components/Discover/Map/Filter/Attributes.vue b/src/components/Discover/Map/Filter/Attributes.vue
index 4a9e8e8..258176f 100644
--- a/src/components/Discover/Map/Filter/Attributes.vue
+++ b/src/components/Discover/Map/Filter/Attributes.vue
@@ -11,7 +11,7 @@
Attribute Name ({{ attTotal }})
-
+
@@ -32,7 +32,7 @@
-
+
@@ -241,11 +241,14 @@ export default {
}
return sliderData;
},
- // user select time start and end
+ // user select value type start and end
attValueTypeStartEnd: function() {
let start;
let end;
- switch (this.selectedAttName.type) {
+ let data;
+ const type = this.selectedAttName.type;
+
+ switch (type) {
case 'date':
start = getMoment(this.startTime).format('YYYY-MM-DDTHH:mm:00');
end = getMoment(this.endTime).format('YYYY-MM-DDTHH:mm:00');
@@ -255,18 +258,77 @@ export default {
end = this.valueEnd;
break;
}
- // this.selectTimeFrame = [start, end]; // 傳給後端的資料
- // this.$emit('on-row-select', e.data);
+ data = { // 傳給後端的資料
+ type: type,
+ data: {
+ key: this.selectedAttName.key,
+ min: start,
+ max: end,
+ }
+ }
+ this.$emit('select-attribute', data);
return [start, end];
},
},
methods: {
/**
- * 切換 Attribute Name 或選取類別型 table 的選項
+ * 選取類別型 table 的選項
+ */
+ onRowSelect() {
+ const type = this.selectedAttName.type;
+ const data = {
+ type: type,
+ data: this.selectedAttRange,
+ };
+ this.$emit('select-attribute', data);
+ },
+ /**
+ * 取消類別型 table 的選項
+ */
+ onRowUnselect() {
+ const type = this.selectedAttName.type;
+ const data = {
+ type: type,
+ data: this.selectedAttRange,
+ };
+ this.$emit('select-attribute', data);
+ },
+ /**
+ * 選取類別型 table 的全選項
* @param {event} e
*/
- onRowSelect(e) {
+ onRowSelectAll(e) {
+ this.selectedAttRange = e.data;
+ const type = this.selectedAttName.type;
+ const data = {
+ type: type,
+ data: this.selectedAttRange,
+ };
+ this.$emit('select-attribute', data);
+ },
+ /**
+ * 取消類別型 table 的全選項
+ */
+ onRowUnelectAll() {
+ this.selectedAttRange = null;
+ const type = this.selectedAttName.type;
+ const data = {
+ type: type,
+ data: this.selectedAttRange,
+ };
+ this.$emit('select-attribute', data)
+ },
+ /**
+ * 切換 Attribute Name Radio
+ * @param {event} e
+ */
+ switchAttNameRadio(e) {
+ this.selectedAttRange = null;
+ this.startTime = null;
+ this.endTime = null;
+ this.valueStart = null;
+ this.valueEnd = null;
if(this.valueData) { // 切換 Attribute Name
// 初始化雙向綁定
this.selectArea = [0, this.selectRange];
@@ -304,8 +366,6 @@ export default {
this.attValueTypeStartEnd;
// 建立圖表
this.createChart();
- } else { // 選取類別型 table 的選項
- // this.$emit('on-row-select', e.data);
}
},
/**
@@ -467,8 +527,8 @@ export default {
this.endMinDate = new Date(start);
this.startMaxDate = new Date(end);
break;
- default:
- this.valueStart = start;
+ default:
+ this.valueStart = start;
this.valueEnd = end;
// 重新設定 start end 日曆選取範圍
this.valueEndMin = start;
@@ -513,9 +573,29 @@ export default {
else return;
},
},
+ created() {
+ this.$emitter.on('map-filter-reset', value => {
+ if(value) {
+ this.selectedAttRange = null;
+ if(this.valueData && this.valueTypes.includes(this.selectedAttName.type)){
+ const min = this.valueData.min;
+ const max = this.valueData.max;
+ this.startTime = new Date(min);
+ this.endTime = new Date(max);
+ this.valueStart = min;
+ this.valueEnd = max;
+ this.selectArea = [0, this.selectRange];
+ this.resizeMask(this.chartComplete);
+ }
+ }
+ });
+ },
mounted() {
// Slider
this.selectArea = [0, this.selectRange]; // 初始化滑塊
+ },
+ beforeUnmount() {
+ this.selectedAttName = {};
}
}
diff --git a/src/components/Discover/Map/SidebarFilter.vue b/src/components/Discover/Map/SidebarFilter.vue
index ddc9af5..68c3a93 100644
--- a/src/components/Discover/Map/SidebarFilter.vue
+++ b/src/components/Discover/Map/SidebarFilter.vue
@@ -85,7 +85,7 @@
-