Use momentjs to calculate pretty_date

Until pretty_date understands future dates
This commit is contained in:
2016-11-07 17:17:47 +01:00
parent 506844a342
commit 8fd3b94f39
4 changed files with 62 additions and 31 deletions

View File

@@ -58,3 +58,15 @@
| {% endif %}
| {% endfor %}
| {% endblock %}
| {% block footer_scripts %}
| {% if current_user.is_authenticated %}
script.
$('#task-list .task-list-item span.due_date').each(function(){
var current = $(this).text();
if (current){
$(this).html(moment().to(current));
}
});
| {% endif %}
| {% endblock %}

View File

@@ -59,4 +59,11 @@ script.
$('#item-details').css({'height': window_height});
});
$('#task-list .task-list-item span.due_date').each(function(){
var current = $(this).text();
if (current){
$(this).html(moment().to(current));
}
});
| {% endblock %}

View File

@@ -29,4 +29,13 @@ script.
handleSelector: ".col-splitter",
resizeHeight: false
});
$('#task-list .task-list-item span.due_date').each(function(){
var current = $(this).text();
if (current){
$(this).html(moment().to(current));
}
});
| {% endblock %}

View File

@@ -91,8 +91,7 @@
input#item-due_date(
type="text",
name="due_date",
placeholder="Deadline for Task",
value="{{ task.properties.due_date | hide_none }}")
placeholder="Deadline for Task")
.input-group-separator
@@ -130,11 +129,11 @@
| {% else %}
span.hint Not assigned yet
| {% endfor %}
.table-row
.table-row.properties-due_date
.table-cell Due Date
.table-cell
| {% if task.properties.due_date %}
| {{ task.properties.due_date }}
span.due_date {{ task.properties.due_date }}
| {% else %}
span.hint No date set
| {% endif %}
@@ -161,36 +160,34 @@
script.
var picker = new Pikaday(
{
field: document.getElementById('item-due_date'),
firstDay: 1,
minDate: new Date(),
maxDate: new Date(2020, 12, 31),
format: 'Do MMMM YYYY',
yearRange: [new Date().getFullYear(),new Date().getFullYear() + 5]
{% if 'PUT' in task.allowed_methods %}
$("#assignees").select2();
var picker = new Pikaday(
{
field: document.getElementById('item-due_date'),
firstDay: 1,
format: 'dddd D, MMMM YYYY',
disableWeekends: true,
yearRange: [new Date().getFullYear(),new Date().getFullYear() + 5]
});
picker.setDate('{{ task.properties.due_date }}');
if (ProjectUtils.context() == 'shot'){
$('.field-type').hide();
}
new Clipboard('.copy-to-clipboard-id')
.on('success', function(e) {
statusBarSet('info', 'Copied task ID to clipboard', 'pi-check');
});
$("#assignees").select2();
new Clipboard('.copy-to-clipboard-shortcode')
.on('success', function(e) {
statusBarSet('info', 'Copied task shortcode to clipboard', 'pi-check');
});
if (ProjectUtils.context() == 'shot'){
$('.field-type').hide();
}
new Clipboard('.copy-to-clipboard-id')
.on('success', function(e) {
statusBarSet('info', 'Copied task ID to clipboard', 'pi-check');
});
new Clipboard('.copy-to-clipboard-shortcode')
.on('success', function(e) {
statusBarSet('info', 'Copied task shortcode to clipboard', 'pi-check');
});
loadActivities("{{ url_for('.activities', project_url=project.url, task_id=task['_id']) }}"); // from 10_tasks.js
loadComments("{{ url_for('nodes.comments_for_node', node_id=task['_id']) }}");
{% if 'PUT' in task.allowed_methods %}
$('#item-description')
.autoResize()
.blur();
@@ -198,6 +195,12 @@ script.
$('#item-status').change(function(){
$("#item-save").trigger( "click" );
});
{% endif %}
$('.task span.due_date').html(moment().to('{{ task.properties.due_date }}'));
loadActivities("{{ url_for('.activities', project_url=project.url, task_id=task['_id']) }}"); // from 10_tasks.js
loadComments("{{ url_for('nodes.comments_for_node', node_id=task['_id']) }}");
$('.js-help').openModalUrl('Help', "{{ url_for('attract.help', project_url=project.url) }}");