Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-foodcoops
third-party
Commits
ad4867a3
Commit
ad4867a3
authored
3 years ago
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
block shifts exchange if unsuscrubed
parent
2b5c057a
5 merge requests
!103
WIP: Dev cooperatic
,
!87
Integration Evolution bdm
,
!104
merge dev_cooperatic into dev_principale
,
!106
Dev principale
,
!84
Ticket 1738
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
47 deletions
+74
-47
members-space-shifts-exchange.css
members_space/static/css/members-space-shifts-exchange.css
+13
-3
members-space-shifts-exchange.js
members_space/static/js/members-space-shifts-exchange.js
+52
-44
shifts_exchange.html
templates/members_space/shifts_exchange.html
+9
-0
No files found.
members_space/static/css/members-space-shifts-exchange.css
View file @
ad4867a3
...
@@ -7,13 +7,13 @@
...
@@ -7,13 +7,13 @@
/* -- Suspended screen */
/* -- Suspended screen */
#suspended_content
{
#suspended_content
,
#unsuscribed_content
{
align-items
:
center
;
align-items
:
center
;
text-align
:
center
;
text-align
:
center
;
}
}
.select_makeups
{
#shifts_exchange
.select_makeups
,
#shifts_exchange
.unsuscribed_form_link
{
margin
:
2
rem
0
;
margin
:
1.5
rem
0
;
}
}
/* -- Calendar screen, shifts list */
/* -- Calendar screen, shifts list */
...
@@ -75,9 +75,19 @@
...
@@ -75,9 +75,19 @@
#calendar
{
#calendar
{
margin
:
2rem
1rem
;
margin
:
2rem
1rem
;
}
.loading-calendar
{
margin
:
3rem
auto
;
display
:
none
;
display
:
none
;
}
}
@media
screen
and
(
max-width
:
768px
)
{
#calendar
{
display
:
none
;
}
}
.fc
.fc-event
{
.fc
.fc-event
{
cursor
:
pointer
;
cursor
:
pointer
;
margin
:
1px
10px
!important
;
margin
:
1px
10px
!important
;
...
...
This diff is collapsed.
Click to expand it.
members_space/static/js/members-space-shifts-exchange.js
View file @
ad4867a3
var
calendar
=
null
,
var
calendar
=
null
,
selected_shift
=
null
;
selected_shift
=
null
,
vw
=
null
;
/**
/**
* A partner can exchange shifts if:
* A partner can exchange shifts if:
...
@@ -23,15 +24,15 @@ function can_select_makeup() {
...
@@ -23,15 +24,15 @@ function can_select_makeup() {
/**
/**
* Proceed to shift exchange or registration
* Proceed to shift exchange or registration
* @param {int} new_shift_id
* @param {int} new_shift_id
*/
*/
function
add_or_change_shift
(
new_shift_id
)
{
function
add_or_change_shift
(
new_shift_id
)
{
if
(
is_time_to
(
'change_shift'
))
{
if
(
is_time_to
(
'change_shift'
))
{
setTimeout
(
openModal
,
100
);
// loading on
setTimeout
(
openModal
,
100
);
// loading on
tData
=
'idNewShift='
+
new_shift_id
tData
=
'idNewShift='
+
new_shift_id
+
'&idPartner='
+
partner_data
.
partner_id
+
'&idPartner='
+
partner_data
.
partner_id
+
'&in_ftop_team='
+
partner_data
.
in_ftop_team
+
'&in_ftop_team='
+
partner_data
.
in_ftop_team
+
'&verif_token='
+
partner_data
.
verif_token
;
+
'&verif_token='
+
partner_data
.
verif_token
;
if
(
selected_shift
===
null
)
{
if
(
selected_shift
===
null
)
{
...
@@ -61,9 +62,10 @@ function add_or_change_shift(new_shift_id) {
...
@@ -61,9 +62,10 @@ function add_or_change_shift(new_shift_id) {
}
}
let
msg
=
"Parfait! "
;
let
msg
=
"Parfait! "
;
msg
+=
(
selected_shift
===
null
)
?
"Le service choisi a été ajouté."
msg
+=
(
selected_shift
===
null
)
:
"Le service a été échangé."
;
?
"Le service choisi a été ajouté."
:
"Le service a été échangé."
;
selected_shift
=
null
;
selected_shift
=
null
;
...
@@ -74,7 +76,7 @@ function add_or_change_shift(new_shift_id) {
...
@@ -74,7 +76,7 @@ function add_or_change_shift(new_shift_id) {
closeModal
();
closeModal
();
setTimeout
(()
=>
{
setTimeout
(()
=>
{
alert
(
msg
);
alert
(
msg
);
},
100
);
},
100
);
...
@@ -86,14 +88,14 @@ function add_or_change_shift(new_shift_id) {
...
@@ -86,14 +88,14 @@ function add_or_change_shift(new_shift_id) {
},
},
error
:
function
(
error
)
{
error
:
function
(
error
)
{
closeModal
();
closeModal
();
selected_shift
=
null
selected_shift
=
null
;
if
(
error
.
status
===
400
)
{
if
(
error
.
status
===
400
)
{
alert
(
`Désolé ! Le service que vous souhaitez échanger démarre dans moins de 24h. `
+
alert
(
`Désolé ! Le service que vous souhaitez échanger démarre dans moins de 24h. `
+
`Il n'est plus possible de l'échanger.`
);
`Il n'est plus possible de l'échanger.`
);
}
else
{
}
else
{
alert
(
`Une erreur est survenue.`
+
alert
(
`Une erreur est survenue.`
+
`Il est néanmoins possible que la requête ait abouti,`
+
`Il est néanmoins possible que la requête ait abouti,`
+
`veuillez patienter quelques secondes puis vérifier vos services enregistrés.`
);
`veuillez patienter quelques secondes puis vérifier vos services enregistrés.`
);
}
}
...
@@ -144,20 +146,21 @@ function init_shifts_list() {
...
@@ -144,20 +146,21 @@ function init_shifts_list() {
$
(
".selectable_shift_line"
).
on
(
"click"
,
function
(
e
)
{
$
(
".selectable_shift_line"
).
on
(
"click"
,
function
(
e
)
{
if
(
can_exchange_shifts
())
{
if
(
can_exchange_shifts
())
{
let
cb
=
$
(
this
).
find
(
".checkbox"
);
let
cb
=
$
(
this
).
find
(
".checkbox"
);
// Select checkbox on click on button
// Select checkbox on click on button
if
(
!
$
(
e
.
target
).
hasClass
(
"checkbox"
))
{
if
(
!
$
(
e
.
target
).
hasClass
(
"checkbox"
))
{
cb
.
prop
(
"checked"
,
!
cb
.
prop
(
"checked"
));
cb
.
prop
(
"checked"
,
!
cb
.
prop
(
"checked"
));
}
}
if
(
cb
.
prop
(
"checked"
))
{
if
(
cb
.
prop
(
"checked"
))
{
selected_shift
=
incoming_shifts
.
find
(
s
=>
s
.
id
==
cb
.
prop
(
"value"
));
selected_shift
=
incoming_shifts
.
find
(
s
=>
s
.
id
==
cb
.
prop
(
"value"
));
}
else
{
}
else
{
selected_shift
=
null
;
selected_shift
=
null
;
}
}
// Unselect other checkboxes
// Unselect other checkboxes
if
(
$
(
this
).
find
(
".checkbox"
).
prop
(
"checked"
))
{
if
(
$
(
this
).
find
(
".checkbox"
)
.
prop
(
"checked"
))
{
for
(
let
cb_item
of
$
(
"#shifts_list"
).
find
(
".checkbox"
))
{
for
(
let
cb_item
of
$
(
"#shifts_list"
).
find
(
".checkbox"
))
{
if
(
cb
.
prop
(
"value"
)
!==
$
(
cb_item
).
prop
(
"value"
))
{
if
(
cb
.
prop
(
"value"
)
!==
$
(
cb_item
).
prop
(
"value"
))
{
$
(
cb_item
).
prop
(
"checked"
,
false
);
$
(
cb_item
).
prop
(
"checked"
,
false
);
...
@@ -173,6 +176,10 @@ function init_shifts_list() {
...
@@ -173,6 +176,10 @@ function init_shifts_list() {
* Inits the page when the calendar is displayed
* Inits the page when the calendar is displayed
*/
*/
function
init_calendar_page
()
{
function
init_calendar_page
()
{
if
(
vw
<=
768
)
{
$
(
".loading-calendar"
).
show
();
}
if
(
incoming_shifts
!==
null
)
{
if
(
incoming_shifts
!==
null
)
{
init_shifts_list
();
init_shifts_list
();
}
else
{
}
else
{
...
@@ -185,7 +192,6 @@ function init_calendar_page() {
...
@@ -185,7 +192,6 @@ function init_calendar_page() {
$
(
"#need_to_select_makeups_message"
).
show
();
$
(
"#need_to_select_makeups_message"
).
show
();
}
}
const
vw
=
window
.
innerWidth
;
let
default_initial_view
=
""
;
let
default_initial_view
=
""
;
let
header_toolbar
=
{};
let
header_toolbar
=
{};
...
@@ -195,19 +201,20 @@ function init_calendar_page() {
...
@@ -195,19 +201,20 @@ function init_calendar_page() {
left
:
'title'
,
left
:
'title'
,
center
:
'dayGridMonth,listWeek,timeGridDay'
,
center
:
'dayGridMonth,listWeek,timeGridDay'
,
right
:
'prev,next today'
right
:
'prev,next today'
}
}
;
}
else
{
}
else
{
default_initial_view
=
'dayGridMonth'
;
default_initial_view
=
'dayGridMonth'
;
header_toolbar
=
{
header_toolbar
=
{
left
:
'prev,next today'
,
left
:
'prev,next today'
,
center
:
'title'
,
center
:
'title'
,
right
:
'dayGridMonth,listWeek,timeGridDay'
right
:
'dayGridMonth,listWeek,timeGridDay'
}
}
;
}
}
const
hidden_days
=
$
.
map
(
days_to_hide
.
split
(
", "
),
Number
);
const
hidden_days
=
$
.
map
(
days_to_hide
.
split
(
", "
),
Number
);
const
calendarEl
=
document
.
getElementById
(
'calendar'
);
const
calendarEl
=
document
.
getElementById
(
'calendar'
);
calendar
=
new
FullCalendar
.
Calendar
(
calendarEl
,
{
calendar
=
new
FullCalendar
.
Calendar
(
calendarEl
,
{
locale
:
'fr'
,
locale
:
'fr'
,
initialView
:
default_initial_view
,
initialView
:
default_initial_view
,
...
@@ -231,22 +238,23 @@ function init_calendar_page() {
...
@@ -231,22 +238,23 @@ function init_calendar_page() {
// Set new shift
// Set new shift
const
datetime_new_shift
=
info
.
event
.
start
;
const
datetime_new_shift
=
info
.
event
.
start
;
let
new_shift_date
=
datetime_new_shift
.
toLocaleDateString
(
"fr-fr"
,
date_options
);
let
new_shift_date
=
datetime_new_shift
.
toLocaleDateString
(
"fr-fr"
,
date_options
);
let
new_shift_time
=
datetime_new_shift
.
toLocaleTimeString
(
"fr-fr"
,
time_options
)
let
new_shift_time
=
datetime_new_shift
.
toLocaleTimeString
(
"fr-fr"
,
time_options
)
;
if
(
selected_shift
!==
null
&&
can_exchange_shifts
())
{
if
(
selected_shift
!==
null
&&
can_exchange_shifts
())
{
/* shift exchange */
/* shift exchange */
// Set old shift
// Set old shift
let
datetime_old_shift
=
new
Date
(
selected_shift
.
date_begin
);
let
datetime_old_shift
=
new
Date
(
selected_shift
.
date_begin
);
let
old_shift_date
=
datetime_old_shift
.
toLocaleDateString
(
"fr-fr"
,
date_options
);
let
old_shift_date
=
datetime_old_shift
.
toLocaleDateString
(
"fr-fr"
,
date_options
);
let
old_shift_time
=
datetime_old_shift
.
toLocaleTimeString
(
"fr-fr"
,
time_options
)
let
old_shift_time
=
datetime_old_shift
.
toLocaleTimeString
(
"fr-fr"
,
time_options
)
;
// Display modal
// Display modal
let
modal_template
=
$
(
"#modal_shift_exchange_template"
);
let
modal_template
=
$
(
"#modal_shift_exchange_template"
);
modal_template
.
find
(
".date_old_shift"
).
text
(
old_shift_date
);
modal_template
.
find
(
".date_old_shift"
).
text
(
old_shift_date
);
modal_template
.
find
(
".time_old_shift"
).
text
(
old_shift_time
);
modal_template
.
find
(
".time_old_shift"
).
text
(
old_shift_time
);
modal_template
.
find
(
".date_new_shift"
).
text
(
new_shift_date
);
modal_template
.
find
(
".date_new_shift"
).
text
(
new_shift_date
);
modal_template
.
find
(
".time_new_shift"
).
text
(
new_shift_time
);
modal_template
.
find
(
".time_new_shift"
).
text
(
new_shift_time
);
openModal
(
openModal
(
modal_template
.
html
(),
modal_template
.
html
(),
()
=>
{
()
=>
{
...
@@ -258,12 +266,13 @@ function init_calendar_page() {
...
@@ -258,12 +266,13 @@ function init_calendar_page() {
/* 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
if
(
can_select_makeup
())
{
}
else
if
(
can_select_makeup
())
{
/* choose a makeup service */
/* choose a makeup service */
let
modal_template
=
$
(
"#modal_add_shift_template"
);
let
modal_template
=
$
(
"#modal_add_shift_template"
);
modal_template
.
find
(
".date_new_shift"
).
text
(
new_shift_date
);
modal_template
.
find
(
".date_new_shift"
).
text
(
new_shift_date
);
modal_template
.
find
(
".time_new_shift"
).
text
(
new_shift_time
);
modal_template
.
find
(
".time_new_shift"
).
text
(
new_shift_time
);
...
@@ -278,11 +287,13 @@ function init_calendar_page() {
...
@@ -278,11 +287,13 @@ function init_calendar_page() {
}
}
},
},
eventDidMount
:
function
()
{
eventDidMount
:
function
()
{
if
(
vw
<=
768
)
{
if
(
vw
<=
768
)
{
$
(
".fc .fc-header-toolbar"
).
addClass
(
"resp-header-toolbar"
);
$
(
".fc .fc-header-toolbar"
).
addClass
(
"resp-header-toolbar"
);
}
$
(
"#calendar"
).
show
();
// Calendar is hidden at first on mobile to hide header change when data is loaded
$
(
".loading-calendar"
).
hide
();
$
(
"#calendar"
).
show
();
}
}
}
});
});
...
@@ -290,21 +301,20 @@ function init_calendar_page() {
...
@@ -290,21 +301,20 @@ function init_calendar_page() {
}
}
function
init_shifts_exchange
()
{
function
init_shifts_exchange
()
{
// TODO : loading
// TODO : suspended
$
(
".shifts_exchange_page_content"
).
hide
();
$
(
".shifts_exchange_page_content"
).
hide
();
vw
=
window
.
innerWidth
;
if
(
partner_data
.
cooperative_state
===
'unsubscribed'
)
{
if
(
partner_data
.
cooperative_state
===
'unsubscribed'
)
{
// TODO
$
(
"#unsuscribed_content"
).
show
();
// $(".unsuscribed_form_link")
// .show()
$
(
".unsuscribed_form_link"
)
// .attr('href', unsuscribe_form_link)
.
show
()
// .on('click', function() {
.
attr
(
'href'
,
unsuscribe_form_link
)
// setTimeout(500, () => {
.
on
(
'click'
,
function
()
{
// $(this).removeClass('active');
setTimeout
(
500
,
()
=>
{
// });
$
(
this
).
removeClass
(
'active'
);
// });
});
});
}
else
if
(
partner_data
.
cooperative_state
===
'suspended'
}
else
if
(
partner_data
.
cooperative_state
===
'suspended'
&&
partner_data
.
date_delay_stop
===
'False'
)
{
&&
partner_data
.
date_delay_stop
===
'False'
)
{
$
(
"#suspended_content"
).
show
();
$
(
"#suspended_content"
).
show
();
...
@@ -318,12 +328,11 @@ function init_shifts_exchange() {
...
@@ -318,12 +328,11 @@ function init_shifts_exchange() {
$
(
"#suspended_content"
).
hide
();
$
(
"#suspended_content"
).
hide
();
$
(
"#shifts_exchange_content"
).
show
();
$
(
"#shifts_exchange_content"
).
show
();
closeModal
();
closeModal
();
init_calendar_page
();
init_calendar_page
();
});
});
});
});
}
else
{
}
else
{
$
(
"#shifts_exchange_content"
).
show
();
$
(
"#shifts_exchange_content"
).
show
();
init_calendar_page
();
init_calendar_page
();
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
templates/members_space/shifts_exchange.html
View file @
ad4867a3
<div
id=
"shifts_exchange"
>
<div
id=
"shifts_exchange"
>
<div
id=
"unsuscribed_content"
class=
"shifts_exchange_page_content"
>
<h3>
Je suis désinscrit.e, je dois remplir un formulaire pour qu'on me réinscrive à un créneau.
</h3>
<a
href=
"#"
target=
"_blank"
class=
"btn--warning unsuscribed_form_link"
>
J'accède au formulaire
</a>
</div>
<div
id=
"suspended_content"
class=
"shifts_exchange_page_content"
>
<div
id=
"suspended_content"
class=
"shifts_exchange_page_content"
>
<h3>
Je suis suspendu.e, je dois sélectionner mes rattrapages pour pouvoir refaire mes courses.
</h3>
<h3>
Je suis suspendu.e, je dois sélectionner mes rattrapages pour pouvoir refaire mes courses.
</h3>
<button
type=
"button"
class=
"btn--danger select_makeups"
>
<button
type=
"button"
class=
"btn--danger select_makeups"
>
...
@@ -20,6 +26,9 @@
...
@@ -20,6 +26,9 @@
</div>
</div>
<div
id=
"shifts_list"
></div>
<div
id=
"shifts_list"
></div>
</div>
</div>
<div
class=
"loading-calendar"
>
<i
class=
"fas fa-spinner fa-spin fa-2x"
></i>
</div>
<div
id=
"calendar"
></div>
<div
id=
"calendar"
></div>
</div>
</div>
</div>
</div>
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment