Made shot and task links real links with JS click handlers.

This allows "open in new window", while still using XHR for regular clicks.
This commit is contained in:
2016-09-23 10:28:47 +02:00
parent 78111968ab
commit e6e03125f7
6 changed files with 55 additions and 22 deletions

View File

@@ -17,7 +17,7 @@ html(lang="en")
| {% block style %}{% endblock %}
body("{% block bodyattrs %}{% endblock %}")
body("{% block bodyattrs %}{% if project %}data-project-url='{{ project.url }}'{% endif %}{% endblock %}")
#app-main
#col_sidebar
nav.sidebar(role="navigation")

View File

@@ -1,6 +1,5 @@
| {% extends 'attract/layout.html' %}
| {% block page_title %}Shots - {{ project.name }}{% endblock %}
| {% block bodyattrs %}data-project-url="{{ project.url }}"{% endblock %}
| {% block body %}
#col_main
.col_header.task-list-header
@@ -29,23 +28,24 @@
.table-cell.shot-status
.table-cell.shot-thumbnail
a(
id="shot-link-{{ shot._id }}"
href="javascript:shot_open('{{ shot._id }}', '{{ project.url }}');",
class="status-{{ shot.properties.status }}")
data-shot-id="{{ shot._id }}",
href="{{ url_for('attract.shots.perproject.view_shot', project_url=project.url, shot_id=shot._id) }}",
class="status-{{ shot.properties.status }} shot-link")
img(src="http://placehold.it/100x60")
.table-cell.shot-name
a(
id="shot-link-{{ shot._id }}"
href="javascript:shot_open('{{ shot._id }}', '{{ project.url }}');",
class="status-{{ shot.properties.status }}")
data-shot-id="{{ shot._id }}",
href="{{ url_for('attract.shots.perproject.view_shot', project_url=project.url, shot_id=shot._id) }}",
class="status-{{ shot.properties.status }} shot-link")
span(class="shot-name-{{ shot._id }}") {{ shot.name }}
| {% for task_type in task_types %}
.table-cell.task-type(class="{{ task_type }}")
| {% for task in tasks_for_shots[shot._id][task_type] %}
a(
data-task-id="{{ task._id }}",
id="task-{{ task._id }}",
href="javascript:task_open('{{ task._id }}', '{{ project.url }}');",
class="status-{{ task.properties.status }}")
href="{{ url_for('attract.shots.perproject.with_task', project_url=project.url, task_id=task._id) }}",
class="status-{{ task.properties.status }} task-link")
| {% endfor %}
| {% if not tasks_for_shots[shot._id][task_type] %}
a.task-add(
@@ -67,10 +67,10 @@ script.
ProjectUtils.setProjectAttributes({context: 'shot'});
{% if open_task_id %}
$(function() { task_open('{{ open_task_id }}', '{{ project.url }}'); });
$(function() { task_open('{{ open_task_id }}'); });
{% endif %}
{% if open_shot_id %}
$(function() { shot_open('{{ open_shot_id }}', '{{ project.url }}'); });
$(function() { shot_open('{{ open_shot_id }}'); });
{% endif %}

View File

@@ -1,7 +1,6 @@
| {% extends 'attract/layout.html' %}
| {% block page_title %}Tasks - {{ project.name }} {% endblock %}
| {% block body %}
#col_main
.col_header.task-list-header
@@ -15,8 +14,9 @@
//- NOTE: this is tightly linked to the JS in tasks.js.
a.col-list-item.task-list-item(
id="task-{{task._id}}",
class="status-{{ task.properties.status }}",
href="javascript:task_open('{{ task._id }}', '{{ project.url }}');")
data-task-id="{{task._id}}",
class="status-{{ task.properties.status }} task-link",
href="{{ url_for('attract.tasks.perproject.view_task', project_url=project.url, task_id=task._id) }}")
span.status-indicator
span.name {{ task.name }}
span.type {{ task.properties.task_type }}
@@ -34,4 +34,8 @@
| {% block footer_scripts %}
script.
ProjectUtils.setProjectAttributes({context: 'task'});
{% if open_task_id %}
$(function() { task_open('{{ open_task_id }}'); });
{% endif %}
| {% endblock %}