Merge branch 'Qwann/calendar' of git.eleves.ens.fr:klub-dev-ens/GestionEvenementiel into Qwann/calendar
This commit is contained in:
commit
bd84b46476
3 changed files with 38 additions and 11 deletions
|
@ -313,6 +313,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#cal-container .cal-event-details .cal-detail-perm-title {
|
#cal-container .cal-event-details .cal-detail-perm-title {
|
||||||
|
display: block;
|
||||||
margin: 0 0 10px 0;
|
margin: 0 0 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -770,7 +770,9 @@ class EventDetails {
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePermManagementCounter () {
|
updatePermManagementCounter () {
|
||||||
let permCounterNode = this.node.find(".cal-detail-perm-count");
|
let permCounterNode = this.node
|
||||||
|
.find(".cal-detail-perm-count")
|
||||||
|
.html(`👤 ${this.event.nbPerms}/${this.event.maxNbPerms}`);
|
||||||
|
|
||||||
if (this.event.minNbPerms > this.event.nbPerms) {
|
if (this.event.minNbPerms > this.event.nbPerms) {
|
||||||
permCounterNode.addClass("cal-perms-missing");
|
permCounterNode.addClass("cal-perms-missing");
|
||||||
|
@ -787,12 +789,37 @@ class EventDetails {
|
||||||
// On click, switch the subscription state
|
// On click, switch the subscription state
|
||||||
// and update objects related to the perm count
|
// and update objects related to the perm count
|
||||||
let event = this.event;
|
let event = this.event;
|
||||||
|
|
||||||
buttonNode.on("click", () => {
|
buttonNode.on("click", () => {
|
||||||
// TODO: subscribe or unsubscribe
|
let goal = event.subscribedByUser ? "unenrol" : "enrol";
|
||||||
event.subscribedByUser = ! event.subscribedByUser;
|
let url = event.calendar.subscriptionURLFormat
|
||||||
|
.replace("999999", event.id);
|
||||||
|
|
||||||
|
$.ajax(url, {
|
||||||
|
method: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
|
||||||
|
headers: {
|
||||||
|
"X-CSRFToken": event.calendar.csrfToken
|
||||||
|
},
|
||||||
|
|
||||||
|
data: {
|
||||||
|
"goal": goal
|
||||||
|
},
|
||||||
|
|
||||||
|
success: (jsonAnswer) => {
|
||||||
|
event.subscribedByUser = jsonAnswer.enrolled;
|
||||||
|
event.nbPerms = jsonAnswer.number;
|
||||||
|
|
||||||
this.updatePermManagementArea();
|
this.updatePermManagementArea();
|
||||||
event.updatePermCounter();
|
event.updatePermCounter();
|
||||||
|
event.updateNodeStyle();
|
||||||
|
},
|
||||||
|
|
||||||
|
error: (_, message) => {
|
||||||
|
alert(message);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return buttonNode;
|
return buttonNode;
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
let cal = new Calendar({
|
let cal = new Calendar({
|
||||||
startDate: new Date(2018, 11, 1, 8),
|
startDate: new Date(2018, 10, 30, 8),
|
||||||
endDate: new Date(2018, 11, 2, 18),
|
endDate: new Date(2018, 11, 2, 6),
|
||||||
subscriptionURLFormat: "{% url "event:enrol_activity" 999999 %}?ajax=json",
|
subscriptionURLFormat: "{% url "event:enrol_activity" 999999 %}?ajax=json",
|
||||||
csrfToken: $(".planning [name=csrfmiddlewaretoken]").val()
|
csrfToken: $(".planning [name=csrfmiddlewaretoken]").val()
|
||||||
});
|
});
|
||||||
|
@ -33,9 +33,9 @@
|
||||||
<div class="content fluid" id="cal-container">
|
<div class="content fluid" id="cal-container">
|
||||||
{% for day in days_list %}
|
{% for day in days_list %}
|
||||||
{% for activity in day.list %}
|
{% for activity in day.list %}
|
||||||
<div class="{% cycle "" "inverted" %} cal-event">
|
<div class="cal-event">
|
||||||
<span class="cal-event-id">{{ activity.id }}</span>
|
<span class="cal-event-id">{{ activity.id }}</span>
|
||||||
<span class="cal-event-name">{{ activity.id }}</span>
|
<span class="cal-event-name">{{ activity.title }}</span>
|
||||||
<span class="cal-event-start-date">{{ activity.beginning | date:"j/m/Y H:i" }}</span>
|
<span class="cal-event-start-date">{{ activity.beginning | date:"j/m/Y H:i" }}</span>
|
||||||
<span class="cal-event-end-date">{{ activity.end | date:"j/m/Y H:i" }}</span>
|
<span class="cal-event-end-date">{{ activity.end | date:"j/m/Y H:i" }}</span>
|
||||||
<span class="cal-event-location">{{ activity.places.all | join:", " }}</span>
|
<span class="cal-event-location">{{ activity.places.all | join:", " }}</span>
|
||||||
|
@ -55,7 +55,6 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue