Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Améliore la gestion de l'autocompletion #657

Merged
merged 9 commits into from
Nov 26, 2022
36 changes: 11 additions & 25 deletions app/Resources/views/admin/booking/_partial/bucket_modal.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -97,39 +97,25 @@ It use the materialize modal class https://materializecss.com/modals.html
</div>
</div>
<div class="collapsible-body">
<form method="post" action="{{ path('admin_shift_book',{'id': shift.id}) }}">
<input id="form__token" type="hidden" name="form[_token]" value="{{ csrf_token('form') }}">
{{ form_start(shift_book_forms[shift.id]) }}
<div class="row">
<div class="col {% if use_fly_and_fixed %}s7{% else %}s9{% endif %} input-field">
<label for="appbundle_shift_shifter{{ shift.id }}">Bénéficiaire</label>
<input id="appbundle_shift_shifter{{ shift.id }}" name="form[shifter]" type="text" class="autocomplete" />
{{ form_label(shift_book_forms[shift.id].shifter) }}
{{ form_widget(shift_book_forms[shift.id].shifter) }}
</div>
{% if use_fly_and_fixed %}
<div class="col s2">
<div>
<label style="color: #5f5a5a; font-weight: 600;">
<input type="radio" name="form[fixe]" value="0" checked>
<span>volant</span>
</label>
</div>
<div>
<label style="color: #5f5a5a; font-weight: 600;">
<input type="radio" name="form[fixe]" value="1">
<span>fixe</span>
</label>
</div>
</div>
<div class="col s3">
<button class="btn add" disabled="disabled">Ajouter</button>
</div>
{% else %}
<div class="col s3">
<input type="hidden" id="appbundle_shift_fixe" name="appbundle_shift[fixe]" value="0" checked>
<button class="btn add">Ajouter</button>
{{ form_widget(shift_book_forms[shift.id].fixe) }}
</div>
{% endif %}
<div class="col s3">
{% if not use_fly_and_fixed %}
{{ form_widget(shift_book_forms[shift.id].fixe) }}
{% endif %}
<button class="btn add">Ajouter</button>
</div>
</div>
</form>
{{ form_end(shift_book_forms[shift.id]) }}
</div>
</li>
{% endif %}
Expand Down
22 changes: 5 additions & 17 deletions app/Resources/views/admin/booking/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
{% include "admin/booking/_partial/bucket_calendar.html.twig" with { bucketsByDay: bucketsByDay } %}

<div id="modal-bucket" class="modal">
<div class="modal-content">
<div id="modal-bucket-content" class="modal-content">
</div>
</div>

Expand All @@ -106,29 +106,17 @@
}
})
.trigger('change');
$('.modal').modal({
$('#modal-bucket').modal({
onCloseEnd: function() {
$('.modal-content').html('');
$('#modal-bucket-content').html('');
},
onOpenStart: function(modal, trigger) {
var url = $(trigger).attr('data-source');
$.get(url, function( data ) {
$('.modal-content').html(data);
$('#modal-bucket-content').html(data);
$('.collapsible').collapsible();
$('input.autocomplete').autocomplete({
petitalb marked this conversation as resolved.
Show resolved Hide resolved
data: {
{% for beneficiary in beneficiaries %}
"{{ beneficiary.displayNameWithMemberNumber }}": null,
{% endfor %}
},
limit: 10,
onAutocomplete: function (val) {
// Callback function when value is autocomplete.
$('button.add').removeAttr('disabled');
},
minLength: 2,
});
$('select').formSelect();
eval($('#modal-bucket-content script').html());
});
}
});
Expand Down
43 changes: 29 additions & 14 deletions app/Resources/views/admin/commission/edit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,20 @@
var data = $form.serialize();
$.ajax($form.attr('action'),{
data: data,
method: 'post'
}).success(function (d) {
//console.log(d);
if (d.success){
Materialize.toast(d.message,2500,'green');
}else{
Materialize.toast(d.message,2500,'red');
method: 'post',
success: function (d) {
M.toast({
html: d.message,
displayLength: 2500,
classes: 'green'
});
},
error: function (d) {
M.toast({
html: d.message,
displayLength: 2500,
classes: 'red'
});
}
});
}
Expand All @@ -149,15 +156,23 @@
var data = $form.serialize();
$.ajax($form.attr('action'),{
data: data,
method: 'post'
}).success(function (d) {
if (d.success){
Materialize.toast(d.message,2500,'green');
method: 'post',
success: function (d) {
M.toast({
html: d.message,
displayLength: 2500,
classes: 'green'
});
$('#users .chips').append(d.html);
}else{
Materialize.toast(d.message,2500,'red');
$('#form_beneficiary').val('');
},
error: function (d) {
M.toast({
html: d.message,
displayLength: 2500,
classes: 'red'
});
}
$('#form_beneficiary').val('');
});
});
});
Expand Down
109 changes: 0 additions & 109 deletions app/Resources/views/admin/mail/edit.html.twig

