summaryrefslogtreecommitdiffstats
path: root/web_src
diff options
context:
space:
mode:
authorgordon-- <gordon_vdlg@gmx.de>2021-02-20 23:08:58 +0100
committerGitHub <noreply@github.com>2021-02-20 17:08:58 -0500
commit343c75635713ecbb494b7729558d0ba05eaf85dc (patch)
tree1c0e61f4d9e015b0036238517c246e1b50fba646 /web_src
parentf3e64f677fd242850beafb1767504722f2dc2703 (diff)
downloadgitea-343c75635713ecbb494b7729558d0ba05eaf85dc.tar.gz
gitea-343c75635713ecbb494b7729558d0ba05eaf85dc.zip
Heatmap days clickable (#13935)
* Heatmap days clickable * Error handling * Unselect filter * better dayclick handler * made linter happy * clickable heatmap for profiles Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/components/ActivityHeatmap.vue21
1 files changed, 20 insertions, 1 deletions
diff --git a/web_src/js/components/ActivityHeatmap.vue b/web_src/js/components/ActivityHeatmap.vue
index 7eb129d139..63e38ea69e 100644
--- a/web_src/js/components/ActivityHeatmap.vue
+++ b/web_src/js/components/ActivityHeatmap.vue
@@ -10,6 +10,7 @@
:end-date="endDate"
:values="values"
:range-color="colorRange"
+ @day-click="handleDayClick($event)"
/>
</div>
</template>
@@ -48,7 +49,25 @@ export default {
}
return s;
}
- }
+ },
+ methods: {
+ handleDayClick(e) {
+ // Reset filter if same date is clicked
+ const params = new URLSearchParams(document.location.search);
+ const queryDate = params.get('date');
+ // Timezone has to be stripped because toISOString() converts to UTC
+ const clickedDate = new Date(e.date - (e.date.getTimezoneOffset() * 60000)).toISOString().substring(0, 10);
+
+ if (queryDate && queryDate === clickedDate) {
+ params.delete('date');
+ } else {
+ params.set('date', clickedDate);
+ }
+
+ const newSearch = params.toString();
+ window.location.search = newSearch.length ? `?${newSearch}` : '';
+ }
+ },
};
</script>
<style scoped/>