changeset 2549:9bf6b767a56a

client: refactored and improved splitscreen for diagrams To make different diagrams possible, the splitscreen view needed to be decoupled from the cross profiles. Also the style has changed to make it more consistent with the rest of the app. The standard box header is now used and there are collapse and expand animations.
author Markus Kottlaender <markus@intevation.de>
date Fri, 08 Mar 2019 08:50:47 +0100
parents 6b34d0fb4498
children dc42faf90e1d
files client/src/assets/application.scss client/src/components/App.vue client/src/components/Main.vue client/src/components/Maplayer.vue client/src/components/Splitscreen.vue client/src/components/Zoom.vue client/src/components/fairway/Fairwayprofile.vue client/src/components/fairway/Infobar.vue client/src/components/ui/UIBoxHeader.vue client/src/store/application.js client/src/store/bottlenecks.js client/src/store/fairway.js
diffstat 12 files changed, 184 insertions(+), 144 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/assets/application.scss	Thu Mar 07 20:03:43 2019 +0100
+++ b/client/src/assets/application.scss	Fri Mar 08 08:50:47 2019 +0100
@@ -35,6 +35,10 @@
   font-weight: bold;
 }
 
+html {
+  overflow: hidden;
+}
+
 a {
   color: $color-info;
 }
--- a/client/src/components/App.vue	Thu Mar 07 20:03:43 2019 +0100
+++ b/client/src/components/App.vue	Fri Mar 08 08:50:47 2019 +0100
@@ -26,6 +26,7 @@
         <Infobar v-if="isMapVisible"></Infobar>
       </div>
       <Zoom v-if="isMapVisible"></Zoom>
+      <Splitscreen />
     </div>
     <div class="d-flex flex-column"><router-view /></div>
     <vue-snotify></vue-snotify>
@@ -34,10 +35,6 @@
 </template>
 
 <style lang="scss" scoped>
-.small {
-  width: $icon-width;
-}
-
 .userinterface {
   position: absolute;
   top: 0;
@@ -115,7 +112,8 @@
     Search: () => import("./Search"),
     Contextbox: () => import("./Contextbox"),
     Toolbar: () => import("./toolbar/Toolbar"),
-    Popup: () => import("./Popup")
+    Popup: () => import("./Popup"),
+    Splitscreen: () => import("./Splitscreen")
   }
 };
 </script>
--- a/client/src/components/Main.vue	Thu Mar 07 20:03:43 2019 +0100
+++ b/client/src/components/Main.vue	Fri Mar 08 08:50:47 2019 +0100
@@ -1,7 +1,6 @@
 <template>
   <div class="main d-flex flex-column">
-    <Maplayer></Maplayer>
-    <FairwayProfile></FairwayProfile>
+    <Maplayer />
   </div>
 </template>
 
@@ -18,13 +17,13 @@
  *
  * Author(s):
  * Thomas Junk <thomas.junk@intevation.de>
+ * Markus Kottländer <markus.kottlaender@intevation.de>
  */
 
 export default {
   name: "mainview",
   components: {
-    Maplayer: () => import("./Maplayer"),
-    FairwayProfile: () => import("./fairway/Fairwayprofile")
+    Maplayer: () => import("./Maplayer")
   }
 };
 </script>
--- a/client/src/components/Maplayer.vue	Thu Mar 07 20:03:43 2019 +0100
+++ b/client/src/components/Maplayer.vue	Fri Mar 08 08:50:47 2019 +0100
@@ -1,19 +1,22 @@
 <template>
-  <div id="map" :class="mapStyle"></div>
+  <div
+    id="map"
+    :class="{
+      splitscreen: this.splitscreen,
+      nocursor: this.hasActiveInteractions
+    }"
+  ></div>
 </template>
 
-<style lang="scss" scoped>
-.nocursor {
-  cursor: none;
-}
+<style lang="sass" scoped>
+#map
+  height: 100vh
 
-.mapsplit {
-  height: 50vh;
-}
+  &.splitscreen
+    height: 50vh
 
-.mapfull {
-  height: 100vh;
-}
+  &.nocursor
+    cursor: none
 </style>
 
 <script>
@@ -47,7 +50,8 @@
   name: "maplayer",
   data() {
     return {
-      projection: "EPSG:3857"
+      projection: "EPSG:3857",
+      splitscreen: false
     };
   },
   computed: {
@@ -63,13 +67,6 @@
     ]),
     ...mapState("bottlenecks", ["selectedSurvey"]),
     ...mapState("application", ["showSplitscreen"]),
