| CODENOTIFIER | HelpYou are not signed inSign in |
Project: taskr
Revision: 217
Author: dvdplm
Date: 22 Aug 2008 07:06:14
Changes:CHANGED: edit/update actions and minor fixes/updates.
Files:| ... | ...@@ -39,7 +39,7 @@ | |
| 39 | 39 | validates_presence_of :task_actions |
| 40 | 40 | validates_associated :task_actions |
| 41 | 41 | |
| 42 | def schedule!(scheduler) | |
| 42 | def schedule!(scheduler = Taskr.scheduler) | |
| 43 | 43 | case schedule_method |
| 44 | 44 | when 'cron' |
| 45 | 45 | method = :schedule |
| ... | ...@@ -62,11 +62,20 @@ | |
| 62 | 62 | |
| 63 | 63 | $LOG.debug "Scheduling task #{name.inspect}: #{self.inspect}" |
| 64 | 64 | |
| 65 | if task_actions.length > 0 | |
| 66 | action = prepare_action | |
| 65 | if self.new_record? # Need to distinguish between the edit/create cases. "Edit" needs to reload the task_actions or nothing works; "Create" needs NOT to relaod the actions, or the validations kick in and nothing works. FIXME!!!!! | |
| 66 | if task_actions.length > 0 | |
| 67 | action = prepare_action | |
| 68 | else | |
| 69 | $LOG.warn "Task #{name.inspect} has no actions and as a result will not be scheduled!" | |
| 70 | return false | |
| 71 | end | |
| 67 | 72 | else |
| 68 | $LOG.warn "Task #{name.inspect} has no actions and as a result will not be scheduled!" | |
| 69 | return false | |
| 73 | if task_actions(true).length > 0 | |
| 74 | action = prepare_action | |
| 75 | else | |
| 76 | $LOG.warn "Task #{name.inspect} has no actions and as a result will not be scheduled!" | |
| 77 | return false | |
| 78 | end | |
| 70 | 79 | end |
| 71 | 80 | |
| 72 | 81 | job_id = scheduler.send(method, t || schedule_when, :schedulable => action) |
| ... | ...@@ -149,6 +158,7 @@ | |
| 149 | 158 | :class_name => 'TaskActionParameter', |
| 150 | 159 | :foreign_key => :task_action_id, |
| 151 | 160 | :dependent => :destroy |
| 161 | alias_method :parameters, :action_parameters | |
| 152 | 162 | |
| 153 | 163 | has_many :log_entries |
| 154 | 164 | has_one :last_log_entry, |
| ... | ...@@ -170,6 +180,10 @@ | |
| 170 | 180 | self[:action_class_name].constantize |
| 171 | 181 | end |
| 172 | 182 | |
| 183 | def description | |
| 184 | action_class.description | |
| 185 | end | |
| 186 | ||
| 173 | 187 | def to_xml(options = {}) |
| 174 | 188 | options[:indent] ||= 2 |
| 175 | 189 | xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent]) |
| ... | ...@@ -2,7 +2,7 @@ | |
| 2 | 2 | module VERSION #:nodoc: |
| 3 | 3 | MAJOR = 0 |
| 4 | 4 | MINOR = 3 |
| 5 | TINY = 0 | |
| 5 | TINY = 2 | |
| 6 | 6 | |
| 7 | 7 | STRING = [MAJOR, MINOR, TINY].join('.') |
| 8 | 8 | end |
| ... | ...@@ -11,8 +11,8 @@ | |
| 11 | 11 | include FileUtils |
| 12 | 12 | require File.join(File.dirname(__FILE__), 'lib', 'taskr', 'version') |
| 13 | 13 | |
| 14 | AUTHOR = "Matt Zukowski" # can also be an array of Authors | |
| 15 | EMAIL = "matt at roughest dot net" | |
| 14 | AUTHOR = ["Matt Zukowski", "David Palm"] # can also be an array of Authors | |
| 15 | EMAIL = ["matt at roughest dot net", "dvd plm on googles free email service"] | |
| 16 | 16 | DESCRIPTION = "cron-like scheduler service with a RESTful interface" |
| 17 | 17 | GEM_NAME = "taskr" # what ppl will type to install your gem |
| 18 | 18 | RUBYFORGE_PROJECT = "taskr" # The unix name for your project |
| ... | ...@@ -20,8 +20,7 @@ | |
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | NAME = "taskr" |
| 23 | #REV = nil | |
| 24 | REV = `svn info`[/Revision: (\d+)/, 1] rescue nil | |
| 23 | REV = nil | |
| 25 | 24 | VERS = ENV['VERSION'] || (Taskr::VERSION::STRING + (REV ? ".#{REV}" : "")) |
| 26 | 25 | CLEAN.include ['**/.*.sw?', '*.gem', '.config'] |
| 27 | 26 | RDOC_OPTS = ['--quiet', '--title', "taskr documentation", |
| ... | ...@@ -61,3 +60,26 @@ | |
| 61 | 60 | ] |
| 62 | 61 | p.spec_extras = {:executables => ['taskr', 'taskr-ctl']} |
| 63 | 62 | end |
| 63 | ||
| 64 | desc "Generate gemspec" | |
| 65 | task :gemspec do |x| | |
| 66 | # Check the manifest before generating the gemspec | |
| 67 | manifest = %x[rake check_manifest] | |
| 68 | manifest.gsub!(/\(in .{1,}\)\n/, "") | |
| 69 | ||
| 70 | unless manifest.empty? | |
| 71 | print "\n", "#"*68, "\n" | |
| 72 | print <<-EOS | |
| 73 | Manifest.txt is not up-to-date. Please review the changes below. | |
| 74 | If the changes are correct, run 'rake check_manifest | patch' | |
| 75 | and then run this command again. | |
| 76 | EOS | |
| 77 | print "#"*68, "\n\n" | |
| 78 | puts manifest | |
| 79 | else | |
| 80 | gemspec = %x[rake debug_gem] | |
| 81 | gemspec.gsub!(/\(in .{1,}\)\n/, "") | |
| 82 | File.open("#{GEM_NAME}.gemspec",'w'){|f| f<<gemspec} | |
| 83 | %x[rake debug_gem > #{GEM_NAME}.gemspec] | |
| 84 | end | |
| 85 | end | |
| 64 | 86 | \ No newline at end of file |
| ... | ...@@ -66,9 +66,117 @@ | |
| 66 | 66 | render :view_task |
| 67 | 67 | end |
| 68 | 68 | |
| 69 | def edit(task_id) | |
| 70 | @task = Task.find(task_id, :include => [:task_actions]) | |
| 71 | @actions = Taskr::Actions.list | |
| 72 | render :edit_task | |
| 73 | end | |
| 74 | ||
| 75 | def update(task_id) | |
| 76 | $LOG.debug "Update Input params: #{@input.inspect}" | |
| 77 | @task = Task.find(task_id, :include => [:task_actions]) | |
| 78 | params = normalize_input(@input) | |
| 79 | @task.attributes= { | |
| 80 | :name => params[:name], | |
| 81 | :schedule_method => params[:schedule_method], | |
| 82 | :schedule_when => params[:schedule_when], | |
| 83 | :memo => params[:memo] | |
| 84 | } | |
| 85 | ||
| 86 | @task.task_actions.each do |action| | |
| 87 | $LOG.debug("Updating parameters for #{action.inspect}") | |
| 88 | action_params = params[:action].delete("action_id_#{action.id}") | |
| 89 | $LOG.debug("Using values #{action_params.inspect}") | |
| 90 | next unless action_params | |
| 91 | action_params.each do |param_name, value| | |
| 92 | $LOG.debug("Looking up \"#{param_name}\". Setting value to \"#{value}\"") | |
| 93 | action.parameters.find_by_name(param_name).update_attribute(:value, value) | |
| 94 | end | |
| 95 | end | |
| 96 | ||
| 97 | # Create new actions/action_parameters for the remaining params | |
| 98 | unless params[:action].empty? | |
| 99 | params[:action].map do |num, params| | |
| 100 | $LOG.debug "Looping remaining action_parameters: #{params.inspect} (num: #{num})" | |
| 101 | action_class = get_action_class(params[:action_class_name]) | |
| 102 | action = TaskAction.new(:order => params[:order] || (@task.task_actions.maximum(:order)+1) || num, :action_class_name => action_class.to_s) | |
| 103 | ||
| 104 | action_class.parameters.each do |p| | |
| 105 | value = params[p] | |
| 106 | value = nil if value.blank? | |
| 107 | action.action_parameters << TaskActionParameter.new(:name => p, :value => value) | |
| 108 | end | |
| 109 | @task.task_actions << action | |
| 110 | end | |
| 111 | end | |
| 112 | ||
| 113 | unless @task.valid? | |
| 114 | @status = 500 | |
| 115 | @actions = Taskr::Actions.list | |
| 116 | else | |
| 117 | @task.save! | |
| 118 | @status = 200 | |
| 119 | end | |
| 120 | ||
| 121 | @task.reload # Ensure any updates to the record goes in | |
| 122 | ||
| 123 | Taskr.scheduler.unschedule(@task.scheduler_job_id) | |
| 124 | @task.schedule! Taskr.scheduler | |
| 125 | ||
| 126 | $LOG.info "Task \"#{@task.name}\" (ID: #{@task.id}) updated sucessfully." | |
| 127 | redirect R(@task) | |
| 128 | end | |
| 129 | ||
| 130 | def normalize_input(hsh) | |
| 131 | hsh[:task] || hsh["0"] || hsh | |
| 132 | end | |
| 133 | ||
| 134 | def normalize_actions_params(input_params) | |
| 135 | $LOG.debug "normalize_actions_params Normalizing: #{input_params.inspect}" | |
| 136 | # some gymnastics here to provide compatibility for the way various | |
| 137 | # REST client libraries submit data | |
| 138 | actions_data = input_params[:actions] || input_params[:action] | |
| 139 | ||
| 140 | raise ArgumentError, "Missing action(s) parameter." if actions_data.blank? | |
| 141 | actions = case actions_data | |
| 142 | when Array | |
| 143 | $LOG.debug "normalize_actions_params Plain Array. Returning as-is." | |
| 144 | actions_data | |
| 145 | when Hash | |
| 146 | $LOG.debug "normalize_actions_params Some weird Hash. Injecting." | |
| 147 | actions_data.inject([]) do |acc,(i,a)| | |
| 148 | $LOG.debug "normalize_actions_params acc: #{acc.inspect} index: #{i.inspect} array: #{a.inspect}." | |
| 149 | acc << a | |
| 150 | acc | |
| 151 | end | |
| 152 | else | |
| 153 | $LOG.debug "normalize_actions_params Not a weird hash.\n\tactions_data[:action]: #{actions_data[:action].inspect}\n\tactions_data[:actions]: #{actions_data[:actions].inspect}\n\tactions_data: #{actions_data.inspect}\n\n" | |
| 154 | actions_data[:action] || actions_data[:actions] || actions_data | |
| 155 | end | |
| 156 | actions = [actions] unless actions.kind_of? Array | |
| 157 | $LOG.debug "normalize_actions_params DONE. Returning: #{actions.inspect}" | |
| 158 | actions | |
| 159 | end | |
| 160 | ||
| 161 | def get_action_class(class_name) | |
| 162 | action_class_name = "Taskr::Actions::#{class_name}" unless class_name =~ /^Taskr::Actions::/ | |
| 163 | ||
| 164 | begin | |
| 165 | action_class = action_class_name.constantize | |
| 166 | unless action_class.include? Rufus::Schedulable | |
| 167 | raise ArgumentError, | |
| 168 | "#{a[:action_class_name].inspect} cannot be used as an action because it does not include the Rufus::Schedulable module." | |
| 169 | end | |
| 170 | rescue NameError | |
| 171 | raise ArgumentError, | |
| 172 | "#{a[:action_class_name].inspect} is not defined (i.e. there is no such action class)." | |
| 173 | end | |
| 174 | action_class | |
| 175 | end | |
| 176 | ||
| 69 | 177 | # Create and schedule a new task. |
| 70 | 178 | def create |
| 71 | puts @input.inspect | |
| 179 | $LOG.debug @input.inspect | |
| 72 | 180 | begin |
| 73 | 181 | # the "0" is for compatibility with PHP's Zend_Rest_Client |
| 74 | 182 | task_data = @input[:task] || @input["0"] || @input |
| ... | ...@@ -125,7 +233,7 @@ | |
| 125 | 233 | end |
| 126 | 234 | |
| 127 | 235 | action = TaskAction.new(:order => a[:order] || i, :action_class_name => action_class_name) |
| 128 | ||
| 236 | $LOG.debug "Action should be initialized and ready for creation: #{action.inspect}" | |
| 129 | 237 | |
| 130 | 238 | action_class.parameters.each do |p| |
| 131 | 239 | value = a[p] |
| ... | ...@@ -147,7 +255,7 @@ | |
| 147 | 255 | |
| 148 | 256 | @task.schedule! Taskr.scheduler |
| 149 | 257 | |
| 150 | if @task.save | |
| 258 | if @task.save! | |
| 151 | 259 | location = "/tasks/#{@task.id}?format=#{@format}" |
| 152 | 260 | $LOG.debug "#{@task} saved successfuly. Setting Location header to #{location.inspect}." |
| 153 | 261 | @headers['Location'] = location |
| ... | ...@@ -174,7 +282,7 @@ | |
| 174 | 282 | # ok to catch exception silently. it should have gotten logged by the action |
| 175 | 283 | end |
| 176 | 284 | |
| 177 | render :view_task | |
| 285 | redirect R(@task) | |
| 178 | 286 | end |
| 179 | 287 | |
| 180 | 288 | # Unschedule and delete an existing task. |
| ... | ...@@ -197,6 +305,19 @@ | |
| 197 | 305 | _error("Task #{id} was not destroyed.", 500) |
| 198 | 306 | end |
| 199 | 307 | end |
| 308 | ||
| 309 | # Reload a task | |
| 310 | def reload(id) | |
| 311 | @task = Task.find(id) | |
| 312 | $LOG.debug "Re-scheduling task #{@task}..." | |
| 313 | if @task.scheduler_job_id | |
| 314 | Taskr.scheduler.unschedule(@task.scheduler_job_id) | |
| 315 | $LOG.debug "\t...unscheduled task #{@task}..." | |
| 316 | end | |
| 317 | @task.schedule! Taskr.scheduler | |
| 318 | $LOG.debug "\t...scheduled task #{@task}...\n" | |
| 319 | redirect R(@task) | |
| 320 | end | |
| 200 | 321 | end |
| 201 | 322 | |
| 202 | 323 | class LogEntries < REST 'log_entries' |
| ... | ...@@ -0,0 +1,46 @@ | |
| 1 | Gem::Specification.new do |s| | |
| 2 | s.name = %q{taskr} | |
| 3 | s.version = "0.3.1" | |
| 4 | ||
| 5 | s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= | |
| 6 | s.authors = ["Matt Zukowski", "David Palm"] | |
| 7 | s.date = %q{2008-08-11} | |
| 8 | s.description = %q{cron-like scheduler service with a RESTful interface} | |
| 9 | s.email = ["matt at roughest dot net", "dvd plm on googles free email service"] | |
| 10 | s.executables = ["taskr", "taskr-ctl"] | |
| 11 | s.extra_rdoc_files = ["CHANGELOG.txt", "GPLv3-LICENSE.txt", "History.txt", "Manifest.txt", "README.txt", "taskr4rails/LICENSE.txt"] | |
| 12 | s.files = ["CHANGELOG.txt", "GPLv3-LICENSE.txt", "History.txt", "Manifest.txt", "README.txt", "Rakefile", "bin/taskr", "bin/taskr-ctl", "config.example.yml", "examples/active_resource_client_example.rb", "examples/php_client_example.php", "lib/public/prototype.js", "lib/public/taskr.css", "lib/taskr.rb", "lib/taskr/actions.rb", "lib/taskr/controllers.rb", "lib/taskr/environment.rb", "lib/taskr/helpers.rb", "lib/taskr/models.rb", "lib/taskr/version.rb", "lib/taskr/views.rb", "setup.rb", "taskr4rails/LICENSE.txt", "taskr4rails/README", "taskr4rails/Rakefile", "taskr4rails/init.rb", "taskr4rails/install.rb", "taskr4rails/lib/taskr4rails_controller.rb", "taskr4rails/tasks/taskr4rails_tasks.rake", "taskr4rails/test/taskr4rails_test.rb", "taskr4rails/uninstall.rb", "test.rb", "test/taskr_test.rb", "test/test_helper.rb"] | |
| 13 | s.has_rdoc = true | |
| 14 | s.homepage = %q{http://taskr.rubyforge.org} | |
| 15 | s.rdoc_options = ["--main", "README.txt"] | |
| 16 | s.require_paths = ["lib"] | |
| 17 | s.rubyforge_project = %q{taskr} | |
| 18 | s.rubygems_version = %q{1.2.0} | |
| 19 | s.summary = %q{cron-like scheduler service with a RESTful interface} | |
| 20 | s.test_files = ["test/taskr_test.rb"] | |
| 21 | ||
| 22 | if s.respond_to? :specification_version then | |
| 23 | current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION | |
| 24 | s.specification_version = 2 | |
| 25 | ||
| 26 | if current_version >= 3 then | |
| 27 | s.add_runtime_dependency(%q<picnic>, ["~> 0.6.4"]) | |
| 28 | s.add_runtime_dependency(%q<reststop>, ["~> 0.3.0"]) | |
| 29 | s.add_runtime_dependency(%q<restr>, ["~> 0.4.0"]) | |
| 30 | s.add_runtime_dependency(%q<rufus-scheduler>, ["~> 1.0.7"]) | |
| 31 | s.add_development_dependency(%q<hoe>, [">= 1.7.0"]) | |
| 32 | else | |
| 33 | s.add_dependency(%q<picnic>, ["~> 0.6.4"]) | |
| 34 | s.add_dependency(%q<reststop>, ["~> 0.3.0"]) | |
| 35 | s.add_dependency(%q<restr>, ["~> 0.4.0"]) | |
| 36 | s.add_dependency(%q<rufus-scheduler>, ["~> 1.0.7"]) | |
| 37 | s.add_dependency(%q<hoe>, [">= 1.7.0"]) | |
| 38 | end | |
| 39 | else | |
| 40 | s.add_dependency(%q<picnic>, ["~> 0.6.4"]) | |
| 41 | s.add_dependency(%q<reststop>, ["~> 0.3.0"]) | |
| 42 | s.add_dependency(%q<restr>, ["~> 0.4.0"]) | |
| 43 | s.add_dependency(%q<rufus-scheduler>, ["~> 1.0.7"]) | |
| 44 | s.add_dependency(%q<hoe>, [">= 1.7.0"]) | |
| 45 | end | |
| 46 | end |
| ... | ...@@ -52,6 +52,7 @@ | |
| 52 | 52 | th "Job ID" |
| 53 | 53 | th "Created On" |
| 54 | 54 | th "Created By" |
| 55 | th "" | |
| 55 | 56 | end |
| 56 | 57 | end |
| 57 | 58 | tbody do |
| ... | ...@@ -73,6 +74,7 @@ | |
| 73 | 74 | td(:class => "job-id") {t.scheduler_job_id} |
| 74 | 75 | td t.created_on |
| 75 | 76 | td t.created_by |
| 77 | td {a(:href => R(t, 'edit')) {"Edit"}} | |
| 76 | 78 | end |
| 77 | 79 | end |
| 78 | 80 | end |
| ... | ...@@ -83,6 +85,96 @@ | |
| 83 | 85 | end |
| 84 | 86 | end |
| 85 | 87 | |
| 88 | def edit_task | |
| 89 | html_scaffold do | |
| 90 | script(:type => 'text/javascript') do | |
| 91 | %{ | |
| 92 | function show_action_parameters(num) { | |
| 93 | new Ajax.Updater('parameters_'+num, '#{R(Actions)}', { | |
| 94 | method: 'get', | |
| 95 | parameters: { | |
| 96 | id: $F('action_class_name_'+num), | |
| 97 | action: 'parameters_form', | |
| 98 | num: num | |
| 99 | } | |
| 100 | }); | |
| 101 | } | |
| 102 | } | |
| 103 | end | |
| 104 | ||
| 105 | a(:href => R(Tasks, :list)) {"Back to Task List"} | |
| 106 | ||
| 107 | form :method => 'put', :action => R(@task, 'update') do | |
| 108 | h1 "Edit Task \"#{@task.name}\"" | |
| 109 | ||
| 110 | p do | |
| 111 | label 'name' | |
| 112 | br | |
| 113 | input :type => 'text', :name => 'name', :value => @task.name, :size => 40 | |
| 114 | end | |
| 115 | ||
| 116 | p do | |
| 117 | label 'schedule' | |
| 118 | br | |
| 119 | select(:name => 'schedule_method') do | |
| 120 | ['every','at','in','cron'].each do |method| | |
| 121 | if @task.schedule_method == method | |
| 122 | option(:value => method, :selected => 'selected') {method} | |
| 123 | else | |
| 124 | option(:value => method) {method} | |
| 125 | end | |
| 126 | end | |
| 127 | end | |
| 128 | input :type => 'text', :name => 'schedule_when', :value => @task.schedule_when, :size => 30 | |
| 129 | end | |
| 130 | ||
| 131 | p do | |
| 132 | label 'description/memo' | |
| 133 | br | |
| 134 | textarea(:name => 'memo', :cols => '60', :rows => '4'){@task.memo} | |
| 135 | end | |
| 136 | ||
| 137 | p do | |
| 138 | label "Actions:" | |
| 139 | @task.task_actions.each do |action| | |
| 140 | div {action_parameters_form(action)} | |
| 141 | end | |
| 142 | # div do | |
| 143 | # if @task.task_actions.length > 1 | |
| 144 | # ol(:style => 'padding-left: 20px') do | |
| 145 | # @task.task_actions.each do |ta| | |
| 146 | # html_task_action_li(ta) | |
| 147 | # end | |
| 148 | # end | |
| 149 | # else | |
| 150 | # html_task_action_li(@task.task_actions.first) | |
| 151 | # end | |
| 152 | # end | |
| 153 | end | |
| 154 | ||
| 155 | ||
| 156 | p do | |
| 157 | a(:id => 'add_action', :href => '#'){'Add another action'} | |
| 158 | end | |
| 159 | ||
| 160 | script(:type => 'text/javascript') do | |
| 161 | %{ | |
| 162 | Event.observe('add_action', 'click', function() { | |
| 163 | new Ajax.Updater('add_action', '#{R(Actions, :new)}', { | |
| 164 | method: 'get', | |
| 165 | parameters: { num: $$('select.action_class_name').size() }, | |
| 166 | insertion: Insertion.Before | |
| 167 | }); | |
| 168 | return false; | |
| 169 | }) | |
| 170 | } | |
| 171 | end | |
| 172 | ||
| 173 | button(:type => 'submit') {"Save"} | |
| 174 | end | |
| 175 | end | |
| 176 | end | |
| 177 | ||
| 86 | 178 | def new_task |
| 87 | 179 | html_scaffold do |
| 88 | 180 | script(:type => 'text/javascript') do |
| ... | ...@@ -158,6 +250,9 @@ | |
| 158 | 250 | form(:method => 'put', :style => 'display: inline', :action => R(@task, 'run')) do |
| 159 | 251 | button(:type => 'submit', :value => 'run') {"Run Now!"} |
| 160 | 252 | end |
| 253 | form(:method => 'put', :style => 'display: inline', :action => R(@task, 'reload')) do | |
| 254 | button(:type => 'submit', :value => 'reload') {"Reload!"} | |
| 255 | end | |
| 161 | 256 | br |
| 162 | 257 | a(:href => R(Tasks, :list)) {"Back to Task List"} |
| 163 | 258 | |
| ... | ...@@ -253,7 +348,7 @@ | |
| 253 | 348 | text "|" |
| 254 | 349 | a(:href => R(LogEntries, :list, :task_id => @task.id, :level => 'ERROR'), |
| 255 | 350 | :target => 'log', :onclick => "clickbold(this)") {"ERROR"} |
| 256 | end | |
| 351 | end | |
| 257 | 352 | iframe(:src => R(LogEntries, :list, :task_id => @task.id, :since => (Time.now - 1.day).to_formatted_s(:db)), |
| 258 | 353 | :style => 'width: 100%; height: 300px', :name => 'log') |
| 259 | 354 | end |
| ... | ...@@ -281,16 +376,20 @@ | |
| 281 | 376 | end |
| 282 | 377 | end |
| 283 | 378 | |
| 284 | def action_parameters_form | |
| 379 | def action_parameters_form(action = @action) | |
| 285 | 380 | @num ||= 0 |
| 286 | 381 | |
| 287 | p {em @action.description} | |
| 382 | p {em action.description} | |
| 288 | 383 | |
| 289 | @action.parameters.each do |param| | |
| 384 | action.parameters.each do |param| | |
| 290 | 385 | p do |
| 291 | 386 | label param |
| 292 | 387 | br |
| 293 | input :type => 'text', :name => "action[#{@num}][#{param}]", :size => 50 | |
| 388 | unless action.is_a?(Taskr::Models::TaskAction) # Setting up a new task | |
| 389 | input :type => 'text', :name => "action[#{@num}][#{param}]", :size => 50 | |
| 390 | else # Editing an existing task | |
| 391 | input :type => 'text', :name => "action[action_id_#{action.id}][#{param.name}]", :size => 50, :value => param.value | |
| 392 | end | |
| 294 | 393 | end |
| 295 | 394 | end |
| 296 | 395 | end |