This file was deleted.

67 changes: 67 additions & 0 deletions app/Resources/views/admin/mail/send.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{% extends 'layout.html.twig' %}

{% block content %}
{{ form_start(form) }}

<div class="row">
<div class="input-field col s12 m6">
{{ form_widget(form.from) }}
{{ form_label(form.from) }}
</div>
<div class="input-field col s12 m6">
{{ form_widget(form.template) }}
{{ form_label(form.template) }}
</div>
<div class="col s12">
{{ form_label(form.to) }}
{{ form_widget(form.to) }}
</div>
<div class="col s12">
<label>Non-membre(s) en copie</label>
<div class="non-members chips">
</div>
</div>
<div class="input-field col s12">
{{ form_widget(form.subject) }}
{{ form_label(form.subject) }}
</div>
<div class="col s12">
{{ form_label(form.message) }}
{{ form_widget(form.message) }}
</div>
<div class="tips right small">
prénom : <input value="{{ '{{' }} beneficiary.firstname {{ '}}' }}"/>
</div>
</div>

<button class="btn waves-effect waves-light" type="submit"><i class="material-icons left">send</i>Envoyer</button>
{{ form_widget(form) }}
{{ form_end(form) }}
{% endblock %}

{% block javascripts %}
<script>
jQuery(
function() {
function updateNonMembers() {
var chipsData = M.Chips.getInstance($('.non-members')).chipsData;
var emails = chipsData.map((member) => (member['tag']));
$("input[name='form[cci]']").val(JSON.stringify(emails));
};
$('.non-members').chips({
placeholder: 'Non-membre',
data: [],
autocompleteOptions: {
data: {{ non_members | json_encode(constant('JSON_UNESCAPED_UNICODE')) | raw }},
limit: Infinity,
minLength: 1
},
onChipAdd: updateNonMembers,
onChipDelete: updateNonMembers
});
updateNonMembers();
}
);
</script>

{% endblock %}
27 changes: 6 additions & 21 deletions app/Resources/views/admin/member/join.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@
{{ form_start(form) }}
<div class="row">
<div class="input-field col m6 s12">
<div class="errors">
{{ form_errors(form.from_text) }}
</div>
<i class="material-icons prefix">person</i>
{{ form_widget(form.from_text) }}
{{ form_label(form.from_text) }}
</div>
<div class="input-field col m6 s12">
<div class="errors">
{{ form_errors(form.dest_text) }}
</div>
<i class="material-icons prefix">person</i>
{{ form_widget(form.dest_text) }}
{{ form_label(form.dest_text) }}
Expand All @@ -38,24 +44,3 @@
{{ form_widget(form.join) }}
{{ form_end(form) }}
{% endblock %}

{% block javascripts %}
<script>
$(document).ready(function() {
$('input.autocomplete').autocomplete({
data: {
{% for member in members %}
{% if member.mainBeneficiary %}
"{{ member.mainBeneficiary.displayNameWithMemberNumber }}": null,
{% endif %}
{% endfor %}
},
limit: 10, // The max amount of results that can be shown at once. Default: Infinity.
onAutocomplete: function(val) {
// Callback function when value is autcompleted.
},
minLength: 1, // The minimum length of the input for the autocomplete to start. Default: 1.
});
})
</script>
{% endblock %}
Loading