Commit 2b533018 by François C.

Add availability to make member adding new shifts

parent 2546a5fa
Pipeline #2353 passed with stage
in 1 minute 29 seconds
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
justify-content: space-between; justify-content: space-between;
} }
@media screen and (max-width:992px) { @media screen and (max-width:992px) {
#calendar_top_info { #calendar_top_info {
display: flex; display: flex;
......
var calendar = null, var calendar = null,
selected_shift = null, selected_shift = null,
vw = null; vw = null,
adding_mode = false;
/* - Logic */ /* - Logic */
...@@ -51,6 +52,9 @@ function add_or_change_shift(new_shift_id) { ...@@ -51,6 +52,9 @@ function add_or_change_shift(new_shift_id) {
if (selected_shift === null) { if (selected_shift === null) {
tUrl = '/shifts/add_shift'; tUrl = '/shifts/add_shift';
if (partner_data.makeups_to_do > 0) {
tData += '&is_makeup=1';
}
} else { } else {
tUrl = '/shifts/change_shift'; tUrl = '/shifts/change_shift';
tData = tData + '&idOldShift='+ selected_shift.shift_id[0] +'&idRegister=' + selected_shift.id; tData = tData + '&idOldShift='+ selected_shift.shift_id[0] +'&idRegister=' + selected_shift.id;
...@@ -143,6 +147,8 @@ function add_or_change_shift(new_shift_id) { ...@@ -143,6 +147,8 @@ function add_or_change_shift(new_shift_id) {
}, 300); }, 300);
} }
}); });
adding_mode = false;
$('#start_adding_shift').prop('disabled', false);
} }
return null; return null;
...@@ -315,6 +321,7 @@ function init_shifts_list() { ...@@ -315,6 +321,7 @@ function init_shifts_list() {
if (!can_exchange_shifts()) { if (!can_exchange_shifts()) {
shift_line_template.find(".selectable_shift_line").addClass("btn"); shift_line_template.find(".selectable_shift_line").addClass("btn");
shift_line_template.find(".checkbox").prop("disabled", "disabled"); shift_line_template.find(".checkbox").prop("disabled", "disabled");
$('#start_adding_shift').prop('disabled', true);
} else { } else {
if (shift.is_makeup==true) { if (shift.is_makeup==true) {
shift_line_template.find(".selectable_shift_line").addClass("btn--warning"); shift_line_template.find(".selectable_shift_line").addClass("btn--warning");
...@@ -577,12 +584,27 @@ function init_calendar_page() { ...@@ -577,12 +584,27 @@ function init_calendar_page() {
"Valider" "Valider"
); );
} else if (selected_shift === null && can_exchange_shifts()) { } else if (selected_shift === null && can_exchange_shifts()) {
if (adding_mode === false) {
/* could exchange shift but no old shift selected */ /* could exchange shift but no old shift selected */
openModal( openModal(
"Je dois sélectionner un service à échanger.", "Je dois sélectionner un service à échanger.",
closeModal, closeModal,
"J'ai compris" "J'ai compris"
); );
} else {
// Display modal
let modal_template = $("#modal_add_shift_template");
modal_template.find(".date_new_shift").text(new_shift_date);
modal_template.find(".time_new_shift").text(new_shift_time);
openModal(
modal_template.html(),
() => {
add_or_change_shift(new_shift_id);
},
"Valider"
);
}
} else if (should_select_makeup()) { } else if (should_select_makeup()) {
/* choose a makeup service */ /* choose a makeup service */
// Check if selected new shift is in less than 6 months // Check if selected new shift is in less than 6 months
...@@ -811,6 +833,19 @@ function init_shifts_exchange() { ...@@ -811,6 +833,19 @@ function init_shifts_exchange() {
init_calendar_page(); init_calendar_page();
} }
$('#start_adding_shift').click((c) => {
openModal(
"<p>Je souhaite sélectionner un service supplémentaire.</p>",
() => {
$(c.target).prop('disabled', true);
adding_mode = true;
closeModal();
},
"Confirmer",
false
);
});
$(window).smartresize(function() { $(window).smartresize(function() {
// only apply if a width threshold is passed // only apply if a width threshold is passed
if ( if (
......
...@@ -130,6 +130,8 @@ def index(request, exception=None): ...@@ -130,6 +130,8 @@ def index(request, exception=None):
if hasattr(settings, 'SHIFT_EXCHANGE_DAYS_TO_HIDE'): if hasattr(settings, 'SHIFT_EXCHANGE_DAYS_TO_HIDE'):
days_to_hide = settings.SHIFT_EXCHANGE_DAYS_TO_HIDE days_to_hide = settings.SHIFT_EXCHANGE_DAYS_TO_HIDE
context['daysToHide'] = days_to_hide context['daysToHide'] = days_to_hide
can_add_shift = getattr(settings, 'CAN_ADD_SHIFT', False)
context['canAddShift'] = "true" if can_add_shift is True else "false"
msettings = MConfig.get_settings('members') msettings = MConfig.get_settings('members')
context['forms_link'] = msettings['forms_link']['value'] if 'forms_link' in msettings else '' context['forms_link'] = msettings['forms_link']['value'] if 'forms_link' in msettings else ''
...@@ -203,6 +205,7 @@ def shifts_exchange(request): ...@@ -203,6 +205,7 @@ def shifts_exchange(request):
template = loader.get_template('members_space/shifts_exchange.html') template = loader.get_template('members_space/shifts_exchange.html')
context = { context = {
'title': 'Échange de Services', 'title': 'Échange de Services',
'canAddShift': getattr(settings, 'CAN_ADD_SHIFT', False)
} }
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
......
...@@ -342,6 +342,10 @@ ...@@ -342,6 +342,10 @@
- BLOCK_ACTIONS_FOR_ATTACHED_PEOPLE = False - BLOCK_ACTIONS_FOR_ATTACHED_PEOPLE = False
Attached people can or not change his services Attached people can or not change his services
- CAN_ADD_SHIFT = True
By default, False. Set if coop can or not add shifts in their memberspace calendar
### Reception ### Reception
- RECEPTION_ADD_ADMIN_MODE = True - RECEPTION_ADD_ADMIN_MODE = True
......
...@@ -281,9 +281,12 @@ def add_shift(request): ...@@ -281,9 +281,12 @@ def add_shift(request):
"idPartner": int(request.POST['idPartner']), "idPartner": int(request.POST['idPartner']),
"idShift":int(request.POST['idNewShift']), "idShift":int(request.POST['idNewShift']),
"shift_type":request.POST['shift_type'], "shift_type":request.POST['shift_type'],
"is_makeup":True "is_makeup": False
} }
if 'is_makeup' in request.POST and request.POST['is_makeup'] == "1":
data['is_makeup'] = True
#Insertion du nouveau shift #Insertion du nouveau shift
st_r_id = False st_r_id = False
try: try:
......
...@@ -153,6 +153,7 @@ ...@@ -153,6 +153,7 @@
"extra_shift_done": parseInt("{{partnerData.extra_shift_done}}", 10) "extra_shift_done": parseInt("{{partnerData.extra_shift_done}}", 10)
}; };
var block_actions_for_attached_people = '{{block_actions_for_attached_people}}'; var block_actions_for_attached_people = '{{block_actions_for_attached_people}}';
const canAddShift = {{canAddShift}};
</script> </script>
<script src="{% static "js/all_common.js" %}?v=1651853225"></script> <script src="{% static "js/all_common.js" %}?v=1651853225"></script>
<script src="{% static "js/members-space-home.js" %}?v=1651853225"></script> <script src="{% static "js/members-space-home.js" %}?v=1651853225"></script>
......
...@@ -50,6 +50,9 @@ ...@@ -50,6 +50,9 @@
<i class="fas fa-spinner fa-spin fa-lg"></i> <i class="fas fa-spinner fa-spin fa-lg"></i>
</div> </div>
<div id="shifts_list"></div> <div id="shifts_list"></div>
{% if canAddShift %}
<button class="btn--primary selectable_shift_line" id="start_adding_shift"><strong>+ Ajouter un service</strong></button>
{% endif %}
</div> </div>
<div id="calendar_explaination_area"></div> <div id="calendar_explaination_area"></div>
<button id="calendar_explaination_button" class="btn--success">Légende du calendrier</button> <button id="calendar_explaination_button" class="btn--success">Légende du calendrier</button>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment