Permalink
Browse files

mini links in list view

  • Loading branch information...
1 parent 8a9e862 commit a580a24c1aa334591426cea6545bb01ab3bc4feb @niklas committed Apr 17, 2012
View
4 TODO
@@ -10,7 +10,7 @@
./app/models/queueable.rb:132:FIXME: -- FIXME won't this loop forever?
./app/models/torrent/content.rb:5:TODO: # TODO WTF is this for?
./app/models/torrent/content.rb:24:FIXME: # FIXME respect #directory
-./app/models/torrent/content.rb:149:FIXME: return nil # FIXME we have no target_dir anymore
+./app/models/torrent/content.rb:151:FIXME: return nil # FIXME we have no target_dir anymore
./app/models/torrent.rb:26:TODO: belongs_to :feed # TODO remove when series assigned
./app/models/torrent.rb:33:FIXME: # FIXME remove this insane stati code
./app/models/torrent.rb:37:FIXME: # FIXME wtf is this?
@@ -22,7 +22,7 @@
./app/models/user.rb:4:FIXME: # FIXME athentication
./app/models/user.rb:18:FIXME: # FIXME wtf
./features/step_definitions/web_steps.rb:76:TODO:# TODO: Add support for checkbox, select or option
-./features/support/selectors.rb:29:TODO: # TODO move to jquery_mobile
+./features/support/selectors.rb:32:TODO: # TODO move to jquery_mobile
./features/support/todo.rb:6:TODO: out << intense_yellow("TODO scenarios\n\n")
./features/support/todo.rb:30:TODO: File.open( Rails.root.join('log/TODO'), 'w' ) do |file|
./lib/action_messenger/base.rb:48:TODO: # TODO: Templates, ActionMailer-style.
@@ -67,6 +67,11 @@ table.torrents {
.status {
width: $pie_size * 1.2;
}
+ .actions {
+ a {
+ float: right;
+ }
+ }
.progress-pie {
width: $pie_size;
height: $pie_size;
@@ -1,7 +1,7 @@
class TorrentDecorator < ApplicationDecorator
decorates :torrent
- allows :running?, :content
+ allows :running?, :content, :moving?
def progress
handle_remote do
@@ -120,6 +120,10 @@ def selector_for(name, resource=nil, *more)
end
end
+ def update_in_list
+ page.replace_partial 'torrents/item', torrent: model
+ end
+
# Accessing Helpers
# You can access any helper via a proxy
#
@@ -15,15 +15,27 @@ def link_to(text, *args, &block)
end
def translate_icon(key, opts={})
- content_tag(:i, '', class: "icon-#{Icons[key] || 'glass'} icon-white") + ' ' + translate_action(key, opts)
+ icon_tag(key) + ' ' + translate_action(key, opts)
+ end
+
+ def icon_tag(key)
+ content_tag(:i, '', class: "icon-#{Icons[key] || 'glass'} icon-white")
end
alias ti translate_icon
+ alias i icon_tag
+
Icons = {
stop: 'stop',
start: 'play',
clear: 'trash',
move: 'share'
}
+
+ def link_to_icon icon_name, url, opts={}
+ opts = opts.merge(remote: true)
+ opts[:class] = "#{opts[:class]} #{icon_name} btn btn-mini"
+ link_to i(icon_name), url, opts
+ end
end
@@ -98,6 +98,10 @@ def info_hash_from_metainfo
has_one :move
+ def moving?
+ ! move.nil?
+ end
+
end
@@ -1,5 +1,5 @@
page.decorate @torrent do |torrent|
torrent.select(:content).replace_with render('torrents/content', torrent: torrent)
torrent.update_flash
+ torrent.update_in_list
end
-
@@ -1,4 +1,5 @@
page.decorate @move.torrent do |td|
td.close_modal
td.update_flash
+ td.update_in_list
end
@@ -4,13 +4,13 @@
= torrent.series
= torrent.content_directory
.span4
- - unless torrent.move
+ - unless torrent.moving?
= link_to_modal ti(:move), new_torrent_move_path(torrent), class: 'btn btn-info'
- else
%span.btn.btn-info.disabled= ti(:move)
.span4
.size= torrent.content_size
- = torrent.link_to_clear
+ = link_to ti(:clear), torrent_content_path(torrent), :method => :delete, class: 'clear btn btn-danger', confirm: "really?", remote: true
- else
.span12
= torrent.series
@@ -9,3 +9,15 @@
%strong= link_to torrent.title, torrent
- else
= link_to torrent.title, torrent
+ %td.actions
+ - if torrent.running?
+ = link_to_icon :stop, torrent_transfer_path(torrent), class: 'btn-danger', method: :delete
+ - else
+ = link_to_icon :start, torrent_transfer_path(torrent), class: 'btn-success', method: :post
+
+ - if torrent.content.exists?
+ - unless torrent.moving?
+ = link_to_modal i(:move), new_torrent_move_path(torrent), class: 'btn btn-info btn-mini'
+ - else
+ %span.btn.btn-info.disabled= i(:move)
+ = link_to_icon :clear, torrent_content_path(torrent), :method => :delete, class: 'clear btn-danger', confirm: "really?"
@@ -3,6 +3,7 @@
%tr
%th.status
%th.title= Torrent.human_attribute_name :title
+ %th.actions
%tbody#torrents
- search.results.each do |torrent|
= render 'torrents/item', torrent: torrent
@@ -1,4 +1,5 @@
decorate @torrent do |torrent|
page.replace_partial 'torrents/transfer', torrent: torrent
+ torrent.update_in_list
end
@@ -1,4 +1,5 @@
decorate @torrent do |torrent|
page.replace_partial 'torrents/transfer', torrent: torrent
+ torrent.update_in_list
end
@@ -59,3 +59,15 @@
Then /^(.+) should disappear$/ do |name|
step %Q~I wait for #{name} to disappear~
end
+
+When /^I click on the (.+)$/ do |target|
+ page.first( selector_for(target) ).click
+end
+
+Then /^I should see a (.+link)/ do |target|
+ page.should have_css( selector_for(target) )
+end
+
+Then /^I should not see a (.+link)/ do |target|
+ page.should have_no_css( selector_for(target) )
+end
@@ -26,6 +26,9 @@ def selector_for(locator)
when 'the modal box'
'div.modal'
+ when /^(\w+) link$/
+ "a.#{$1}"
+
# TODO move to jquery_mobile
when /^(?:a )?flash (notice|alert)$/
"#flash .alert-#{$1}"
@@ -12,14 +12,21 @@ Feature: Transferring torrents
And the file for the torrent exists
And I am signed in
- Scenario: Start the transfer
+ Scenario: Start the transfer form the list
+ When I click on the start link
+ Then I should be on the list page
+ And the rtorrent main view should contain the torrent
+ And I should see a stop link
+ But I should not see a start link
+
+ Scenario: Start the transfer from the page of the torrent
Given I am on the page for the torrent
When I follow "Start"
Then I should be on the page for the torrent
#And I should see notice "started Tails"
+ And I should see no link "Start"
And the rtorrent main view should contain the torrent
And rtorrent should download the torrent
- And I should see no link "Start"
@todo
@wip

0 comments on commit a580a24

Please sign in to comment.