mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
Merge remote-tracking branch 'origin/improve_location' into 106_tasks_to_parcours
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
const contactDataBlock = document.querySelector('div.location-form-contact');
|
||||
const addressBlock = document.querySelector('div.location-form-address');
|
||||
const locationType = document.getElementById('chill_mainbundle_location_locationType');
|
||||
|
||||
const getSelectedAttributes =
|
||||
(select, attr) => select.selectedOptions[0].getAttribute(attr)
|
||||
|
||||
|
||||
const removeRequired = (formBlock) => {
|
||||
formBlock.querySelectorAll('label').forEach(
|
||||
l => l.classList.remove('required')
|
||||
);
|
||||
formBlock.querySelectorAll('input').forEach(
|
||||
i => i.removeAttribute('required')
|
||||
);
|
||||
}
|
||||
|
||||
const addRequired = (formBlock) => {
|
||||
formBlock.querySelectorAll('label').forEach(
|
||||
l => l.classList.add('required')
|
||||
);
|
||||
formBlock.querySelectorAll('input').forEach(
|
||||
i => i.setAttribute('required', '')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
const onLocationTypeChange = () => {
|
||||
console.log(getSelectedAttributes(locationType, 'data-address'))
|
||||
console.log(getSelectedAttributes(locationType, 'data-contact'))
|
||||
switch (getSelectedAttributes(locationType, 'data-address')) {
|
||||
case 'optional':
|
||||
default:
|
||||
removeRequired(addressBlock);
|
||||
addressBlock.classList.remove('d-none');
|
||||
break;
|
||||
case 'required':
|
||||
addRequired(addressBlock);
|
||||
addressBlock.classList.remove('d-none');
|
||||
break;
|
||||
case 'never':
|
||||
removeRequired(addressBlock);
|
||||
addressBlock.classList.add('d-none');
|
||||
break;
|
||||
}
|
||||
switch (getSelectedAttributes(locationType, 'data-contact')) {
|
||||
case 'optional':
|
||||
default:
|
||||
removeRequired(contactDataBlock);
|
||||
contactDataBlock.classList.remove('d-none');
|
||||
break;
|
||||
case 'required':
|
||||
addRequired(contactDataBlock);
|
||||
contactDataBlock.classList.remove('d-none');
|
||||
break;
|
||||
case 'never':
|
||||
removeRequired(contactDataBlock);
|
||||
contactDataBlock.classList.add('d-none');
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', _e => {
|
||||
onLocationTypeChange();
|
||||
locationType.addEventListener('change', onLocationTypeChange);
|
||||
});
|
@@ -0,0 +1,33 @@
|
||||
{#
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
<info@champs-libres.coop> / <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#}
|
||||
|
||||
{% extends "@ChillMain/Admin/layoutWithVerticalMenu.html.twig" %}
|
||||
|
||||
{% block vertical_menu_content %}
|
||||
{{ chill_menu('admin_location', {
|
||||
'layout': '@ChillMain/Admin/menu_admin_location.html.twig',
|
||||
}) }}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
||||
{% block layout_wvm_content %}
|
||||
{% block admin_content %}
|
||||
<h1>{{ 'Management of location' |trans }}</h1>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
@@ -0,0 +1,20 @@
|
||||
{#
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
<info@champs-libres.coop> / <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#}
|
||||
|
||||
{% extends "@ChillMain/Menu/verticalMenu.html.twig" %}
|
||||
{% block v_menu_title %}{{ 'Location Menu'|trans }}{% endblock %}
|
@@ -0,0 +1,39 @@
|
||||
{% extends '@ChillMain/Admin/layout.html.twig' %}
|
||||
|
||||
{% block title %}
|
||||
{% include('@ChillMain/CRUD/_edit_title.html.twig') %}
|
||||
{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
{% embed '@ChillMain/CRUD/_edit_content.html.twig' %}
|
||||
|
||||
{% block crud_content_form_rows %}
|
||||
|
||||
{{ form_row(form.locationType) }}
|
||||
|
||||
<div class="location-form-address">
|
||||
{{ form_row(form.address) }}
|
||||
</div>
|
||||
|
||||
{{ form_row(form.name) }}
|
||||
|
||||
<div class="location-form-contact">
|
||||
{{ form_row(form.phonenumber1) }}
|
||||
{{ form_row(form.phonenumber2) }}
|
||||
{{ form_row(form.email) }}
|
||||
</div>
|
||||
|
||||
{% endblock crud_content_form_rows %}
|
||||
|
||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
{{ encore_entry_script_tags('mod_input_address') }}
|
||||
{{ encore_entry_script_tags('page_location') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{{ encore_entry_link_tags('mod_input_address') }}
|
||||
{% endblock %}
|
@@ -0,0 +1,56 @@
|
||||
{% extends "@ChillMain/Admin/layout_location.html.twig" %}
|
||||
|
||||
{% block admin_content %}
|
||||
<h1>{{ 'Location list'|trans }}</h1>
|
||||
|
||||
<table class="records_list table table-bordered border-dark">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ 'Name'|trans }}</th>
|
||||
<th>{{ 'Phonenumber1'|trans }}</th>
|
||||
<th>{{ 'Phonenumber2'|trans }}</th>
|
||||
<th>{{ 'Email'|trans }}</th>
|
||||
<th>{{ 'Address'|trans }}</th>
|
||||
<th>{{ 'Active'|trans }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for entity in entities %}
|
||||
<tr>
|
||||
<td>{{ entity.name }}</td>
|
||||
<td>{{ entity.phonenumber1 }}</td>
|
||||
<td>{{ entity.phonenumber2 }}</td>
|
||||
<td>{{ entity.email }}</td>
|
||||
<td>
|
||||
{% if entity.address is not null %}
|
||||
{{ entity.address.street}}, {{ entity.address.streetnumber }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td style="text-align:center;">
|
||||
{%- if entity.active -%}
|
||||
<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="{{ path('chill_crud_main_location_edit', { 'id': entity.id }) }}" class="btn btn-edit" title="{{ 'edit'|trans }}"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a href="{{ path('chill_crud_main_location_new') }}" class="btn btn-create">
|
||||
{{ 'Create a new location'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
@@ -0,0 +1,39 @@
|
||||
{% extends '@ChillMain/Admin/layout.html.twig' %}
|
||||
|
||||
{% block title %}
|
||||
{% include('@ChillMain/CRUD/_new_title.html.twig') %}
|
||||
{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
{% embed '@ChillMain/CRUD/_new_content.html.twig' %}
|
||||
|
||||
{% block crud_content_form_rows %}
|
||||
|
||||
{{ form_row(form.locationType) }}
|
||||
|
||||
<div class="location-form-address">
|
||||
{{ form_row(form.address) }}
|
||||
</div>
|
||||
|
||||
{{ form_row(form.name) }}
|
||||
|
||||
<div class="location-form-contact">
|
||||
{{ form_row(form.phonenumber1) }}
|
||||
{{ form_row(form.phonenumber2) }}
|
||||
{{ form_row(form.email) }}
|
||||
</div>
|
||||
|
||||
{% endblock crud_content_form_rows %}
|
||||
|
||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
{{ encore_entry_script_tags('mod_input_address') }}
|
||||
{{ encore_entry_script_tags('page_location') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{{ encore_entry_link_tags('mod_input_address') }}
|
||||
{% endblock %}
|
@@ -0,0 +1,14 @@
|
||||
{% extends '@ChillMain/Admin/layout.html.twig' %}
|
||||
|
||||
{% block title %}
|
||||
{% include('@ChillMain/CRUD/_edit_title.html.twig') %}
|
||||
{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
{# {% as we are in the admin layout, we override the admin content with the CRUD content %} #}
|
||||
{% embed '@ChillMain/CRUD/_edit_content.html.twig' %}
|
||||
{# we do not have "view" page. We empty the corresponding block #}
|
||||
{% block content_form_actions_view %}{% endblock %}
|
||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
@@ -0,0 +1,55 @@
|
||||
{% extends "@ChillMain/Admin/layout_location.html.twig" %}
|
||||
|
||||
{% block admin_content %}
|
||||
<h1>{{ 'Location type list'|trans }}</h1>
|
||||
|
||||
<table class="records_list table table-bordered border-dark">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ 'Title'|trans }}</th>
|
||||
<th>{{ 'Available for users'|trans }}</th>
|
||||
<th>{{ 'Address required'|trans }}</th>
|
||||
<th>{{ 'Contact data'|trans }}</th>
|
||||
<th>{{ 'Active'|trans }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for entity in entities %}
|
||||
<tr>
|
||||
<td>{{ entity.title | localize_translatable_string }}</td>
|
||||
<td style="text-align:center;">
|
||||
{%- if entity.availableForUsers -%}
|
||||
<i class="fa fa-check-square-o"></i>
|
||||
{%- else -%}
|
||||
<i class="fa fa-square-o"></i>
|
||||
{%- endif -%}
|
||||
</td>
|
||||
<td>{{ entity.addressRequired|trans }}</td>
|
||||
<td>{{ entity.contactData|trans }}</td>
|
||||
<td style="text-align:center;">
|
||||
{%- if entity.active -%}
|
||||
<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="{{ path('chill_crud_main_location_type_edit', { 'id': entity.id }) }}" class="btn btn-edit" title="{{ 'edit'|trans }}"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a href="{{ path('chill_crud_main_location_type_new') }}" class="btn btn-create">
|
||||
{{ 'Create a new location type'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
@@ -0,0 +1,11 @@
|
||||
{% extends '@ChillMain/Admin/layout.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 %}
|
Reference in New Issue
Block a user