mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 102_activites_annexes into 'improve_ux'
This commit is contained in:
commit
0f87d77896
@ -5,11 +5,13 @@ image: registry.gitlab.com/chill-projet/chill-app/php-base-image:7.4
|
||||
cache:
|
||||
paths:
|
||||
- tests/app/vendor/
|
||||
- .composer
|
||||
|
||||
before_script:
|
||||
# add extensions to postgres
|
||||
- PGPASSWORD=$POSTGRES_PASSWORD psql -U $POSTGRES_USER -h db -c "CREATE EXTENSION IF NOT EXISTS unaccent; CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
||||
# Install and run Composer
|
||||
- mkdir -p $COMPOSER_HOME
|
||||
- curl -sS https://getcomposer.org/installer | php
|
||||
- php -d memory_limit=2G composer.phar install
|
||||
- php tests/app/bin/console doctrine:migrations:migrate -n
|
||||
@ -34,6 +36,10 @@ variables:
|
||||
REDIS_HOST: redis
|
||||
REDIS_PORT: 6379
|
||||
REDIS_URL: redis://redis:6379
|
||||
# change vendor dir to make the app install into tests/apps
|
||||
COMPOSER_VENDOR_DIR: tests/app/vendor
|
||||
# cache some composer data
|
||||
COMPOSER_HOME: .composer
|
||||
|
||||
|
||||
# Run our tests
|
||||
|
@ -20,7 +20,8 @@
|
||||
"Chill\\ReportBundle\\": "src/Bundle/ChillReportBundle",
|
||||
"Chill\\TaskBundle\\": "src/Bundle/ChillTaskBundle",
|
||||
"Chill\\ThirdPartyBundle\\": "src/Bundle/ChillThirdPartyBundle",
|
||||
"Chill\\AsideActivityBundle\\": "src/Bundle/ChillAsideActivityBundle/src"
|
||||
"Chill\\AsideActivityBundle\\": "src/Bundle/ChillAsideActivityBundle/src",
|
||||
"Chill\\DocGeneratorBundle\\": "src/Bundle/ChillDocGeneratorBundle"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
@ -90,4 +91,4 @@
|
||||
"config": {
|
||||
"bin-dir": "bin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ Then, render the pagination using the dedicated twig function.
|
||||
|
||||
.. code-block:: html+twig
|
||||
|
||||
{% extends "ChillPersonBundle::layout.html.twig" %}
|
||||
{% extends "@ChillPerson/Person/layout.html.twig" %}
|
||||
|
||||
{% block title 'Item list'|trans %}
|
||||
|
||||
|
@ -149,7 +149,7 @@ It proposes a new block :
|
||||
|
||||
* where to display the admin content
|
||||
|
||||
ChillPersonBundle::layout.html.twig
|
||||
@ChillPersonBundle/Person/layout.html.twig
|
||||
-----------------------------------
|
||||
|
||||
This layout extend `ChillMainBundle::layoutWithVerticalMenu.html.twig` add the person details in the block `top_banner`, set the menu `person` as the vertical menu.
|
||||
|
@ -1,14 +1,105 @@
|
||||
// Access to Bootstrap variables and mixins
|
||||
@import '~ChillMainAssets/module/bootstrap/shared';
|
||||
|
||||
//@import '~ChillMainSass/custom/mixins/entity';
|
||||
// activity creation first step: select type page
|
||||
div.new-activity-select-type {
|
||||
div.activity-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
|
||||
//.chill-entity.chill-entity__activity-reason {
|
||||
// @include entity($chill-pink, white);
|
||||
//}
|
||||
div.bloc {
|
||||
width: 200px;
|
||||
align-self: flex-end;
|
||||
height: 140px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.activity {
|
||||
//color: $chill-green;
|
||||
// exceptions for flex-table in list-records
|
||||
div.activity-list {
|
||||
div.flex-table {
|
||||
div.item-bloc {
|
||||
div.item-row.main {
|
||||
div.item-col {
|
||||
&:first-child {
|
||||
flex-basis: 27%;
|
||||
}
|
||||
ul.list-content {
|
||||
li.social-issues, li.social-actions {
|
||||
.badge-primary {
|
||||
font-variant: small-caps;
|
||||
font-weight: bold;
|
||||
font-size: 88%;
|
||||
margin-bottom: 0.2em;
|
||||
}
|
||||
}
|
||||
li.social-issues .badge-primary {
|
||||
background-color: $orange;
|
||||
}
|
||||
li.social-actions .badge-primary {
|
||||
background-color: $green;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
div.item-row.details {
|
||||
flex-direction: row;
|
||||
& > div.item-col {
|
||||
justify-content: flex-start;
|
||||
align-self: center;
|
||||
&:nth-child(1) {
|
||||
flex-grow: 1; flex-shrink: 0; flex-basis: 30%;
|
||||
}
|
||||
&:nth-child(2) {
|
||||
flex-grow: 0; flex-shrink: 1; flex-basis: 70%;
|
||||
}
|
||||
|
||||
&:only-child {
|
||||
flex-grow: 0; flex-shrink: 0; flex-basis: 100%;
|
||||
& > div.concerned-groups {
|
||||
flex-grow: 0; flex-shrink: 0; flex-basis: 100%;
|
||||
display: flex;
|
||||
flex-direction: column; // TODO pas fini
|
||||
div.group {
|
||||
flex-grow: 1; flex-shrink: 0; flex-basis: 30%;
|
||||
h4 {}
|
||||
ul.list-content {
|
||||
li {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
div.concerned-groups {
|
||||
font-size: 85%;
|
||||
h4 {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
}
|
||||
}
|
||||
ul.list-content {
|
||||
list-style-type: none;
|
||||
padding-left: 1em;
|
||||
margin: 0 0;
|
||||
li {
|
||||
margin-bottom: 0.2em;
|
||||
}
|
||||
}
|
||||
}
|
||||
div.duration {
|
||||
font-size: smaller;
|
||||
padding-left: 1em;
|
||||
margin-top: 1em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// exceptions for flex-bloc in concerned-groups
|
||||
@ -22,7 +113,7 @@ div.flex-bloc.concerned-groups {
|
||||
li {
|
||||
margin-bottom: 0.2em;
|
||||
a {
|
||||
color: white;
|
||||
color: $white;
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
color: #ffffffab;
|
||||
@ -36,97 +127,3 @@ div.flex-bloc.concerned-groups {
|
||||
}
|
||||
}
|
||||
|
||||
// exceptions for flex-table in list-records
|
||||
div.flex-table.list-records {
|
||||
div.item-bloc {
|
||||
div.item-row.main {
|
||||
div.item-col {
|
||||
&:first-child {
|
||||
flex-basis: 27%;
|
||||
}
|
||||
ul.list-content {
|
||||
li.social-issues, li.social-actions {
|
||||
.badge-primary {
|
||||
font-variant: small-caps;
|
||||
font-weight: bold;
|
||||
font-size: 88%;
|
||||
margin-bottom: 0.2em;
|
||||
}
|
||||
}
|
||||
li.social-issues .badge-primary {
|
||||
background-color: var(--chill-orange);
|
||||
}
|
||||
li.social-actions .badge-primary {
|
||||
background-color: var(--chill-green);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
div.item-row.details {
|
||||
flex-direction: row;
|
||||
& > div.item-col {
|
||||
justify-content: flex-start;
|
||||
align-self: center;
|
||||
&:nth-child(1) {
|
||||
flex-grow: 1; flex-shrink: 0; flex-basis: 30%;
|
||||
}
|
||||
&:nth-child(2) {
|
||||
flex-grow: 0; flex-shrink: 1; flex-basis: 70%;
|
||||
}
|
||||
|
||||
&:only-child {
|
||||
flex-grow: 0; flex-shrink: 0; flex-basis: 100%;
|
||||
& > div.concerned-groups {
|
||||
flex-grow: 0; flex-shrink: 0; flex-basis: 100%;
|
||||
display: flex;
|
||||
flex-direction: column; // TODO pas fini
|
||||
div.group {
|
||||
flex-grow: 1; flex-shrink: 0; flex-basis: 30%;
|
||||
h4 {}
|
||||
ul.list-content {
|
||||
li {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
div.concerned-groups {
|
||||
font-size: 85%;
|
||||
h4 {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
}
|
||||
}
|
||||
ul.list-content {
|
||||
list-style-type: none;
|
||||
padding-left: 1em;
|
||||
margin: 0 0;
|
||||
li {
|
||||
margin-bottom: 0.2em;
|
||||
}
|
||||
}
|
||||
}
|
||||
div.duration {
|
||||
font-size: smaller;
|
||||
padding-left: 1em;
|
||||
margin-top: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
div.activity-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
div.bloc {
|
||||
width: 200px;
|
||||
align-self: flex-end;
|
||||
height: 140px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,10 @@
|
||||
<li>
|
||||
<a href="{{ _self.href(bloc.path, bloc.key, item.id) }}">
|
||||
<span class="badge bg-primary">
|
||||
{{ item|chill_entity_render_box({'render': 'raw'}) }}
|
||||
{{ item|chill_entity_render_box({
|
||||
'render': 'raw',
|
||||
'addAltNames': false
|
||||
}) }}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
@ -72,7 +75,7 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if (with_display == 'row') %}
|
||||
<div class="concerned-groups">
|
||||
{% for bloc in blocs %}
|
||||
@ -84,7 +87,10 @@
|
||||
<li>
|
||||
<a href="{{ _self.href(bloc.path, bloc.key, item.id) }}">
|
||||
<span class="badge bg-primary">
|
||||
{{ item|chill_entity_render_box({'only_denomination': true}) }}
|
||||
{{ item|chill_entity_render_box({
|
||||
'render': 'raw',
|
||||
'addAltNames': false
|
||||
}) }}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
|
@ -54,7 +54,7 @@
|
||||
{{ form_row(edit_form.date) }}
|
||||
{% endif %}
|
||||
|
||||
.. location
|
||||
{# TODO .. location #}
|
||||
|
||||
{%- if edit_form.durationTime is defined -%}
|
||||
{{ form_row(edit_form.durationTime) }}
|
||||
@ -65,7 +65,7 @@
|
||||
{% endif %}
|
||||
|
||||
{%- if edit_form.comment is defined -%}
|
||||
.. public and private
|
||||
{# TODO .. public and private #}
|
||||
{{ form_row(edit_form.comment) }}
|
||||
{% endif %}
|
||||
|
||||
@ -77,7 +77,7 @@
|
||||
{{ form_row(edit_form.attendee) }}
|
||||
{% endif %}
|
||||
|
||||
.. status
|
||||
{# TODO .. status #}
|
||||
|
||||
{% set person_id = null %}
|
||||
{% if entity.person %}
|
||||
|
@ -1,184 +1,163 @@
|
||||
{% set person_id = null %}
|
||||
{% if person %}
|
||||
{% set person_id = person.id %}
|
||||
{% endif %}
|
||||
<div class="activity-list context-{{ context }}">
|
||||
|
||||
{% set accompanying_course_id = null %}
|
||||
{% if accompanyingCourse %}
|
||||
{% set accompanying_course_id = accompanyingCourse.id %}
|
||||
{% endif %}
|
||||
{% if activities|length == 0 %}
|
||||
<p class="chill-no-data-statement">
|
||||
{{ "There isn't any activities."|trans }}
|
||||
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'accompanying_period_id': accompanying_course_id}) }}" class="btn btn-sm btn-create"></a>
|
||||
</p>
|
||||
|
||||
<h2>{{ 'Activity list' |trans }}</h2>
|
||||
{% else %}
|
||||
<div class="flex-table">
|
||||
{% for activity in activities %}
|
||||
{% set t = activity.type %}
|
||||
<div class="item-bloc">
|
||||
<div class="item-row main">
|
||||
<div class="item-col">
|
||||
|
||||
{% if activities|length == 0 %}
|
||||
<p class="chill-no-data-statement">
|
||||
{{ "There isn't any activities."|trans }}
|
||||
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'accompanying_period_id': accompanying_course_id}) }}" class="btn btn-create button-small"></a>
|
||||
</p>
|
||||
{% else %}
|
||||
|
||||
<div class="flex-table list-records context-{{ context }}">
|
||||
|
||||
{% for activity in activities %}
|
||||
{% set t = activity.type %}
|
||||
<div class="item-bloc">
|
||||
<div class="item-row main">
|
||||
<div class="item-col">
|
||||
|
||||
{% if activity.date %}
|
||||
<h3>{{ activity.date|format_date('long') }}</h3>
|
||||
{% endif %}
|
||||
|
||||
<div class="duration">
|
||||
{% if t.durationTimeVisible > 0 %}
|
||||
<p>
|
||||
<i class="fa fa-fw fa-hourglass-end"></i>
|
||||
{{ activity.durationTime|date('H:i') }}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if activity.travelTime and t.travelTimeVisible %}
|
||||
<p>
|
||||
<i class="fa fa-fw fa-car"></i>
|
||||
{{ activity.travelTime|date('H:i') }}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if context == 'person' and activity.accompanyingPeriod is not empty %}
|
||||
<div class="accompanyingPeriodLink" style="margin-top: 1rem">
|
||||
<a href="{{ chill_path_add_return_path(
|
||||
"chill_person_accompanying_course_index",
|
||||
{ 'accompanying_period_id': activity.accompanyingPeriod.id }
|
||||
) }}">
|
||||
<i class="fa fa-random"></i>
|
||||
{{ activity.accompanyingPeriod.id }}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
<div class="item-col">
|
||||
<ul class="list-content">
|
||||
{% if activity.user and t.userVisible %}
|
||||
<li>
|
||||
<b>{{ 'by'|trans }}{{ activity.user.usernameCanonical }}</b>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
<li>
|
||||
<b>{{ activity.type.name | localize_translatable_string }}</b>
|
||||
|
||||
{% if activity.attendee is not null and t.attendeeVisible %}
|
||||
{% if activity.attendee %}
|
||||
{{ '→ ' ~ 'present'|trans|capitalize }}
|
||||
{% else %}
|
||||
{{ '→ ' ~ 'not present'|trans|capitalize }}
|
||||
{% endif %}
|
||||
{% if activity.date %}
|
||||
<h3>{{ activity.date|format_date('long') }}</h3>
|
||||
{% endif %}
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<b>{{ 'location'|trans ~ ': ' }}</b>
|
||||
Domicile de l'usager
|
||||
{#
|
||||
{% if activity.location %}{{ activity.location }}{% endif %}
|
||||
#}
|
||||
</li>
|
||||
<div class="duration">
|
||||
{% if t.durationTimeVisible > 0 %}
|
||||
<p>
|
||||
<i class="fa fa-fw fa-hourglass-end"></i>
|
||||
{{ activity.durationTime|date('H:i') }}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if activity.travelTime and t.travelTimeVisible %}
|
||||
<p>
|
||||
<i class="fa fa-fw fa-car"></i>
|
||||
{{ activity.travelTime|date('H:i') }}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{%- if t.reasonsVisible -%}
|
||||
<li>
|
||||
{%- if activity.reasons is empty -%}
|
||||
<span class="chill-no-data-statement">{{ 'No reason associated'|trans }}</span>
|
||||
{%- else -%}
|
||||
{% for r in activity.reasons %}
|
||||
{{ r|chill_entity_render_box }}
|
||||
{% endfor %}
|
||||
{%- endif -%}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if context == 'person' and activity.accompanyingPeriod is not empty %}
|
||||
<div class="accompanyingPeriodLink" style="margin-top: 1rem">
|
||||
<a href="{{ chill_path_add_return_path(
|
||||
"chill_person_accompanying_course_index",
|
||||
{ 'accompanying_period_id': activity.accompanyingPeriod.id }
|
||||
) }}">
|
||||
<i class="fa fa-random"></i>
|
||||
{{ activity.accompanyingPeriod.id }}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{%- if t.socialIssuesVisible %}
|
||||
<li class="social-issues">
|
||||
{%- if activity.socialIssues is empty -%}
|
||||
<span class="chill-no-data-statement">{{ 'No social issues associated'|trans }}</span>
|
||||
{%- else -%}
|
||||
{% for r in activity.socialIssues %}
|
||||
{{ r|chill_entity_render_box }}
|
||||
{% endfor %}
|
||||
{%- endif -%}
|
||||
</li>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="item-col">
|
||||
<ul class="list-content">
|
||||
{% if activity.user and t.userVisible %}
|
||||
<li>
|
||||
<b>{{ 'by'|trans }}{{ activity.user.usernameCanonical }}</b>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{%- if t.socialActionsVisible -%}
|
||||
<li class="social-actions">
|
||||
{%- if activity.socialActions is empty -%}
|
||||
<span class="chill-no-data-statement">{{ 'No social actions associated'|trans }}</span>
|
||||
{%- else -%}
|
||||
{% for r in activity.socialActions %}
|
||||
<span class="badge bg-primary">{{ r.title|localize_translatable_string }}</span>
|
||||
{% endfor %}
|
||||
{%- endif -%}
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>
|
||||
<b>{{ activity.type.name | localize_translatable_string }}</b>
|
||||
|
||||
{% if activity.attendee is not null and t.attendeeVisible %}
|
||||
{% if activity.attendee %}
|
||||
{{ '→ ' ~ 'present'|trans|capitalize }}
|
||||
{% else %}
|
||||
{{ '→ ' ~ 'not present'|trans|capitalize }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<b>{{ 'location'|trans ~ ': ' }}</b>
|
||||
Domicile de l'usager
|
||||
{#
|
||||
{% if activity.location %}{{ activity.location }}{% endif %}
|
||||
#}
|
||||
</li>
|
||||
|
||||
{%- if t.reasonsVisible -%}
|
||||
<li>
|
||||
{%- if activity.reasons is not empty -%}
|
||||
{% for r in activity.reasons %}
|
||||
{{ r|chill_entity_render_box }}
|
||||
{% endfor %}
|
||||
{%- endif -%}
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{%- if t.socialIssuesVisible %}
|
||||
<li class="social-issues">
|
||||
{%- if activity.socialIssues is not empty -%}
|
||||
{% for r in activity.socialIssues %}
|
||||
{{ r|chill_entity_render_box }}
|
||||
{% endfor %}
|
||||
{%- endif -%}
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{%- if t.socialActionsVisible -%}
|
||||
<li class="social-actions">
|
||||
{%- if activity.socialActions is not empty -%}
|
||||
{% for r in activity.socialActions %}
|
||||
<span class="badge bg-primary">{{ r.title|localize_translatable_string }}</span>
|
||||
{% endfor %}
|
||||
{%- endif -%}
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
|
||||
</ul>
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a href="{{ path('chill_activity_activity_show', { 'id': activity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id }) }}" class="btn btn-show "></a>
|
||||
</li>
|
||||
{# TOOD
|
||||
</ul>
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a href="{{ path('chill_activity_activity_show', { 'id': activity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id }) }}"
|
||||
class="btn btn-sm btn-show "></a>
|
||||
</li>
|
||||
{# TOOD
|
||||
{% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %}
|
||||
#}
|
||||
<li>
|
||||
<a href="{{ path('chill_activity_activity_edit', { 'id': activity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id }) }}" class="btn btn-update "></a>
|
||||
</li>
|
||||
{# TOOD
|
||||
#}
|
||||
<li>
|
||||
<a href="{{ path('chill_activity_activity_edit', { 'id': activity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id }) }}"
|
||||
class="btn btn-sm btn-update "></a>
|
||||
</li>
|
||||
{# TOOD
|
||||
{% endif %}
|
||||
{% if is_granted('CHILL_ACTIVITY_DELETE', activity) %}
|
||||
#}
|
||||
<li>
|
||||
<a href="{{ path('chill_activity_activity_delete', { 'id': activity.id, 'person_id' : person_id, 'accompanying_period_id': accompanying_course_id } ) }}" class="btn btn-delete "></a>
|
||||
</li>
|
||||
{#
|
||||
{% endif %}
|
||||
#}
|
||||
</ul>
|
||||
#}
|
||||
<li>
|
||||
<a href="{{ path('chill_activity_activity_delete', { 'id': activity.id, 'person_id' : person_id, 'accompanying_period_id': accompanying_course_id } ) }}"
|
||||
class="btn btn-sm btn-delete "></a>
|
||||
</li>
|
||||
{#
|
||||
{% endif %}
|
||||
#}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if activity.comment.comment is not empty
|
||||
or activity.persons|length > 0
|
||||
or activity.thirdParties|length > 0
|
||||
or activity.users|length > 0
|
||||
%}
|
||||
<div class="item-row details">
|
||||
<div class="item-col">
|
||||
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'row', 'entity': activity } %}
|
||||
</div>
|
||||
|
||||
{% if activity.comment.comment is not empty %}
|
||||
<div class="item-col">
|
||||
{{ activity.comment|chill_entity_render_box({
|
||||
'disable_markdown': false,
|
||||
'limit_lines': 3,
|
||||
'metadata': false,
|
||||
}) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{%
|
||||
if activity.comment.comment is not empty
|
||||
or activity.persons|length > 0
|
||||
or activity.thirdParties|length > 0
|
||||
or activity.users|length > 0
|
||||
%}
|
||||
<div class="item-row details">
|
||||
<div class="item-col">
|
||||
|
||||
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'row', 'entity': activity } %}
|
||||
</div>
|
||||
|
||||
{% if activity.comment.comment is not empty %}
|
||||
<div class="item-col comment">
|
||||
{{ activity.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if context != 'person' %}
|
||||
{# TODO set this condition in configuration #}
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'accompanying_period_id': accompanying_course_id}) }}" class="btn btn-create">
|
||||
{{ 'Add a new activity' | trans }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@ -5,5 +5,27 @@
|
||||
{% block title %}{{ 'Activity list' |trans }}{% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% set person_id = null %}
|
||||
{% if person %}
|
||||
{% set person_id = person.id %}
|
||||
{% endif %}
|
||||
|
||||
{% set accompanying_course_id = null %}
|
||||
{% if accompanyingCourse %}
|
||||
{% set accompanying_course_id = accompanyingCourse.id %}
|
||||
{% endif %}
|
||||
|
||||
<h1>{{ 'Activity list' |trans }}</h1>
|
||||
|
||||
{% include 'ChillActivityBundle:Activity:list.html.twig' with {'context': 'accompanyingCourse'} %}
|
||||
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'accompanying_period_id': accompanying_course_id}) }}" class="btn btn-create">
|
||||
{{ 'Add a new activity' | trans }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
|
@ -21,5 +21,27 @@
|
||||
{% block title %}{{ 'Activity list' |trans }}{% endblock title %}
|
||||
|
||||
{% block personcontent %}
|
||||
|
||||
{% set person_id = null %}
|
||||
{% if person %}
|
||||
{% set person_id = person.id %}
|
||||
{% endif %}
|
||||
|
||||
{% set accompanying_course_id = null %}
|
||||
{% if accompanyingCourse %}
|
||||
{% set accompanying_course_id = accompanyingCourse.id %}
|
||||
{% endif %}
|
||||
|
||||
<h1>{{ 'Activity list' |trans }}</h1>
|
||||
|
||||
{% include 'ChillActivityBundle:Activity:list.html.twig' with {'context': 'person'} %}
|
||||
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'accompanying_period_id': accompanying_course_id}) }}"
|
||||
class="btn btn-create disabled" tabindex="-1" role="button" aria-disabled="true">{{ 'Add a new activity' | trans }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
|
@ -55,7 +55,7 @@
|
||||
{{ form_row(form.date) }}
|
||||
{% endif %}
|
||||
|
||||
.. location
|
||||
{# TODO .. location #}
|
||||
|
||||
{%- if form.durationTime is defined -%}
|
||||
{{ form_row(form.durationTime) }}
|
||||
@ -66,7 +66,7 @@
|
||||
{% endif %}
|
||||
|
||||
{%- if form.comment is defined -%}
|
||||
.. public and private
|
||||
{# TODO .. public and private #}
|
||||
{{ form_row(form.comment) }}
|
||||
{% endif %}
|
||||
|
||||
@ -78,13 +78,13 @@
|
||||
{{ form_row(form.attendee) }}
|
||||
{% endif %}
|
||||
|
||||
.. status
|
||||
{# TODO .. status #}
|
||||
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
<li class="cancel">
|
||||
<a
|
||||
<a
|
||||
class="btn btn-cancel"
|
||||
{%- if context == 'person' -%}
|
||||
{%- if context == 'person' -%}
|
||||
href="{{ chill_return_path_or('chill_activity_activity_list', { 'person_id': person.id } )}}"
|
||||
{%- else -%}
|
||||
href="{{ chill_return_path_or('chill_activity_activity_list', { 'accompanying_period_id': accompanyingCourse.id } )}}"
|
||||
|
@ -1,28 +1,30 @@
|
||||
<h2 class="chill-red">{{ "Activity creation"|trans }}</h2>
|
||||
<div class="new-activity-select-type">
|
||||
<h2 class="chill-red">{{ "Activity creation"|trans }}</h2>
|
||||
|
||||
{# TODO: refaire l'html css des tuilles #}
|
||||
{# TODO: refaire l'html css des tuilles #}
|
||||
|
||||
{% for row in data %}
|
||||
<h3>{{ row.activityTypeCategory.name|localize_translatable_string }}</h3>
|
||||
<div class="activity-row">
|
||||
{% for activityType in row.activityTypes %}
|
||||
{% for row in data %}
|
||||
<h3>{{ row.activityTypeCategory.name|localize_translatable_string }}</h3>
|
||||
<div class="activity-row">
|
||||
{% for activityType in row.activityTypes %}
|
||||
|
||||
{% set person_id = null %}
|
||||
{% if person %}
|
||||
{% set person_id = person.id %}
|
||||
{% endif %}
|
||||
{% set person_id = null %}
|
||||
{% if person %}
|
||||
{% set person_id = person.id %}
|
||||
{% endif %}
|
||||
|
||||
{% set accompanying_course_id = null %}
|
||||
{% if accompanyingCourse %}
|
||||
{% set accompanying_course_id = accompanyingCourse.id %}
|
||||
{% endif %}
|
||||
{% set accompanying_course_id = null %}
|
||||
{% if accompanyingCourse %}
|
||||
{% set accompanying_course_id = accompanyingCourse.id %}
|
||||
{% endif %}
|
||||
|
||||
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'activityType_id': activityType.id, 'accompanying_period_id': accompanying_course_id }) }}">
|
||||
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'activityType_id': activityType.id, 'accompanying_period_id': accompanying_course_id }) }}">
|
||||
|
||||
<div class="bloc btn btn-primary btn-lg btn-block">
|
||||
{{ activityType.name|localize_translatable_string }}
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="bloc btn btn-primary btn-lg btn-block">
|
||||
{{ activityType.name|localize_translatable_string }}
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
@ -81,9 +81,9 @@ activity:
|
||||
'%user% has done an %activity_type%': '%user% a effectué une activité de type "%activity_type%"'
|
||||
|
||||
#controller
|
||||
'Success : activity created!': Bravo ! L'activité a été créée.
|
||||
'Success : activity created!': L'activité a été créée.
|
||||
'The form is not valid. The activity has not been created !': Le formulaire est invalide. L'activité n'a pas été créée.
|
||||
'Success : activity updated!': Bravo ! L'activité a été mise à jour.
|
||||
'Success : activity updated!': L'activité a été mise à jour.
|
||||
'The form is not valid. The activity has not been updated !': Le formulaire est invalide. L'activité n'a pas été mise à jour.
|
||||
|
||||
# ROLES
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Application\Migrations;
|
||||
namespace Chill\Migrations\AsideActivity;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Application\Migrations;
|
||||
namespace Chill\Migrations\AsideActivity;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Application\Migrations;
|
||||
namespace Chill\Migrations\AsideActivity;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Application\Migrations;
|
||||
namespace Chill\Migrations\AsideActivity;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
@ -43,6 +43,6 @@ final class Version20210810084456 extends AbstractMigration
|
||||
$this->addSql('COMMENT ON COLUMN chill_asideactivity.AsideActivity.createdat IS \'(DC2Type:datetime_immutable)\'');
|
||||
$this->addSql('COMMENT ON COLUMN chill_asideactivity.AsideActivity.updatedat IS \'(DC2Type:datetime_immutable)\'');
|
||||
$this->addSql('COMMENT ON COLUMN chill_asideactivity.AsideActivity.date IS \'(DC2Type:datetime_immutable)\'');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
11
src/Bundle/ChillDocGeneratorBundle/.gitignore
vendored
Normal file
11
src/Bundle/ChillDocGeneratorBundle/.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
composer.lock
|
||||
vendor/*
|
||||
parameters.yml
|
||||
*~
|
||||
*.DS_Store
|
||||
*.sass-cache
|
||||
Resources/node_modules/
|
||||
Tests/Fixtures/App/app/config/parameters.yml
|
||||
/nbproject/private/
|
||||
Resources/test/Fixtures/App/bootstrap.php.cache
|
||||
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocGeneratorBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class ChillDocGeneratorBundle extends Bundle
|
||||
{
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocGeneratorBundle\Context;
|
||||
|
||||
/**
|
||||
* Interface for context for for document generation
|
||||
*/
|
||||
interface DocGeneratorContextInterface
|
||||
{
|
||||
/**
|
||||
* has form
|
||||
*/
|
||||
public function hasForm(): bool;
|
||||
|
||||
/**
|
||||
* Generate the form that display
|
||||
*/
|
||||
public function getForm($entity);
|
||||
|
||||
/**
|
||||
* True of false which entity supports
|
||||
*/
|
||||
public function supports(string $entityClass): bool;
|
||||
|
||||
/**
|
||||
* Get the data that will be injected to the generated document
|
||||
*/
|
||||
public function getData($entity): array;
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocGeneratorBundle\Context;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
|
||||
/**
|
||||
* Context that display a form to select a member of a houseHold
|
||||
*/
|
||||
class HouseholdMemberSelectionContext implements DocGeneratorContextInterface
|
||||
{
|
||||
/**
|
||||
* has form
|
||||
*/
|
||||
public function hasForm(): bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the form that display
|
||||
*/
|
||||
public function getForm($entity) {
|
||||
// TODO Get FormFactory and create a form
|
||||
|
||||
|
||||
// access to the house hold for the AccompanyingPeriod pr the SocialAction
|
||||
// and configure the form to select member of the family
|
||||
}
|
||||
|
||||
/**
|
||||
* True of false which entity supports
|
||||
*/
|
||||
public function supports(string $entityClass): bool {
|
||||
return
|
||||
($entityClass == AccompanyingPeriod::class) ||
|
||||
($entityClass == SocialAction::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data that will be injected to the generated document
|
||||
*/
|
||||
public function getData($entity): array {
|
||||
$ret = [];
|
||||
|
||||
if(get_class($entity) == AccompanyingPeriod::class) {
|
||||
// TODO mettre ça dans un service
|
||||
$ret = ['AccompanyingPeriod' => $entity];
|
||||
} elseif(get_class($entity) == SocialAction::class) {
|
||||
$ret = ['SocialAction' => $entity];
|
||||
}
|
||||
|
||||
// TODO AJOUTER LES DONNES DU FORMULAIRE
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocGeneratorBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
|
||||
class AdminDocGeneratorTemplateController extends CRUDController
|
||||
{
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocGeneratorBundle\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\HeaderUtils;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlOpenstackGenerator;
|
||||
use PhpOffice\PhpWord\TemplateProcessor;
|
||||
|
||||
/**
|
||||
* Class DocGeneratorController
|
||||
*
|
||||
* @package Chill\DocGenerator\Controller
|
||||
*/
|
||||
class DocGeneratorController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route(
|
||||
* "{_locale}/doc/gen/test",
|
||||
* name="chill_docgenerator_test"
|
||||
* )
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function testAction()
|
||||
{
|
||||
return (new Response())
|
||||
->setContent('Test');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "{_locale}/doc/gen/test",
|
||||
* name="chill_docgenerator_test"
|
||||
* )
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function getDoc(Request $request, TempUrlOpenstackGenerator $tempUrlGenerator)
|
||||
{
|
||||
$p = $tempUrlGenerator->generate(
|
||||
'GET',
|
||||
'FORMULAIRE_AEB.docx',
|
||||
$request->query->has('expires_delay') ? $request->query->getInt('expires_delay', 0) : null
|
||||
);
|
||||
|
||||
$tmpfname = tempnam(sys_get_temp_dir(), 'DOC_TEMPLATE');
|
||||
file_put_contents($tmpfname, file_get_contents($p->{"url"}));
|
||||
|
||||
$templateProcessor = new TemplateProcessor($tmpfname);
|
||||
$templateProcessor->setValues(array('firstname' => 'John', 'lastname' => 'Doe'));
|
||||
|
||||
$tmpfname2 = tempnam(sys_get_temp_dir(), 'DOC_GENERATED');
|
||||
$templateProcessor->saveAs($tmpfname2);
|
||||
|
||||
unlink($tmpfname);
|
||||
|
||||
$fileContent = fopen($tmpfname2, 'r'); // the generated file content
|
||||
$response = new Response(fread($fileContent, filesize($tmpfname2)));
|
||||
|
||||
$disposition = HeaderUtils::makeDisposition(
|
||||
HeaderUtils::DISPOSITION_ATTACHMENT,
|
||||
'foo.docx'
|
||||
);
|
||||
|
||||
$response->headers->set('Content-Disposition', $disposition);
|
||||
unlink($tmpfname2);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocGeneratorBundle\DataFixtures\ORM;
|
||||
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
|
||||
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
|
||||
/**
|
||||
* Load DocGeneratorTemplate
|
||||
*
|
||||
* @author Champs-Libres Coop
|
||||
*/
|
||||
class LoadDocGeneratorTemplate extends AbstractFixture
|
||||
{
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
$templates = [
|
||||
[
|
||||
'name' => ['fr' => 'FORMULAIRE AEB'],
|
||||
'desc' => 'stocké sur openstack comedienbe',
|
||||
'file' => 'FORMULAIRE_AEB.docx',
|
||||
'context' => 'Chill\DocGeneratorBundle\Context\HouseholdMemberSelectionContext',
|
||||
'entities' => ['Chill\PersonBundle\Entity\AccompanyingPeriod', 'Chill\PersonBundle\Entity\SocialWork\SocialAction'],
|
||||
], [
|
||||
'name' => ['fr' => 'AIDE ALIMENTAIRE'],
|
||||
'desc' => 'stocké sur openstack comedienbe',
|
||||
'file' => 'AIDE_ALIMENTAIRE.docx',
|
||||
'context' => 'Chill\DocGeneratorBundle\Context\HouseholdMemberSelectionContext',
|
||||
'entities' => ['Chill\PersonBundle\Entity\AccompanyingPeriod', 'Chill\PersonBundle\Entity\SocialWork\SocialAction'],
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($templates as $template) {
|
||||
|
||||
print('Adding doc generator templates '.$template['file'].")\n");
|
||||
|
||||
$newTemplate = (new DocGeneratorTemplate())
|
||||
->setName($template['name'])
|
||||
->setDescription($template['desc'])
|
||||
->setFile($template['file'])
|
||||
->setContext($template['context'])
|
||||
->setEntities($template['entities'])
|
||||
;
|
||||
|
||||
$manager->persist($newTemplate);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocGeneratorBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\Loader;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
|
||||
/**
|
||||
* This is the class that loads and manages your bundle configuration.
|
||||
*
|
||||
* @link http://symfony.com/doc/current/cookbook/bundles/extension.html
|
||||
*/
|
||||
class ChillDocGeneratorExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$configuration = new Configuration();
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('services.yml');
|
||||
$loader->load('services/controller.yml');
|
||||
$loader->load('services/fixtures.yml');
|
||||
$loader->load('services/form.yml');
|
||||
}
|
||||
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
$this->preprendRoutes($container);
|
||||
$this->prependCruds($container);
|
||||
}
|
||||
|
||||
protected function preprendRoutes(ContainerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('chill_main', array(
|
||||
'routing' => array(
|
||||
'resources' => array(
|
||||
'@ChillDocGeneratorBundle/Resources/config/routes.yml'
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
*/
|
||||
protected function prependCruds(ContainerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('chill_main', [
|
||||
'cruds' => [
|
||||
[
|
||||
'class' => \Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate::class,
|
||||
'name' => 'docgen_template',
|
||||
'base_path' => '/admin/docgen/template',
|
||||
'form_class' => \Chill\DocGeneratorBundle\Form\DocGeneratorTemplateType::class,
|
||||
'controller' => \Chill\DocGeneratorBundle\Controller\AdminDocGeneratorTemplateController::class,
|
||||
'actions' => [
|
||||
'index' => [
|
||||
'template' => '@ChillDocGenerator/Admin/DocGeneratorTemplate/index.html.twig',
|
||||
'role' => 'ROLE_ADMIN'
|
||||
],
|
||||
'new' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillDocGenerator/Admin/DocGeneratorTemplate/new.html.twig',
|
||||
],
|
||||
'edit' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillDocGenerator/Admin/DocGeneratorTemplate/edit.html.twig',
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocGeneratorBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
/**
|
||||
* This is the class that validates and merges configuration from your app/config files.
|
||||
*
|
||||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_calendar');
|
||||
$rootNode = $treeBuilder->getRootNode('chill_calendar');
|
||||
|
||||
// Here you should define the parameters that are allowed to
|
||||
// configure your bundle. See the documentation linked above for
|
||||
// more information on that topic.
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocGeneratorBundle\Entity;
|
||||
|
||||
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=DocGeneratorTemplateRepository::class)
|
||||
* @ORM\Table(name="chill_docgen_template")
|
||||
|
||||
*/
|
||||
class DocGeneratorTemplate
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private int $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json_array")
|
||||
*/
|
||||
private array $name = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
private string $description;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="simple_array")
|
||||
*
|
||||
* Class name of the entities for which this template can be used
|
||||
*
|
||||
* so if $entities = ['Chill\PersonBundle\Entity\AccompanyingPeriod', 'Chill\PersonBundle\Entity\SocialWork\SocialAction']
|
||||
* this template can be selected for an AccompanyingPeriod or a SocialAction
|
||||
*/
|
||||
private array $entities = [];
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*
|
||||
* Class name of the context to use
|
||||
*
|
||||
* so if $context = ''
|
||||
* this template will use '' as context
|
||||
*/
|
||||
private string $context;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private string $file;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?array
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(array $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription(?string $description): self
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFile(): ?string
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
public function setFile(string $file): self
|
||||
{
|
||||
$this->file = $file;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEntities(): ?array
|
||||
{
|
||||
return $this->entities;
|
||||
}
|
||||
|
||||
public function setEntities(array $entities): self
|
||||
{
|
||||
$this->entities = $entities;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContext(): ?string
|
||||
{
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
public function setContext(string $context): self
|
||||
{
|
||||
$this->context = $context;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocGeneratorBundle\Form;
|
||||
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||
|
||||
|
||||
class DocGeneratorTemplateType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* @param FormBuilderInterface $builder
|
||||
* @param array $options
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('name', TranslatableStringFormType::class, [
|
||||
'label' => 'Nom'
|
||||
])
|
||||
->add('description')
|
||||
->add('file')
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OptionsResolver $resolver
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver
|
||||
->setDefault('class', DocGeneratorTemplate::class)
|
||||
;
|
||||
}
|
||||
}
|
661
src/Bundle/ChillDocGeneratorBundle/LICENSE
Normal file
661
src/Bundle/ChillDocGeneratorBundle/LICENSE
Normal file
@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
5
src/Bundle/ChillDocGeneratorBundle/README.md
Normal file
5
src/Bundle/ChillDocGeneratorBundle/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
Doc generator bundle
|
||||
====================
|
||||
|
||||
This bundle generates documents (from templates)
|
||||
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocGeneratorBundle\Repository;
|
||||
|
||||
use App\Entity\DocGeneratorTemplate;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method DocGeneratorTemplate|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method DocGeneratorTemplate|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method DocGeneratorTemplate[] findAll()
|
||||
* @method DocGeneratorTemplate[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class DocGeneratorTemplateRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, DocGeneratorTemplate::class);
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
chill_docgen_controllers:
|
||||
resource: '../../Controller/'
|
||||
type: annotation
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
services:
|
||||
|
||||
Chill\DocGeneratorBundle\Repository\:
|
||||
autowire: true
|
||||
resource: '../../Repository/'
|
||||
tags:
|
||||
- { name: 'doctrine.repository_service' }
|
@ -0,0 +1,5 @@
|
||||
services:
|
||||
Chill\DocGeneratorBundle\Controller\:
|
||||
autowire: true
|
||||
resource: '../../../Controller'
|
||||
tags: ['controller.service_arguments']
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
services:
|
||||
Chill\DocGeneratorBundle\DataFixtures\ORM\:
|
||||
autowire: true
|
||||
resource: ../../DataFixtures/ORM
|
||||
tags: [ 'doctrine.fixture.orm' ]
|
@ -0,0 +1,2 @@
|
||||
---
|
||||
services:
|
@ -0,0 +1,12 @@
|
||||
{% extends '@ChillPerson/Admin/layout.html.twig' %}
|
||||
|
||||
{% block title %}
|
||||
{% include('@ChillMain/CRUD/_edit_title.html.twig') %}
|
||||
{% endblock %}
|
||||
|
||||
{% block layout_wvm_content %}
|
||||
{% embed '@ChillMain/CRUD/_edit_content.html.twig' %}
|
||||
{% block content_form_actions_view %}{% endblock %}
|
||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
@ -0,0 +1,19 @@
|
||||
{% extends '@ChillPerson/Admin/layout.html.twig' %}
|
||||
|
||||
{% block layout_wvm_content %}
|
||||
{% embed '@ChillMain/CRUD/_index.html.twig' %}
|
||||
{% block table_entities_thead_tr %}
|
||||
<th>{{ 'Title'|trans }}</th>
|
||||
<th>{{ 'File'|trans }}</th>
|
||||
{% endblock %}
|
||||
|
||||
{% block table_entities_tbody %}
|
||||
{% for entity in entities %}
|
||||
<tr>
|
||||
<td>{{ entity.name | localize_translatable_string }}</td>
|
||||
<td>{{ entity.file }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
@ -0,0 +1,11 @@
|
||||
{% extends '@ChillPerson/Admin/layout.html.twig' %}
|
||||
|
||||
{% block title %}
|
||||
{% include('@ChillMain/CRUD/_new_title.html.twig') %}
|
||||
{% endblock %}
|
||||
|
||||
{% block layout_wvm_content %}
|
||||
{% embed '@ChillMain/CRUD/_new_content.html.twig' %}
|
||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
@ -0,0 +1,6 @@
|
||||
// this file loads all assets from the Chill DocGenerator bundle
|
||||
module.exports = function(encore, entries) {
|
||||
encore.addAliases({
|
||||
ChillDocGeneratorAssets: __dirname + '/Resources/public'
|
||||
});
|
||||
};
|
30
src/Bundle/ChillDocGeneratorBundle/composer.json
Normal file
30
src/Bundle/ChillDocGeneratorBundle/composer.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "chill-project/docgen",
|
||||
"description": "This bundle extends chill for generation of documents",
|
||||
"type": "symfony-bundle",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"keywords" : ["chill", "social work"],
|
||||
"homepage" : "hhttps://gitlab.com/Chill-Projet/chill-bundles/",
|
||||
"autoload": {
|
||||
"psr-4": { "Chill\\DocGeneratorBundle\\": "" }
|
||||
},
|
||||
"autoload-dev": {
|
||||
"classmap": [ "Resources/test/Fixtures/App/app/AppKernel.php" ]
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Champs-Libres",
|
||||
"email": "info@champs-libres.coop"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
},
|
||||
"require-dev": {
|
||||
},
|
||||
"extra": {
|
||||
"app-migrations-dir": "Resources/test/Fixtures/App/app/DoctrineMigrations",
|
||||
"symfony-app-dir": "Test/Fixtures/App/app/"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\DocGenerator;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Creation of table for storing DocGenTemplate
|
||||
*/
|
||||
final class Version20210805162522 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Creation of table for storing DocGenTemplate';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE SEQUENCE chill_docgen_template_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE TABLE chill_docgen_template (id INT NOT NULL, name JSON NOT NULL, description TEXT DEFAULT NULL, file VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP SEQUENCE chill_docgen_template_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_docgen_template');
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\DocGenerator;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add entities and context fields to DocGenTemplate
|
||||
*/
|
||||
final class Version20210812214310 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add entities and context fields to DocGenTemplate';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_docgen_template ADD entities TEXT');
|
||||
$this->addSql('ALTER TABLE chill_docgen_template ADD context VARCHAR(255)');
|
||||
$this->addSql('COMMENT ON COLUMN chill_docgen_template.entities IS \'(DC2Type:simple_array)\'');
|
||||
$this->addSql('COMMENT ON COLUMN chill_docgen_template.name IS \'(DC2Type:json_array)\'');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_docgen_template DROP entities');
|
||||
$this->addSql('ALTER TABLE chill_docgen_template DROP context');
|
||||
$this->addSql('COMMENT ON COLUMN chill_docgen_template.name IS NULL');
|
||||
}
|
||||
}
|
@ -22,7 +22,9 @@
|
||||
|
||||
namespace Chill\MainBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\Search\SearchApiNoQueryException;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Chill\MainBundle\Search\UnknowSearchDomainException;
|
||||
@ -33,6 +35,7 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Chill\MainBundle\Search\SearchProvider;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Search\SearchApi;
|
||||
@ -46,15 +49,15 @@ use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||
class SearchController extends AbstractController
|
||||
{
|
||||
protected SearchProvider $searchProvider;
|
||||
|
||||
|
||||
protected TranslatorInterface $translator;
|
||||
|
||||
|
||||
protected PaginatorFactory $paginatorFactory;
|
||||
|
||||
protected SearchApi $searchApi;
|
||||
|
||||
|
||||
function __construct(
|
||||
SearchProvider $searchProvider,
|
||||
SearchProvider $searchProvider,
|
||||
TranslatorInterface $translator,
|
||||
PaginatorFactory $paginatorFactory,
|
||||
SearchApi $searchApi
|
||||
@ -65,14 +68,14 @@ class SearchController extends AbstractController
|
||||
$this->searchApi = $searchApi;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function searchAction(Request $request, $_format)
|
||||
{
|
||||
$pattern = $request->query->get('q', '');
|
||||
|
||||
|
||||
if ($pattern === ''){
|
||||
switch($_format) {
|
||||
case 'html':
|
||||
case 'html':
|
||||
return $this->render('@ChillMain/Search/error.html.twig',
|
||||
array(
|
||||
'message' => $this->translator->trans("Your search is empty. "
|
||||
@ -86,16 +89,16 @@ class SearchController extends AbstractController
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$name = $request->query->get('name', NULL);
|
||||
|
||||
|
||||
try {
|
||||
if ($name === NULL) {
|
||||
if ($_format === 'json') {
|
||||
return new JsonResponse('Currently, we still do not aggregate results '
|
||||
. 'from different providers', JsonResponse::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
|
||||
// no specific search selected. Rendering result in "preview" mode
|
||||
$results = $this->searchProvider
|
||||
->getSearchResults(
|
||||
@ -119,7 +122,7 @@ class SearchController extends AbstractController
|
||||
),
|
||||
$_format
|
||||
)];
|
||||
|
||||
|
||||
if ($_format === 'json') {
|
||||
return new JsonResponse(\reset($results));
|
||||
}
|
||||
@ -141,8 +144,8 @@ class SearchController extends AbstractController
|
||||
'pattern' => $pattern
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return $this->render('@ChillMain/Search/list.html.twig',
|
||||
array('results' => $results, 'pattern' => $pattern)
|
||||
);
|
||||
@ -159,29 +162,33 @@ class SearchController extends AbstractController
|
||||
." one type");
|
||||
}
|
||||
|
||||
$collection = $this->searchApi->getResults($query, $types, []);
|
||||
try {
|
||||
$collection = $this->searchApi->getResults($query, $types, []);
|
||||
} catch (SearchApiNoQueryException $e) {
|
||||
throw new BadRequestHttpException($e->getMessage(), $e);
|
||||
}
|
||||
|
||||
return $this->json($collection);
|
||||
return $this->json($collection, \Symfony\Component\HttpFoundation\Response::HTTP_OK, [], [ "groups" => ["read"]]);
|
||||
}
|
||||
|
||||
|
||||
public function advancedSearchListAction(Request $request)
|
||||
{
|
||||
/* @var $variable Chill\MainBundle\Search\SearchProvider */
|
||||
$searchProvider = $this->searchProvider;
|
||||
$advancedSearchProviders = $searchProvider
|
||||
->getHasAdvancedFormSearchServices();
|
||||
|
||||
|
||||
if(\count($advancedSearchProviders) === 1) {
|
||||
\reset($advancedSearchProviders);
|
||||
|
||||
|
||||
return $this->redirectToRoute('chill_main_advanced_search', [
|
||||
'name' => \key($advancedSearchProviders)
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
return $this->render('@ChillMain/Search/choose_list.html.twig');
|
||||
}
|
||||
|
||||
|
||||
public function advancedSearchAction($name, Request $request)
|
||||
{
|
||||
try {
|
||||
@ -190,22 +197,22 @@ class SearchController extends AbstractController
|
||||
/* @var $variable Chill\MainBundle\Search\HasAdvancedSearchFormInterface */
|
||||
$search = $this->searchProvider
|
||||
->getHasAdvancedFormByName($name);
|
||||
|
||||
|
||||
} catch (\Chill\MainBundle\Search\UnknowSearchNameException $e) {
|
||||
throw $this->createNotFoundException("no advanced search for "
|
||||
. "$name");
|
||||
}
|
||||
|
||||
|
||||
if ($request->query->has('q')) {
|
||||
$data = $search->convertTermsToFormData($searchProvider->parse(
|
||||
$request->query->get('q')));
|
||||
}
|
||||
|
||||
|
||||
$form = $this->createAdvancedSearchForm($name, $data ?? []);
|
||||
|
||||
|
||||
if ($request->isMethod(Request::METHOD_POST)) {
|
||||
$form->handleRequest($request);
|
||||
|
||||
|
||||
if ($form->isValid()) {
|
||||
$pattern = $this->searchProvider
|
||||
->getHasAdvancedFormByName($name)
|
||||
@ -215,8 +222,8 @@ class SearchController extends AbstractController
|
||||
'q' => $pattern, 'name' => $name
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->render('@ChillMain/Search/advanced_search.html.twig',
|
||||
[
|
||||
'form' => $form->createView(),
|
||||
@ -224,15 +231,15 @@ class SearchController extends AbstractController
|
||||
'title' => $search->getAdvancedSearchTitle()
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
protected function createAdvancedSearchForm($name, array $data = [])
|
||||
{
|
||||
$builder = $this
|
||||
->get('form.factory')
|
||||
->createNamedBuilder(
|
||||
null,
|
||||
FormType::class,
|
||||
$data,
|
||||
FormType::class,
|
||||
$data,
|
||||
[ 'method' => Request::METHOD_POST ]
|
||||
);
|
||||
|
||||
@ -240,12 +247,12 @@ class SearchController extends AbstractController
|
||||
->getHasAdvancedFormByName($name)
|
||||
->buildForm($builder)
|
||||
;
|
||||
|
||||
|
||||
$builder->add('submit', SubmitType::class, [
|
||||
'label' => 'Search'
|
||||
]);
|
||||
|
||||
|
||||
return $builder->getForm();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ trait LoadAbstractNotificationsTrait
|
||||
{
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
return;
|
||||
foreach ($this->notifs as $notif) {
|
||||
$entityId = $this->getReference($notif['entityRef'])->getId();
|
||||
|
||||
|
@ -32,9 +32,8 @@ use Chill\MainBundle\Doctrine\DQL\JsonAggregate;
|
||||
use Chill\MainBundle\Doctrine\DQL\JsonbExistsInArray;
|
||||
use Chill\MainBundle\Doctrine\DQL\Similarity;
|
||||
use Chill\MainBundle\Doctrine\DQL\OverlapsI;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Chill\MainBundle\Doctrine\DQL\Replace;
|
||||
use Chill\MainBundle\Doctrine\ORM\Hydration\FlatHierarchyEntityHydrator;
|
||||
use Chill\MainBundle\Doctrine\Type\NativeDateIntervalType;
|
||||
use Chill\MainBundle\Doctrine\Type\PointType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@ -186,6 +185,9 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
'OVERLAPSI' => OverlapsI::class,
|
||||
],
|
||||
],
|
||||
'hydrators' => [
|
||||
'chill_flat_hierarchy_list' => FlatHierarchyEntityHydrator::class,
|
||||
],
|
||||
],
|
||||
],
|
||||
);
|
||||
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Doctrine\ORM\Hydration;
|
||||
|
||||
use Doctrine\ORM\Internal\Hydration\ObjectHydrator;
|
||||
use Generator;
|
||||
|
||||
final class FlatHierarchyEntityHydrator extends ObjectHydrator
|
||||
{
|
||||
public const LIST = 'chill_flat_hierarchy_list';
|
||||
|
||||
protected function hydrateAllData()
|
||||
{
|
||||
return array_values(iterator_to_array($this->flatListGenerator($this->buildChildrenHashmap(parent::hydrateAllData()))));
|
||||
}
|
||||
|
||||
private function flatListGenerator(array $hashMap, ?object $parent = null): Generator
|
||||
{
|
||||
$parent = null === $parent ? null : spl_object_id($parent);
|
||||
$hashMap += [$parent => []];
|
||||
|
||||
foreach ($hashMap[$parent] as $node) {
|
||||
yield spl_object_id($node) => $node;
|
||||
yield from $this->flatListGenerator($hashMap, $node);
|
||||
}
|
||||
}
|
||||
|
||||
private function buildChildrenHashmap(array $nodes): array
|
||||
{
|
||||
return array_reduce(
|
||||
$nodes,
|
||||
static function (array $collect, $node): array {
|
||||
$parentId = (null === $parent = $node->getParent()) ?
|
||||
null :
|
||||
spl_object_id($parent);
|
||||
|
||||
$collect[$parentId][] = $node;
|
||||
|
||||
return $collect;
|
||||
},
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
|
||||
* <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/>.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Pagination;
|
||||
|
||||
use Twig\Environment;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
/**
|
||||
* add twig function to render pagination
|
||||
*
|
||||
* @author Mathieu Jaumotte <mathieu.jaumotte@champs-libres.coop>
|
||||
* @author Champs Libres <info@champs-libres.coop>
|
||||
*/
|
||||
class ChillItemsPerPageTwig extends AbstractExtension
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'chill_items_per_page';
|
||||
}
|
||||
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new TwigFunction(
|
||||
'chill_items_per_page',
|
||||
array($this, 'paginationRender'),
|
||||
array(
|
||||
'needs_environment' => true,
|
||||
'is_safe' => ['html']
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function paginationRender(
|
||||
Environment $env,
|
||||
PaginatorInterface $paginator,
|
||||
$template = '@ChillMain/Pagination/items_per_page.html.twig'
|
||||
) {
|
||||
|
||||
return $env->render($template, array(
|
||||
'paginator' => $paginator,
|
||||
'current' => $paginator->getItemsPerPage()
|
||||
));
|
||||
}
|
||||
}
|
@ -61,7 +61,7 @@ class PaginatorFactory
|
||||
public function __construct(
|
||||
RequestStack $requestStack,
|
||||
RouterInterface $router,
|
||||
$itemPerPage = 50
|
||||
$itemPerPage = 20
|
||||
) {
|
||||
$this->itemPerPage = $itemPerPage;
|
||||
$this->requestStack = $requestStack;
|
||||
|
@ -4,23 +4,153 @@
|
||||
// Chill mixins
|
||||
@import './scss/mixins';
|
||||
|
||||
// Chill buttons
|
||||
@import './scss/buttons';
|
||||
|
||||
// Chill forms
|
||||
@import './scss/forms';
|
||||
|
||||
// Chill record_actions
|
||||
@import './scss/record_actions';
|
||||
|
||||
// Chill entity render box system
|
||||
@import './scss/render_box';
|
||||
|
||||
// Chill flex responsive table/block presentation
|
||||
@import './scss/flex_table';
|
||||
|
||||
|
||||
/*
|
||||
* Specific rules
|
||||
* BASE LAYOUT POSITION
|
||||
*/
|
||||
|
||||
.custom_field_no_data,
|
||||
.chill-no-data-statement {
|
||||
font-style: italic;
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
footer {
|
||||
margin-top: auto;
|
||||
}
|
||||
}
|
||||
|
||||
header {
|
||||
nav.navbar {
|
||||
padding: 0;
|
||||
a.navbar-brand img {
|
||||
height: 50px;
|
||||
margin: 8px 0;
|
||||
}
|
||||
div.navbar-collapse {
|
||||
float: right;
|
||||
}
|
||||
ul.navbar-nav {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
li.nav-item {
|
||||
display: flex;
|
||||
&.btn {
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
& > a {
|
||||
align-self: center;
|
||||
}
|
||||
form.form-inline {
|
||||
align-self: center;
|
||||
display: flex;
|
||||
input.form-control {
|
||||
align-self: center;
|
||||
height: 32px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
div.dropdown-menu {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
a.dropdown-item {
|
||||
width: 120%;
|
||||
border: 0;
|
||||
border-bottom: 1px solid $gray-200;
|
||||
font-size: smaller;
|
||||
i {
|
||||
float: right; }
|
||||
&:hover {
|
||||
color: $gray-500 !important; }
|
||||
}
|
||||
}
|
||||
|
||||
// fullwidth menu when navbar is collapsed
|
||||
@media (max-width: 767px) {
|
||||
& {
|
||||
position: relative;
|
||||
}
|
||||
button.navbar-toggler {
|
||||
float: right;
|
||||
}
|
||||
div.navbar-collapse {
|
||||
float: none;
|
||||
position: absolute;
|
||||
top: 4em;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 2;
|
||||
padding: 1em;
|
||||
border-top: 1px solid shade-color($primary, 25%);
|
||||
ul.navbar-nav {
|
||||
display: grid;
|
||||
grid-template-areas:
|
||||
"sear sear sear"
|
||||
"sect user lang";
|
||||
li.nav-item {
|
||||
flex-direction: column;
|
||||
border: 0;
|
||||
a.nav-link {}
|
||||
&.navigation-search {
|
||||
grid-area: sear;
|
||||
margin-bottom: 1em;
|
||||
form {
|
||||
width: 100%;
|
||||
input.form-control {}
|
||||
button.btn {}
|
||||
}
|
||||
}
|
||||
&.nav-section { grid-area: sect; }
|
||||
&.nav-user { grid-area: user; }
|
||||
&.nav-language { grid-area: lang; }
|
||||
}
|
||||
li.dropdown {
|
||||
&, & > * {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
a.dropdown-toggle {}
|
||||
div.dropdown-menu {
|
||||
display: block;
|
||||
border: 0;
|
||||
a.dropdown-item {
|
||||
width: 100%;
|
||||
border: 0;
|
||||
border-top: 1px dotted $gray-200;
|
||||
background-color: transparent !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// styles communs pour tous les bandeaux
|
||||
div.banner {
|
||||
a {
|
||||
text-decoration: none;
|
||||
&.phone,
|
||||
&.email {
|
||||
color: $white;
|
||||
}
|
||||
}
|
||||
.id-number {
|
||||
font-weight: lighter;
|
||||
font-size: 50%;
|
||||
@ -28,17 +158,230 @@ div.banner {
|
||||
&:before { content: '(n°'; }
|
||||
&:after { content: ')'; }
|
||||
}
|
||||
a.phone,
|
||||
a.email {
|
||||
color: white;
|
||||
}
|
||||
ul.list-content {
|
||||
//margin: 0 auto;
|
||||
}
|
||||
span.age {
|
||||
margin-left: 0.5em;
|
||||
&:before { content: '('; }
|
||||
&:after { content: ')'; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
div.vertical-menu {
|
||||
border-radius: 0;
|
||||
margin-top: 0.5rem;
|
||||
a.list-group-item {
|
||||
background-color: $chill-yellow;
|
||||
border: 0;
|
||||
margin-bottom: 0.25rem;
|
||||
&:hover {
|
||||
background-color: tint-color($chill-yellow, 20%)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
footer.footer {
|
||||
background: $dark;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
width: 100%;
|
||||
p {
|
||||
font-family: Open Sans;
|
||||
font-weight: 300;
|
||||
clear: both;
|
||||
color: $white;
|
||||
font-size: 0.9em;
|
||||
line-height: 1.5em;
|
||||
margin: auto;
|
||||
max-width: 35em;
|
||||
text-align: center;
|
||||
a, a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* SPECIFIC RULES
|
||||
*/
|
||||
|
||||
/// titles
|
||||
h1, h2,
|
||||
.h1, .h2 {
|
||||
font-weight: $headings-font-weight + 200;
|
||||
}
|
||||
|
||||
/// typography
|
||||
.open_sansbold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/// no borders on head table
|
||||
table.table-bordered {
|
||||
thead, thead * {
|
||||
border: 0 !important;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
/// comments quotes
|
||||
.chill-user-quote {
|
||||
border-left: 10px solid $yellow;
|
||||
margin: 1.5em 10px;
|
||||
padding: 0.5em 15px;
|
||||
background-color: $gray-200;
|
||||
color: $gray-800;
|
||||
font-size: 90%;
|
||||
|
||||
// test a bottom right decoration (to be confirmed)
|
||||
&.test {
|
||||
position: relative;
|
||||
&:after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 0px; height: 0px;
|
||||
bottom: 0; right: 0;
|
||||
background: $white;
|
||||
border-top: 10px solid $gray-200;
|
||||
border-left: 10px solid $gray-200;
|
||||
border-right: 10px solid $white;
|
||||
border-bottom: 10px solid $white;
|
||||
}
|
||||
}
|
||||
|
||||
// ckeditor citation
|
||||
blockquote p {
|
||||
font-style: italic;
|
||||
padding-left: 2em;
|
||||
quotes: "“" "„";
|
||||
position: relative;
|
||||
&:before {
|
||||
content: open-quote;
|
||||
font-size: 400%;
|
||||
color: $gray-400;
|
||||
position: absolute;
|
||||
top: -25px;
|
||||
left: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
div.metadata {
|
||||
font-size: smaller;
|
||||
color: $gray-600;
|
||||
span.user, span.date {
|
||||
text-decoration: underline dotted;
|
||||
&:hover {
|
||||
color: $gray-700;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// display definition list
|
||||
// with dt and dd on same line
|
||||
|
||||
dl.definition-inline {
|
||||
dd {
|
||||
display: inline;
|
||||
margin: 0;
|
||||
&:after{
|
||||
display: block;
|
||||
content: '';
|
||||
}
|
||||
}
|
||||
dt{
|
||||
display: inline-block;
|
||||
min-width: 200px;
|
||||
}
|
||||
}
|
||||
|
||||
/// when there is no data
|
||||
.custom_field_no_data,
|
||||
.chill-no-data-statement {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
//// still used ?
|
||||
// move from chillmain.css, converted to sass
|
||||
|
||||
div#usefulbar {
|
||||
background-color: $yellow;
|
||||
z-index: 1000;
|
||||
padding-right: 15px;
|
||||
|
||||
form {
|
||||
margin: 0;
|
||||
}
|
||||
i.menu {
|
||||
font-size: 2em;
|
||||
}
|
||||
ul {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin: 0;
|
||||
padding-top: 5px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
li {
|
||||
color: $white;
|
||||
margin-left: 10px;
|
||||
a {
|
||||
color: $white;
|
||||
text-shadow: 0px 0px 1px $gray-600;
|
||||
}
|
||||
i.icon-user-add {
|
||||
&:before {
|
||||
vertical-align: -5px;
|
||||
}
|
||||
}
|
||||
&#search_element {
|
||||
text-align: right;
|
||||
div#search_form {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
div, .field {
|
||||
margin: 0;
|
||||
}
|
||||
button {
|
||||
color: $white;
|
||||
border: none;
|
||||
bottom: -2px;
|
||||
height: 35px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
div#flashMessages {
|
||||
margin-top: 20px;
|
||||
.flash-notice {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.personName {
|
||||
font-variant: small-caps;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
// probably used in client chill.
|
||||
// think to rename like above
|
||||
input.belgian_national_number_inversed_date {
|
||||
width: 7em;
|
||||
margin-right: 1em;
|
||||
}
|
||||
input.belgian_national_number_daily_counter {
|
||||
width: 4em;
|
||||
margin-right: 1em;
|
||||
}
|
||||
input.belgian_national_number_control_digit {
|
||||
width: 3em;
|
||||
}
|
||||
|
||||
//
|
||||
input.belgian_national_number {
|
||||
&.inversed_date {}
|
||||
&.daily_counter {}
|
||||
&.control_digit {}
|
||||
}
|
||||
|
@ -1,25 +0,0 @@
|
||||
div#usefulbar { background-color: #fbba3a; z-index: 1000; padding-right: 15px; }
|
||||
div#usefulbar form { margin: 0; }
|
||||
div#usefulbar i.menu { font-size: 2em; }
|
||||
div#usefulbar ul { display: flex; justify-content: flex-end; margin: 0; padding-top: 5px; padding-right: 10px; }
|
||||
div#usefulbar li { color: white; margin-left: 10px; }
|
||||
div#usefulbar li a { color: white; text-shadow: 0px 0px 1px #555; }
|
||||
div#usefulbar li i.icon-user-add:before { vertical-align: -5px; }
|
||||
div#usefulbar li#search_element { text-align: right; }
|
||||
div#usefulbar li#search_element div#search_form { margin: 0; padding: 0; }
|
||||
div#usefulbar li#search_element div#search_form div { margin: 0; }
|
||||
div#usefulbar li#search_element div#search_form .field { margin: 0; }
|
||||
div#usefulbar li#search_element div#search_form button { color: white; border: none; bottom: -2px; height: 35px; }
|
||||
|
||||
div#flashMessages { margin-top: 20px; }
|
||||
div#flashMessages .flash-notice { margin-top: 10px; margin-bottom: 10px; }
|
||||
|
||||
.personName { font-variant: small-caps; text-transform: capitalize; }
|
||||
|
||||
.personName { text-transform: capitalize; }
|
||||
|
||||
input.belgian_national_number_inversed_date { width: 7em; margin-right: 1em; }
|
||||
|
||||
input.belgian_national_number_daily_counter { width: 4em; margin-right: 1em; }
|
||||
|
||||
input.belgian_national_number_control_digit { width: 3em; }
|
@ -14,12 +14,12 @@ global.select2 = select2;
|
||||
require('select2/dist/css/select2.css');
|
||||
require('select2-bootstrap-theme/dist/select2-bootstrap.css');
|
||||
|
||||
|
||||
/*
|
||||
* Load Chill themes assets
|
||||
*/
|
||||
|
||||
require('./chillmain.scss');
|
||||
require('./css/chillmain.css');
|
||||
|
||||
import { chill } from './js/chill.js';
|
||||
global.chill = chill;
|
||||
@ -34,6 +34,7 @@ require('./img/favicon.ico');
|
||||
require('./img/logo-chill-sans-slogan_white.png');
|
||||
require('./img/logo-chill-outil-accompagnement_white.png');
|
||||
|
||||
|
||||
/*
|
||||
* Load local libs
|
||||
* Some libs are only used in a few pages, they are loaded on a case by case basis
|
||||
@ -45,7 +46,6 @@ require('../lib/breadcrumb/index.js');
|
||||
require('../lib/download-report/index.js');
|
||||
require('../lib/select_interactive_loading/index.js');
|
||||
require('../lib/export-list/index.js');
|
||||
require('../lib/entity/index.js');
|
||||
|
||||
//require('../lib/show_hide/index.js');
|
||||
//require('../lib/tabs/index.js');
|
||||
|
@ -62,10 +62,10 @@ $chill-theme-buttons: (
|
||||
&.btn-view::before,
|
||||
&.btn-save::before,
|
||||
&.btn-duplicate::before,
|
||||
&.btn-not-duplicate::before,
|
||||
&.btn-submit::before,
|
||||
&.btn-reset::before,
|
||||
&.btn-action::before,
|
||||
// &.btn-not-duplicate::before,
|
||||
// &.btn-submit::before,
|
||||
// &.btn-reset::before,
|
||||
// &.btn-action::before,
|
||||
&.btn-delete::before,
|
||||
&.btn-remove::before,
|
||||
&.btn-cancel::before {
|
||||
@ -101,3 +101,18 @@ $chill-theme-buttons: (
|
||||
color: $light;
|
||||
}
|
||||
}
|
||||
|
||||
/// allow to hide icon (herited from scratch)
|
||||
.btn {
|
||||
&.change-icon {
|
||||
&::before {
|
||||
content: '';
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fix min-width on small pictos buttons
|
||||
.btn-sm, .btn-group-sm > .btn {
|
||||
min-width: 36px;
|
||||
}
|
@ -1,59 +1,81 @@
|
||||
/*
|
||||
* FLEX RESPONSIVE TABLE/BLOCK PRESENTATION
|
||||
*/
|
||||
|
||||
div.flex-bloc,
|
||||
div.flex-table {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
align-content: stretch;
|
||||
box-sizing: border-box;
|
||||
margin: 1.5em 0;
|
||||
|
||||
div.item-bloc {
|
||||
display: flex;
|
||||
@include border-collapse;
|
||||
padding: 1em;
|
||||
|
||||
div.item-row {
|
||||
display: flex;
|
||||
|
||||
div.item-col:last-child {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
h2, h3, h4, dl, p {
|
||||
margin: 0;
|
||||
}
|
||||
h2, h3, h4 {
|
||||
color: var(--bs-chill-blue);
|
||||
color: $blue;
|
||||
}
|
||||
div.item-bloc {
|
||||
@include border-collapse;
|
||||
|
||||
ul.record_actions {
|
||||
margin: 0;
|
||||
li {
|
||||
margin-right: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Bloc appearance
|
||||
*/
|
||||
|
||||
div.flex-bloc {
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-items: stretch;
|
||||
align-content: stretch;
|
||||
|
||||
div.item-bloc {
|
||||
flex-grow: 0; flex-shrink: 1; flex-basis: auto;
|
||||
margin: 0;
|
||||
padding: 1em;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 0;
|
||||
hyphens: auto;
|
||||
|
||||
div.item-row {
|
||||
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
div.item-col {
|
||||
&.separator {
|
||||
margin-top: 0.5em;
|
||||
border-top: 1px dotted $gray-900;
|
||||
padding-top: 0.5em;
|
||||
}
|
||||
|
||||
&:first-child {
|
||||
flex-grow: 0; flex-shrink: 0; flex-basis: auto;
|
||||
padding-bottom: 0.5em;
|
||||
border-bottom: 1px dotted #0000004f;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
|
||||
display: flex;
|
||||
|
||||
.list-content { // ul, dl, or div
|
||||
}
|
||||
ul.record_actions {
|
||||
margin: 0;
|
||||
align-self: flex-end;
|
||||
flex-grow: 1; flex-shrink: 0; flex-basis: auto;
|
||||
margin: 0;
|
||||
|
||||
li {
|
||||
margin-right: 5px;
|
||||
}
|
||||
@ -67,51 +89,47 @@ div.flex-bloc {
|
||||
/*
|
||||
* Table appearance
|
||||
*/
|
||||
|
||||
div.flex-table {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
align-content: stretch;
|
||||
|
||||
div.item-bloc {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 1em;
|
||||
|
||||
&:nth-child(even) {
|
||||
background-color: $gray-200;
|
||||
|
||||
.chill-user-quote {
|
||||
background-color: shade-color($gray-200, 5%)
|
||||
}
|
||||
}
|
||||
|
||||
div.item-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
&:not(:first-child) {
|
||||
|
||||
&.separator {
|
||||
margin-top: 0.5em;
|
||||
border-top: 1px dotted #0000004f;
|
||||
border-top: 1px dotted $gray-900;
|
||||
padding-top: 0.5em;
|
||||
flex-direction: column;
|
||||
//flex-direction: column;
|
||||
}
|
||||
|
||||
div.item-col {
|
||||
&:first-child {
|
||||
flex-grow: 0; flex-shrink: 0; flex-basis: 33%;
|
||||
flex-grow: 0; flex-shrink: 0; flex-basis: auto;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
|
||||
.list-content { // ul, dl, or div
|
||||
}
|
||||
ul.record_actions {
|
||||
margin: 0;
|
||||
align-self: flex-start;
|
||||
flex-grow: 1; flex-shrink: 0; flex-basis: auto;
|
||||
li {
|
||||
margin-right: 5px;
|
||||
}
|
||||
align-self: flex-start;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 900px) {
|
||||
flex-direction: column;
|
||||
div.item-col {
|
||||
@ -122,9 +140,6 @@ div.flex-table {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// neutralize
|
||||
div.chill_address div.chill_address_address p { text-indent: 0; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
/// forms
|
||||
form {
|
||||
|
||||
/* avoid useless html in first level of the custom fields row loop in forms
|
||||
* (better should to improve the loop)
|
||||
*/
|
||||
& > div.container-fluid {
|
||||
& > div.row > .parent {
|
||||
padding: 0;
|
||||
& div.cf-fields span.cf-title {
|
||||
margin: 1em -15px 0;
|
||||
width: calc(100% + 30px);
|
||||
@include title_in_form;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fieldset {
|
||||
margin-top: 1em;
|
||||
& > legend {
|
||||
@include title_in_form;
|
||||
}
|
||||
}
|
||||
|
||||
// customfields titles in form
|
||||
span.cf-title {
|
||||
@include title_in_form;
|
||||
}
|
||||
|
||||
label {
|
||||
display: inline;
|
||||
&.required:after {
|
||||
content: " *";
|
||||
color: $red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.col-form-label {
|
||||
padding-top: .5em;
|
||||
padding-bottom: .5em;
|
||||
font-weight: 700;
|
||||
margin-bottom: .375em;
|
||||
}
|
@ -1,4 +1,18 @@
|
||||
|
||||
//
|
||||
// Titles in forms
|
||||
//
|
||||
|
||||
@mixin title_in_form {
|
||||
font-size: 1.438em;
|
||||
font-weight: 700;
|
||||
width: 100%;
|
||||
border-bottom: 3px solid $gray-200;
|
||||
margin-bottom: 1em;
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
// We use box-shadow instead of border
|
||||
// to avoid to manage border double-width
|
||||
// Then we can simulate border-collapse: collapse (table)
|
||||
|
@ -1,13 +1,22 @@
|
||||
ul.record_actions,
|
||||
ul.record_actions_column {
|
||||
ul.record_actions {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap-reverse;
|
||||
justify-content: flex-end;
|
||||
padding: 0.5em 0;
|
||||
|
||||
&.record_actions--left {
|
||||
&.column {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
&.left {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
padding: 0.5em 0;
|
||||
flex-wrap: wrap-reverse;
|
||||
|
||||
&.sticky-form-buttons {
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
li {
|
||||
display: inline-block;
|
||||
@ -18,37 +27,34 @@ ul.record_actions_column {
|
||||
&:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
li.cancel {
|
||||
order: 1;
|
||||
margin-right: auto;
|
||||
&.cancel {
|
||||
order: 1;
|
||||
margin-right: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ul.record_actions {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
ul.record_actions_column {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
ul.record_actions.sticky-form-buttons {
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
.sticky-form-buttons {
|
||||
margin-top: 4em;
|
||||
background-color: $beige;
|
||||
position: sticky;
|
||||
bottom: 0.3em;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
padding: 0.8em 1.6em;
|
||||
border-radius: 0;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
/// EXCEPTIONS
|
||||
// inside table exceptions
|
||||
table {
|
||||
|
||||
td ul.record_actions,
|
||||
ul.record_actions_small {
|
||||
li {
|
||||
margin-right: 0.2em;
|
||||
}
|
||||
}
|
||||
|
||||
ul.record_actions {
|
||||
margin: 0;
|
||||
padding: 0.5em;
|
@ -13,12 +13,18 @@ section.chill-entity {
|
||||
}
|
||||
|
||||
// specific rules
|
||||
// all render box doesn't use a section tag !
|
||||
.chill-entity {
|
||||
|
||||
// used for: entity-person, entity-thirdparty
|
||||
&.entity-person,
|
||||
&.entity-thirdparty {
|
||||
|
||||
span.entity-raw {
|
||||
& > span:not(:first-child):before {
|
||||
content: " ";
|
||||
}
|
||||
}
|
||||
div.entity-label {
|
||||
div.denomination {
|
||||
&.h3 {
|
||||
@ -87,9 +93,25 @@ section.chill-entity {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
span.address-valid {
|
||||
&.address-since {}
|
||||
&.address-until {}
|
||||
.address-valid {
|
||||
margin-top: 2em;
|
||||
&.date-since {}
|
||||
&.date-until {}
|
||||
}
|
||||
}
|
||||
|
||||
// used for comment-embeddable
|
||||
&.entity-comment-embeddable {
|
||||
width: 100%;
|
||||
div.metadata {
|
||||
font-size: smaller;
|
||||
color: $gray-600;
|
||||
span.user, span.date {
|
||||
text-decoration: underline dotted;
|
||||
&:hover {
|
||||
color: $gray-700;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +0,0 @@
|
||||
.chill-entity__comment-embeddable {
|
||||
.chill-entity__comment-embeddable__metadata {
|
||||
font-size: smaller;
|
||||
color: var(--chill-light-gray);
|
||||
}
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
// css classes to render entities
|
||||
require('./comment_embeddable.scss');
|
@ -1,284 +1,6 @@
|
||||
/*
|
||||
* These custom styles will override bootstrap enabled stylesheets
|
||||
* in mod_bootstrap entrypoint
|
||||
*/
|
||||
|
||||
/// chill buttons
|
||||
@import 'custom/_buttons';
|
||||
|
||||
// chill record_actions
|
||||
@import 'custom/_record_actions';
|
||||
|
||||
/// titles
|
||||
h1, h2, .h1, .h2 {
|
||||
font-weight: $headings-font-weight + 200;
|
||||
}
|
||||
|
||||
/// typography
|
||||
.open_sansbold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/// forms
|
||||
|
||||
@mixin title_in_form {
|
||||
font-size: 1.438em;
|
||||
font-weight: 700;
|
||||
width: 100%;
|
||||
border-bottom: 3px solid $gray-200;
|
||||
margin-bottom: 1em;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.col-form-label {
|
||||
padding-top: .5em;
|
||||
padding-bottom: .5em;
|
||||
font-weight: 700;
|
||||
margin-bottom: .375em;
|
||||
}
|
||||
|
||||
form {
|
||||
/* avoid useless html in first level of the custom fields row loop in forms
|
||||
* (better should to improve the loop)
|
||||
*/
|
||||
& > div.container-fluid {
|
||||
& > div.row > .parent {
|
||||
padding: 0;
|
||||
& div.cf-fields span.cf-title {
|
||||
margin: 1em -15px 0;
|
||||
width: calc(100% + 30px);
|
||||
@include title_in_form;
|
||||
}
|
||||
}
|
||||
}
|
||||
fieldset {
|
||||
margin-top: 1em;
|
||||
& > legend {
|
||||
@include title_in_form;
|
||||
}
|
||||
}
|
||||
label {
|
||||
display: inline;
|
||||
&.required:after {
|
||||
content: " *";
|
||||
color: $red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// table
|
||||
|
||||
table.table-bordered {
|
||||
thead, thead * {
|
||||
border: 0 !important;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
/// chill elements of design
|
||||
|
||||
.sticky-form-buttons {
|
||||
margin-top: 4em;
|
||||
background-color: $beige;
|
||||
position: sticky;
|
||||
bottom: 0.3em;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
padding: 0.8em 1.6em;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.chill-user-quote {
|
||||
border-left: 10px solid $yellow;
|
||||
margin: 1.5em 10px;
|
||||
padding: 0.5em 15px;
|
||||
quotes: "\201C" "\201D" "\2018" "\2019";
|
||||
background-color: $gray-200;
|
||||
blockquote {
|
||||
border-left: 0.4em solid $gray-400;
|
||||
padding-left: 0.9em;
|
||||
margin-left: 0.9em;
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
|
||||
div.chill_address {
|
||||
div.chill_address_address {
|
||||
margin: 0.7em 0;
|
||||
font-size: 98%;
|
||||
font-variant: small-caps;
|
||||
p {
|
||||
display: inline-block;
|
||||
margin: 0 0 0 1.5em;
|
||||
text-indent: -1.5em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// base layout positions
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
footer {
|
||||
margin-top: auto;
|
||||
}
|
||||
}
|
||||
|
||||
header {
|
||||
nav.navbar {
|
||||
padding: 0;
|
||||
a.navbar-brand img {
|
||||
height: 50px;
|
||||
margin: 8px 0;
|
||||
}
|
||||
div.navbar-collapse {
|
||||
float: right;
|
||||
}
|
||||
ul.navbar-nav {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
li.nav-item {
|
||||
display: flex;
|
||||
&.btn {
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
& > a {
|
||||
align-self: center;
|
||||
}
|
||||
form.form-inline {
|
||||
align-self: center;
|
||||
display: flex;
|
||||
input.form-control {
|
||||
align-self: center;
|
||||
height: 32px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
div.dropdown-menu {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
a.dropdown-item {
|
||||
width: 120%;
|
||||
border: 0;
|
||||
border-bottom: 1px solid $gray-200;
|
||||
font-size: smaller;
|
||||
i {
|
||||
float: right; }
|
||||
&:hover {
|
||||
color: $gray-500 !important; }
|
||||
}
|
||||
}
|
||||
|
||||
// fullwidth menu when navbar is collapsed
|
||||
@media (max-width: 767px) {
|
||||
& {
|
||||
position: relative;
|
||||
}
|
||||
button.navbar-toggler {
|
||||
float: right;
|
||||
}
|
||||
div.navbar-collapse {
|
||||
float: none;
|
||||
position: absolute;
|
||||
top: 4em;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 2;
|
||||
padding: 1em;
|
||||
border-top: 1px solid shade-color($primary, 25%);
|
||||
ul.navbar-nav {
|
||||
display: grid;
|
||||
grid-template-areas:
|
||||
"sear sear sear"
|
||||
"sect user lang";
|
||||
li.nav-item {
|
||||
flex-direction: column;
|
||||
border: 0;
|
||||
a.nav-link {}
|
||||
&.navigation-search {
|
||||
grid-area: sear;
|
||||
margin-bottom: 1em;
|
||||
form {
|
||||
width: 100%;
|
||||
input.form-control {}
|
||||
button.btn {}
|
||||
}
|
||||
}
|
||||
&.nav-section { grid-area: sect; }
|
||||
&.nav-user { grid-area: user; }
|
||||
&.nav-language { grid-area: lang; }
|
||||
}
|
||||
li.dropdown {
|
||||
&, & > * {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
a.dropdown-toggle {}
|
||||
div.dropdown-menu {
|
||||
display: block;
|
||||
border: 0;
|
||||
a.dropdown-item {
|
||||
width: 100%;
|
||||
border: 0;
|
||||
border-top: 1px dotted $gray-200;
|
||||
background-color: transparent !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
div.banner {
|
||||
div.header-name,
|
||||
div.header-details {
|
||||
div.row > div:first-child {
|
||||
@media (min-width: 576px) {
|
||||
//margin-left: 1.5em;
|
||||
}
|
||||
}
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
div.vertical-menu {
|
||||
border-radius: 0;
|
||||
margin-top: 0.5rem;
|
||||
a.list-group-item {
|
||||
background-color: $chill-yellow;
|
||||
border: 0;
|
||||
margin-bottom: 0.25rem;
|
||||
&:hover {
|
||||
background-color: tint-color($chill-yellow, 20%)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
footer.footer {
|
||||
background: $dark;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
width: 100%;
|
||||
p {
|
||||
font-family: Open Sans;
|
||||
font-weight: 300;
|
||||
clear: both;
|
||||
color: $white;
|
||||
font-size: 0.9em;
|
||||
line-height: 1.5em;
|
||||
margin: auto;
|
||||
max-width: 35em;
|
||||
text-align: center;
|
||||
a, a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ $gray-400: #ced4da !default;
|
||||
$gray-500: #b2b2b2 !default;
|
||||
$gray-600: #6c757d !default;
|
||||
$gray-700: #495057 !default;
|
||||
$gray-800: #333333 !default;
|
||||
$gray-800: #2c2d2f !default;
|
||||
$gray-900: #212529 !default;
|
||||
$black: #111 !default;
|
||||
// scss-docs-end gray-color-variables
|
||||
@ -160,7 +160,7 @@ $chill-pink: $pink;
|
||||
$chill-gray: $gray-600;
|
||||
$chill-dark-gray: $gray-800;
|
||||
$chill-light-gray: $gray-200;
|
||||
$chill-llight-gray: $gray-100;
|
||||
$chill-llight-gray: $gray-100;
|
||||
// scss-docs-end theme-color-variables
|
||||
|
||||
// scss-docs-start theme-colors-map
|
||||
@ -176,7 +176,7 @@ $theme-colors: (
|
||||
) !default;
|
||||
// scss-docs-end theme-colors-map
|
||||
|
||||
$chill-colors: (
|
||||
$chill-colors: (
|
||||
"chill-blue": $chill-blue,
|
||||
"chill-green": $chill-green,
|
||||
"chill-green-dark": $chill-green-dark,
|
||||
@ -382,7 +382,7 @@ $border-color: $gray-300 !default;
|
||||
// scss-docs-end border-variables
|
||||
|
||||
// scss-docs-start border-radius-variables
|
||||
$border-radius: .25rem !default; // <==
|
||||
$border-radius: .25rem !default; // <==
|
||||
$border-radius-sm: .2rem !default;
|
||||
$border-radius-lg: .3rem !default;
|
||||
$border-radius-pill: 50rem !default;
|
||||
|
@ -1,147 +1,86 @@
|
||||
<template>
|
||||
<div class="chill-entity entity-address">
|
||||
|
||||
<h2 v-if="!edit">{{ $t('create_a_new_address') }}</h2>
|
||||
<h2 v-else>{{ $t('edit_address') }}</h2>
|
||||
|
||||
<show-address
|
||||
v-if="address"
|
||||
v-bind:address="address">
|
||||
</show-address>
|
||||
|
||||
<add-address
|
||||
@addNewAddress="addNewAddress">
|
||||
</add-address>
|
||||
<div v-for="error in displayErrors" class="alert alert-danger my-2">
|
||||
{{ error }}
|
||||
</div>
|
||||
|
||||
<div v-if="!edit" class='person-address__valid'>
|
||||
<h2>{{ $t('date') }}</h2>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="validFrom"><i class="fa fa-fw fa-calendar"></i></span>
|
||||
<input type="date" class="form-control form-control-lg" name="validFrom"
|
||||
v-bind:placeholder="$t('validFrom')"
|
||||
v-model="validFrom"
|
||||
aria-describedby="validFrom" />
|
||||
</div>
|
||||
|
||||
<div v-if="errors.length > 0">
|
||||
{{ errors }}
|
||||
</div>
|
||||
<div v-if="loading">
|
||||
{{ $t('loading') }}
|
||||
</div>
|
||||
<div v-if="success">
|
||||
{{ $t('person_address_creation_success') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
<li class="cancel">
|
||||
<a :href="backUrl" class="btn btn-cancel">{{ $t('back_to_the_list') }}</a>
|
||||
</li>
|
||||
<li v-if="!edit">
|
||||
<button type="submit" class="btn btn-update" @click="addToPerson">
|
||||
{{ $t('add_an_address_to_person') }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<add-address
|
||||
v-bind:key="context.entity.type"
|
||||
v-bind:context="context"
|
||||
v-bind:options="addAddress.options"
|
||||
v-bind:result="addAddress.result"
|
||||
@submitAddress="submitAddress"
|
||||
ref="addAddress">
|
||||
</add-address>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/*
|
||||
* Address component is a uniq component for many contexts.
|
||||
* Allow to create/attach/edit an address to
|
||||
* - a person (new or edit address),
|
||||
* - a household (move or edit address)
|
||||
*
|
||||
* */
|
||||
import AddAddress from './components/AddAddress.vue';
|
||||
import ShowAddress from './components/ShowAddress.vue';
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
name: "App",
|
||||
components: {
|
||||
AddAddress,
|
||||
ShowAddress
|
||||
AddAddress
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
edit: window.mode === 'edit',
|
||||
personId: window.personId,
|
||||
addressId: window.addressId,
|
||||
backUrl: `/fr/person/${window.personId}/address/list`, //TODO better way to pass this
|
||||
validFrom: new Date().toISOString().split('T')[0]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
address() {
|
||||
return this.$store.state.address;
|
||||
},
|
||||
errors() {
|
||||
return this.$store.state.errorMsg;
|
||||
},
|
||||
loading() {
|
||||
return this.$store.state.loading;
|
||||
},
|
||||
success() {
|
||||
return this.$store.state.success;
|
||||
context: {
|
||||
edit: window.mode === 'edit',
|
||||
entity: {
|
||||
type: window.entityType,
|
||||
id: window.entityId
|
||||
},
|
||||
addressId: window.addressId | null,
|
||||
backUrl: window.backUrl,
|
||||
},
|
||||
addAddress: {
|
||||
options: {
|
||||
|
||||
/// Options override default.
|
||||
/// null value take default component value defined in AddAddress data()
|
||||
button: {
|
||||
text: {
|
||||
create: window.buttonText || null,
|
||||
edit: window.buttonText || null
|
||||
},
|
||||
size: window.buttonSize || null,
|
||||
displayText: window.buttonDisplayText //boolean, default: true
|
||||
},
|
||||
|
||||
/// Modal title text if create or edit address (trans chain, see i18n)
|
||||
title: {
|
||||
create: window.modalTitle || null,
|
||||
edit: window.modalTitle || null
|
||||
},
|
||||
|
||||
/// Display each step in page or Modal
|
||||
bindModal: {
|
||||
step1: window.binModalStep1, //boolean, default: true
|
||||
step2: window.binModalStep2 //boolean, default: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addNewAddress({ address, modal }) {
|
||||
console.log('@@@ CLICK button addNewAdress', address);
|
||||
|
||||
let newAddress = {
|
||||
'isNoAddress': address.isNoAddress,
|
||||
'street': address.isNoAddress ? '' : address.street,
|
||||
'streetNumber': address.isNoAddress ? '' : address.streetNumber,
|
||||
'postcode': {'id': address.selected.city.id},
|
||||
'floor': address.floor,
|
||||
'corridor': address.corridor,
|
||||
'steps': address.steps,
|
||||
'flat': address.flat,
|
||||
'buildingName': address.buildingName,
|
||||
'distribution': address.distribution,
|
||||
'extra': address.extra
|
||||
};
|
||||
|
||||
if (address.selected.address.point !== undefined){
|
||||
newAddress = Object.assign(newAddress, {
|
||||
'point': address.selected.address.point.coordinates
|
||||
});
|
||||
}
|
||||
|
||||
if (address.writeNewPostalCode){
|
||||
let newPostalCode = address.newPostalCode;
|
||||
newPostalCode = Object.assign(newPostalCode, {
|
||||
'country': {'id': address.selected.country.id },
|
||||
});
|
||||
newAddress = Object.assign(newAddress, {
|
||||
'newPostalCode': newPostalCode
|
||||
});
|
||||
}
|
||||
|
||||
if (this.edit){
|
||||
this.$store.dispatch('updateAddress', {
|
||||
addressId: this.addressId,
|
||||
newAddress: newAddress
|
||||
});
|
||||
} else {
|
||||
this.$store.dispatch('addAddress', newAddress);
|
||||
}
|
||||
|
||||
modal.showModal = false;
|
||||
displayErrors() {
|
||||
return this.$refs.addAddress.errorMsg;
|
||||
},
|
||||
addToPerson() {
|
||||
this.$store.dispatch('addDateToAddressAndAddressToPerson', {
|
||||
personId: this.personId,
|
||||
addressId: this.$store.state.address.address_id,
|
||||
body: { validFrom: {datetime: `${this.validFrom}T00:00:00+0100`}},
|
||||
backUrl: this.backUrl
|
||||
})
|
||||
},
|
||||
getEditAddress() {
|
||||
this.$store.dispatch('getEditAddress', this.addressId);
|
||||
submitAddress() {
|
||||
console.log('@@@ click on Submit Address Button');
|
||||
|
||||
// Cast child method
|
||||
this.$refs.addAddress.submitNewAddress();
|
||||
// it fetch post request only for person and household
|
||||
// else get returned payload then dispatch from here (parent)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.edit) {
|
||||
this.getEditAddress();
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @returns {Promise} a promise containing all Country object
|
||||
*/
|
||||
const fetchCountries = () => {
|
||||
console.log('<<< fetching countries');
|
||||
//console.log('<<< fetching countries');
|
||||
|
||||
const url = `/api/1.0/main/country.json?item_per_page=1000`;
|
||||
return fetch(url)
|
||||
@ -20,7 +20,7 @@ const fetchCountries = () => {
|
||||
* @returns {Promise} a promise containing all Postal Code objects filtered with country
|
||||
*/
|
||||
const fetchCities = (country) => {
|
||||
console.log('<<< fetching cities for', country);
|
||||
//console.log('<<< fetching cities for', country);
|
||||
const url = `/api/1.0/main/postal-code.json?item_per_page=1000&country=${country.id}`;
|
||||
return fetch(url)
|
||||
.then(response => {
|
||||
@ -35,7 +35,7 @@ const fetchCities = (country) => {
|
||||
* @returns {Promise} a promise containing all AddressReference objects filtered with postal code
|
||||
*/
|
||||
const fetchReferenceAddresses = (postalCode) => {
|
||||
console.log('<<< fetching references addresses for', postalCode);
|
||||
//console.log('<<< fetching references addresses for', postalCode);
|
||||
const url = `/api/1.0/main/address-reference.json?item_per_page=1000&postal_code=${postalCode.id}`;
|
||||
return fetch(url)
|
||||
.then(response => {
|
||||
@ -50,7 +50,7 @@ const fetchReferenceAddresses = (postalCode) => {
|
||||
* @returns {Promise} a promise containing all AddressReference objects filtered with postal code
|
||||
*/
|
||||
const fetchAddresses = () => {
|
||||
console.log('<<< fetching addresses');
|
||||
//console.log('<<< fetching addresses');
|
||||
//TODO deal with huge number of addresses... we should do suggestion...
|
||||
const url = `/api/1.0/main/address.json?item_per_page=1000`;
|
||||
return fetch(url)
|
||||
@ -125,31 +125,6 @@ const postPostalCode = (postalCode) => {
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Endpoint chill_api_single_person_address
|
||||
* method POST, post Person instance
|
||||
*
|
||||
* @id integer - id of Person
|
||||
* @body Object - dictionary with changes to post
|
||||
*/
|
||||
const postAddressToPerson = (personId, addressId) => {
|
||||
console.log(personId);
|
||||
console.log(addressId);
|
||||
const body = {
|
||||
'id': addressId
|
||||
};
|
||||
const url = `/api/1.0/person/person/${personId}/address.json`
|
||||
return fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json;charset=utf-8'},
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Endpoint chill_api_single_address__index
|
||||
* method GET, get Address Object
|
||||
@ -157,7 +132,7 @@ const postAddressToPerson = (personId, addressId) => {
|
||||
* @returns {Promise} a promise containing a Address object
|
||||
*/
|
||||
const getAddress = (id) => {
|
||||
console.log('<<< get address');
|
||||
//console.log('<< get address');
|
||||
const url = `/api/1.0/main/address/${id}.json`;
|
||||
return fetch(url)
|
||||
.then(response => {
|
||||
@ -174,6 +149,5 @@ export {
|
||||
postAddress,
|
||||
patchAddress,
|
||||
postPostalCode,
|
||||
postAddressToPerson,
|
||||
getAddress
|
||||
};
|
||||
|
@ -1,273 +1,618 @@
|
||||
<template>
|
||||
<button v-if="!edit" class="btn btn-create mt-4" @click="openModal">
|
||||
{{ $t('add_an_address_title') }}
|
||||
</button>
|
||||
<button v-else class="btn btn-create mt-4" @click="openModal">
|
||||
{{ $t('edit_address') }}
|
||||
|
||||
<!-- start with a button -->
|
||||
<button v-if="step1WithModal"
|
||||
@click="openShowPane"
|
||||
class="btn" :class="getClassButton"
|
||||
type="button" name="button" :title="$t(getTextButton)">
|
||||
<span v-if="displayTextButton">{{ $t(getTextButton) }}</span>
|
||||
</button>
|
||||
|
||||
<teleport to="body">
|
||||
<modal v-if="modal.showModal"
|
||||
v-bind:modalDialogClass="modal.modalDialogClass"
|
||||
@close="modal.showModal = false">
|
||||
<!-- step 1 -->
|
||||
<teleport to="body" v-if="step1WithModal">
|
||||
<modal v-if="flag.showPane"
|
||||
modalDialogClass="modal-dialog-scrollable modal-xl"
|
||||
@close="flag.showPane = false">
|
||||
|
||||
<template v-slot:header>
|
||||
<h3 v-if="!edit" class="modal-title">{{ $t('add_an_address_title') }}</h3>
|
||||
<h3 v-if="edit" class="modal-title">{{ $t('edit_an_address_title') }}</h3>
|
||||
<h2 class="modal-title">{{ $t(getTextTitle) }}
|
||||
<span v-if="flag.loading" class="loading">
|
||||
<i class="fa fa-circle-o-notch fa-spin fa-fw"></i>
|
||||
<span class="sr-only">{{ $t('loading') }}</span>
|
||||
</span>
|
||||
</h2>
|
||||
</template>
|
||||
|
||||
<template v-slot:body>
|
||||
<div class="address-form">
|
||||
|
||||
<h4 class="h3">{{ $t('select_an_address_title') }}
|
||||
<span v-if="loading">
|
||||
<i class="fa fa-circle-o-notch fa-spin fa-lg"></i>
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="row my-3">
|
||||
<div class="col-lg-6">
|
||||
|
||||
<div class="form-check">
|
||||
<input type="checkbox"
|
||||
class="form-check-input"
|
||||
id="isNoAddress"
|
||||
v-model="isNoAddress"
|
||||
v-bind:value="value" />
|
||||
<label class="form-check-label" for="isNoAddress">
|
||||
{{ $t('isNoAddress') }}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<country-selection
|
||||
v-bind:address="address"
|
||||
v-bind:getCities="getCities">
|
||||
</country-selection>
|
||||
|
||||
<city-selection
|
||||
v-bind:address="address"
|
||||
v-bind:focusOnAddress="focusOnAddress"
|
||||
v-bind:getReferenceAddresses="getReferenceAddresses">
|
||||
</city-selection>
|
||||
|
||||
<address-selection
|
||||
v-if="!isNoAddress"
|
||||
v-bind:address="address"
|
||||
v-bind:updateMapCenter="updateMapCenter">
|
||||
</address-selection>
|
||||
|
||||
</div>
|
||||
<div class="col-lg-6 mt-3 mt-lg-0">
|
||||
|
||||
<address-map
|
||||
v-bind:address="address"
|
||||
ref="addressMap">
|
||||
</address-map>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<address-more
|
||||
v-if="!isNoAddress"
|
||||
v-bind:address="address">
|
||||
</address-more>
|
||||
|
||||
</div>
|
||||
<show-address-pane
|
||||
v-bind:context="this.context"
|
||||
v-bind:options="this.options"
|
||||
v-bind:default="this.default"
|
||||
v-bind:entity="this.entity"
|
||||
v-bind:valid="this.valid"
|
||||
v-bind:flag="this.flag"
|
||||
ref="showAddress">
|
||||
</show-address-pane>
|
||||
</template>
|
||||
|
||||
<template v-slot:footer>
|
||||
<button class="btn btn-create"
|
||||
@click.prevent="$emit('addNewAddress', { address, modal })">
|
||||
{{ $t('action.add')}}
|
||||
<button @click="openEditPane"
|
||||
class="btn btn-update">
|
||||
{{ $t('action.edit')}}
|
||||
</button>
|
||||
<button class="btn btn-save"
|
||||
@click.prevent="$emit('submitAddress')">
|
||||
{{ $t('action.save')}}
|
||||
</button>
|
||||
</template>
|
||||
|
||||
</modal>
|
||||
</teleport>
|
||||
<div class="mt-4" v-else>
|
||||
|
||||
<show-address-pane v-if="flag.showPane"
|
||||
v-bind:context="this.context"
|
||||
v-bind:options="this.options"
|
||||
v-bind:default="this.default"
|
||||
v-bind:entity="this.entity"
|
||||
v-bind:valid="this.valid"
|
||||
v-bind:flag="this.flag"
|
||||
ref="showAddress"
|
||||
v-bind:insideModal="false" @openEditPane="openEditPane"
|
||||
@submitAddress="$emit('submitAddress')">
|
||||
</show-address-pane>
|
||||
</div>
|
||||
|
||||
<!-- step 2 -->
|
||||
<teleport to="body" v-if="step2WithModal">
|
||||
<modal v-if="flag.editPane"
|
||||
modalDialogClass="modal-dialog-scrollable modal-xl"
|
||||
@close="flag.editPane = false">
|
||||
|
||||
<template v-slot:header>
|
||||
<h2 class="modal-title">{{ $t(getTextTitle) }}
|
||||
<span v-if="flag.loading" class="loading">
|
||||
<i class="fa fa-circle-o-notch fa-spin fa-fw"></i>
|
||||
<span class="sr-only">{{ $t('loading') }}</span>
|
||||
</span>
|
||||
</h2>
|
||||
</template>
|
||||
|
||||
<template v-slot:body>
|
||||
<edit-address-pane
|
||||
v-bind:context="this.context"
|
||||
v-bind:options="this.options"
|
||||
v-bind:default="this.default"
|
||||
v-bind:entity="this.entity"
|
||||
v-bind:flag="this.flag"
|
||||
@getCities="getCities"
|
||||
@getReferenceAddresses="getReferenceAddresses">
|
||||
</edit-address-pane>
|
||||
</template>
|
||||
|
||||
<template v-slot:footer>
|
||||
<button class="btn btn-cancel change-icon" @click="flag.showPane = true; flag.editPane = false;">
|
||||
{{ $t('action.cancel') }}
|
||||
</button>
|
||||
<button class="btn btn-update"
|
||||
@click="closeEditPane">
|
||||
{{ $t('action.valid')}}
|
||||
</button>
|
||||
</template>
|
||||
|
||||
</modal>
|
||||
</teleport>
|
||||
<div class="mt-4" v-else>
|
||||
|
||||
<edit-address-pane v-if="flag.editPane"
|
||||
v-bind:context="this.context"
|
||||
v-bind:options="this.options"
|
||||
v-bind:default="this.default"
|
||||
v-bind:entity="this.entity"
|
||||
v-bind:flag="this.flag"
|
||||
v-bind:insideModal="false" @closeEditPane="closeEditPane"
|
||||
@getCities="getCities"
|
||||
@getReferenceAddresses="getReferenceAddresses">
|
||||
</edit-address-pane>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Modal from 'ChillMainAssets/vuejs/_components/Modal';
|
||||
import { fetchCountries, fetchCities, fetchReferenceAddresses } from '../api'
|
||||
|
||||
import CountrySelection from './AddAddress/CountrySelection';
|
||||
import CitySelection from './AddAddress/CitySelection';
|
||||
import AddressSelection from './AddAddress/AddressSelection';
|
||||
import AddressMap from './AddAddress/AddressMap';
|
||||
import AddressMore from './AddAddress/AddressMore'
|
||||
import { getAddress, fetchCountries, fetchCities, fetchReferenceAddresses, patchAddress, postAddress, postPostalCode } from '../api';
|
||||
import { postAddressToPerson, postAddressToHousehold } from "ChillPersonAssets/vuejs/_api/AddAddress.js";
|
||||
import ShowAddressPane from './ShowAddressPane.vue';
|
||||
import EditAddressPane from './EditAddressPane.vue';
|
||||
|
||||
export default {
|
||||
name: 'AddAddresses',
|
||||
name: "AddAddress",
|
||||
props: ['context', 'options', 'result'],
|
||||
emits: ['submitAddress'],
|
||||
components: {
|
||||
Modal,
|
||||
CountrySelection,
|
||||
CitySelection,
|
||||
AddressSelection,
|
||||
AddressMap,
|
||||
AddressMore
|
||||
ShowAddressPane,
|
||||
EditAddressPane,
|
||||
},
|
||||
props: [
|
||||
],
|
||||
emits: ['addNewAddress'],
|
||||
data() {
|
||||
return {
|
||||
edit: window.mode === 'edit',
|
||||
modal: {
|
||||
showModal: false,
|
||||
modalDialogClass: "modal-dialog-scrollable modal-xl"
|
||||
flag: {
|
||||
showPane: false,
|
||||
editPane: false,
|
||||
loading: false,
|
||||
success: false
|
||||
},
|
||||
loading: false,
|
||||
address: {
|
||||
writeNewAddress: false,
|
||||
writeNewPostalCode: false,
|
||||
default: {
|
||||
button: {
|
||||
text: { create: 'add_an_address_title', edit: 'edit_address' },
|
||||
type: { create: 'btn-create', edit: 'btn-update'},
|
||||
displayText: true
|
||||
},
|
||||
title: { create: 'add_an_address_title', edit: 'edit_address' },
|
||||
bindModal: {
|
||||
step1: true,
|
||||
step2: true,
|
||||
},
|
||||
},
|
||||
entity: {
|
||||
address: {}, // <== loaded and returned
|
||||
loaded: {
|
||||
countries: [],
|
||||
cities: [],
|
||||
addresses: [],
|
||||
},
|
||||
selected: {
|
||||
selected: { // <== make temporary changes
|
||||
isNoAddress: false,
|
||||
country: {},
|
||||
city: {},
|
||||
postcode: {
|
||||
code: null,
|
||||
name: null
|
||||
},
|
||||
address: {},
|
||||
},
|
||||
newPostalCode: {
|
||||
code: null,
|
||||
name: null
|
||||
writeNew: {
|
||||
address: false,
|
||||
postcode: false
|
||||
}
|
||||
},
|
||||
addressMap: {
|
||||
center : [48.8589, 2.3469], // Note: LeafletJs demands [lat, lon] cfr https://macwright.com/lonlat/
|
||||
// Note: LeafletJs demands [lat, lon]
|
||||
// cfr https://macwright.com/lonlat/
|
||||
center : [48.8589, 2.3469],
|
||||
zoom: 12
|
||||
},
|
||||
isNoAddress: false,
|
||||
street: null,
|
||||
streetNumber: null,
|
||||
floor: null,
|
||||
corridor: null,
|
||||
steps: null,
|
||||
floor: null,
|
||||
flat: null,
|
||||
buildingName: null,
|
||||
extra: null,
|
||||
distribution: null,
|
||||
},
|
||||
errorMsg: {},
|
||||
valid: {
|
||||
from: new Date(),
|
||||
to: null
|
||||
},
|
||||
errorMsg: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isNoAddress: {
|
||||
set(value) {
|
||||
console.log('value', value);
|
||||
this.address.isNoAddress = value;
|
||||
},
|
||||
get() {
|
||||
return this.address.isNoAddress;
|
||||
step1WithModal() {
|
||||
return (this.options.bindModal !== null && typeof this.options.bindModal.step1 !== 'undefined') ?
|
||||
this.options.bindModal.step1 : this.default.bindModal.step1;
|
||||
},
|
||||
step2WithModal() {
|
||||
let step2 = (this.options.bindModal !== null && typeof this.options.bindModal.step2 !== 'undefined') ?
|
||||
this.options.bindModal.step2 : this.default.bindModal.step2;
|
||||
|
||||
if (step2 === false && this.step1WithModal === true) {
|
||||
console.log("step2 must open in a Modal");
|
||||
return true;
|
||||
}
|
||||
return step2;
|
||||
},
|
||||
getTextTitle() {
|
||||
if ( typeof this.options.title !== 'undefined'
|
||||
&& ( this.options.title.edit !== null
|
||||
|| this.options.title.create !== null
|
||||
)) {
|
||||
return (this.context.edit) ? this.options.title.edit : this.options.title.create;
|
||||
}
|
||||
return (this.context.edit) ? this.default.title.edit : this.default.title.create;
|
||||
},
|
||||
getTextButton() {
|
||||
if ( typeof this.options.button.text !== 'undefined'
|
||||
&& ( this.options.button.text.edit !== null
|
||||
|| this.options.button.text.create !== null
|
||||
)) {
|
||||
return (this.context.edit) ? this.options.button.text.edit : this.options.button.text.create;
|
||||
}
|
||||
return (this.context.edit) ? this.default.button.text.edit : this.default.button.text.create;
|
||||
},
|
||||
getClassButton() {
|
||||
let type = (this.context.edit) ? this.default.button.type.edit : this.default.button.type.create;
|
||||
let size = (typeof this.options.button !== 'undefined' && this.options.button.size !== null) ?
|
||||
`${this.options.button.size} ` : '';
|
||||
return `${size}${type}`;
|
||||
},
|
||||
displayTextButton() {
|
||||
return (typeof this.options.button !== 'undefined' && typeof this.options.button.displayText !== 'undefined') ?
|
||||
this.options.button.displayText : this.default.button.displayText;
|
||||
},
|
||||
context() {
|
||||
return this.context;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getCountries();
|
||||
if (!this.step1WithModal) {
|
||||
//console.log('Mounted now !');
|
||||
this.openShowPane();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
openModal() {
|
||||
this.modal.showModal = true;
|
||||
this.resetAll();
|
||||
//this.$nextTick(function() {
|
||||
// this.$refs.search.focus(); // positionner le curseur à l'ouverture de la modale
|
||||
//})
|
||||
|
||||
/*
|
||||
* Opening and closing Panes when interacting with buttons
|
||||
*/
|
||||
openShowPane() {
|
||||
console.log('open the Show Panel');
|
||||
|
||||
if (this.context.edit) {
|
||||
this.getInitialAddress(this.context.addressId);
|
||||
}
|
||||
|
||||
// when create new address, start first with editPane
|
||||
if ( this.context.edit === false
|
||||
&& this.flag.editPane === false
|
||||
) {
|
||||
this.openEditPane();
|
||||
this.flag.editPane = true;
|
||||
|
||||
} else {
|
||||
this.flag.showPane = true;
|
||||
}
|
||||
},
|
||||
focusOnCity() {
|
||||
const citySelector = document.getElementById('citySelector');
|
||||
citySelector.focus();
|
||||
|
||||
openEditPane() {
|
||||
console.log('open the Edit panel');
|
||||
this.initForm();
|
||||
this.getCountries();
|
||||
},
|
||||
focusOnAddress() {
|
||||
const addressSelector = document.getElementById('addressSelector');
|
||||
addressSelector.focus();
|
||||
|
||||
closeEditPane() {
|
||||
console.log('close the Edit Panel');
|
||||
this.applyChanges();
|
||||
this.flag.showPane = true;
|
||||
this.flag.editPane = false;
|
||||
},
|
||||
getCountries() {
|
||||
console.log('getCountries');
|
||||
this.loading = true;
|
||||
fetchCountries().then(countries => new Promise((resolve, reject) => {
|
||||
this.address.loaded.countries = countries.results;
|
||||
resolve()
|
||||
this.loading = false;
|
||||
}))
|
||||
.catch((error) => {
|
||||
this.errorMsg.push(error.message);
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
getCities(country) {
|
||||
console.log('getCities for', country.name);
|
||||
this.loading = true;
|
||||
fetchCities(country).then(cities => new Promise((resolve, reject) => {
|
||||
this.address.loaded.cities = cities.results.filter(c => c.origin !== 3); // filter out user-defined cities
|
||||
resolve();
|
||||
this.loading = false;
|
||||
|
||||
/*
|
||||
* Async Fetch datas
|
||||
*/
|
||||
getInitialAddress(id) {
|
||||
this.flag.loading = true;
|
||||
getAddress(id).then(
|
||||
address => new Promise((resolve, reject) => {
|
||||
this.entity.address = address;
|
||||
this.flag.loading = false;
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
this.errorMsg.push(error.message);
|
||||
this.loading = false;
|
||||
this.flag.loading = false;
|
||||
});
|
||||
},
|
||||
getReferenceAddresses(city) {
|
||||
this.loading = true;
|
||||
console.log('getReferenceAddresses for', city.name);
|
||||
fetchReferenceAddresses(city).then(addresses => new Promise((resolve, reject) => {
|
||||
console.log('addresses', addresses);
|
||||
this.address.loaded.addresses = addresses.results;
|
||||
|
||||
getCountries() {
|
||||
this.flag.loading = true;
|
||||
fetchCountries().then(
|
||||
countries => new Promise((resolve, reject) => {
|
||||
this.entity.loaded.countries = countries.results;
|
||||
this.flag.showPane = false;
|
||||
this.flag.editPane = true;
|
||||
this.flag.loading = false;
|
||||
resolve()
|
||||
}))
|
||||
.catch((error) => {
|
||||
this.errorMsg.push(error.message);
|
||||
this.flag.loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
getCities(country) {
|
||||
this.flag.loading = true;
|
||||
fetchCities(country).then(
|
||||
cities => new Promise((resolve, reject) => {
|
||||
this.entity.loaded.cities = cities.results.filter(c => c.origin !== 3); // filter out user-defined cities
|
||||
this.flag.loading = false;
|
||||
resolve();
|
||||
this.loading = false;
|
||||
}))
|
||||
}))
|
||||
.catch((error) => {
|
||||
this.errorMsg.push(error.message);
|
||||
this.flag.loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
getReferenceAddresses(city) {
|
||||
this.flag.loading = true;
|
||||
fetchReferenceAddresses(city).then(
|
||||
addresses => new Promise((resolve, reject) => {
|
||||
this.entity.loaded.addresses = addresses.results;
|
||||
this.flag.loading = false;
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
this.errorMsg.push(error.message);
|
||||
this.flag.loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
/*
|
||||
* Make form ready for new changes
|
||||
*/
|
||||
initForm() {
|
||||
console.log('init form');
|
||||
|
||||
this.entity.loaded.addresses = [];
|
||||
this.entity.loaded.cities = [];
|
||||
this.entity.loaded.countries = [];
|
||||
|
||||
this.entity.selected.isNoAddress = (this.context.edit && this.entity.address.text === '') ? true : false;
|
||||
|
||||
this.entity.selected.country = this.context.edit ? this.entity.address.country : {};
|
||||
this.entity.selected.postcode = this.context.edit ? this.entity.address.postcode : {};
|
||||
this.entity.selected.city = {};
|
||||
|
||||
this.entity.selected.address = {};
|
||||
this.entity.selected.address.street = this.context.edit ? this.entity.address.street: null;
|
||||
this.entity.selected.address.streetNumber = this.context.edit ? this.entity.address.streetNumber: null;
|
||||
this.entity.selected.address.floor = this.context.edit ? this.entity.address.floor: null;
|
||||
this.entity.selected.address.corridor = this.context.edit ? this.entity.address.corridor: null;
|
||||
this.entity.selected.address.steps = this.context.edit ? this.entity.address.steps: null;
|
||||
this.entity.selected.address.flat = this.context.edit ? this.entity.address.flat: null;
|
||||
this.entity.selected.address.buildingName = this.context.edit ? this.entity.address.buildingName: null;
|
||||
this.entity.selected.address.distribution = this.context.edit ? this.entity.address.distribution: null;
|
||||
this.entity.selected.address.extra = this.context.edit ? this.entity.address.extra: null;
|
||||
|
||||
this.entity.selected.writeNew.address = this.context.edit;
|
||||
this.entity.selected.writeNew.postcode = this.context.edit;
|
||||
},
|
||||
|
||||
/*
|
||||
* When changes are validated (get out step2 edit pane, button valid),
|
||||
* apply some transformations before asyncing with backend
|
||||
* from entity.selected to entity.address
|
||||
*/
|
||||
applyChanges()
|
||||
{
|
||||
let newAddress = {
|
||||
'isNoAddress': this.entity.selected.isNoAddress,
|
||||
'street': this.entity.selected.isNoAddress ? '' : this.entity.selected.address.street,
|
||||
'streetNumber': this.entity.selected.isNoAddress ? '' : this.entity.selected.address.streetNumber,
|
||||
'postcode': {'id': this.entity.selected.city.id },
|
||||
'floor': this.entity.selected.address.floor,
|
||||
'corridor': this.entity.selected.address.corridor,
|
||||
'steps': this.entity.selected.address.steps,
|
||||
'flat': this.entity.selected.address.flat,
|
||||
'buildingName': this.entity.selected.address.buildingName,
|
||||
'distribution': this.entity.selected.address.distribution,
|
||||
'extra': this.entity.selected.address.extra
|
||||
};
|
||||
|
||||
if (this.entity.selected.address.point !== undefined) {
|
||||
newAddress = Object.assign(newAddress, {
|
||||
'point': this.entity.selected.address.point.coordinates
|
||||
});
|
||||
}
|
||||
if (this.entity.selected.writeNew.postcode) {
|
||||
let newPostcode = this.entity.selected.postcode;
|
||||
newPostcode = Object.assign(newPostcode, {
|
||||
'country': {'id': this.entity.selected.country.id },
|
||||
});
|
||||
newAddress = Object.assign(newAddress, {
|
||||
'newPostcode': newPostcode
|
||||
});
|
||||
}
|
||||
|
||||
if (this.context.edit) {
|
||||
this.updateAddress({
|
||||
addressId: this.context.addressId,
|
||||
newAddress: newAddress
|
||||
});
|
||||
} else {
|
||||
this.addAddress(newAddress);
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* Async POST transactions,
|
||||
* creating new address, and receive backend datas when promise is resolved
|
||||
*/
|
||||
addAddress(payload)
|
||||
{
|
||||
this.flag.loading = true;
|
||||
if ('newPostcode' in payload) {
|
||||
|
||||
let postcodeBody = payload.newPostcode;
|
||||
if (this.context.entity.type === 'person') {
|
||||
postcodeBody = Object.assign(postcodeBody, {'origin': 3});
|
||||
}
|
||||
|
||||
postPostalCode(postcodeBody)
|
||||
.then(postalCode => {
|
||||
let body = payload;
|
||||
body.postcode = {'id': postalCode.id },
|
||||
postAddress(body)
|
||||
.then(address => new Promise((resolve, reject) => {
|
||||
this.entity.address = address;
|
||||
this.flag.loading = false;
|
||||
this.flag.success = true;
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
this.errorMsg.push(error);
|
||||
this.flag.loading = false;
|
||||
});
|
||||
})
|
||||
|
||||
} else {
|
||||
postAddress(payload)
|
||||
.then(address => new Promise((resolve, reject) => {
|
||||
this.entity.address = address;
|
||||
this.flag.loading = false;
|
||||
this.flag.success = true;
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
this.errorMsg.push(error);
|
||||
this.flag.loading = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* Async PATCH transactions,
|
||||
* then update existing address with backend datas when promise is resolved
|
||||
*/
|
||||
updateAddress(payload)
|
||||
{
|
||||
// TODO change the condition because it writes new postal code in edit mode now: !writeNewPostalCode
|
||||
this.flag.loading = true;
|
||||
if ('newPostcode' in payload.newAddress) {
|
||||
|
||||
let postcodeBody = payload.newAddress.newPostcode;
|
||||
postcodeBody = Object.assign(postcodeBody, {'origin': 3});
|
||||
|
||||
postPostalCode(postcodeBody)
|
||||
.then(postalCode => {
|
||||
let body = payload.newAddress;
|
||||
body.postcode = {'id': postalCode.id },
|
||||
patchAddress(payload.addressId, body)
|
||||
.then(address => new Promise((resolve, reject) => {
|
||||
this.entity.address = address;
|
||||
this.flag.loading = false;
|
||||
this.flag.success = true;
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
this.errorMsg.push(error);
|
||||
this.flag.loading = false;
|
||||
});
|
||||
})
|
||||
|
||||
} else {
|
||||
patchAddress(payload.addressId, payload.newAddress)
|
||||
.then(address => new Promise((resolve, reject) => {
|
||||
this.entity.address = address;
|
||||
this.flag.loading = false;
|
||||
this.flag.success = true;
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
this.errorMsg.push(error);
|
||||
this.flag.loading = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* When submit address
|
||||
* (get out step1 show pane, submit button)
|
||||
*/
|
||||
submitNewAddress()
|
||||
{
|
||||
let payload = {
|
||||
entity: this.context.entity.type,
|
||||
entityId: this.context.entity.id,
|
||||
addressId: this.entity.address.address_id,
|
||||
body: {
|
||||
validFrom: {
|
||||
datetime: `${this.valid.from.toISOString().split('T')[0]}T00:00:00+0100`
|
||||
}
|
||||
},
|
||||
backUrl: this.context.backUrl
|
||||
}
|
||||
|
||||
if ( payload.entity !== 'person' && payload.entity !== 'household' ) {
|
||||
|
||||
// just return payload to parent
|
||||
// (changes will be patched in parent store)
|
||||
this.initForm();
|
||||
this.flag.showPane = false;
|
||||
return payload;
|
||||
}
|
||||
|
||||
console.log('submitNewAddress with', payload);
|
||||
this.addDateToAddressAndAddressTo(payload);
|
||||
|
||||
this.initForm();
|
||||
this.flag.showPane = false;
|
||||
},
|
||||
|
||||
addDateToAddressAndAddressTo(payload)
|
||||
{
|
||||
console.log('addDateToAddressAndAddressTo', payload.entity)
|
||||
this.flag.loading = true;
|
||||
return patchAddress(payload.addressId, payload.body)
|
||||
.then(address => new Promise((resolve, reject) => {
|
||||
this.valid.from = address.validFrom;
|
||||
resolve();
|
||||
})
|
||||
.then(this.postAddressTo(payload))
|
||||
)
|
||||
.catch((error) => {
|
||||
this.errorMsg.push(error.message);
|
||||
this.loading = false;
|
||||
this.errorMsg.push(error);
|
||||
this.flag.loading = false;
|
||||
});
|
||||
},
|
||||
updateMapCenter(point) {
|
||||
console.log('point', point);
|
||||
this.address.addressMap.center[0] = point.coordinates[1]; // TODO use reverse()
|
||||
this.address.addressMap.center[1] = point.coordinates[0];
|
||||
this.$refs.addressMap.update(); // cast child methods
|
||||
|
||||
postAddressTo(payload)
|
||||
{
|
||||
console.log('postAddressTo', payload.entity);
|
||||
if (!this.context.edit) {
|
||||
switch (payload.entity) {
|
||||
case 'household':
|
||||
postAddressToHousehold(payload.entityId, payload.addressId)
|
||||
.then(household => new Promise((resolve, reject) => {
|
||||
console.log('postAddressToHousehold', household);
|
||||
this.flag.loading = false;
|
||||
this.flag.success = true;
|
||||
window.location.assign(payload.backUrl);
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
this.errorMsg.push(error);
|
||||
this.flag.loading = false;
|
||||
})
|
||||
;
|
||||
break;
|
||||
case 'person':
|
||||
postAddressToPerson(payload.entityId, payload.addressId)
|
||||
.then(person => new Promise((resolve, reject) => {
|
||||
console.log('postAddressToPerson', person);
|
||||
this.flag.loading = false;
|
||||
this.flag.success = true;
|
||||
window.location.assign(payload.backUrl);
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
this.errorMsg.push(error);
|
||||
this.flag.loading = false;
|
||||
})
|
||||
;
|
||||
break;
|
||||
default:
|
||||
this.errorMsg.push('That entity is not managed by address !');
|
||||
}
|
||||
} else {
|
||||
// address is already linked, just finish !
|
||||
window.location.assign(payload.backUrl);
|
||||
}
|
||||
},
|
||||
resetAll() {
|
||||
console.log('reset all selected');
|
||||
this.address.loaded.addresses = [];
|
||||
this.address.selected.address = {};
|
||||
this.address.loaded.cities = [];
|
||||
this.address.selected.city = {};
|
||||
this.address.selected.country = {};
|
||||
this.address.isNoAddress = this.edit ? this.$store.state.editAddress.isNoAddress: false;;
|
||||
this.address.street = this.edit ? this.$store.state.editAddress.street: null;
|
||||
this.address.streetNumber = this.edit ? this.$store.state.editAddress.streetNumber: null;
|
||||
this.address.floor = this.edit ? this.$store.state.editAddress.floor: null;
|
||||
this.address.corridor = this.edit ? this.$store.state.editAddress.corridor: null;
|
||||
this.address.steps = this.edit ? this.$store.state.editAddress.steps: null;
|
||||
this.address.flat = this.edit ? this.$store.state.editAddress.flat: null;
|
||||
this.address.buildingName = this.edit ? this.$store.state.editAddress.buildingName: null;
|
||||
this.address.distribution = this.edit ? this.$store.state.editAddress.distribution: null;
|
||||
this.address.extra = this.edit ? this.$store.state.editAddress.extra: null;
|
||||
this.address.writeNewAddress = this.edit;
|
||||
this.address.writeNewPostalCode = this.edit;
|
||||
this.address.newPostalCode = this.edit ?
|
||||
{
|
||||
code: this.$store.state.editAddress.postcode !== undefined ? this.$store.state.editAddress.postcode.code : null,
|
||||
name: this.$store.state.editAddress.postcode !== undefined ? this.$store.state.editAddress.postcode.name : null
|
||||
} : {};
|
||||
console.log('cities and addresses', this.address.loaded.cities, this.address.loaded.addresses);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
div.address-form {
|
||||
h4.h3 {
|
||||
font-weight: bold;
|
||||
}
|
||||
div#address_map {
|
||||
height: 400px;
|
||||
width: 100%;
|
||||
div.entity-address {
|
||||
position: relative;
|
||||
div.loading {
|
||||
position: absolute;
|
||||
right: 0; top: -55px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -13,16 +13,18 @@ let marker;
|
||||
|
||||
export default {
|
||||
name: 'AddressMap',
|
||||
props: ['address'],
|
||||
props: ['entity'],
|
||||
computed: {
|
||||
center() {
|
||||
return this.address.addressMap.center;
|
||||
return this.entity.selected.addressMap.center;
|
||||
},
|
||||
},
|
||||
methods:{
|
||||
init() {
|
||||
map = L.map('address_map').setView([46.67059, -1.42683], 12);
|
||||
|
||||
map.scrollWheelZoom.disable();
|
||||
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
@ -36,9 +38,9 @@ export default {
|
||||
|
||||
},
|
||||
update() {
|
||||
console.log('update map with : ', this.address.addressMap.center)
|
||||
marker.setLatLng(this.address.addressMap.center);
|
||||
map.setView(this.address.addressMap.center, 15);
|
||||
//console.log('update map with : ', this.address.addressMap.center)
|
||||
marker.setLatLng(this.entity.addressMap.center);
|
||||
map.setView(this.entity.addressMap.center, 15);
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
|
@ -74,69 +74,62 @@
|
||||
<script>
|
||||
export default {
|
||||
name: "AddressMore",
|
||||
props: ['address'],
|
||||
props: ['entity'],
|
||||
computed: {
|
||||
floor: {
|
||||
set(value) {
|
||||
console.log('value', value);
|
||||
this.address.floor = value;
|
||||
this.entity.selected.address.floor = value;
|
||||
},
|
||||
get() {
|
||||
return this.address.floor;
|
||||
return this.entity.selected.address.floor;
|
||||
}
|
||||
},
|
||||
corridor: {
|
||||
set(value) {
|
||||
console.log('value', value);
|
||||
this.address.corridor = value;
|
||||
this.entity.selected.address.corridor = value;
|
||||
},
|
||||
get() {
|
||||
return this.address.corridor;
|
||||
return this.entity.selected.address.corridor;
|
||||
}
|
||||
},
|
||||
steps: {
|
||||
set(value) {
|
||||
console.log('value', value);
|
||||
this.address.steps = value;
|
||||
this.entity.selected.address.steps = value;
|
||||
},
|
||||
get() {
|
||||
return this.address.steps;
|
||||
return this.entity.selected.address.steps;
|
||||
}
|
||||
},
|
||||
flat: {
|
||||
set(value) {
|
||||
console.log('value', value);
|
||||
this.address.flat = value;
|
||||
this.entity.selected.address.flat = value;
|
||||
},
|
||||
get() {
|
||||
return this.address.flat;
|
||||
return this.entity.selected.address.flat;
|
||||
}
|
||||
},
|
||||
buildingName: {
|
||||
set(value) {
|
||||
console.log('value', value);
|
||||
this.address.buildingName = value;
|
||||
this.entity.selected.address.buildingName = value;
|
||||
},
|
||||
get() {
|
||||
return this.address.buildingName;
|
||||
return this.entity.selected.address.buildingName;
|
||||
}
|
||||
},
|
||||
extra: {
|
||||
set(value) {
|
||||
console.log('value', value);
|
||||
this.address.extra = value;
|
||||
this.entity.selected.address.extra = value;
|
||||
},
|
||||
get() {
|
||||
return this.address.extra;
|
||||
return this.entity.selected.address.extra;
|
||||
}
|
||||
},
|
||||
distribution: {
|
||||
set(value) {
|
||||
console.log('value', value);
|
||||
this.address.distribution = value;
|
||||
this.entity.selected.address.distribution = value;
|
||||
},
|
||||
get() {
|
||||
return this.address.distribution;
|
||||
return this.entity.selected.address.distribution;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ import VueMultiselect from 'vue-multiselect';
|
||||
export default {
|
||||
name: 'AddressSelection',
|
||||
components: { VueMultiselect },
|
||||
props: ['address', 'updateMapCenter'],
|
||||
props: ['entity', 'updateMapCenter'],
|
||||
data() {
|
||||
return {
|
||||
value: null
|
||||
@ -55,28 +55,28 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
writeNewAddress() {
|
||||
return this.address.writeNewAddress;
|
||||
return this.entity.selected.writeNew.address;
|
||||
},
|
||||
writeNewPostalCode() {
|
||||
return this.address.writeNewPostalCode;
|
||||
return this.entity.selected.writeNew.postCode;
|
||||
},
|
||||
addresses() {
|
||||
return this.address.loaded.addresses;
|
||||
return this.entity.loaded.addresses;
|
||||
},
|
||||
street: {
|
||||
set(value) {
|
||||
this.address.street = value;
|
||||
this.entity.selected.address.street = value;
|
||||
},
|
||||
get() {
|
||||
return this.address.street;
|
||||
return this.entity.selected.address.street;
|
||||
}
|
||||
},
|
||||
streetNumber: {
|
||||
set(value) {
|
||||
this.address.streetNumber = value;
|
||||
this.entity.selected.address.streetNumber = value;
|
||||
},
|
||||
get() {
|
||||
return this.address.streetNumber;
|
||||
return this.entity.selected.address.streetNumber;
|
||||
}
|
||||
},
|
||||
},
|
||||
@ -85,13 +85,13 @@ export default {
|
||||
return value.streetNumber === undefined ? value.street : `${value.streetNumber}, ${value.street}`
|
||||
},
|
||||
selectAddress(value) {
|
||||
this.address.selected.address = value;
|
||||
this.address.street = value.street;
|
||||
this.address.streetNumber = value.streetNumber;
|
||||
this.entity.selected.address = value;
|
||||
this.entity.selected.address.street = value.street;
|
||||
this.entity.selected.address.streetNumber = value.streetNumber;
|
||||
this.updateMapCenter(value.point);
|
||||
},
|
||||
addAddress() {
|
||||
this.address.writeNewAddress = true;
|
||||
this.entity.selected.writeNew.address = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -12,13 +12,13 @@
|
||||
:placeholder="$t('select_city')"
|
||||
:taggable="true"
|
||||
:multiple="false"
|
||||
@tag="addPostalCode"
|
||||
@tag="addPostcode"
|
||||
:tagPlaceholder="$t('create_postal_code')"
|
||||
:options="cities">
|
||||
</VueMultiselect>
|
||||
</div>
|
||||
|
||||
<div class="custom-postcode row g-1" v-if="writeNewPostalCode">
|
||||
|
||||
<div class="custom-postcode row g-1" v-if="writeNewPostcode">
|
||||
<div class="col-4">
|
||||
<div class="form-floating">
|
||||
<input class="form-control"
|
||||
@ -28,7 +28,7 @@
|
||||
v-model="code"/>
|
||||
<label for="code">{{ $t('postalCode_code') }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-8">
|
||||
<div class="form-floating">
|
||||
<input class="form-control"
|
||||
@ -48,33 +48,34 @@ import VueMultiselect from 'vue-multiselect';
|
||||
export default {
|
||||
name: 'CitySelection',
|
||||
components: { VueMultiselect },
|
||||
props: ['address', 'getReferenceAddresses', 'focusOnAddress'],
|
||||
props: ['entity', 'focusOnAddress'],
|
||||
emits: ['getReferenceAddresses'],
|
||||
data() {
|
||||
return {
|
||||
value: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
writeNewPostalCode() {
|
||||
return this.address.writeNewPostalCode;
|
||||
writeNewPostcode() {
|
||||
return this.entity.selected.writeNew.postcode;
|
||||
},
|
||||
cities() {
|
||||
return this.address.loaded.cities;
|
||||
return this.entity.loaded.cities;
|
||||
},
|
||||
name: {
|
||||
set(value) {
|
||||
this.address.newPostalCode.name = value;
|
||||
this.entity.selected.postcode.name = value;
|
||||
},
|
||||
get() {
|
||||
return this.address.newPostalCode.name;
|
||||
return this.entity.selected.postcode.name;
|
||||
}
|
||||
},
|
||||
code: {
|
||||
set(value) {
|
||||
this.address.newPostalCode.code= value;
|
||||
this.entity.selected.postcode.code= value;
|
||||
},
|
||||
get() {
|
||||
return this.address.newPostalCode.code;
|
||||
return this.entity.selected.postcode.code;
|
||||
}
|
||||
},
|
||||
},
|
||||
@ -83,14 +84,14 @@ export default {
|
||||
return `${value.code}-${value.name}`
|
||||
},
|
||||
selectCity(value) {
|
||||
this.address.selected.city = value;
|
||||
this.address.newPostalCode.name = value.name;
|
||||
this.address.newPostalCode.code = value.code;
|
||||
this.getReferenceAddresses(value);
|
||||
this.entity.selected.city = value;
|
||||
this.entity.selected.postcode.name = value.name;
|
||||
this.entity.selected.postcode.code = value.code;
|
||||
this.$emit('getReferenceAddresses', value);
|
||||
this.focusOnAddress();
|
||||
},
|
||||
addPostalCode() {
|
||||
this.address.writeNewPostalCode = true;
|
||||
addPostcode() {
|
||||
this.entity.selected.writeNew.postcode = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -2,13 +2,13 @@
|
||||
<div class="my-1">
|
||||
<label class="col-form-label" for="countrySelect">{{ $t('country') }}</label>
|
||||
<VueMultiselect
|
||||
v-model="value"
|
||||
id="countrySelect"
|
||||
track-by="id"
|
||||
label="name"
|
||||
:custom-label="transName"
|
||||
:placeholder="$t('select_country')"
|
||||
:options="countries"
|
||||
track-by="id"
|
||||
v-bind:custom-label="transName"
|
||||
v-bind:placeholder="$t('select_country')"
|
||||
v-bind:options="sortedCountries"
|
||||
v-model="value"
|
||||
@select="selectCountry">
|
||||
</VueMultiselect>
|
||||
</div>
|
||||
@ -20,43 +20,47 @@ import VueMultiselect from 'vue-multiselect';
|
||||
export default {
|
||||
name: 'CountrySelection',
|
||||
components: { VueMultiselect },
|
||||
props: ['address', 'getCities'],
|
||||
props: ['context', 'entity'],
|
||||
emits: ['getCities'],
|
||||
data() {
|
||||
return {
|
||||
edit: window.mode === 'edit',
|
||||
defaultCountry: this.edit ? this.$store.state.editAddress.country.code : 'FR',
|
||||
value: this.address.loaded.countries.filter(c => c.countryCode === this.defaultCountry)[0]
|
||||
value: this.selectCountryByCode(
|
||||
this.context.edit ? this.entity.selected.country.code : 'FR'
|
||||
)
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
sortedCountries() {
|
||||
//console.log('sorted countries');
|
||||
const countries = this.entity.loaded.countries;
|
||||
let sortedCountries = [];
|
||||
sortedCountries.push(...countries.filter(c => c.countryCode === 'FR'))
|
||||
sortedCountries.push(...countries.filter(c => c.countryCode === 'BE'))
|
||||
sortedCountries.push(...countries.filter(c => c.countryCode !== 'FR').filter(c => c.countryCode !== 'BE'))
|
||||
return sortedCountries;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.value = this.edit ?
|
||||
this.address.loaded.countries.filter(c => c.countryCode === this.$store.state.editAddress.country.code)[0]:
|
||||
this.address.loaded.countries.filter(c => c.countryCode === 'FR')[0]
|
||||
if (this.value !== undefined) {
|
||||
this.selectCountry(this.value);
|
||||
}
|
||||
},
|
||||
selectCountryByCode(countryCode) {
|
||||
return this.entity.loaded.countries.filter(c => c.countryCode === countryCode)[0];
|
||||
},
|
||||
transName ({ name }) {
|
||||
return name.fr //TODO multilang
|
||||
},
|
||||
selectCountry(value) {
|
||||
this.address.selected.country = value;
|
||||
this.getCities(value);
|
||||
},
|
||||
},
|
||||
mounted(){
|
||||
this.init()
|
||||
},
|
||||
computed: {
|
||||
countries() {
|
||||
const countries = this.address.loaded.countries;
|
||||
let orderedCountries = [];
|
||||
orderedCountries.push(...countries.filter(c => c.countryCode === 'FR'))
|
||||
orderedCountries.push(...countries.filter(c => c.countryCode === 'BE'))
|
||||
orderedCountries.push(...countries.filter(c => c.countryCode !== 'FR').filter(c => c.countryCode !== 'BE'))
|
||||
return orderedCountries;
|
||||
//console.log('select country', value);
|
||||
this.entity.selected.country = value;
|
||||
this.$emit('getCities', value);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -0,0 +1,160 @@
|
||||
<template>
|
||||
<div class="address-form">
|
||||
|
||||
<!-- Not display in modal -->
|
||||
<div v-if="insideModal == false" class="loading">
|
||||
<i v-if="flag.loading" class="fa fa-circle-o-notch fa-spin fa-2x fa-fw"></i>
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
|
||||
<h4 class="h3">{{ $t('select_an_address_title') }}</h4>
|
||||
<div class="row my-3">
|
||||
<div class="col-lg-6">
|
||||
|
||||
<div class="form-check">
|
||||
<input type="checkbox"
|
||||
class="form-check-input"
|
||||
id="isNoAddress"
|
||||
v-model="isNoAddress"
|
||||
v-bind:value="value" />
|
||||
<label class="form-check-label" for="isNoAddress">
|
||||
{{ $t('isNoAddress') }}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<country-selection
|
||||
v-bind:context="context"
|
||||
v-bind:entity="entity"
|
||||
@getCities="$emit('getCities', selected.country)">
|
||||
</country-selection>
|
||||
|
||||
<city-selection
|
||||
v-bind:entity="entity"
|
||||
v-bind:focusOnAddress="focusOnAddress"
|
||||
@getReferenceAddresses="$emit('getReferenceAddresses', selected.city)">
|
||||
</city-selection>
|
||||
|
||||
<address-selection v-if="!isNoAddress"
|
||||
v-bind:entity="entity"
|
||||
v-bind:updateMapCenter="updateMapCenter">
|
||||
</address-selection>
|
||||
|
||||
</div>
|
||||
<div class="col-lg-6 mt-3 mt-lg-0">
|
||||
|
||||
<address-map
|
||||
v-bind:entity="entity"
|
||||
ref="addressMap">
|
||||
</address-map>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<address-more v-if="!isNoAddress"
|
||||
v-bind:entity="entity">
|
||||
</address-more>
|
||||
|
||||
<!-- Not display in modal -->
|
||||
<ul v-if="insideModal == false"
|
||||
class="record_actions sticky-form-buttons">
|
||||
<li class="cancel">
|
||||
<a class="btn btn-cancel" v-bind:href="context.backUrl">
|
||||
{{ $t('back_to_the_list') }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-cancel change-icon" @click="flag.showPane = true; flag.editPane = false;">
|
||||
{{ $t('action.cancel') }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-update" @click.prevent="$emit('closeEditPane')">
|
||||
{{ $t('action.valid_and_see')}}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CountrySelection from './AddAddress/CountrySelection';
|
||||
import CitySelection from './AddAddress/CitySelection';
|
||||
import AddressSelection from './AddAddress/AddressSelection';
|
||||
import AddressMap from './AddAddress/AddressMap';
|
||||
import AddressMore from './AddAddress/AddressMore'
|
||||
|
||||
export default {
|
||||
name: "EditAddressPane",
|
||||
components: {
|
||||
CountrySelection,
|
||||
CitySelection,
|
||||
AddressSelection,
|
||||
AddressMap,
|
||||
AddressMore
|
||||
},
|
||||
props: [
|
||||
'context',
|
||||
'options',
|
||||
'default',
|
||||
'flag',
|
||||
'entity',
|
||||
'errorMsg',
|
||||
'insideModal'
|
||||
],
|
||||
emits: ['closeEditPane', 'getCities', 'getReferenceAddresses'],
|
||||
data() {
|
||||
return {
|
||||
value: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
address() {
|
||||
return this.entity.address;
|
||||
},
|
||||
loaded() {
|
||||
return this.entity.loaded;
|
||||
},
|
||||
selected() {
|
||||
return this.entity.selected;
|
||||
},
|
||||
addressMap() {
|
||||
return this.entity.addressMap;
|
||||
},
|
||||
isNoAddress: {
|
||||
set(value) {
|
||||
console.log('isNoAddress value', value);
|
||||
this.entity.selected.isNoAddress = value;
|
||||
},
|
||||
get() {
|
||||
return this.entity.selected.isNoAddress;
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
focusOnAddress() {
|
||||
const addressSelector = document.getElementById('addressSelector');
|
||||
addressSelector.focus();
|
||||
},
|
||||
updateMapCenter(point) {
|
||||
//console.log('point', point);
|
||||
this.addressMap.center[0] = point.coordinates[1]; // TODO use reverse()
|
||||
this.addressMap.center[1] = point.coordinates[0];
|
||||
this.$refs.addressMap.update(); // cast child methods
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
div.address-form {
|
||||
h4.h3 {
|
||||
font-weight: bold;
|
||||
}
|
||||
div#address_map {
|
||||
height: 400px;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
@ -1,64 +1,62 @@
|
||||
<template>
|
||||
<div class="address multiline">
|
||||
<p v-if="address.text"
|
||||
class="street">
|
||||
{{ address.text }}
|
||||
</p>
|
||||
<p v-if="address.postcode"
|
||||
class="postcode">
|
||||
{{ address.postcode.name }}
|
||||
</p>
|
||||
<p v-if="address.country"
|
||||
class="country">
|
||||
{{ address.country.name.fr }}
|
||||
</p>
|
||||
|
||||
<div v-if="address.floor">
|
||||
<span class="floor">
|
||||
<b>{{ $t('floor') }}</b>: {{ address.floor }}
|
||||
</span>
|
||||
<div class="chill-entity entity-address my-3">
|
||||
<div class="address multiline">
|
||||
<p v-if="address.text"
|
||||
class="street">
|
||||
{{ address.text }}
|
||||
</p>
|
||||
<p v-if="address.postcode"
|
||||
class="postcode">
|
||||
{{ address.postcode.code }} {{ address.postcode.name }}
|
||||
</p>
|
||||
<p v-if="address.country"
|
||||
class="country">
|
||||
{{ address.country.name.fr }}
|
||||
</p>
|
||||
</div>
|
||||
<div v-if="address.corridor">
|
||||
<span class="corridor">
|
||||
<b>{{ $t('corridor') }}</b>: {{ address.corridor }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.steps">
|
||||
<span class="steps">
|
||||
<b>{{ $t('steps') }}</b>: {{ address.steps }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.flat">
|
||||
<span class="flat">
|
||||
<b>{{ $t('flat') }}</b>: {{ address.flat }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.buildingName">
|
||||
<span class="buildingName">
|
||||
<b>{{ $t('buildingName') }}</b>: {{ address.buildingName }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.extra">
|
||||
<span class="extra">
|
||||
<b>{{ $t('extra') }}</b>: {{ address.extra }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.distribution">
|
||||
<span class="distribution">
|
||||
<b>{{ $t('distribution') }}</b>: {{ address.distribution }}
|
||||
</span>
|
||||
<div>
|
||||
<div v-if="address.floor">
|
||||
<span class="floor">
|
||||
<b>{{ $t('floor') }}</b>: {{ address.floor }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.corridor">
|
||||
<span class="corridor">
|
||||
<b>{{ $t('corridor') }}</b>: {{ address.corridor }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.steps">
|
||||
<span class="steps">
|
||||
<b>{{ $t('steps') }}</b>: {{ address.steps }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.flat">
|
||||
<span class="flat">
|
||||
<b>{{ $t('flat') }}</b>: {{ address.flat }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.buildingName">
|
||||
<span class="buildingName">
|
||||
<b>{{ $t('buildingName') }}</b>: {{ address.buildingName }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.extra">
|
||||
<span class="extra">
|
||||
<b>{{ $t('extra') }}</b>: {{ address.extra }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.distribution">
|
||||
<span class="distribution">
|
||||
<b>{{ $t('distribution') }}</b>: {{ address.distribution }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'ShowAddress',
|
||||
props: ['address'],
|
||||
data() {
|
||||
return {
|
||||
}
|
||||
},
|
||||
};
|
||||
name: "ShowAddress",
|
||||
props: ['address']
|
||||
}
|
||||
</script>
|
||||
|
@ -0,0 +1,101 @@
|
||||
<template>
|
||||
|
||||
<div v-if="insideModal == false" class="loading">
|
||||
<i v-if="flag.loading" class="fa fa-circle-o-notch fa-spin fa-2x fa-fw"></i>
|
||||
<span class="sr-only">{{ $t('loading') }}</span>
|
||||
</div>
|
||||
<div v-if="errorMsg && errorMsg.length > 0" class="alert alert-danger">
|
||||
{{ errorMsg }}
|
||||
</div>
|
||||
<div v-if="flag.success" class="alert alert-success">
|
||||
{{ $t(getSuccessText) }}
|
||||
</div>
|
||||
|
||||
<show-address :address="address"></show-address>
|
||||
|
||||
<div v-if="showDateFrom" class='address-valid date-since'>
|
||||
<h3>{{ $t(getValidFromDateText) }}</h3>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="validFrom"><i class="fa fa-fw fa-calendar"></i></span>
|
||||
<input type="date" class="form-control form-control-lg" name="validFrom"
|
||||
v-bind:placeholder="$t(getValidFromDateText)"
|
||||
v-model="validFrom"
|
||||
aria-describedby="validFrom"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul v-if="insideModal == false"
|
||||
class="record_actions sticky-form-buttons">
|
||||
<li class="cancel">
|
||||
<a class="btn btn-cancel" v-bind:href="context.backUrl">
|
||||
{{ $t('back_to_the_list') }}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a @click.prevent="$emit('openEditPane')"
|
||||
class="btn btn-update">
|
||||
{{ $t('action.edit')}}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-save"
|
||||
@click.prevent="$emit('submitAddress')">
|
||||
{{ $t('action.save')}}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { dateToISO, ISOToDate, ISOToDatetime } from 'ChillMainAssets/chill/js/date.js';
|
||||
import ShowAddress from './ShowAddress.vue';
|
||||
|
||||
export default {
|
||||
name: 'ShowAddressPane',
|
||||
components: {
|
||||
ShowAddress
|
||||
},
|
||||
props: [
|
||||
'context',
|
||||
'options',
|
||||
'default',
|
||||
'flag',
|
||||
'entity',
|
||||
'valid',
|
||||
'errorMsg',
|
||||
'insideModal'
|
||||
],
|
||||
emits: ['openEditPane', 'submitAddress'], //?
|
||||
computed: {
|
||||
address() {
|
||||
return this.entity.address;
|
||||
},
|
||||
validFrom: {
|
||||
set(value) {
|
||||
this.valid.from = ISOToDate(value);
|
||||
},
|
||||
get() {
|
||||
return dateToISO(this.valid.from);
|
||||
}
|
||||
},
|
||||
getValidFromDateText() {
|
||||
return (this.context.entity.type === 'household') ? 'move_date' : 'validFrom';
|
||||
},
|
||||
getSuccessText() {
|
||||
switch (this.context.entity.type) {
|
||||
/*
|
||||
case 'household':
|
||||
return (this.context.edit) ? 'household_address_edit_success' : 'household_address_move_success';
|
||||
case 'person':
|
||||
return (this.context.edit) ? 'person_address_edit_success' : 'person_address_creation_success';
|
||||
*/
|
||||
default:
|
||||
return (this.context.edit) ? 'address_edit_success' : 'address_new_success';
|
||||
}
|
||||
},
|
||||
showDateFrom() {
|
||||
return !this.context.edit && !this.options.hideDateFrom;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,55 @@
|
||||
const addressMessages = {
|
||||
fr: {
|
||||
add_an_address_title: 'Créer une adresse',
|
||||
edit_an_address_title: 'Modifier une adresse',
|
||||
create_a_new_address: 'Créer une nouvelle adresse',
|
||||
edit_address: 'Modifier l\'adresse',
|
||||
select_an_address_title: 'Sélectionner une adresse',
|
||||
fill_an_address: 'Compléter l\'adresse',
|
||||
select_country: 'Choisir le pays',
|
||||
country: 'Pays',
|
||||
select_city: 'Choisir une localité',
|
||||
city: 'Localité',
|
||||
other_city: 'Autre localité',
|
||||
select_address: 'Choisir une adresse',
|
||||
address: 'Adresse',
|
||||
other_address: 'Autre adresse',
|
||||
create_address: 'Adresse inconnue. Cliquez ici pour créer une nouvelle adresse',
|
||||
isNoAddress: 'Pas d\'adresse complète',
|
||||
street: 'Nom de rue',
|
||||
streetNumber: 'Numéro',
|
||||
floor: 'Étage',
|
||||
corridor: 'Couloir',
|
||||
steps: 'Escalier',
|
||||
flat: 'Appartement',
|
||||
buildingName: 'Nom du bâtiment',
|
||||
extra: 'Complément d\'adresse',
|
||||
distribution: 'Service particulier de distribution',
|
||||
create_postal_code: 'Localité inconnue. Cliquez ici pour créer une nouvelle localité',
|
||||
postalCode_name: 'Nom',
|
||||
postalCode_code: 'Code postal',
|
||||
date: 'Date de la nouvelle adresse',
|
||||
validFrom: 'Date de la nouvelle adresse',
|
||||
back_to_the_list: 'Retour à la liste',
|
||||
loading: 'chargement en cours...',
|
||||
address_new_success: 'La nouvelle adresse est enregistrée',
|
||||
address_edit_success: 'L\'adresse a été mise à jour',
|
||||
|
||||
// person specific
|
||||
add_an_address_to_person: 'Ajouter l\'adresse à la personne',
|
||||
person_address_creation_success: 'La nouvelle adresse de la personne est enregistrée',
|
||||
person_address_edit_success: 'L\'adresse de la personne a été mise à jour',
|
||||
|
||||
// household specific
|
||||
move_date: 'Date du déménagement',
|
||||
select_a_existing_address: 'Sélectionner une adresse existante',
|
||||
add_an_address_to_household: 'Enregistrer',
|
||||
household_address_move_success: 'La nouvelle adresse du ménage est enregistrée',
|
||||
household_address_edit_success: 'L\'adresse du ménage a été mise à jour',
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
export {
|
||||
addressMessages
|
||||
};
|
@ -1,16 +1,13 @@
|
||||
import { createApp } from 'vue'
|
||||
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
|
||||
import { addressMessages } from './js/i18n'
|
||||
import { store } from './store'
|
||||
|
||||
import { createApp } from 'vue';
|
||||
import App from './App.vue';
|
||||
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n';
|
||||
import { addressMessages } from './i18n';
|
||||
|
||||
const i18n = _createI18n(addressMessages);
|
||||
const i18n = _createI18n( addressMessages );
|
||||
|
||||
const app = createApp({
|
||||
template: `<app></app>`,
|
||||
template: `<app></app>`,
|
||||
})
|
||||
.use(store)
|
||||
.use(i18n)
|
||||
.component('app', App)
|
||||
.mount('#address');
|
||||
|
@ -1,42 +0,0 @@
|
||||
const addressMessages = {
|
||||
fr: {
|
||||
add_an_address_title: 'Créer une adresse',
|
||||
edit_an_address_title: 'Modifier une adresse',
|
||||
create_a_new_address: 'Créer une nouvelle adresse',
|
||||
edit_address: 'Modifier l\'adresse',
|
||||
select_an_address_title: 'Sélectionner une adresse',
|
||||
fill_an_address: 'Compléter l\'adresse',
|
||||
select_country: 'Choisir le pays',
|
||||
country: 'Pays',
|
||||
select_city: 'Choisir une localité',
|
||||
city: 'Localité',
|
||||
other_city: 'Autre localité',
|
||||
select_address: 'Choisir une adresse',
|
||||
address: 'Adresse',
|
||||
other_address: 'Autre adresse',
|
||||
create_address: 'Adresse inconnue. Cliquez ici pour créer une nouvelle adresse',
|
||||
isNoAddress: 'Pas d\'adresse complète',
|
||||
street: 'Nom de rue',
|
||||
streetNumber: 'Numéro',
|
||||
floor: 'Étage',
|
||||
corridor: 'Couloir',
|
||||
steps: 'Escalier',
|
||||
flat: 'Appartement',
|
||||
buildingName: 'Nom du bâtiment',
|
||||
extra: 'Complément d\'adresse',
|
||||
distribution: 'Service particulier de distribution',
|
||||
create_postal_code: 'Localité inconnue. Cliquez ici pour créer une nouvelle localité',
|
||||
postalCode_name: 'Nom',
|
||||
postalCode_code: 'Code postal',
|
||||
date: 'Date de la nouvelle adresse',
|
||||
add_an_address_to_person: 'Ajouter l\'adresse à la personne',
|
||||
validFrom: 'Date de la nouvelle adresse',
|
||||
back_to_the_list: 'Retour à la liste',
|
||||
person_address_creation_success: 'La nouvelle adresse de la personne est enregistrée',
|
||||
loading: 'chargement en cours...'
|
||||
}
|
||||
};
|
||||
|
||||
export {
|
||||
addressMessages
|
||||
};
|
@ -0,0 +1,14 @@
|
||||
import 'es6-promise/auto';
|
||||
import { createStore } from 'vuex';
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
|
||||
const store = createStore({
|
||||
strict: debug,
|
||||
state: {},
|
||||
getters: {},
|
||||
mutations: {},
|
||||
actions: {},
|
||||
});
|
||||
|
||||
export { store };
|
@ -1,158 +0,0 @@
|
||||
import 'es6-promise/auto';
|
||||
import { createStore } from 'vuex';
|
||||
|
||||
import { patchAddress, postAddress, postPostalCode, postAddressToPerson, getAddress } from '../api'
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
|
||||
const store = createStore({
|
||||
strict: debug,
|
||||
state: {
|
||||
address: {},
|
||||
editAddress: {}, //TODO or should be address?
|
||||
person: {},
|
||||
errorMsg: [],
|
||||
loading: false,
|
||||
success: false
|
||||
},
|
||||
getters: {
|
||||
},
|
||||
mutations: {
|
||||
catchError(state, error) {
|
||||
state.errorMsg.push(error);
|
||||
},
|
||||
addAddress(state, address) {
|
||||
console.log('@M addAddress address', address);
|
||||
state.address = address;
|
||||
},
|
||||
updateAddress(state, address) {
|
||||
console.log('@M updateAddress address', address);
|
||||
state.address = address;
|
||||
},
|
||||
addAddressToPerson(state, person) {
|
||||
console.log('@M addAddressToPerson person', person);
|
||||
state.person = person;
|
||||
},
|
||||
addDateToAddress(state, validFrom) {
|
||||
console.log('@M addDateToAddress address.validFrom', validFrom);
|
||||
state.validFrom = validFrom;
|
||||
},
|
||||
getEditAddress(state, address) {
|
||||
console.log('@M getEditAddress address', address);
|
||||
state.editAddress = address;
|
||||
},
|
||||
setLoading(state, b) {
|
||||
state.loading = b;
|
||||
},
|
||||
setSuccess(state, b) {
|
||||
state.success = b;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
addAddress({ commit }, payload) {
|
||||
console.log('@A addAddress payload', payload);
|
||||
commit('setLoading', true);
|
||||
if('newPostalCode' in payload){
|
||||
let postalCodeBody = payload.newPostalCode;
|
||||
postalCodeBody = Object.assign(postalCodeBody, {'origin': 3});
|
||||
postPostalCode(postalCodeBody)
|
||||
.then(postalCode => {
|
||||
let body = payload;
|
||||
body.postcode = {'id': postalCode.id},
|
||||
postAddress(body)
|
||||
.then(address => new Promise((resolve, reject) => {
|
||||
commit('addAddress', address);
|
||||
resolve();
|
||||
commit('setLoading', false);
|
||||
}))
|
||||
.catch((error) => {
|
||||
commit('catchError', error);
|
||||
commit('setLoading', false);
|
||||
});
|
||||
})
|
||||
|
||||
} else {
|
||||
postAddress(payload)
|
||||
.then(address => new Promise((resolve, reject) => {
|
||||
commit('addAddress', address);
|
||||
resolve();
|
||||
commit('setLoading', false);
|
||||
}))
|
||||
.catch((error) => {
|
||||
commit('catchError', error);
|
||||
commit('setLoading', false);
|
||||
});
|
||||
}
|
||||
},
|
||||
addDateToAddressAndAddressToPerson({ commit }, payload) {
|
||||
console.log('@A addDateToAddressAndAddressToPerson payload', payload);
|
||||
commit('setLoading', true);
|
||||
patchAddress(payload.addressId, payload.body)
|
||||
.then(address => new Promise((resolve, reject) => {
|
||||
commit('addDateToAddress', address.validFrom);
|
||||
resolve();
|
||||
}).then(
|
||||
postAddressToPerson(payload.personId, payload.addressId)
|
||||
.then(person => new Promise((resolve, reject) => {
|
||||
commit('addAddressToPerson', person);
|
||||
commit('setLoading', false);
|
||||
commit('setSuccess', true);
|
||||
window.location.assign(payload.backUrl);
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
commit('catchError', error);
|
||||
commit('setLoading', false);
|
||||
})
|
||||
))
|
||||
.catch((error) => {
|
||||
commit('catchError', error);
|
||||
commit('setLoading', false);
|
||||
});
|
||||
},
|
||||
updateAddress({ commit }, payload) {
|
||||
console.log('@A updateAddress payload', payload);
|
||||
|
||||
if('newPostalCode' in payload.newAddress){ // TODO change the condition because it writes new postal code in edit mode now: !writeNewPostalCode
|
||||
let postalCodeBody = payload.newAddress.newPostalCode;
|
||||
postalCodeBody = Object.assign(postalCodeBody, {'origin': 3});
|
||||
postPostalCode(postalCodeBody)
|
||||
.then(postalCode => {
|
||||
let body = payload.newAddress;
|
||||
body.postcode = {'id': postalCode.id },
|
||||
patchAddress(payload.addressId, body)
|
||||
.then(address => new Promise((resolve, reject) => {
|
||||
commit('updateAddress', address);
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
commit('catchError', error);
|
||||
});
|
||||
})
|
||||
|
||||
} else {
|
||||
patchAddress(payload.addressId, payload.newAddress)
|
||||
.then(address => new Promise((resolve, reject) => {
|
||||
commit('updateAddress', address);
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
commit('catchError', error);
|
||||
});
|
||||
}
|
||||
},
|
||||
getEditAddress({ commit }, payload) {
|
||||
console.log('@A getEditAddress payload', payload);
|
||||
|
||||
getAddress(payload).then(address => new Promise((resolve, reject) => {
|
||||
commit('getEditAddress', address);
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
commit('catchError', error);
|
||||
});
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
export { store };
|
@ -24,16 +24,16 @@
|
||||
<!-- :: end styles bootstrap :: -->
|
||||
</div>
|
||||
</transition>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/*
|
||||
* This Modal component is a mix between Vue3 modal implementation
|
||||
* This Modal component is a mix between Vue3 modal implementation
|
||||
* [+] with 'v-if:showModal' directive:parameter, html scope is added/removed not just shown/hidden
|
||||
* [+] with slot we can pass content from parent component
|
||||
* [+] some classes are passed from parent component
|
||||
* and Bootstrap 4.6 _modal.scss module
|
||||
* [+] using bootstrap css classes, the modal have a responsive behaviour,
|
||||
* [+] using bootstrap css classes, the modal have a responsive behaviour,
|
||||
* [+] modal design can be configured using css classes (size, scroll)
|
||||
*/
|
||||
export default {
|
||||
@ -54,7 +54,7 @@ export default {
|
||||
background-color: rgba(0, 0, 0, 0.75);
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
.modal-header .close {
|
||||
.modal-header .close {
|
||||
border-top-right-radius: 0.3rem;
|
||||
}
|
||||
/*
|
||||
@ -71,7 +71,8 @@ export default {
|
||||
.modal-leave-active {
|
||||
opacity: 0;
|
||||
}
|
||||
.modal-enter .modal-container,
|
||||
.modal-enter
|
||||
.modal-container,
|
||||
.modal-leave-active .modal-container {
|
||||
-webkit-transform: scale(1.1);
|
||||
transform: scale(1.1);
|
||||
@ -80,4 +81,9 @@ export default {
|
||||
font-size: 1.5rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
div.modal-footer {
|
||||
button:first-child {
|
||||
margin-right: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -1,21 +1,21 @@
|
||||
<template>
|
||||
|
||||
<a class="btn" target="_blank"
|
||||
|
||||
<a class="btn btn-sm" target="_blank"
|
||||
:class="classAction"
|
||||
:title="$t(titleAction)"
|
||||
@click="openModal">
|
||||
{{ buttonText }}
|
||||
</a>
|
||||
|
||||
|
||||
<teleport to="body">
|
||||
<modal v-if="modal.showModal"
|
||||
:modalDialogClass="modal.modalDialogClass"
|
||||
@close="modal.showModal = false">
|
||||
|
||||
|
||||
<template v-slot:header>
|
||||
<h3 class="modal-title">{{ $t(titleModal) }}</h3>
|
||||
</template>
|
||||
|
||||
|
||||
<template v-slot:body v-if="type === 'person'">
|
||||
<on-the-fly-person
|
||||
v-bind:id="id"
|
||||
@ -24,7 +24,7 @@
|
||||
ref="castPerson">
|
||||
</on-the-fly-person>
|
||||
</template>
|
||||
|
||||
|
||||
<template v-slot:body v-else-if="type === 'thirdparty'">
|
||||
<on-the-fly-thirdparty
|
||||
v-bind:id="id"
|
||||
@ -33,31 +33,29 @@
|
||||
ref="castThirdparty">
|
||||
</on-the-fly-thirdparty>
|
||||
</template>
|
||||
|
||||
|
||||
<template v-slot:body v-else>
|
||||
<on-the-fly-create
|
||||
v-bind:action="action"
|
||||
ref="castNew">
|
||||
</on-the-fly-create>
|
||||
</template>
|
||||
|
||||
|
||||
<template v-slot:footer>
|
||||
<button v-if="action === 'show'"
|
||||
@click="changeActionTo('edit')"
|
||||
class="btn btn-update"> <!-- @click.prevent="$emit('..', ..)" -->
|
||||
class="btn btn-update">
|
||||
</button>
|
||||
<button v-else
|
||||
class="btn btn-save"
|
||||
@click="saveAction"
|
||||
> <!--
|
||||
-->
|
||||
@click="saveAction">
|
||||
{{ $t('action.save')}}
|
||||
</button>
|
||||
</template>
|
||||
|
||||
|
||||
</modal>
|
||||
</teleport>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@ -128,7 +126,7 @@ export default {
|
||||
},
|
||||
changeActionTo(action) {
|
||||
// [BUG] clic first on show item button; in modal clic edit button; close modal; clic again on show item button
|
||||
this.$data.action = action;
|
||||
this.$data.action = action;
|
||||
},
|
||||
saveAction() {
|
||||
console.log('saveAction');
|
||||
|
@ -32,6 +32,8 @@ const messages = {
|
||||
remove: "Enlever",
|
||||
delete: "Supprimer",
|
||||
save: "Enregistrer",
|
||||
valid: "Valider",
|
||||
valid_and_see: "Valider et voir",
|
||||
add: "Ajouter",
|
||||
show_modal: "Ouvrir une modale",
|
||||
ok: "OK",
|
||||
@ -61,7 +63,7 @@ const messages = {
|
||||
title: "Création d'un nouvel usager ou d'un tiers professionnel",
|
||||
person: "un nouvel usager",
|
||||
thirdparty: "un nouveau tiers professionnel"
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -1,36 +1,45 @@
|
||||
{{ opening_box|raw }}
|
||||
<div class="">
|
||||
<div class="comment-embeddable_comment">
|
||||
|
||||
{%- if options['limit_lines'] is not null -%}
|
||||
{% set content = comment.comment|split('\n')|slice(0, options['limit_lines'])|join('\n') %}
|
||||
{%- else -%}
|
||||
{% set content = comment.comment %}
|
||||
{%- endif -%}
|
||||
{#
|
||||
Template to render a comment
|
||||
|
||||
<blockquote class="chill-user-quote">
|
||||
OPTIONS
|
||||
* disable_markdown bool
|
||||
* limit_lines integer|null
|
||||
* metadata bool
|
||||
|
||||
#}
|
||||
{{ opening_box|raw }}
|
||||
{%- if options['limit_lines'] is not null -%}
|
||||
{% set content = comment.comment|split('\n')|slice(0, options['limit_lines'])|join('\n') %}
|
||||
{%- else -%}
|
||||
{% set content = comment.comment %}
|
||||
{%- endif -%}
|
||||
|
||||
<blockquote class="chill-user-quote">
|
||||
{% if options['disable_markdown'] %}
|
||||
{{ content|nl2br }}
|
||||
{% else %}
|
||||
{{ content|chill_markdown_to_html }}
|
||||
{% endif %}
|
||||
</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
{% if options['metadata'] %}
|
||||
<div class="chill-entity__comment-embeddable__metadata">
|
||||
{% if user is not empty %}
|
||||
<span class="chill-entity__comment-embeddable__user">
|
||||
{{ 'Last updated by'| trans }} {{ user|chill_entity_render_box(options['user']) }}
|
||||
</span>';
|
||||
{% endif %}
|
||||
|
||||
{% if comment.date is not empty %}
|
||||
<span class="chill-entity__comment-embeddable__date">
|
||||
{% if user is empty %}{{ 'Last updated on'|trans ~ ' ' }}{% else %}{{ 'on'|trans ~ ' ' }}{% endif %}
|
||||
{{ comment.date|format_datetime("medium", "short") }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ closing_box|raw }}
|
||||
|
||||
{% if options['metadata'] %}
|
||||
<div class="metadata">
|
||||
{% if user is not empty %}
|
||||
{{ 'Last updated by'| trans }}
|
||||
<span class="user">
|
||||
{{ user|chill_entity_render_box(options['user']) }}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if comment.date is not empty %}
|
||||
{% if user is empty %}
|
||||
{{ 'Last updated on'|trans ~ ' ' }}
|
||||
{% else %}
|
||||
{{ 'on'|trans ~ ' ' }}
|
||||
{% endif %}
|
||||
<span class="date">
|
||||
{{ comment.date|format_datetime("medium", "short") }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</blockquote>
|
||||
{{ closing_box|raw }}
|
||||
|
@ -71,12 +71,12 @@
|
||||
|
||||
{% macro validity(address, options) %}
|
||||
{%- if options['with_valid_from'] == true -%}
|
||||
<span class="address-valid address-since">
|
||||
<span class="address-valid date-since">
|
||||
{{ 'Since %date%'|trans( { '%date%' : address.validFrom|format_date('long') } ) }}
|
||||
</span>
|
||||
{%- endif -%}
|
||||
{%- if options['with_valid_to'] == true -%}
|
||||
<span class="address-valid address-until">
|
||||
<span class="address-valid date-until">
|
||||
{{ 'Until %date%'|trans( { '%date%' : address.validTo|format_date('long') } ) }}
|
||||
</span>
|
||||
{%- endif -%}
|
||||
|
@ -0,0 +1,20 @@
|
||||
<select class="form-select" aria-label="items Per Page" id="itemsPerPage">
|
||||
<option value="10">10 {{ 'results'|trans }}</option>
|
||||
<option value="20">20 {{ 'results'|trans }}</option>
|
||||
<option value="50">50 {{ 'results'|trans }}</option>
|
||||
<option value="100">100 {{ 'results'|trans }}</option>
|
||||
</select>
|
||||
<script>
|
||||
let select = document.querySelector("select#itemsPerPage");
|
||||
window.addEventListener('load', () =>
|
||||
select.value = {{ current }}
|
||||
);
|
||||
select.addEventListener('change', () => {
|
||||
let url = new URL(window.location.href);
|
||||
let params = url.searchParams;
|
||||
params.set('page', '1');
|
||||
params.set('item_per_page', select.value);
|
||||
url.search = params.toString();
|
||||
window.location.href = url.toString();
|
||||
});
|
||||
</script>
|
@ -53,23 +53,30 @@
|
||||
{% block sublayout_content %}
|
||||
<div class="row justify-content-center my-5">
|
||||
|
||||
{% for flashMessage in app.session.flashbag.get('success') %}
|
||||
<div class="col-8 mb-5 alert alert-success flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{# Flash messages ! #}
|
||||
{% if app.session.flashbag.keys()|length > 0 %}
|
||||
<div class="col-8 mb-5 flash_message">
|
||||
|
||||
{% for flashMessage in app.session.flashbag.get('error') %}
|
||||
<div class="col-8 mb-5 alert alert-danger flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% for flashMessage in app.session.flashbag.get('success') %}
|
||||
<div class="col-8 alert alert-success flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% for flashMessage in app.session.flashbag.get('notice') %}
|
||||
<div class="col-8 mb-5 alert alert-warning flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% for flashMessage in app.session.flashbag.get('error') %}
|
||||
<div class="col-8 alert alert-danger flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% for flashMessage in app.session.flashbag.get('notice') %}
|
||||
<div class="col-8 alert alert-warning flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-8 main_search">
|
||||
|
@ -27,23 +27,30 @@
|
||||
<div class="row">
|
||||
<div class="col-md-9 my-5">
|
||||
|
||||
{% for flashMessage in app.session.flashbag.get('success') %}
|
||||
<div class="col-8 mb-5 alert alert-success flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{# Flash messages ! #}
|
||||
{% if app.session.flashbag.keys()|length > 0 %}
|
||||
<div class="row justify-content-center mb-5">
|
||||
|
||||
{% for flashMessage in app.session.flashbag.get('error') %}
|
||||
<div class="col-8 mb-5 alert alert-danger flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% for flashMessage in app.session.flashbag.get('success') %}
|
||||
<div class="col-8 alert alert-success flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% for flashMessage in app.session.flashbag.get('notice') %}
|
||||
<div class="col-8 mb-5 alert alert-warning flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% for flashMessage in app.session.flashbag.get('error') %}
|
||||
<div class="col-8 alert alert-danger flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% for flashMessage in app.session.flashbag.get('notice') %}
|
||||
<div class="col-8 alert alert-warning flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% block layout_wvm_content %}<!-- content of the layoutWithVerticalMenu is empty -->
|
||||
{% endblock %}
|
||||
|
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\MainBundle\Search\Entity;
|
||||
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
use Chill\MainBundle\Search\SearchApiInterface;
|
||||
use Chill\MainBundle\Search\SearchApiQuery;
|
||||
|
||||
class SearchUserApiProvider implements SearchApiInterface
|
||||
{
|
||||
private UserRepository $userRepository;
|
||||
|
||||
/**
|
||||
* @param UserRepository $userRepository
|
||||
*/
|
||||
public function __construct(UserRepository $userRepository)
|
||||
{
|
||||
$this->userRepository = $userRepository;
|
||||
}
|
||||
|
||||
public function provideQuery(string $pattern, array $parameters): SearchApiQuery
|
||||
{
|
||||
$query = new SearchApiQuery();
|
||||
$query
|
||||
->setSelectKey("user")
|
||||
->setSelectJsonbMetadata("jsonb_build_object('id', u.id)")
|
||||
->setSelectPertinence("GREATEST(SIMILARITY(LOWER(UNACCENT(?)), u.usernamecanonical),
|
||||
SIMILARITY(LOWER(UNACCENT(?)), u.emailcanonical))", [ $pattern, $pattern ])
|
||||
->setFromClause("users AS u")
|
||||
->setWhereClause("SIMILARITY(LOWER(UNACCENT(?)), u.usernamecanonical) > 0.15
|
||||
OR
|
||||
SIMILARITY(LOWER(UNACCENT(?)), u.emailcanonical) > 0.15
|
||||
", [ $pattern, $pattern ]);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function supportsTypes(string $pattern, array $types, array $parameters): bool
|
||||
{
|
||||
return \in_array('user', $types);
|
||||
}
|
||||
|
||||
public function prepare(array $metadatas): void
|
||||
{
|
||||
$ids = \array_map(fn($m) => $m['id'], $metadatas);
|
||||
|
||||
$this->userRepository->findBy([ 'id' => $ids ]);
|
||||
}
|
||||
|
||||
public function supportsResult(string $key, array $metadatas): bool
|
||||
{
|
||||
return $key === 'user';
|
||||
}
|
||||
|
||||
public function getResult(string $key, array $metadata, float $pertinence)
|
||||
{
|
||||
return $this->userRepository->find($metadata['id']);
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Chill\MainBundle\Search;
|
||||
|
||||
use Chill\MainBundle\Search\Entity\SearchUserApiProvider;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\PersonBundle\Search\SearchPersonApiProvider;
|
||||
@ -25,12 +26,14 @@ class SearchApi
|
||||
EntityManagerInterface $em,
|
||||
SearchPersonApiProvider $searchPerson,
|
||||
ThirdPartyApiSearch $thirdPartyApiSearch,
|
||||
SearchUserApiProvider $searchUser,
|
||||
PaginatorFactory $paginator
|
||||
)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->providers[] = $searchPerson;
|
||||
$this->providers[] = $thirdPartyApiSearch;
|
||||
$this->providers[] = $searchUser;
|
||||
$this->paginator = $paginator;
|
||||
}
|
||||
|
||||
@ -41,6 +44,10 @@ class SearchApi
|
||||
{
|
||||
$queries = $this->findQueries($pattern, $types, $parameters);
|
||||
|
||||
if (0 === count($queries)) {
|
||||
throw new SearchApiNoQueryException($pattern, $types, $parameters);
|
||||
}
|
||||
|
||||
$total = $this->countItems($queries, $types, $parameters);
|
||||
$paginator = $this->paginator->create($total);
|
||||
|
||||
@ -49,9 +56,7 @@ class SearchApi
|
||||
$this->prepareProviders($rawResults);
|
||||
$results = $this->buildResults($rawResults);
|
||||
|
||||
$collection = new Collection($results, $paginator);
|
||||
|
||||
return $collection;
|
||||
return new Collection($results, $paginator);
|
||||
}
|
||||
|
||||
private function findQueries($pattern, array $types, array $parameters): array
|
||||
@ -77,7 +82,7 @@ class SearchApi
|
||||
$rsmCount->addScalarResult('count', 'count');
|
||||
$countNq = $this->em->createNativeQuery($countQuery, $rsmCount);
|
||||
$countNq->setParameters($parameters);
|
||||
|
||||
|
||||
return $countNq->getSingleScalarResult();
|
||||
}
|
||||
|
||||
@ -130,7 +135,7 @@ class SearchApi
|
||||
|
||||
$nq = $this->em->createNativeQuery($union, $rsm);
|
||||
$nq->setParameters($parameters);
|
||||
|
||||
|
||||
return $nq->getResult();
|
||||
}
|
||||
|
||||
@ -142,7 +147,7 @@ class SearchApi
|
||||
if ($p->supportsResult($r['key'], $r['metadata'])) {
|
||||
$metadatas[$k][] = $r['metadata'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +166,7 @@ class SearchApi
|
||||
$p->getResult($r['key'], $r['metadata'], $r['pertinence'])
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\MainBundle\Search;
|
||||
|
||||
use Throwable;
|
||||
|
||||
class SearchApiNoQueryException extends \RuntimeException
|
||||
{
|
||||
private string $pattern;
|
||||
private array $types;
|
||||
private array $parameters;
|
||||
|
||||
public function __construct(string $pattern = "", array $types = [], array $parameters = [], $code = 0, Throwable $previous = null)
|
||||
{
|
||||
$typesStr = \implode(", ", $types);
|
||||
$message = "No query for this search: pattern : {$pattern}, types: {$typesStr}";
|
||||
$this->pattern = $pattern;
|
||||
$this->types = $types;
|
||||
$this->parameters = $parameters;
|
||||
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
@ -127,8 +127,6 @@ paths:
|
||||
- person
|
||||
- thirdparty
|
||||
description: >
|
||||
**Warning**: This is currently a stub (not really implemented
|
||||
|
||||
The search is performed across multiple entities. The entities must be listed into
|
||||
`type` parameters.
|
||||
|
||||
@ -152,6 +150,7 @@ paths:
|
||||
enum:
|
||||
- person
|
||||
- thirdparty
|
||||
- user
|
||||
responses:
|
||||
200:
|
||||
description: "OK"
|
||||
|
@ -15,3 +15,8 @@ services:
|
||||
class: Chill\MainBundle\Pagination\ChillPaginationTwig
|
||||
tags:
|
||||
- { name: twig.extension }
|
||||
|
||||
chill_main.paginator.items_per_page.twig_extensions:
|
||||
class: Chill\MainBundle\Pagination\ChillItemsPerPageTwig
|
||||
tags:
|
||||
- { name: twig.extension }
|
||||
|
@ -7,3 +7,8 @@ services:
|
||||
Chill\MainBundle\Search\SearchApi:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
|
||||
Chill\MainBundle\Search\Entity\:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
resource: '../../Search/Entity'
|
||||
|
@ -85,6 +85,7 @@ Search %pattern%: Recherche de "%pattern%"
|
||||
Results %start%-%end% of %total%: Résultats %start%-%end% sur %total%
|
||||
See all results: Voir tous les résultats
|
||||
Advanced search: Recherche avancée
|
||||
results: résultats
|
||||
|
||||
# timeline
|
||||
Global timeline: Historique global
|
||||
|
@ -6,10 +6,12 @@ use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Repository\Household\HouseholdRepository;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class HouseholdApiController extends ApiController
|
||||
{
|
||||
@ -50,4 +52,45 @@ class HouseholdApiController extends ApiController
|
||||
return $this->json($collection, Response::HTTP_OK, [],
|
||||
[ "groups" => ["read"]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/address/suggest/by-household/{household_id}.{_format}",
|
||||
* name="chill_person_address_suggest_by_household",
|
||||
* requirements={
|
||||
* "_format"="json"
|
||||
* }
|
||||
* )
|
||||
* @ParamConverter("household", options={"id" = "household_id"})
|
||||
*/
|
||||
public function suggestAddressByHousehold(Household $household, string $_format)
|
||||
{
|
||||
// TODO add acl
|
||||
|
||||
$addresses = [];
|
||||
// collect addresses from location in courses
|
||||
foreach ($household->getCurrentPersons() as $person) {
|
||||
foreach ($person->getAccompanyingPeriodParticipations() as $participation) {
|
||||
if (null !== $participation->getAccompanyingPeriod()->getAddressLocation()) {
|
||||
$a = $participation->getAccompanyingPeriod()->getAddressLocation();
|
||||
$addresses[$a->getId()] = $a;
|
||||
}
|
||||
if (null !== $personLocation = $participation
|
||||
->getAccompanyingPeriod()->getPersonLocation()) {
|
||||
$a = $personLocation->getCurrentHouseholdAddress();
|
||||
if (null !== $a) {
|
||||
$addresses[$a->getId()] = $a;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// remove the actual address
|
||||
$actual = $household->getCurrentAddress();
|
||||
if (null !== $actual) {
|
||||
$addresses = \array_filter($addresses, fn($a) => $a !== $actual);
|
||||
}
|
||||
|
||||
return $this->json(\array_values($addresses), Response::HTTP_OK, [],
|
||||
[ 'groups' => [ 'read' ] ]);
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,15 @@
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
|
||||
class PersonApiController extends ApiController
|
||||
{
|
||||
@ -54,4 +57,41 @@ class PersonApiController extends ApiController
|
||||
return $this->addRemoveSomething('address', $id, $request, $_format, 'address', Address::class, [ 'groups' => [ 'read' ] ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/address/suggest/by-person/{person_id}.{_format}",
|
||||
* name="chill_person_address_suggest_by_person",
|
||||
* requirements={
|
||||
* "_format"="json"
|
||||
* }
|
||||
* )
|
||||
* @ParamConverter("person", options={"id" = "person_id"})
|
||||
*/
|
||||
public function suggestAddress(Person $person, Request $request, string $_format): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
|
||||
|
||||
$addresses = [];
|
||||
// collect addresses from location in courses
|
||||
foreach ($person->getAccompanyingPeriodParticipations() as $participation) {
|
||||
if (null !== $participation->getAccompanyingPeriod()->getAddressLocation()) {
|
||||
$a = $participation->getAccompanyingPeriod()->getAddressLocation();
|
||||
$addresses[$a->getId()] = $a;
|
||||
}
|
||||
if (null !== $personLocation = $participation
|
||||
->getAccompanyingPeriod()->getPersonLocation()) {
|
||||
$a = $personLocation->getCurrentHouseholdAddress();
|
||||
if (null !== $a) {
|
||||
$addresses[$a->getId()] = $a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// remove the actual address
|
||||
$actual = $person->getCurrentHouseholdAddress();
|
||||
if (null !== $actual) {
|
||||
$addresses = \array_filter($addresses, fn($a) => $a !== $actual);
|
||||
}
|
||||
|
||||
return $this->json(\array_values($addresses), Response::HTTP_OK, [], [ 'groups' => [ 'read' ]]);
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,12 @@
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Chill\MainBundle\Doctrine\ORM\Hydration\FlatHierarchyEntityHydrator;
|
||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Query;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class SocialIssueApiController extends ApiController
|
||||
{
|
||||
@ -16,6 +20,25 @@ class SocialIssueApiController extends ApiController
|
||||
$query->expr()->isNull('e.desactivationDate')
|
||||
)
|
||||
);
|
||||
$query->setParameter('now', new \DateTimeImmutable());
|
||||
$query->setParameter('now', new DateTimeImmutable());
|
||||
}
|
||||
|
||||
protected function getQueryResult(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, $query)
|
||||
{
|
||||
// In order to work, this hydrator only works with
|
||||
// entities having the field "children" set up.
|
||||
return $query
|
||||
->getQuery()
|
||||
->setHint(Query::HINT_INCLUDE_META_COLUMNS, true)
|
||||
->getResult(FlatHierarchyEntityHydrator::LIST);
|
||||
}
|
||||
|
||||
protected function onPostIndexBuildQuery(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, $query): ?Response
|
||||
{
|
||||
$query
|
||||
->orderBy("GET_JSON_FIELD_BY_KEY(e.title, :locale)", 'ASC')
|
||||
->setParameter(':locale', $request->getLocale());
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS, <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/>.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Controller\SocialWork;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
|
||||
/**
|
||||
* Class AdminSocialIssueController
|
||||
* Controller for social issues
|
||||
*
|
||||
* @package Chill\PersonBundle\Controller
|
||||
*/
|
||||
class AdminEvaluationController extends CRUDController
|
||||
{
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user