Skip to content

Commit

Permalink
fix bugs with drag and drop in task overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
PalmerAL committed Apr 27, 2016
1 parent 1725c79 commit 52dd8e3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 11 additions & 1 deletion js/api-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,17 @@ function switchToTask(id) {
var taskData = tasks.get(id);

if (taskData.tabs.length > 0) {
switchToTab(taskData.tabs.getSelected());
var selectedTab = taskData.tabs.getSelected();

//if the task has no tab that is selected, switch to the most recent one

if(!selectedTab) {
selectedTab = taskData.tabs.get().sort(function(a, b) {
return b.lastActivity - a.lastActivity;
})[0].id;
}

switchToTab(selectedTab);
} else {
addTab();
}
Expand Down
5 changes: 4 additions & 1 deletion js/taskOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function getTaskOverlayTabElement(tab, task) {
});

item.setAttribute("data-tab", tab.id);
item.setAttribute("data-task", task.id);

return item;
}
Expand Down Expand Up @@ -113,7 +114,7 @@ function getTaskElement(task, taskIndex) {
var el = getTaskOverlayTabElement(task.tabs[i], task);

el.addEventListener("click", function (e) {
switchToTask(task.id);
switchToTask(this.getAttribute("data-task"));
switchToTab(this.getAttribute("data-tab"));

taskOverlay.hide();
Expand Down Expand Up @@ -238,6 +239,8 @@ function syncStateAndOverlay() {
if (newTabs.length != 0) {
for (var i = 0; i < newTabs.length; i++) {
task.tabs.add(tabSet[newTabs[i].getAttribute("data-tab")]);
//update the data-task attribute of the tab element
newTabs[i].setAttribute("data-task", task.id);
}
} else {
//the task has no tabs, remove it
Expand Down

0 comments on commit 52dd8e3

Please sign in to comment.