mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-23 16:13:50 +00:00
Merge branch 'master' into VSR-issues
This commit is contained in:
@@ -67,13 +67,18 @@ export const makeFetch = <Input, Output>(method: 'POST'|'GET'|'PUT'|'PATCH'|'DEL
|
||||
},
|
||||
};
|
||||
|
||||
if (body !== null || typeof body !== 'undefined') {
|
||||
console.log('for url '+url, body);
|
||||
console.log('for url '+url, body !== null);
|
||||
|
||||
if (body !== null && typeof body !== 'undefined') {
|
||||
Object.assign(opts, {body: JSON.stringify(body)})
|
||||
}
|
||||
|
||||
if (typeof options !== 'undefined') {
|
||||
opts = Object.assign(opts, options);
|
||||
}
|
||||
console.log('will fetch', url);
|
||||
console.log('content for ' + url, opts);
|
||||
|
||||
return fetch(url, opts)
|
||||
.then(response => {
|
||||
|
@@ -315,8 +315,11 @@ export default {
|
||||
addressMap: {
|
||||
// Note: LeafletJs demands [lat, lon]
|
||||
// cfr https://macwright.com/lonlat/
|
||||
center : [48.8589, 2.3469],
|
||||
zoom: 12
|
||||
center : [
|
||||
this.context.defaults.map_center.x,
|
||||
this.context.defaults.map_center.y,
|
||||
],
|
||||
zoom: this.context.defaults.map_center.z
|
||||
},
|
||||
},
|
||||
errorMsg: []
|
||||
|
@@ -8,8 +8,12 @@ import L from 'leaflet';
|
||||
import markerIconPng from 'leaflet/dist/images/marker-icon.png'
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
|
||||
const lonLatForLeaflet = (coordinates) => {
|
||||
return [coordinates[1], coordinates[0]];
|
||||
}
|
||||
|
||||
export default {
|
||||
name: 'AddressMap',
|
||||
name: 'AddressMap',
|
||||
props: ['entity'],
|
||||
data() {
|
||||
return {
|
||||
@@ -21,10 +25,47 @@ export default {
|
||||
center() {
|
||||
return this.entity.addressMap.center;
|
||||
},
|
||||
hasAddressPoint() {
|
||||
if (Object.keys(this.entity.address).length === 0) {
|
||||
return false;
|
||||
}
|
||||
if (null !== this.entity.address.addressReference) {
|
||||
return true;
|
||||
}
|
||||
if (null !== this.entity.address.postcode && null !== this.entity.address.postcode.center) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @returns {coordinates: [float, float], type: "Point"}
|
||||
*/
|
||||
addressPoint() {
|
||||
if (Object.keys(this.entity.address).length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (null !== this.entity.address.addressReference) {
|
||||
return this.entity.address.addressReference.point;
|
||||
}
|
||||
|
||||
if (null !== this.entity.address.postcode && null !== this.entity.address.postcode.center) {
|
||||
return this.entity.address.postcode.center;
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
},
|
||||
methods:{
|
||||
init() {
|
||||
this.map = L.map('address_map').setView([46.67059, -1.42683], 12);
|
||||
this.map = L.map('address_map');
|
||||
|
||||
if (!this.hasAddressPoint) {
|
||||
this.map.setView(lonLatForLeaflet(this.entity.addressMap.center), this.entity.addressMap.zoom);
|
||||
} else {
|
||||
this.map.setView(lonLatForLeaflet(this.addressPoint.coordinates), 15);
|
||||
}
|
||||
|
||||
this.map.scrollWheelZoom.disable();
|
||||
|
||||
@@ -37,20 +78,22 @@ export default {
|
||||
iconAnchor: [12, 41],
|
||||
});
|
||||
|
||||
this.marker = L.marker([48.8589, 2.3469], {icon: markerIcon});
|
||||
if (!this.hasAddressPoint) {
|
||||
this.marker = L.marker(lonLatForLeaflet(this.entity.addressMap.center), {icon: markerIcon});
|
||||
} else {
|
||||
this.marker = L.marker(lonLatForLeaflet(this.addressPoint.coordinates), {icon: markerIcon});
|
||||
}
|
||||
this.marker.addTo(this.map);
|
||||
},
|
||||
update() {
|
||||
console.log('update map with : ', this.center)
|
||||
if (this.marker && this.center) {
|
||||
this.marker.setLatLng(this.center);
|
||||
this.map.setView(this.center, 15);
|
||||
if (this.marker && this.entity.addressMap.center) {
|
||||
this.marker.setLatLng(lonLatForLeaflet(this.entity.addressMap.center));
|
||||
this.map.panTo(lonLatForLeaflet(this.entity.addressMap.center));
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
mounted() {
|
||||
this.init();
|
||||
this.update();
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
@@ -30,7 +30,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
value: this.selectCountryByCode(
|
||||
this.context.edit ? this.entity.selected.country.code : 'FR'
|
||||
this.context.edit ? this.entity.selected.country.code : this.context.defaults.default_country
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -45,14 +45,12 @@ export default {
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
console.log('country selection mounted', this.value);
|
||||
if (this.value !== undefined) {
|
||||
this.selectCountry(this.value);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
if (this.value !== undefined) {
|
||||
this.selectCountry(this.value);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
selectCountryByCode(countryCode) {
|
||||
return this.entity.loaded.countries.filter(c => c.countryCode === countryCode)[0];
|
||||
},
|
||||
|
@@ -174,8 +174,8 @@ export default {
|
||||
},
|
||||
updateMapCenter(point) {
|
||||
console.log('point', point);
|
||||
this.addressMap.center[0] = point.coordinates[1]; // TODO use reverse()
|
||||
this.addressMap.center[1] = point.coordinates[0];
|
||||
this.addressMap.center[0] = point.coordinates[0];
|
||||
this.addressMap.center[1] = point.coordinates[1];
|
||||
this.$refs.addressMap.update(); // cast child methods
|
||||
}
|
||||
}
|
||||
|
@@ -93,7 +93,7 @@ export default {
|
||||
],
|
||||
emits: ['openEditPane'],
|
||||
mounted() {
|
||||
console.log('context', this.context)
|
||||
//console.log('context', this.context)
|
||||
},
|
||||
computed: {
|
||||
address() {
|
||||
|
@@ -20,7 +20,8 @@ containers.forEach((container) => {
|
||||
},
|
||||
edit: container.dataset.mode === 'edit', //boolean
|
||||
addressId: parseInt(container.dataset.addressId) || null,
|
||||
backUrl: container.dataset.backUrl || null
|
||||
backUrl: container.dataset.backUrl || null,
|
||||
defaults: JSON.parse(container.dataset.addressDefaults)
|
||||
},
|
||||
options: {
|
||||
/// Options override default.
|
||||
|
@@ -19,7 +19,6 @@ const addAddressInput = (inputs) => {
|
||||
if (container === null) {
|
||||
throw Error("no container");
|
||||
}
|
||||
console.log('useValidFrom', el.dataset.useValidFrom === '1');
|
||||
|
||||
const app = createApp({
|
||||
template: `<app v-bind:addAddress="this.addAddress" @address-created="associateToInput"></app>`,
|
||||
@@ -34,6 +33,7 @@ const addAddressInput = (inputs) => {
|
||||
},
|
||||
edit: isEdit,
|
||||
addressId: addressIdInt,
|
||||
defaults: window.addaddress,
|
||||
},
|
||||
options: {
|
||||
/// Options override default.
|
||||
|
@@ -72,6 +72,8 @@
|
||||
{% if onlyButton is defined and onlyButton == 1 %}
|
||||
data-hide-address="true"
|
||||
{% endif %}
|
||||
|
||||
data-address-defaults="{{ add_address|json_encode|e('html') }}"
|
||||
></div>
|
||||
|
||||
{{ encore_entry_script_tags('vue_address') }}
|
||||
|
@@ -0,0 +1,11 @@
|
||||
{% extends '@ChillMain/CRUD/Admin/index.html.twig' %}
|
||||
|
||||
{% block title %}
|
||||
{% include('@ChillMain/CRUD/_edit_title.html.twig') %}
|
||||
{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
{% embed '@ChillMain/CRUD/_edit_content.html.twig' %}
|
||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock admin_content %}
|
@@ -0,0 +1,39 @@
|
||||
{% extends '@ChillMain/CRUD/Admin/index.html.twig' %}
|
||||
|
||||
{% block admin_content %}
|
||||
{% embed '@ChillMain/CRUD/_index.html.twig' %}
|
||||
{% block table_entities_thead_tr %}
|
||||
<th>{{ 'Label'|trans }}</th>
|
||||
<th>{{ 'Active'|trans }}</th>
|
||||
<th> </th>
|
||||
{% endblock %}
|
||||
|
||||
{% block table_entities_tbody %}
|
||||
{% for entity in entities %}
|
||||
<tr>
|
||||
<td>{{ entity.name }}</td>
|
||||
<td style="text-align:center">
|
||||
{% if entity.isActive %}
|
||||
<i class="fa fa-check-square-o"></i>
|
||||
{% else %}
|
||||
<i class="fa fa-square-o"></i>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a href="{{ chill_path_add_return_path('chill_crud_regroupment_edit', { 'id': entity.id }) }}" class="btn btn-edit"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% block actions_before %}
|
||||
<li class='cancel'>
|
||||
<a href="{{ path('chill_main_admin_central') }}" class="btn btn-cancel">{{'Back to the admin'|trans}}</a>
|
||||
</li>
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
@@ -0,0 +1,11 @@
|
||||
{% extends '@ChillMain/CRUD/Admin/index.html.twig' %}
|
||||
|
||||
{% block title %}
|
||||
{% include('@ChillMain/CRUD/_new_title.html.twig') %}
|
||||
{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
{% embed '@ChillMain/CRUD/_new_content.html.twig' %}
|
||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock admin_content %}
|
@@ -9,6 +9,11 @@
|
||||
{% block head_custom %}{% endblock %}
|
||||
<link rel="shortcut icon" href="{{ asset('build/images/favicon.ico') }}" type="image/x-icon">
|
||||
|
||||
<script type="application/javascript">
|
||||
{# this is global data, in use for all js app #}
|
||||
window.addaddress = {{ add_address|json_encode|raw }};
|
||||
</script>
|
||||
|
||||
{{ encore_entry_link_tags('mod_bootstrap') }}
|
||||
{{ encore_entry_link_tags('mod_forkawesome') }}
|
||||
{{ encore_entry_link_tags('mod_ckeditor5') }}
|
||||
|
Reference in New Issue
Block a user