feat: add geo metadata typy iptions
This commit is contained in:
parent
9a720991aa
commit
c656252d20
|
@ -1,19 +1,82 @@
|
|||
<template>
|
||||
<section>
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.getHelperTitle('tainacan-text', 'display_suggestions')">
|
||||
|
||||
<b-switch
|
||||
size="is-small"
|
||||
:value="displaySuggestions"
|
||||
@input="onUpdateDisplaySuggestions"
|
||||
:true-value="'yes'"
|
||||
:false-value="'no'" />
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('tainacan-text', 'display_suggestions')"
|
||||
:message="$i18n.getHelperMessage('tainacan-text', 'display_suggestions')"/>
|
||||
<b-field :addons="false" >
|
||||
<label class="label is-inline">
|
||||
{{ $i18n.getHelperTitle('tainacan-text', 'mapProvider') }}
|
||||
<span> * </span>
|
||||
<help-button
|
||||
:title="'Titulo do helper'"
|
||||
:message="'message do helper'" />
|
||||
</label>
|
||||
<b-input
|
||||
name="mapProvider"
|
||||
v-model="mapProvider"
|
||||
@input="emitValues()" />
|
||||
</b-field>
|
||||
|
||||
<b-field :addons="false" >
|
||||
<label class="label is-inline">
|
||||
{{ $i18n.getHelperTitle('tainacan-text', 'extraTileLayer') }}
|
||||
<help-button
|
||||
:title="'Titulo do helper'"
|
||||
:message="'message do helper'" />
|
||||
</label>
|
||||
<b-input
|
||||
name="extraTileLayer"
|
||||
v-model="extraTileLayer"
|
||||
@input="emitValues()" />
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
:addons="false" >
|
||||
<label class="label is-inline">
|
||||
{{ $i18n.getHelperTitle('tainacan-text', 'atrribution') }}
|
||||
<span> * </span>
|
||||
<help-button
|
||||
:title="'Titulo do helper'"
|
||||
:message="'message do helper'" />
|
||||
</label>
|
||||
<b-input
|
||||
name="atrribution"
|
||||
v-model="atrribution"
|
||||
@input="emitValues()" />
|
||||
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
:addons="false" >
|
||||
<label class="label is-inline">
|
||||
{{ $i18n.getHelperTitle('tainacan-text', 'initialZoom') }}
|
||||
<span> * </span>
|
||||
<help-button
|
||||
:title="'Titulo do helper'"
|
||||
:message="'message do helper'" />
|
||||
</label>
|
||||
<b-input
|
||||
name="initialZoom"
|
||||
v-model="initialZoom"
|
||||
@input="emitValues()"
|
||||
type="number"
|
||||
step="1" />
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
:addons="false" >
|
||||
<label class="label is-inline">
|
||||
{{ $i18n.getHelperTitle('tainacan-text', 'maximumZoom') }}
|
||||
<span> * </span>
|
||||
<help-button
|
||||
:title="'Titulo do helper'"
|
||||
:message="'message do helper'" />
|
||||
</label>
|
||||
<b-input
|
||||
name="maximumZoom"
|
||||
v-model="maximumZoom"
|
||||
@input="emitValues()"
|
||||
type="number"
|
||||
step="1" />
|
||||
</b-field>
|
||||
|
||||
</section>
|
||||
</template>
|
||||
|
||||
|
@ -24,17 +87,32 @@
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
displaySuggestions: String
|
||||
mapProvider: String,
|
||||
extraTileLayer: [],
|
||||
atrribution: String,
|
||||
initialZoom: Number,
|
||||
maximumZoom: Number,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.displaySuggestions = this.value && this.value.display_suggestions ? this.value.display_suggestions : 'no';
|
||||
if (this.value) {
|
||||
this.mapProvider = this.value.map_provider || 'http://?';
|
||||
this.extraTileLayer = this.value.extra_tile_layer || [];
|
||||
this.atrribution = this.value.atrribution || '';
|
||||
this.initialZoom = this.value.initial_zoom || 5;
|
||||
this.maximumZoom = this.value.maximum_zoom || 12;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onUpdateDisplaySuggestions(value) {
|
||||
this.displaySuggestions = value;
|
||||
this.$emit('input', { display_suggestions: value });
|
||||
}
|
||||
emitValues(){
|
||||
this.$emit('input',{
|
||||
map_provider: this.mapProvider,
|
||||
extra_tile_layer: this.extraTileLayer,
|
||||
atrribution: this.atrribution,
|
||||
initial_zoom: this.initialZoom,
|
||||
maximum_zoom: this.maximumZoom,
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -21,6 +21,13 @@ class GeoCoordinate extends Metadata_Type {
|
|||
$this->set_form_component('tainacan-form-geocoordinate');
|
||||
$this->set_name( __('GeoCoordinate', 'tainacan') );
|
||||
$this->set_description( __('Represents a geographical location that is determined by latitude and longitude coordinates.', 'tainacan') );
|
||||
$this->set_default_options([
|
||||
'map_provider' => 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
'extra_tile_layer' => [],
|
||||
'atrribution' => '© <a target="_blank" href="http://osm.org/copyright">OpenStreetMap</a> contributors',
|
||||
'initial_zoom' => 5,
|
||||
'maximum_zoom' => 12,
|
||||
]);
|
||||
$this->set_preview_template('
|
||||
<div>
|
||||
<div class="control">
|
||||
|
@ -30,6 +37,34 @@ class GeoCoordinate extends Metadata_Type {
|
|||
');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_form_labels(){
|
||||
return [
|
||||
'map_tile_provider' => [
|
||||
'title' => __( 'Tile provides', 'tainacan' ),
|
||||
'description' => __( 'Link to the service used as source for displaying tile layers on the map', 'tainacan' ),
|
||||
],
|
||||
'extra_map_tile_layer' => [
|
||||
'title' => __( 'Extra tile layer', 'tainacan' ),
|
||||
'description' => __( 'The extra layer of blocks to be displayed on the map', 'tainacan' ),
|
||||
],
|
||||
'attribution' => [
|
||||
'title' => __( 'Attribution', 'tainacan' ),
|
||||
'description' => __( 'Text/HTML to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes source of map data and is often a legal obligation towards copyright holders and tile providers.', 'tainacan' ),
|
||||
],
|
||||
'initial_zoom' => [
|
||||
'title' => __( 'Initial zoom', 'tainacan' ),
|
||||
'description' => __( 'Initial zoom level of the map.', 'tainacan' ),
|
||||
],
|
||||
'maximum_zoom' => [
|
||||
'title' => __( 'Maximum zoom', 'tainacan' ),
|
||||
'description' => __( 'Maximum zoom level of the map.', 'tainacan' ),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a given coordinate
|
||||
*
|
||||
|
@ -110,4 +145,8 @@ class GeoCoordinate extends Metadata_Type {
|
|||
' . $return . '
|
||||
</span>';
|
||||
}
|
||||
|
||||
public function get_options_as_html() {
|
||||
return "";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue