Mercurial > gemma
changeset 1377:fa7d647f8d77
added timestamp to saved cross profiles
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Tue, 27 Nov 2018 13:29:10 +0100 |
parents | e27176811d2f |
children | 68bf92edafe1 8fdaf0439a68 |
files | client/src/components/map/fairway/Profiles.vue client/src/store/fairway.js |
diffstat | 2 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/map/fairway/Profiles.vue Tue Nov 27 13:05:33 2018 +0100 +++ b/client/src/components/map/fairway/Profiles.vue Tue Nov 27 13:29:10 2018 +0100 @@ -302,7 +302,8 @@ const newEntry = { label: this.cutLabel, bottleneckName: this.selectedBottleneck, - coordinates: [...this.startPoint, ...this.endPoint] + coordinates: [...this.startPoint, ...this.endPoint], + timestamp: new Date().getTime() }; const existingEntry = previousCuts.find(cut => { return JSON.stringify(cut) === JSON.stringify(newEntry);
--- a/client/src/store/fairway.js Tue Nov 27 13:05:33 2018 +0100 +++ b/client/src/store/fairway.js Tue Nov 27 13:29:10 2018 +0100 @@ -217,11 +217,13 @@ JSON.parse(localStorage.getItem("previousCuts")) || []; commit( "previousCuts", - previousCuts.filter(cut => { - return ( - cut.bottleneckName === rootState.bottlenecks.selectedBottleneck - ); - }) + previousCuts + .filter(cut => { + return ( + cut.bottleneckName === rootState.bottlenecks.selectedBottleneck + ); + }) + .sort((a, b) => (a.timestamp < b.timestamp ? 1 : -1)) ); } }