Some tweaks for shot editing

This commit is contained in:
2016-09-22 15:44:24 +02:00
parent b5d335672e
commit a786fc3b3d
2 changed files with 21 additions and 10 deletions

View File

@@ -19,6 +19,16 @@
;
return this;
};
$.fn.removeClassPrefix = function(prefix) {
this.each(function(i, el) {
var classes = el.className.split(" ").filter(function(c) {
return c.lastIndexOf(prefix, 0) !== 0;
});
el.className = $.trim(classes.join(" "));
});
return this;
};
}(jQuery));
/**
@@ -150,10 +160,11 @@ function task_save(task_id, task_url) {
$task.find('span.type').text(saved_task.task_type);
$task.find('span.status').text(saved_task.properties.status.replace('_', ' '));
// FIXME: remove all existing status-XXX classes.
$task
.removeClass('col-list-item task-list-item')
.addClass('col-list-item task-list-item status-' + saved_task.properties.status);
.removeClassPrefix('status-')
.addClass('status-' + saved_task.properties.status)
.flashOnce()
;
},
fail: function($item, xhr_or_response_data) {
$('#task-details').html(xhr_or_response_data.responseText);
@@ -165,12 +176,12 @@ function shot_save(shot_id, shot_url) {
return attract_form_save('shot_form', 'shot-' + shot_id, shot_url, {
done: function($shot, saved_shot) {
// Update the shot list.
$('.shot-name-' + saved_shot._id).text(saved_shot.name).flashOnce();
// FIXME: remove all existing status-XXX classes.
$('.shot-name-' + saved_shot._id).text(saved_shot.name);
$shot
.removeClass('col-list-item shot-list-item')
.addClass('col-list-item shot-list-item status-' + saved_shot.properties.status);
.removeClassPrefix('status-')
.addClass('status-' + saved_shot.properties.status)
.flashOnce()
;
},
fail: function($item, xhr_or_response_data) {
$('#task-details').html(xhr_or_response_data.responseText);

View File

@@ -18,7 +18,7 @@
| {% endfor %}
.table-body
| {% for shot in shots %}
.table-row
.table-row(id="shot-{{ shot._id }}")
.table-cell
img(src="http://placehold.it/100x60")
.table-cell.shot-name
@@ -28,7 +28,7 @@
class="status-{{ shot.properties.status }}")
span(class="shot-name-{{ shot._id }}") {{ shot.name }}
| {% for task_type in task_types %}
.table-cell.task-name
.table-cell
| {% for task in tasks_for_shots[shot._id][task_type] %}
a(
href="javascript:task_open('{{ task._id }}', '{{ project.url }}');",