-    mapStyle() {
-      return {
-        mapfull: !this.showSplitscreen,
-        mapsplit: this.showSplitscreen,
-        nocursor: this.hasActiveInteractions
-      };
-    },
     hasActiveInteractions() {
       return (
         (this.lineTool && this.lineTool.getActive()) ||
@@ -143,7 +140,16 @@
     }
   },
   watch: {
-    showSplitscreen() {
+    showSplitscreen(show) {
+      if (show) {
+        setTimeout(() => {
+          this.splitscreen = true;
+        }, 350);
+      } else {
+        this.splitscreen = false;
+      }
+    },
+    splitscreen() {
       const map = this.openLayersMap;
       this.$nextTick(() => {
         map && map.updateSize();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/client/src/components/Splitscreen.vue	Fri Mar 08 08:50:47 2019 +0100
@@ -0,0 +1,92 @@
+<template>
+  <div
+    :class="[
+      'splitscreen bg-white d-flex flex-column ui-element',
+      { show: showSplitscreen }
+    ]"
+    v-if="splitscreen"
+  >
+    <UIBoxHeader
+      :icon="splitscreen.icon"
+      :title="splitscreen.title"
+      :closeCallback="close"
+      :collapseCallback="collapse"
+    />
+    <div class="d-flex flex-fill">
+      <transition name="fade">
+        <div
+          class="loading d-flex justify-content-center align-items-center"
+          v-if="splitscreenLoading"
+        >
+          <font-awesome-icon icon="spinner" spin />
+        </div>
+      </transition>
+      <component :is="splitscreen.component" />
+    </div>
+  </div>
+</template>
+
+<style lang="sass" scoped>
+.splitscreen
+  position: absolute
+  bottom: -50vh
+  left: 0
+  right: 0
+  height: 50vh
+  overflow: hidden
+  z-index: 3
+  transition: bottom 0.3s
+  &.show
+    bottom: 0
+
+  .loading
+    background: rgba(255, 255, 255, 0.96)
+    position: absolute
+    z-index: 99
+    top: 34px
+    right: 0
+    bottom: 0
+    left: 0
+</style>
+
+<script>
+/* This is Free Software under GNU Affero General Public License v >= 3.0
+ * without warranty, see README.md and license for details.
+ *
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ * License-Filename: LICENSES/AGPL-3.0.txt
+ *
+ * Copyright (C) 2018 by via donau
+ *   – Österreichische Wasserstraßen-Gesellschaft mbH
+ * Software engineering by Intevation GmbH
+ *
+ * Author(s):
+ * Markus Kottländer <markus.kottlaender@intevation.de>
+ */
+
+import { mapState } from "vuex";
+
+export default {
+  components: {
+    Fairwayprofile: () => import("@/components/fairway/Fairwayprofile")
+  },
+  computed: {
+    ...mapState("application", [
+      "splitscreen",
+      "showSplitscreen",
+      "splitscreenLoading"
+    ])
+  },
+  methods: {
+    collapse() {
+      this.$store.commit("application/showSplitscreen", false);
+      if (this.splitscreen.collapseCallback)
+        this.splitscreen.collapseCallback();
+    },
+    close() {
+      this.$store.commit("application/showSplitscreen", false);
+      if (this.splitscreen.closeCallback) this.splitscreen.closeCallback();
+    }
+  }
+};
+</script>
--- a/client/src/components/Zoom.vue	Thu Mar 07 20:03:43 2019 +0100
+++ b/client/src/components/Zoom.vue	Fri Mar 08 08:50:47 2019 +0100
@@ -29,6 +29,7 @@
   bottom: 0;
   left: 50%;
   margin-left: -$icon-width;
+  transition: margin-bottom 0.3s;
 }
 
 .zoomButton {
--- a/client/src/components/fairway/Fairwayprofile.vue	Thu Mar 07 20:03:43 2019 +0100
+++ b/client/src/components/fairway/Fairwayprofile.vue	Fri Mar 08 08:50:47 2019 +0100
@@ -1,92 +1,7 @@
 <template>
-  <div :class="['position-relative', { show: showSplitscreen }]">
-    <div class="profile bg-white position-relative d-flex flex-column">
-      <div
-        class="d-flex flex-row justify-content-between align-items-center border-bottom position-relative"
-      >
-        <div class="flex-row mr-auto ml-auto">
-          <h5
-            class="headline mb-0 py-2"
-            v-if="selectedBottleneck && selectedSurvey"
-          >
-            {{ selectedBottleneck }} ({{ selectedSurvey.date_info }})
-          </h5>
-        </div>
-        <div>
-          <button
-            class="rounded-bottom bg-white border-0 splitscreen-toggle"
-            @click="$store.commit('application/showSplitscreen', false)"
-            v-if="showSplitscreen"
-          >
-            <font-awesome-icon icon="angle-down" />
-          </button>
-          <button
-            class="rounded-bottom bg-white border-0 clear-selection"
-            @click="$store.dispatch('fairwayprofile/clearSelection')"
-            v-if="showSplitscreen"
-          >
-            <font-awesome-icon icon="times" class="pointer" />
-          </button>
-        </div>
-      </div>
-      <div class="d-flex flex-fill">
-        <div
-          class="loading d-flex justify-content-center align-items-center"
-          v-if="surveysLoading || profileLoading"
-        >
-          <font-awesome-icon icon="spinner" spin />
-        </div>
-        <div class="fairwayprofile m-3 mt-0 bg-white flex-grow-1"></div>
-      </div>
-    </div>
-  </div>
+  <div class="fairwayprofile m-3 mt-0 bg-white flex-grow-1"></div>
 </template>
 
-<style lang="scss" scoped>
-.profile {
-  width: 100vw;
-  height: 0;
-  overflow: hidden;
-  z-index: 2;
-}
-
-.splitscreen-toggle,
-.clear-selection {
-  width: 2rem;
-  height: 2rem;
-  margin-top: 8px;
-  z-index: 3;
-  outline: none;
-}
-
-.splitscreen-toggle svg path,
-.clear-selection svg path {
-  fill: #666;
-}
-
-.splitscreen-toggle {
-  right: 2.5rem;
-}
-
-.clear-selection {
-  right: 0.5rem;
-}
-
-.show .profile {
-  height: 50vh;
-}
-
-.loading {
-  background: rgba(255, 255, 255, 0.96);
-  position: absolute;
-  z-index: 99;
-  top: 0;
-  right: 0;
-  bottom: 0;
-  left: 0;
-}
-</style>
-
 <script>
 /* This is Free Software under GNU Affero General Public License v >= 3.0
  * without warranty, see README.md and license for details.
@@ -100,6 +15,7 @@
  *
  * Author(s):
  * Thomas Junk <thomas.junk@intevation.de>
+ * Markus Kottländer <markus.kottlaender@intevation.de>
  */
 import * as d3 from "d3";
 import { mapState, mapGetters } from "vuex";
@@ -127,7 +43,6 @@
   },
   computed: {
     ...mapGetters("fairwayprofile", ["totalLength"]),
-    ...mapState("application", ["showSplitscreen"]),
     ...mapState("fairwayprofile", [
       "additionalSurvey",
       "currentProfile",
@@ -135,17 +50,12 @@
       "fairwayData",
       "minAlt",
       "maxAlt",
-      "profileLoading",
       "referenceWaterLevel",
       "selectedWaterLevel",
       "startPoint",
       "waterLevels"
     ]),
-    ...mapState("bottlenecks", [
-      "selectedBottleneck",
-      "selectedSurvey",
-      "surveysLoading"
-    ]),
+    ...mapState("bottlenecks", ["selectedSurvey"]),
     relativeWaterLevelDelta() {
       return this.selectedWaterLevel.value - this.referenceWaterLevel;
     },
--- a/client/src/components/fairway/Infobar.vue	Thu Mar 07 20:03:43 2019 +0100
+++ b/client/src/components/fairway/Infobar.vue	Fri Mar 08 08:50:47 2019 +0100
@@ -1,6 +1,6 @@
 <template>
   <div
-    v-if="Object.keys(currentProfile).length && !showSplitscreen"
+    v-if="Object.keys(currentProfile).length"
     class="ui-element shadow-xs infobar rounded bg-white ml-auto mb-2 mr-2"
   >
     <div class="d-flex flex-row justify-content-between h-100">
@@ -26,7 +26,6 @@
 <style lang="scss" scoped>
 .infobar {
   height: 2.2rem;
-  z-index: 2;
 }
 
 .infobar svg path {
--- a/client/src/components/ui/UIBoxHeader.vue	Thu Mar 07 20:03:43 2019 +0100
+++ b/client/src/components/ui/UIBoxHeader.vue	Fri Mar 08 08:50:47 2019 +0100
@@ -9,9 +9,14 @@
       />
       {{ $gettext(title) }}
     </span>
-    <span class="box-close" @click="closeCallback" v-if="closeCallback">
-      <font-awesome-icon icon="times" />
-    </span>
+    <div class="box-controls">
+      <span @click="collapseCallback" v-if="collapseCallback">
+        <font-awesome-icon icon="angle-down" />
+      </span>
+      <span @click="closeCallback" v-if="closeCallback">
+        <font-awesome-icon icon="times" />
+      </span>
+    </div>
   </h6>
 </template>
 
@@ -20,7 +25,7 @@
   display: flex
   justify-content: space-between
   align-items: center
-  min-height: 35px
+  min-height: 34px
   padding-left: .5rem
   border-bottom: 1px solid #dee2e6
   color: $color-info
@@ -31,15 +36,18 @@
     padding-left: 0.25rem
     .box-icon
       margin-right: 0.25rem
-  .box-close
-    color: #888
-    padding: 3px 7px
-    border-radius: 0.25rem
-    cursor: pointer
-    transition: background-color 0.3s, color 0.3s
-    &:hover
-      color: #666
-      background-color: #eee
+  .box-controls
+    span
+      display: inline-block
+      margin-left: 3px
+      color: #888
+      padding: 3px 7px
+      border-radius: 0.25rem
+      cursor: pointer
+      transition: background-color 0.3s, color 0.3s
+      &:hover
+        color: #666
+        background-color: #eee
 </style>
 
 <script>
@@ -58,6 +66,6 @@
  */
 
 export default {
-  props: ["icon", "title", "closeCallback"]
+  props: ["icon", "title", "collapseCallback", "closeCallback"]
 };
 </script>
--- a/client/src/store/application.js	Thu Mar 07 20:03:43 2019 +0100
+++ b/client/src/store/application.js	Fri Mar 08 08:50:47 2019 +0100
@@ -26,6 +26,8 @@
     showSidebar: false,
     showUsermenu: false,
     showSplitscreen: false,
+    splitscreenLoading: false,
+    splitscreen: null,
     showSearchbar: false,
     showSearchbarLastState: false,
     showIdentify: false,
@@ -75,6 +77,12 @@
     showSplitscreen: (state, show) => {
       state.showSplitscreen = show;
     },
+    splitscreenLoading: (state, loading) => {
+      state.splitscreenLoading = loading;
+    },
+    splitscreen: (state, config) => {
+      state.splitscreen = config;
+    },
     showUsermenu: (state, show) => {
       state.showUsermenu = show;
     },
--- a/client/src/store/bottlenecks.js	Thu Mar 07 20:03:43 2019 +0100
+++ b/client/src/store/bottlenecks.js	Fri Mar 08 08:50:47 2019 +0100
@@ -65,8 +65,11 @@
       return new Promise((resolve, reject) => {
         if (name !== state.selectedBottleneck) {
           commit("selectedSurvey", null);
-          commit("fairwayprofile/clearCurrentProfile", null, { root: true });
+          commit("application/splitscreenLoading", true, { root: true });
           commit("application/showSplitscreen", false, { root: true });
+          setTimeout(() => {
+            commit("fairwayprofile/clearCurrentProfile", null, { root: true });
+          }, 350);
           rootState.map.cutTool.setActive(false);
           rootGetters["map/getVSourceByName"](LAYERS.CUTTOOL).clear();
         }
--- a/client/src/store/fairway.js	Thu Mar 07 20:03:43 2019 +0100
+++ b/client/src/store/fairway.js	Fri Mar 08 08:50:47 2019 +0100
@@ -133,7 +133,6 @@
       dispatch("bottlenecks/setSelectedBottleneck", null, { root: true });
       dispatch("map/enableIdentifyTool", null, { root: true });
       commit("clearCurrentProfile");
-      commit("application/showSplitscreen", false, { root: true });
       rootState.map.cutTool.setActive(false);
       rootGetters["map/getVSourceByName"](LAYERS.CUTTOOL).clear();
     },
@@ -161,7 +160,6 @@
                 resolve(response);
               } else {
                 commit("clearCurrentProfile");
-                commit("application/showSplitscreen", false, { root: true });
                 reject({
                   response: {
                     status: null,
@@ -209,6 +207,8 @@
             );
           }
 
+          commit("application/showSplitscreen", true, { root: true });
+          commit("application/splitscreenLoading", true, { root: true });
           commit("profileLoading", true);
           Promise.all(profileLoaders)
             .then(() => {
@@ -232,7 +232,6 @@
                   };
                   if (fairwayCoordinates.length > 0) {
                     commit("addFairwayData", fairwayData);
-                    commit("application/showSplitscreen", true, { root: true });
                   }
                 }
               );
@@ -255,7 +254,6 @@
                   };
                   if (fairwayCoordinates.length > 0) {
                     commit("addFairwayData", fairwayData);
-                    commit("application/showSplitscreen", true, { root: true });
                   }
                 }
               );
@@ -278,7 +276,6 @@
                   };
                   if (fairwayCoordinates.length > 0) {
                     commit("addFairwayData", fairwayData);
-                    commit("application/showSplitscreen", true, { root: true });
                   }
                 }
               );
@@ -292,6 +289,21 @@
               });
             })
             .finally(() => {
+              commit(
+                "application/splitscreen",
+                {
+                  component: "fairwayprofile",
+                  title: `${rootState.bottlenecks.selectedBottleneck} (${
+                    rootState.bottlenecks.selectedSurvey.date_info
+                  })`,
+                  icon: "chart-area",
+                  closeCallback: () => {
+                    dispatch("clearSelection");
+                  }
+                },
+                { root: true }
+              );
+              commit("application/splitscreenLoading", false, { root: true });
               commit("profileLoading", false);
             });
         }