view client/src/components/Main.vue @ 3041:ccda334eed92

client: panes: improved panes rotation, works with pure css so that components don't need to be re-mounted
author Markus Kottlaender <markus@intevation.de>
date Sat, 13 Apr 2019 14:51:56 +0200
parents 5d7db2ea16c8
children 0233845cadb7
line wrap: on
line source

<template>
  <div id="panes" :class="'d-flex position-absolute rotate' + paneRotate">
    <div id="pane1" :class="'pane d-flex ' + pane1Class">
      <component :is="panes[0]" />
    </div>

    <template v-if="panes.length === 2">
      <div id="pane2" :class="'pane d-flex ' + pane2Class">
        <component :is="panes[1]" />
      </div>
    </template>

    <template v-if="panes.length === 3">
      <div id="pane3" class="pane d-flex wh-50">
        <component :is="panes[2]" />
      </div>
      <div id="pane2" class="pane d-flex wh-50">
        <component :is="panes[1]" />
      </div>
    </template>

    <template v-if="panes.length === 4">
      <div id="pane2" class="pane d-flex wh-50">
        <component :is="panes[1]" />
      </div>
      <div id="pane4" class="pane d-flex wh-50">
        <component :is="panes[3]" />
      </div>
      <div id="pane3" class="pane d-flex wh-50">
        <component :is="panes[2]" />
      </div>
    </template>
  </div>
</template>

<style lang="sass" scoped>
#panes
  top: -0.5px
  right: -0.5px
  bottom: -0.5px
  left: -0.5px
  z-index: 1
  &.rotate1
    flex-wrap: wrap
    flex-direction: row
  &.rotate2
    flex-wrap: wrap-reverse
    flex-direction: column
  &.rotate3
    flex-wrap: wrap-reverse
    flex-direction: row-reverse
  &.rotate4
    flex-wrap: wrap
    flex-direction: column-reverse
  .pane
    border: solid 0.5px #fff
    background: #fff
</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):
 * Thomas Junk <thomas.junk@intevation.de>
 * Markus Kottländer <markus.kottlaender@intevation.de>
 */

import { mapState } from "vuex";

export default {
  components: {
    // all components that are supposed to be displayed in a pane must be registered here
    Map: () => import("./map/Map"),
    Fairwayprofile: () => import("./fairway/Fairwayprofile"),
    AvailableFairwayDepth: () => import("./fairway/AvailableFairwayDepth"),
    Waterlevel: () => import("./gauge/Waterlevel"),
    HydrologicalConditions: () => import("./gauge/HydrologicalConditions")
  },
  computed: {
    ...mapState("application", ["panes", "paneRotate"]),
    // pane 1 and 2 are the only ones that can have varying size
    // thats why tehre is no pane3class or pane4class
    pane1Class() {
      if (this.panes.length === 1) return "wh-100";
      if (this.panes.length === 2 || this.panes.length === 3) {
        if (this.paneRotate === 1 || this.paneRotate === 3) return "w-100 h-50";
        if (this.paneRotate === 2 || this.paneRotate === 4) return "w-50 h-100";
      }
      if (this.panes.length === 4) {
        return "wh-50";
      }
    },
    pane2Class() {
      if (this.panes.length === 2) {
        if (this.paneRotate === 1 || this.paneRotate === 3) return "w-100 h-50";
        if (this.paneRotate === 2 || this.paneRotate === 4) return "w-50 h-100";
      } else {
        return "wh-50";
      }
    }
  }
};
</script>