Skip to content

Commit

Permalink
merge fix
Browse files Browse the repository at this point in the history
  • Loading branch information
colinyoung87 committed Nov 13, 2015
2 parents 23f7c94 + 63abfdb commit 7e50665
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions app/assets/javascripts/directives/task_item.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module("OpenHq").directive("taskItem", function($rootScope, Task, TasksRepository, ConfirmDialog) {
angular.module("OpenHq").directive("taskItem", function($rootScope, $routeParams, Task, TasksRepository, ConfirmDialog) {
return {
restrict: "E",
scope: {
Expand All @@ -11,6 +11,7 @@ angular.module("OpenHq").directive("taskItem", function($rootScope, Task, TasksR
$scope.editTask = angular.copy($scope.task);
$scope.editing = false;
$scope.task.completeInline = false; // still show the task, even if it is completed
$scope.$task_list = $(".tasks ul.sortable");

$scope.startEditing = function() {
$scope.editing = true;
Expand Down Expand Up @@ -45,12 +46,17 @@ angular.module("OpenHq").directive("taskItem", function($rootScope, Task, TasksR
}
});

$(".tasks ul.sortable").sortable({
// Remove sortable if already initalized
if ($scope.$task_list.hasClass('ui-sortable')) {
$scope.$task_list.sortable("destroy");
}

// Set updated list as sorted
$scope.$task_list.sortable({
items: "li",
update: function() {
var $this = $(this),
story_id = $this.attr('data-story-id'),
order = $this.sortable("toArray");
var story_id = $routeParams.slug,
order = $(this).sortable("toArray");

TasksRepository.updateOrder(story_id, order);
}
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/templates/stories/show.jst.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</div>
<div ng-show="story.tasks.length > 0" class="tasks-list-container">
<h4>{{ story.tasks | incompleteTasks | countArray }} Incomplete Tasks</h4>
<ul class="sortable" data-story-id="{{ story.id }}">
<ul class="sortable">
<li ng-repeat="task in story.tasks" id="{{ task.id }}" ng-class="{'complete' : task.completed}" ng-show="!task.completed || task.completeInline || story.showingCompletedTasks">
<task-item task="task" users="story.users_select_array"></task-item>
</li>
Expand Down

0 comments on commit 7e50665

Please sign in to comment.