Created
October 18, 2014 03:19
-
-
Save manku-timma/5febce2639489d98cd16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/taskwarrior-web/app.rb b/lib/taskwarrior-web/app.rb | |
index 48da31a..ea3e7a1 100644 | |
--- a/lib/taskwarrior-web/app.rb | |
+++ b/lib/taskwarrior-web/app.rb | |
@@ -154,6 +154,8 @@ class TaskwarriorWeb::App < Sinatra::Base | |
get('/ajax/projects/?') { TaskwarriorWeb::Command.new(:projects).run.split("\n").to_json } | |
get('/ajax/count/?') { task_count } | |
post('/ajax/task-complete/:id/?') { TaskwarriorWeb::Command.new(:complete, params[:id]).run } | |
+ post('/ajax/task-start/:id/?') { TaskwarriorWeb::Command.new(:start, params[:id]).run } | |
+ post('/ajax/task-stop/:id/?') { TaskwarriorWeb::Command.new(:stop, params[:id]).run } | |
get('/ajax/badge/?') { badge_count } | |
# Error handling | |
diff --git a/lib/taskwarrior-web/helpers.rb b/lib/taskwarrior-web/helpers.rb | |
index af1fcb0..460ee8d 100644 | |
--- a/lib/taskwarrior-web/helpers.rb | |
+++ b/lib/taskwarrior-web/helpers.rb | |
@@ -72,6 +72,12 @@ module TaskwarriorWeb::App::Helpers | |
string << %(<a href="/tasks/#{task.uuid}?destination=#{ERB::Util.u(request.path_info)}"><i class="icon-pencil"></i></a>) | |
string << %( | ) | |
string << %(<a href="/tasks/#{task.uuid}?destination=#{ERB::Util.u(request.path_info)}" data-method="DELETE" data-confirm="Are you sure you want to delete this task?"><i class="icon-trash"></i></a>) | |
+ string << %( | ) | |
+ if task.start | |
+ string << %(<i class="icon-pause start-stop" data-task-id="#{task.uuid}" data-action="stop" style="cursor:pointer"></i>) | |
+ else | |
+ string << %(<i class="icon-play start-stop" data-task-id="#{task.uuid}" data-action="start" style="cursor:pointer"></i>) | |
+ end | |
string << %(</span>) | |
string | |
end | |
diff --git a/lib/taskwarrior-web/public/js/application.js b/lib/taskwarrior-web/public/js/application.js | |
index 33c3ae9..4ce58cc 100644 | |
--- a/lib/taskwarrior-web/public/js/application.js | |
+++ b/lib/taskwarrior-web/public/js/application.js | |
@@ -8,6 +8,7 @@ $(document).ready(function() { | |
initUjs(); | |
initAutoclose(); | |
refreshDockBadge(); | |
+ initTaskStartStop(); | |
// Hack to account for navbar when clicking anchor links. | |
$('#sidebar .nav li a').click(function(event) { | |
@@ -23,6 +24,7 @@ var refreshPageContents = function() { | |
success: function(data) { | |
$('#listing').replaceWith($('#listing', data)); | |
initTaskCompletion(); | |
+ initTaskStartStop(); | |
refreshSubnavCount(); | |
refreshDockBadge(); | |
} | |
@@ -76,6 +78,32 @@ var initTaskCompletion = function() { | |
}); | |
}; | |
+var initTaskStartStop = function() { | |
+ $('i.start-stop').not('.start-stop-processed').each(function(index, element) { | |
+ $(this).addClass('start-stop-processed'); | |
+ $(this).click(function(e) { | |
+ e.preventDefault(); | |
+ | |
+ // Cache the checkbox in case we need to restore it. | |
+ var $container = $(this).parent(), | |
+ icons = $container.html(); | |
+ $container.html('<img src="/img/ajax-loader.gif" />'); | |
+ $.ajax({ | |
+ url: '/ajax/task-' + $(this).data('action') + '/' + $(this).data('task-id'), | |
+ type: 'POST', | |
+ success: function(data) { | |
+ refreshPageContents(); | |
+ set_message(data === '' ? 'Task marked as completed.' : data); | |
+ }, | |
+ error: function(data) { | |
+ set_message('There was an error when marking the task as completed.', 'error'); | |
+ $container.html(icons); | |
+ } | |
+ }); | |
+ }); | |
+ }); | |
+}; | |
+ | |
var initHotkeys = function() { | |
$('#hotkeys').modal({show: false}); | |
diff --git a/lib/taskwarrior-web/services/builder/base.rb b/lib/taskwarrior-web/services/builder/base.rb | |
index c6dd4b6..a99e120 100644 | |
--- a/lib/taskwarrior-web/services/builder/base.rb | |
+++ b/lib/taskwarrior-web/services/builder/base.rb | |
@@ -11,6 +11,8 @@ module TaskwarriorWeb::CommandBuilder::Base | |
:annotate => ':id annotate', | |
:denotate => ':id denotate', | |
:projects => '_projects', | |
+ :start => ':id start', | |
+ :stop => ':id stop', | |
:tags => '_tags' | |
} | |
diff --git a/lib/taskwarrior-web/views/layout.erb b/lib/taskwarrior-web/views/layout.erb | |
index 76fd490..9d7c4c9 100644 | |
--- a/lib/taskwarrior-web/views/layout.erb | |
+++ b/lib/taskwarrior-web/views/layout.erb | |
@@ -20,7 +20,6 @@ | |
<%= erb :'partials/_topbar' %> | |
<%= erb :'partials/_subnav' %> | |
<section class="content"> | |
- <%= erb :'partials/_flash' %> | |
<%= yield %> | |
</section> | |
</div> | |
diff --git a/lib/taskwarrior-web/views/tasks/index.erb b/lib/taskwarrior-web/views/tasks/index.erb | |
index 251bd03..db52945 100644 | |
--- a/lib/taskwarrior-web/views/tasks/index.erb | |
+++ b/lib/taskwarrior-web/views/tasks/index.erb | |
@@ -10,6 +10,7 @@ | |
<table class="table table-striped table-hover table-sortable"> | |
<thead> | |
<tr> | |
+ <th>Index</th> | |
<% if params[:status] == 'pending' %><th class="no-sort"></th><% end %> | |
<th>Description</th> | |
<th>Project</th> | |
@@ -23,12 +24,14 @@ | |
%> | |
<th>Tags</th> | |
<th data-sort-map='{"H": 0, "M": 1, "": 2, "L": 3}'>Priority</th> | |
- <% if can_edit %><th class="no-sort"></th><% end %> | |
+ <% if can_edit %><th class="no-sort">Operations</th><% end %> | |
+ <th>Created</th> | |
</tr> | |
</thead> | |
<tbody> | |
- <% @tasks.each do |task| %> | |
+ <% @tasks.each_with_index do |task, index| %> | |
<tr<%= %{ class="#{colorize_date(task.due)}"} if task.active? %>> | |
+ <td><%= (index+1).to_s + "." %></td> | |
<% if params[:status] == 'pending' %> | |
<td><input type="checkbox" class="complete" data-task-id="<%= task.uuid %>" /></td> | |
<% end %> | |
@@ -57,6 +60,7 @@ | |
<td><%= format_tags(task.tags) unless task.tags.nil? %></td> | |
<td><%= task.priority unless task.priority.nil? %></td> | |
<% if can_edit %><td><%= crud_links(task) %></td><% end %> | |
+ <td><%= format_date(task.entry) %></td> | |
</tr> | |
<% end %> | |
</tbody> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment