Skip to content
Snippets Groups Projects
ProjectMappingContextLayer.vue 3.87 KiB
Newer Older
  <div
    :id="layer.dataKey"
    :class="`ui segment layer-item basemap-${basemapid}`"
      <div
        class="field"
        data-type="layer-field"
      >
        <label
          class="layer-handle-sort"
        >
Florent Lavelle's avatar
Florent Lavelle committed
          <i
            class="th icon"
            aria-hidden="true"
          />
          couche
          :selected="selectedLayer.name"
          :selection.sync="selectedLayer"
          :search="true"
          :placeholder="placeholder"
        />
      </div>
      <div class="six wide field">
        <label for="opacity">Opacité</label>
        <input
          v-model.number="layerOpacity"
          type="number"
          oninput="validity.valid||(value='');"
          step="0.01"
          min="0"
          max="1"
        >
      </div>
      <div class="field">
          @click="updateLayer({ ...layer, queryable: !layer.queryable })"
          class="ui checkbox"
            :checked="layer.queryable"
            class="hidden"
            type="checkbox"
            name="queryable"
        @click="removeLayer"
        class="ui compact small icon floated button button-hover-red"
        <i
          class="ui grey trash alternate icon"
          aria-hidden="true"
        />
        <span>&nbsp;Supprimer cette couche</span>
      </button>
import Dropdown from '@/components/Dropdown.vue';
import { mapState } from 'vuex';
  name: 'ProjectMappingContextLayer',
Timothee P's avatar
Timothee P committed
  props: {
    layer:
     {
       type: Object,
       default: null,
     },
    basemapid:
      {
        type: Number,
        default: null,
      },
  },
    ...mapState('map', ['availableLayers']),
        return this.retrieveLayer(this.layer.title) || [];
leandro's avatar
leandro committed
        const matchingLayer = this.retrieveLayer(newValue.title);
Timothee P's avatar
Timothee P committed
        if (matchingLayer !== undefined) {
leandro's avatar
leandro committed
          this.updateLayer({
            ...this.layer,
            service: newValue.name,
            title: newValue.value,
leandro's avatar
leandro committed
          });
        }
      },
    },

    layerOpacity: {
      get() {
        return this.layer.opacity;
      },
      set(newValue) {
        if (newValue) {
          //* check if value was filled
          this.updateLayer({ ...this.layer, opacity: newValue });
        }
    availableLayerOptions: function () {
      return this.availableLayers.map((el) => {
Timothee P's avatar
Timothee P committed
          name: `${el.title} - ${el.service}`,
      });
    },

    placeholder: function () {
      return this.selectedLayer && this.selectedLayer.name
        ? ''
        : 'Choisissez une couche';
  mounted() {
    const matchingLayer = this.retrieveLayer(this.layer.title);
    if (matchingLayer !== undefined) {
      this.updateLayer({
        ...this.layer,
        service: matchingLayer.service,
        title: matchingLayer.title,
        id: matchingLayer.id,
      });
    }
  },

      return this.availableLayerOptions.find((el) => el.title === title);
      this.$store.commit('map/DELETE_BASEMAP_LAYER', {
        basemapId: this.basemapid,
        layerId: this.layer.dataKey,
      });
    },

    updateLayer(layer) {
      this.$store.commit('map/UPDATE_BASEMAP_LAYER', {
        basemapId: this.basemapid,
        layerId: this.layer.dataKey,
        layer,
      });
    },
  },
};
Florent Lavelle's avatar
Florent Lavelle committed
</script>