Skip to content
Draft
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 34 additions & 46 deletions dojo/templates/dojo/calendar.html
Original file line number Diff line number Diff line change
@@ -1,49 +1,32 @@
{% extends 'base.html' %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this changed/removed?

{% load static %}
{% load i18n %}

{% block content %}
{% block head_extra %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this changed/removed?

{{ block.super }}
<form method="GET" id="calfilter" action="/calendar">
<div class="container-fluid chosen-container side-by-side">
<div class="row">
<div style="display: inline-block;">
<select data-placeholder="Calendar type" id="caltype" class="chosen-select">
<option value="engagements">Engagements</option>
<option value="tests">Tests</option>
</select>
</div>
<div style="display: inline-block;">
<select data-placeholder="All users" multiple id="lead" name="lead" class="chosen-select">
<option value="0">All users</option>
<option value="-1">Unassigned</option>
{% for u in users %}
<option value="{{ u.id }}">{{ u.username }}</option>
{% endfor %}
</select>
</div>
<div style="display: inline-block;">
<input class="btn btn-primary" type="submit" value="Apply" />
</div>
</div>
</div>
</form>
<br/><br/>
<div id="calendar"></div>
<br/><br/>
Comment on lines 7 to 33
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this changed/removed?

<!-- Using locally stored FullCalendar CSS (no external CDN) -->
<link href="{% static 'vendor/fullcalendar/fullcalendar.min.css' %}" rel="stylesheet" />
{% endblock %}

{% block postscript %}
{{ block.super }}
<!-- Using locally stored JS libraries to avoid missing SRI on external CDNs -->
<script src="{% static 'vendor/fullcalendar/jquery.min.js' %}"></script>
<script src="{% static 'vendor/fullcalendar/moment.min.js' %}"></script>
<script src="{% static 'vendor/fullcalendar/fullcalendar.min.js' %}"></script>

<script>
$(function () {
$('#caltype').change(function() {
$('#calfilter').attr('action', '/calendar/' + $(this).val());
});

if (caltype) {
$('#caltype').val('{{ caltype }}');
$('#caltype').trigger('change');
}

$('#lead').val([{% for lead in leads %} '{{ lead }}', {% endfor %}]);

$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
Expand All @@ -56,35 +39,40 @@
{% if caltype == 'tests' %}
{% for t in tests %}
{
title: '{{t.engagement.product.name}}: {{ t.engagement.name|default:"Unknown" }} - {{ t.test_type }} ({{ t.lead|default:"Unassigned" }})',
start: '{{t.target_start|date:"c"}}',
end: '{{t.target_end|date:"c"}}',
title: '{{ t.engagement.product.name }}: {{ t.engagement.name|default:"Unknown" }} - {{ t.test_type }} ({{ t.lead|default:"Unassigned" }})',
start: '{{ t.target_start|date:"c" }}',
end: '{{ t.target_end|date:"c" }}',
url: '{% url 'view_test' t.id %}',
color: {% if t.engagement.active %}'#337ab7'{% else %}'#b9b9b9'{% endif %},
color: {% if t.engagement.active %}'#337ab7'{% else %}'#b9b9b9'{% endif %},
overlap: true
},
{% endfor %}
{% endfor %}
{% else %}
{% for e in engagements %}
{
title: '{{e.product.name}}: {{ e.name|default:"Unknown" }} ({{ e.lead|default:"Unassigned" }})',
start: '{{e.target_start|date:"c"}}',
end: '{{e.target_end|date:"c"}}',
title: '{{ e.product.name }}: {{ e.name|default:"Unknown" }} ({{ e.lead|default:"Unassigned" }})',
start: '{{ e.target_start|date:"c" }}',
end: '{{ e.target_end|date:"c" }}',
url: '{% url 'view_engagement' e.id %}',
color: {% if e.active %}'#337ab7'{% else %}'#b9b9b9'{% endif %},
color: {% if e.active %}'#337ab7'{% else %}'#b9b9b9'{% endif %},
overlap: true
},
{% endfor %}
{% endfor %}
{% endif %}
],
viewRender: function(view, element) {
// Updating aria-label attributes calendar switches after the view is rendered
$('.fc-prev-button').attr('aria-label', '{% trans "Previous month" %}');
$('.fc-next-button').attr('aria-label', '{% trans "Next month" %}');
$('.fc-month-button').attr('aria-label', '{% trans "Month preview" %}');
$('.fc-basicWeek-button').attr('aria-label', '{% trans "Week preview" %}');
$('.fc-basicDay-button').attr('aria-label', '{% trans "Day preview" %}');
}
$('.fc-prev-button').attr('aria-label', '{% trans "Previous month" %}');
$('.fc-next-button').attr('aria-label', '{% trans "Next month" %}');
$('.fc-month-button').attr('aria-label', '{% trans "Month preview" %}');
$('.fc-basicWeek-button').attr('aria-label', '{% trans "Week preview" %}');
$('.fc-basicDay-button').attr('aria-label', '{% trans "Day preview" %}');
},
dayRender: function(date, cell) {
// Highlight Saturdays and Sundays
if (date.day() === 0 || date.day() === 6) {
cell.css("background-color", "#f0e68c");
}
}
});
});
</script>
Expand Down