Task-add: Use a button instead of a link, and prevent default

Avoids the issue of re-loading the page on task-add
This commit is contained in:
2017-02-14 15:34:29 +01:00
parent 9aaa2365cf
commit aa90a4433f
3 changed files with 39 additions and 17 deletions

View File

@@ -206,18 +206,6 @@ nav.sidebar
&.active
background-image: none
&.task-add
width: auto
border-radius: initial
opacity: 0
vertical-align: middle
padding: 5px
display: flex
justify-content: center
&:hover, &:focus
opacity: 1
&:hover
&:before
opacity: .8
@@ -225,6 +213,22 @@ nav.sidebar
&.active:before
transform: translate(-50%, -50%) scale(1.3)
button.task-add
display: flex
width: auto
border-radius: initial
opacity: 0
vertical-align: middle
padding: 5px
justify-content: center
color: $color-primary
border: none
background: none
&:hover, &:focus
opacity: 1
.item-list-header
a
color: $color-text-dark

View File

@@ -63,10 +63,11 @@
| {% endfor %}
//- Dirty hack, assume a user can create a task for a asset if they can edit the asset.
| {% if 'PUT' in asset.allowed_methods %}
a.task-add(
button.task-add(
title="Add a new '{{ task_type }}' task",
class="task-add-link {% if tasks_for_assets[asset._id][task_type] %}hidden{% endif %}"
href="javascript:task_create('{{ asset._id }}', '{{ task_type }}');")
class="task-add-link {% if tasks_for_assets[asset._id][task_type] %}hidden{% endif %}",
data-parent-id='{{ asset._id }}',
data-task-type='{{ task_type }}')
i.pi-plus
| Task
| {% endif %}
@@ -93,6 +94,14 @@ script.
$(function() { item_open('{{ open_asset_id }}', 'asset', false); });
{% endif %}
$('button.task-add').on('click', function(e){
e.preventDefault();
var parent_id = $(this).attr('data-parent-id');
var task_type = $(this).attr('data-task-type');
task_create(parent_id, task_type);
});
var same_cells;
/* Collapse columns by clicking on the title */

View File

@@ -62,10 +62,11 @@
| {% endfor %}
//- Dirty hack, assume a user can create a task for a shot if they can edit the shot.
| {% if 'PUT' in shot.allowed_methods %}
a.task-add(
button.task-add(
title="Add a new '{{ task_type }}' task",
class="task-add-link {% if tasks_for_shots[shot._id][task_type] %}hidden{% endif %}"
href="javascript:task_create('{{ shot._id }}', '{{ task_type }}');")
data-parent-id='{{ shot._id }}',
data-task-type='{{ task_type }}')
i.pi-plus
| Task
| {% endif %}
@@ -92,6 +93,14 @@ script.
$(function() { item_open('{{ open_shot_id }}', 'shot', false); });
{% endif %}
$('button.task-add').on('click', function(e){
e.preventDefault();
var parent_id = $(this).attr('data-parent-id');
var task_type = $(this).attr('data-task-type');
task_create(parent_id, task_type);
});
var same_cells;
/* Collapse columns by clicking on the title */