- id = [workflow.to_s, task.to_s] * "__" - action = File.join('/', workflow.to_s, task.to_s) - task_info = workflow.task_info(task) .workflow_task(id=id) .title %h3 %a(href="/#{workflow.to_s}")= workflow — =Misc.humanize task .description - if task_info[:description] %p.task_description :markdown #{task_info[:description]} .form.action_parameters.ui.segment = partial_render('partials/form', :id => id, :action => action, :method => 'post', :enctype => "multipart/form-data", :info => task_info, :klass => 'workflow_task', :locals => locals) - if workflow.libdir.examples[task.to_s].exists? .examples :javascript example_inputs = []; Click to load example data: %ul.ui.buttons - workflow.libdir.examples[task.to_s].glob('*').each do |example_dir| - name = File.basename(example_dir) - task_info = workflow.task_info task - inputs = Workflow.load_inputs(example_dir, task_info[:inputs], task_info[:input_types]) - inputs.each{ |k,v| v.replace Open.read(v) if String === v and File.exists? v } :javascript example_inputs["#{ name }"] = #{inputs.to_json} %li.ui.link.button %a.load_example(href="#" task=task name=name)= name :javascript defer(function(){ var form = $('.workflow_task[id=#{id}] > .form > form') $("a.load_example").click(function(){ var link = $(this); var name = $(link).attr('name'); var inputs = example_inputs[name]; //form[0].reset() for (var input in inputs){ var value = inputs[input] var input = form.find('[name=' + input + ']') if (input.is('[type=checkbox]')){ input.prop('checked', value) }else{ input.val(value) } } form.find('[name=jobname]').val(name) return false }) }) :deferjs var autofill = rbbt.LS.load('autofill') var workflow = '#{workflow}' var task_name = '#{task}' var key = [workflow, task_name].join("#") if (autofill != undefined && autofill[key]){ var inputs = autofill[key] var form = $('.workflow_task[id=#{id}] > .form > form') forHash(inputs, function(name,value){ var input = form.find('[name=' + name + ']'); if (input.length > 0 && typeof value == 'string' && value.match(/TRUNCATED/)){ var err= "Error loading input " + name + ". It was truncated due to it length."; rbbt.modal.controller.error(m('.ui.error.message', [m('.header', err), m('.description', m('pre', m.trust(value)))]), "Form entry not loaded correctly") } if (input.is('[type=checkbox]')){ input.prop('checked', value); }else{ input.val(value); } }) } rbbt.LS.delete('autofill')