view client/src/identify/Identify.vue @ 1202:68fb4af05b73

fix: prevent identify tool from jumping during page load In order to prevent jumping search embedded in spacer div with 100% size.
author Thomas Junk <thomas.junk@intevation.de>
date Mon, 19 Nov 2018 10:09:25 +0100
parents 1ae93a0438df
children 4f666dbb9abd
line wrap: on
line source

<template>
    <div class="identifymenu">
        <div
            @click="$store.commit('application/showIdentify', !showIdentify)"
            class="d-flex flex-column ui-element minimizer"
        >
            <div :class="infoStyle">
                <i class="fa fa-info"></i>
            </div>
        </div>
        <div :class="identifyStyle">
            <div v-if="showIdentify" class="card-body">
                <div class="headline">
                    <h4 class="card-title">Identified</h4>
                </div>
                <hr>
                <div class="d-flex flex-column features">
                    <small v-if="currentMeasurement">
                        {{ currentMeasurement.quantity }}
                        ({{ currentMeasurement.unitSymbol }}):
                        {{ currentMeasurement.value }}
                    </small>
                    <div v-for="feature of identifiedFeatures" :key="feature.getId()">
                        <div v-if="feature.getId()">
                            {{ feature.getId().replace(/[.][^.]*$/,"") /* cut away everything from the last . to the end */}}:
                            <small
                                v-for="(value, key) in prepareProperties(feature)"
                                :key="key"
                            >
                                <div v-if="value">{{key}}:{{value}}</div>
                            </small>
                        </div>
                    </div>
                </div>
                <div class="versioninfo">
                    <hr>gemma
                    <a href="https://hg.intevation.de/gemma/file/tip">source-code</a>
                    {{ versionStr }}
                    <br>Some data ©
                    <a href="https://www.openstreetmap.org/copyright">OpenSteetMap</a>contributors
                </div>
            </div>
        </div>
    </div>
</template>

<style lang="sass" scoped>
.features
  max-height: $identify-height
  overflow-y: auto
  margin-bottom: $x-large-offset + $large-offset

.versioninfo
  font-size: 60%
  position: absolute
  bottom: $large-offset

.identifymenu
  position: relative
  margin-left: $offset

.identify
  background-color: white
  opacity: $slight-transparent
  text-align: left

.identifycollapsed
  min-height: $icon-height
  width: $icon-width
  transition: $transition-fast

.identifyexpanded
  width: $identify-width

.minimizer
  position: absolute
  z-index: 2
  right: 0
  margin-top: $x-small-offset
  border-radius: $border-radius
  height: $icon-width
  width: $icon-height
</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>
 *   Bernhard E. Reiter <bernhard.reiter@intevation.de>
 */
import { mapState, mapGetters } from "vuex";

export default {
  name: "identify",
  computed: {
    ...mapGetters("application", ["versionStr"]),
    ...mapState("application", ["showIdentify"]),
    ...mapState("map", ["identifiedFeatures", "currentMeasurement"]),
    identifyStyle() {
      return {
        "ui-element": true,
        card: true,
        identify: true,
        shadow: true,
        identifyexpanded: this.showIdentify,
        identifycollapsed: !this.showIdentify
      };
    },
    infoStyle() {
      return {
        info: true,
        "text-info":
          this.identifiedFeatures && this.identifiedFeatures.length > 0
      };
    }
  },
  methods: {
    prepareProperties(feature) {
      // return dict object with propertyname:plainvalue prepared for display
      var properties = feature.getProperties();
      delete properties[feature.getGeometryName()];
      return properties;
    }
  }
};
</script>