Skip to content
Snippets Groups Projects
EditingToolbar.vue 2.73 KiB
Newer Older
DESPRES Damien's avatar
DESPRES Damien committed
<template>
  <div class="editionToolbar">
    <div v-if="showDrawTool">
Florent Lavelle's avatar
Florent Lavelle committed
      <div class="leaflet-bar">
Florent Lavelle's avatar
Florent Lavelle committed
        <a
          class="leaflet-draw-draw-polygon"
Florent Lavelle's avatar
Florent Lavelle committed
          :title="
            editionService.geom_type === 'polygon' ? 'Dessiner un polygone' :
            editionService.geom_type === 'linestring' ? 'Dessiner une ligne' :
            'Dessiner un point'
          "
DESPRES Damien's avatar
DESPRES Damien committed
        >
          <img
            v-if="editionService.geom_type === 'linestring'"
            class="list-image-type"
            src="@/assets/img/line.png"
          >
          <img
            v-if="editionService.geom_type === 'point'"
            class="list-image-type"
            src="@/assets/img/marker.png"
          >
          <img
            v-if="editionService.geom_type === 'polygon'"
            class="list-image-type"
            src="@/assets/img/polygon.png"
          >
        </a>
      </div>
    </div>
    <div v-if="!showDrawTool">
      <div class="leaflet-bar">
        <a @click="update">
DESPRES Damien's avatar
DESPRES Damien committed
          <i class="edit outline icon" />
          <span class="sr-only">Modifier l'objet</span></a>
        <a @click="deleteObj">
Florent Lavelle's avatar
Florent Lavelle committed
          <i class="trash alternate outline icon" />
DESPRES Damien's avatar
DESPRES Damien committed
          <span class="sr-only">Supprimer l'objet</span></a>
      </div>
    </div>
  </div>
</template>

<script>
import editionService from '@/services/edition-service';

export default {
  name: 'EditingToolbar',
  data() {
    return {
      editionService: editionService,
    };
  },
  computed: {
    showDrawTool() {
      return this.editionService && this.editionService.editing_feature === undefined;
DESPRES Damien's avatar
DESPRES Damien committed
    }
  },
  mounted() {

  },
  methods: {
    update(){
      editionService.activeUpdateFeature();
    },
    deleteObj(){
      editionService.activeDeleteFeature();
    },
Florent Lavelle's avatar
Florent Lavelle committed

DESPRES Damien's avatar
DESPRES Damien committed
  }
};
</script>

<style scoped>
.editionToolbar{
  position: absolute;
  top: 80px;
  right: 5px;
}
.leaflet-bar {
Florent Lavelle's avatar
Florent Lavelle committed
  border: 2px solid rgba(0,0,0,.2);
  background-clip: padding-box;
  padding: 0;
  border-radius: 2px;
DESPRES Damien's avatar
DESPRES Damien committed
}
.leaflet-bar a:first-child {
Florent Lavelle's avatar
Florent Lavelle committed
  border-top-left-radius: 2px;
  border-top-right-radius: 2px;
DESPRES Damien's avatar
DESPRES Damien committed
}
.leaflet-bar a:last-child {
Florent Lavelle's avatar
Florent Lavelle committed
  border-bottom-left-radius: 2px;
  border-bottom-right-radius: 2px;
DESPRES Damien's avatar
DESPRES Damien committed
  border-bottom: none;
}
.leaflet-bar a, .leaflet-control-layers-toggle {
  background-position: 50% 50%;
  background-repeat: no-repeat;
  display: block;
}
Florent Lavelle's avatar
Florent Lavelle committed
.leaflet-bar a {
DESPRES Damien's avatar
DESPRES Damien committed
  background-color: #fff;
Florent Lavelle's avatar
Florent Lavelle committed
  width: 30px;
  height: 30px;
DESPRES Damien's avatar
DESPRES Damien committed
  display: block;
  text-align: center;
  text-decoration: none;
  color: black;
}
Florent Lavelle's avatar
Florent Lavelle committed
.leaflet-bar a > i {
  margin: 0;
  vertical-align: middle;
}
.list-image-type {
  height: 20px;
  vertical-align: middle;
  margin: 5px 0 5px 0;
}
.leaflet-bar a:hover {
  cursor: pointer;
  background-color: #ebebeb;
}
.leaflet-bar a:focus {
  background-color: #ebebeb;
}
DESPRES Damien's avatar
DESPRES Damien committed
</style>