mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 22:46:13 +00:00
use pick dynamic user type for reassigning + layout stuffs
This commit is contained in:
parent
0ec859e345
commit
8113fddcb2
@ -51,9 +51,7 @@ function loadDynamicPicker(element) {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addNewEntity(entity) {
|
addNewEntity(entity) {
|
||||||
console.log('addNewEntity', entity);
|
|
||||||
if (this.multiple) {
|
if (this.multiple) {
|
||||||
console.log('adding multiple');
|
|
||||||
if (!this.picked.some(el => {
|
if (!this.picked.some(el => {
|
||||||
return el.type === entity.type && el.id === entity.id;
|
return el.type === entity.type && el.id === entity.id;
|
||||||
})) {
|
})) {
|
||||||
@ -71,7 +69,6 @@ function loadDynamicPicker(element) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeEntity(entity) {
|
removeEntity(entity) {
|
||||||
console.log('removeEntity', entity);
|
|
||||||
this.picked = this.picked.filter(e => !(e.type === entity.type && e.id === entity.id));
|
this.picked = this.picked.filter(e => !(e.type === entity.type && e.id === entity.id));
|
||||||
input.value = JSON.stringify(this.picked);
|
input.value = JSON.stringify(this.picked);
|
||||||
},
|
},
|
||||||
@ -86,7 +83,6 @@ function loadDynamicPicker(element) {
|
|||||||
|
|
||||||
|
|
||||||
document.addEventListener('show-hide-show', function(e) {
|
document.addEventListener('show-hide-show', function(e) {
|
||||||
console.log('creation event caught')
|
|
||||||
loadDynamicPicker(e.detail.container)
|
loadDynamicPicker(e.detail.container)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -94,17 +90,14 @@ document.addEventListener('show-hide-hide', function(e) {
|
|||||||
console.log('hiding event caught')
|
console.log('hiding event caught')
|
||||||
e.detail.container.querySelectorAll('[data-module="pick-dynamic"]').forEach((el) => {
|
e.detail.container.querySelectorAll('[data-module="pick-dynamic"]').forEach((el) => {
|
||||||
let uniqId = el.dataset.uniqid;
|
let uniqId = el.dataset.uniqid;
|
||||||
console.log(uniqId);
|
|
||||||
if (appsOnPage.has(uniqId)) {
|
if (appsOnPage.has(uniqId)) {
|
||||||
appsOnPage.get(uniqId).unmount();
|
appsOnPage.get(uniqId).unmount();
|
||||||
console.log('App has been unmounted')
|
|
||||||
appsOnPage.delete(uniqId);
|
appsOnPage.delete(uniqId);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function(e) {
|
document.addEventListener('DOMContentLoaded', function(e) {
|
||||||
console.log('loaded event', e)
|
|
||||||
loadDynamicPicker(document)
|
loadDynamicPicker(document)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -66,9 +66,18 @@ export default {
|
|||||||
translatedListOfTypes() {
|
translatedListOfTypes() {
|
||||||
let trans = [];
|
let trans = [];
|
||||||
this.types.forEach(t => {
|
this.types.forEach(t => {
|
||||||
trans.push(appMessages.fr.pick_entity[t].toLowerCase());
|
if (this.$props.multiple) {
|
||||||
|
trans.push(appMessages.fr.pick_entity[t].toLowerCase());
|
||||||
|
} else {
|
||||||
|
trans.push(appMessages.fr.pick_entity[t + '_one'].toLowerCase());
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return appMessages.fr.pick_entity.modal_title + trans.join(', ');
|
|
||||||
|
if (this.$props.multiple) {
|
||||||
|
return appMessages.fr.pick_entity.modal_title + trans.join(', ');
|
||||||
|
} else {
|
||||||
|
return appMessages.fr.pick_entity.modal_title_one + trans.join(', ');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -79,15 +88,10 @@ export default {
|
|||||||
);
|
);
|
||||||
this.$refs.addPersons.resetSearch(); // to cast child method
|
this.$refs.addPersons.resetSearch(); // to cast child method
|
||||||
modal.showModal = false;
|
modal.showModal = false;
|
||||||
console.log(this.picked)
|
|
||||||
},
|
},
|
||||||
removeEntity(entity) {
|
removeEntity(entity) {
|
||||||
console.log('remove entity', entity);
|
|
||||||
this.$emit('removeEntity', entity);
|
this.$emit('removeEntity', entity);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
console.log(this.picked);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -11,6 +11,10 @@ const appMessages = {
|
|||||||
user: 'Utilisateurs',
|
user: 'Utilisateurs',
|
||||||
person: 'Usagers',
|
person: 'Usagers',
|
||||||
thirdparty: 'Tiers',
|
thirdparty: 'Tiers',
|
||||||
|
modal_title_one: 'Indiquer un ',
|
||||||
|
user_one: 'Utilisateur',
|
||||||
|
thirdparty_one: 'Tiers',
|
||||||
|
person_one: 'Usager',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,6 +217,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block pick_entity_dynamic_widget %}
|
{% block pick_entity_dynamic_widget %}
|
||||||
|
{{ form_help(form)}}
|
||||||
<input type="hidden" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %} data-input-uniqid="{{ form.vars['uniqid'] }}"/>
|
<input type="hidden" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %} data-input-uniqid="{{ form.vars['uniqid'] }}"/>
|
||||||
<div data-module="pick-dynamic" data-types="{{ form.vars['types']|json_encode }}" data-multiple="{{ form.vars['multiple'] }}" data-uniqid="{{ form.vars['uniqid'] }}"></div>
|
<div data-module="pick-dynamic" data-types="{{ form.vars['types']|json_encode }}" data-multiple="{{ form.vars['multiple'] }}" data-uniqid="{{ form.vars['uniqid'] }}"></div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\PersonBundle\Controller;
|
namespace Chill\PersonBundle\Controller;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Chill\MainBundle\Form\Type\PickUserDynamicType;
|
||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||||
use Chill\MainBundle\Repository\UserRepository;
|
use Chill\MainBundle\Repository\UserRepository;
|
||||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||||
@ -31,7 +32,10 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
use Symfony\Component\Templating\EngineInterface;
|
use Symfony\Component\Templating\EngineInterface;
|
||||||
|
use Symfony\Component\Validator\Constraints\NotEqualTo;
|
||||||
|
use Symfony\Component\Validator\Constraints\NotIdenticalTo;
|
||||||
use function is_int;
|
use function is_int;
|
||||||
|
|
||||||
class ReassignAccompanyingPeriodController extends AbstractController
|
class ReassignAccompanyingPeriodController extends AbstractController
|
||||||
@ -129,18 +133,17 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|
||||||
// redirect to the first page
|
// redirect to the first page
|
||||||
return $this->redirectToRoute('chill_course_list_reassign', [
|
return $this->redirectToRoute('chill_course_list_reassign', $request->query->all());
|
||||||
'form' => ['user' => $userFrom->getId()],
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response(
|
return new Response(
|
||||||
$this->engine->render('@ChillPerson/AccompanyingPeriod/reassign_list.html.twig', [
|
$this->engine->render('@ChillPerson/AccompanyingPeriod/reassign_list.html.twig', [
|
||||||
|
'assignForm' => $assignForm->createView(),
|
||||||
|
'form' => $form->createView(),
|
||||||
'paginator' => $paginator,
|
'paginator' => $paginator,
|
||||||
'periods' => $periods,
|
'periods' => $periods,
|
||||||
'form' => $form->createView(),
|
'userFrom' => $userFrom,
|
||||||
'assignForm' => $assignForm->createView(),
|
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -154,15 +157,11 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
'method' => 'get', 'csrf_protection' => false, ]);
|
'method' => 'get', 'csrf_protection' => false, ]);
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('user', EntityType::class, [
|
->add('user', PickUserDynamicType::class, [
|
||||||
'class' => User::class, // pickUserType or PickDyamicUserType
|
|
||||||
'choices' => $this->userRepository->findByActive(['username' => 'ASC']),
|
|
||||||
'choice_label' => function (User $u) {
|
|
||||||
return $this->userRender->renderString($u, []);
|
|
||||||
},
|
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'label' => 'User',
|
'label' => 'reassign.Current user',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
'help' => 'reassign.Choose a user and click on "Filter" to apply',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $builder->getForm();
|
return $builder->getForm();
|
||||||
@ -173,26 +172,23 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
$defaultData = [
|
$defaultData = [
|
||||||
'userFrom' => $userFrom,
|
'userFrom' => $userFrom,
|
||||||
'periods' => json_encode($periodIds),
|
'periods' => json_encode($periodIds),
|
||||||
'assignTo' => null,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$builder = $this->formFactory->createBuilder(FormType::class, $defaultData);
|
$builder = $this->formFactory->createNamedBuilder('reassign', FormType::class, $defaultData);
|
||||||
|
|
||||||
|
if (null !== $userFrom) {
|
||||||
|
$constraints = [new NotIdenticalTo(['value' => $userFrom])];
|
||||||
|
}
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('periods', HiddenType::class)
|
->add('periods', HiddenType::class)
|
||||||
->add('userFrom', HiddenType::class)
|
->add('userFrom', HiddenType::class)
|
||||||
->add('userTo', EntityType::class, [
|
->add('userTo', PickUserDynamicType::class, [
|
||||||
'class' => User::class, // PickUserType
|
|
||||||
'choices' => $this->userRepository->findByActive(['username' => 'ASC']),
|
|
||||||
'choice_label' => function (User $u) {
|
|
||||||
return $this->userRender->renderString($u, []);
|
|
||||||
},
|
|
||||||
'placeholder' => 'Choose a user to reassign to',
|
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'label' => 'User',
|
'label' => 'reassign.Next user',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
// add a constraint: userFrom is not equal to userTo
|
'help' => 'reassign.All periods on this list will be reassigned to this user, excepted the one you manually reassigned before',
|
||||||
//'constraints' => NotEqualToh
|
'constraints' => $constraints ?? [],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->get('userFrom')->addModelTransformer(new CallbackTransformer(
|
$builder->get('userFrom')->addModelTransformer(new CallbackTransformer(
|
||||||
|
@ -4,10 +4,12 @@
|
|||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
{{ encore_entry_script_tags('mod_set_referrer') }}
|
{{ encore_entry_script_tags('mod_set_referrer') }}
|
||||||
|
{{ encore_entry_script_tags('mod_pickentity_type') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
{{ encore_entry_link_tags('mod_set_referrer') }}
|
{{ encore_entry_link_tags('mod_set_referrer') }}
|
||||||
|
{{ encore_entry_link_tags('mod_pickentity_type') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% macro period_meta(period) %}
|
{% macro period_meta(period) %}
|
||||||
@ -38,61 +40,66 @@
|
|||||||
{% import _self as m %}
|
{% import _self as m %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="col-10">
|
<div class="row col-10">
|
||||||
<h1>{{ block('title') }}</h1>
|
<h1>{{ block('title') }}</h1>
|
||||||
|
|
||||||
{{ form_start(form) }}
|
|
||||||
<div class="row filter-box">
|
<div class="row filter-box">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
|
{{ form_start(form) }}
|
||||||
{{ form_label(form.user ) }}
|
{{ form_label(form.user ) }}
|
||||||
{{ form_widget(form.user, {'attr': {'class': 'select2'}}) }}
|
{{ form_widget(form.user, {'attr': {'class': 'select2'}}) }}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<ul class="record_actions">
|
|
||||||
<li>
|
|
||||||
<button type="submit" class="btn btn-save change-icon">
|
|
||||||
<i class="fa fa-filter"></i> {{ 'Filter'|trans }}
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
{{ form_end(form) }}
|
|
||||||
|
|
||||||
{% if form.user.vars.value is empty %}
|
|
||||||
<p class="chill-no-data-statement">{{ 'period_by_user_list.Pick a user'|trans }}</p>
|
|
||||||
{% elseif periods|length == 0 and form.user.vars.value is not empty %}
|
|
||||||
<p class="chill-no-data-statement">{{ 'period_by_user_list.Any course or no authorization to see them'|trans }}</p>
|
|
||||||
{% else %}
|
|
||||||
<h3>{{ 'Attribute parcours in this list to the following user,'|trans }}</h3>
|
|
||||||
<p><span class="badge rounded-pill bg-primary">{{ paginator.totalItems }}</span> parcours à réassigner (calculé ce jour à {{ null|format_time('medium') }})</p>
|
|
||||||
|
|
||||||
{{ form_start(assignForm) }}
|
|
||||||
<div class="row filter-box">
|
|
||||||
<div class="col-md-6">
|
|
||||||
{{ form_label(assignForm.userTo ) }}
|
|
||||||
{{ form_widget(assignForm.userTo, {'attr': {'class': 'select2'}}) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
<button type="submit" class="btn btn-save change-icon">
|
<button type="submit" class="btn btn-misc">
|
||||||
{{ 'Reassign'|trans }}
|
<i class="fa fa-filter"></i> {{ 'Filter'|trans }}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{{ form_end(assignForm) }}
|
{{ form_end(form) }}
|
||||||
<div class="flex-table">
|
|
||||||
{% for period in periods %}
|
|
||||||
{% include '@ChillPerson/AccompanyingPeriod/_list_item.html.twig' with {'period': period,
|
|
||||||
'recordAction': m.period_actions(period), 'itemMeta': m.period_meta(period) } %}
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
{% if userFrom is not null %}
|
||||||
|
<div>
|
||||||
|
{{ form_start(assignForm) }}
|
||||||
|
{{ form_label(assignForm.userTo ) }}
|
||||||
|
{{ form_widget(assignForm.userTo, {'attr': {'class': 'select2'}}) }}
|
||||||
|
</div>
|
||||||
|
<ul class="record_actions">
|
||||||
|
<li>
|
||||||
|
<button type="submit" class="btn btn-update change-icon">
|
||||||
|
{{ 'reassign.Reassign'|trans }}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{{ form_end(assignForm) }}
|
||||||
|
{% else %}
|
||||||
|
<div class="alert alert-info">{{ 'reassign.List periods to be able to reassign them'|trans }}</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if userFrom is not null %}
|
||||||
|
<p><span class="badge rounded-pill bg-primary">{{ paginator.totalItems }}</span> parcours à réassigner (calculé ce jour à {{ null|format_time('medium') }})</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if paginator is defined %}
|
<div class="flex-table">
|
||||||
{{ chill_pagination(paginator) }}
|
{% for period in periods %}
|
||||||
{% endif %}
|
{% include '@ChillPerson/AccompanyingPeriod/_list_item.html.twig' with {'period': period,
|
||||||
|
'recordAction': m.period_actions(period), 'itemMeta': m.period_meta(period) } %}
|
||||||
|
{% else %}
|
||||||
|
{% if userFrom is same as(null) %}
|
||||||
|
<p class="chill-no-data-statement">{{ 'period_by_user_list.Pick a user'|trans }}</p>
|
||||||
|
{% else %}
|
||||||
|
<p class="chill-no-data-statement">{{ 'period_by_user_list.Any course or no authorization to see them'|trans }}</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if paginator is defined %}
|
||||||
|
{{ chill_pagination(paginator) }}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -596,3 +596,11 @@ period_by_user_list:
|
|||||||
Period by user: Parcours d'accompagnement par utilisateur
|
Period by user: Parcours d'accompagnement par utilisateur
|
||||||
Pick a user: Choisissez un utilisateur pour obtenir la liste de ses parcours
|
Pick a user: Choisissez un utilisateur pour obtenir la liste de ses parcours
|
||||||
Any course or no authorization to see them: Aucun parcours pour ce référent, ou aucun droit pour visualiser les parcours de ce référent.
|
Any course or no authorization to see them: Aucun parcours pour ce référent, ou aucun droit pour visualiser les parcours de ce référent.
|
||||||
|
|
||||||
|
reassign:
|
||||||
|
Current user: Parcours par référent
|
||||||
|
Next user: Nouveau référent
|
||||||
|
Choose a user and click on "Filter" to apply: Choisissez un utilisateur et cliquez sur "Filtrer" pour visualiser ses parcours
|
||||||
|
All periods on this list will be reassigned to this user, excepted the one you manually reassigned before: Tous les parcours visibles sur cette page seront assignés à cet utilisateur, sauf ceux que vous aurez assigné à un utilisateur manuellement.
|
||||||
|
Reassign: Assigner le référent
|
||||||
|
List periods to be able to reassign them: Choisissez un utilisateur et cliquez sur "Filtrer" pour visualiser ses parcours. Vous pourrez ensuite les réassigner.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user