<commit_before>- id      = nil unless defined? id
- action  = nil unless defined? action
- klass   = nil unless defined? klass
- method  = 'post' unless (defined?(method) and not method.nil?)
- enctype = 'multipart/form-data' unless defined? enctype
- info    = {} unless defined? info
- locals  = {} unless defined? locals
- bundle  = false unless defined? bundle

- klass = "#{klass} custom"

- if defined?(description) and description
  .form_description
    =description
  %hr

- info = info.dup
%form.ui.form(class=klass action=action method=method id=id enctype=enctype)

  - inputs       = consume_parameter(:inputs, info) || []
  - types        = consume_parameter(:input_types, info) || {}
  - defaults     = consume_parameter(:input_defaults, info) || {}
  - descriptions = consume_parameter(:input_descriptions, info) || {}
  - use          = consume_parameter(:input_use, info) || {}
  - options      = consume_parameter(:input_options, info) || {}
  - values       = consume_parameter(:values, info) || {}

  - workflows = use.values.collect{|i| i.keys}.flatten.collect{|v| v.to_s}.uniq
  - if workflows.length > 1 && use && use.any?
    - ws_id = 'workflow_select_' << id
    .ui.very.basic.segment
      .header
        Select workflow inputs to show
      .description
        .ui.buttons.workflow_select(id=ws_id)
          - workflows.each do |wfname|
            .ui.tiny.button.view_workflow.active= wfname
    %hr
    :sass
      form
        .ui.buttons.workflow_select
          margin-bottom: 2em
    :deferjs
      $('##{ws_id}').find('.view_workflow').click(function(){
        var button = $(this);
        var workflow = button.text()
        button.toggleClass('active')
        if (!button.hasClass('active'))
          $('##{id}').find('div.field[attr-use_tags*=' + workflow + ']').hide()
        if (button.hasClass('active'))
          $('##{id}').find('div.field[attr-use_tags*=' + workflow + ']').show()
      })
      
  - inputs.each do |input|
    - uses = use.nil? ? nil : use[input]
    - use_tags = []
    - if uses
      - uses.each do |workflow, tasks|
        - tasks.each do |task|
          - use_tags << [workflow, task] * "#"
    - input_id = id.nil? ? nil : id + "__" << input.to_s
    - hide = (options[input] != nil and options[input][:hide])
    %div(class="field #{types[input]} #{input} #{hide ? 'hide' : ''}" attr-use_tags='#{use_tags * " "}')
      - input_options = options[input]
      - input_options = input_options.dup unless input_options.nil?
      - description = descriptions[input]
      - if use[input]
        - description += "\n\nUsed in:\n"
        - uses.each do |workflow, tasks|<commit_msg>Don't hide form inputs in they belong to another workflow that is shown<commit_after>- id      = nil unless defined? id
- action  = nil unless defined? action
- klass   = nil unless defined? klass
- method  = 'post' unless (defined?(method) and not method.nil?)
- enctype = 'multipart/form-data' unless defined? enctype
- info    = {} unless defined? info
- locals  = {} unless defined? locals
- bundle  = false unless defined? bundle

- klass = "#{klass} custom"

- if defined?(description) and description
  .form_description
    =description
  %hr

- info = info.dup
%form.ui.form(class=klass action=action method=method id=id enctype=enctype)

  - inputs       = consume_parameter(:inputs, info) || []
  - types        = consume_parameter(:input_types, info) || {}
  - defaults     = consume_parameter(:input_defaults, info) || {}
  - descriptions = consume_parameter(:input_descriptions, info) || {}
  - use          = consume_parameter(:input_use, info) || {}
  - options      = consume_parameter(:input_options, info) || {}
  - values       = consume_parameter(:values, info) || {}

  - workflows = use.values.collect{|i| i.keys}.flatten.collect{|v| v.to_s}.uniq
  - if workflows.length > 1 && use && use.any?
    - ws_id = 'workflow_select_' << id
    .ui.very.basic.segment
      .header
        Select workflow inputs to show
      .description
        .ui.buttons.workflow_select(id=ws_id)
          - workflows.each do |wfname|
            .ui.tiny.button.view_workflow.active= wfname
    %hr
    :sass
      form
        .ui.buttons.workflow_select
          margin-bottom: 2em
    :deferjs
      $('##{ws_id}').find('.view_workflow').click(function(){
        var button = $(this);
        button.toggleClass('active')

        active_workflows = button.parent('.workflow_select').find('.view_workflow.active')
        $('##{id}').find('div.field[attr-use_tags]').hide()
        active_workflows.each(function(button){
          var workflow = $(this).text()
          $('##{id}').find('div.field[attr-use_tags*=' + workflow + ']').show()
        })
      })
      
  - inputs.each do |input|
    - uses = use.nil? ? nil : use[input]
    - use_tags = []
    - if uses
      - uses.each do |workflow, tasks|
        - tasks.each do |task|
          - use_tags << [workflow, task] * "#"
    - input_id = id.nil? ? nil : id + "__" << input.to_s
    - hide = (options[input] != nil and options[input][:hide])
    %div(class="field #{types[input]} #{input} #{hide ? 'hide' : ''}" attr-use_tags='#{use_tags * " "}')
      - input_options = options[input]
      - input_options = input_options.dup unless input_options.nil?
      - description = descriptions[input]
      - if use[input]
        - description += "\n\nUsed in:\n"
        - uses.each do |workflow, tasks|
{'fraction_non_alphanumeric': 0.1591619187649329, 'fraction_numerical': 0.0007351589781290203, 'mean_word_length': 2.6450100468854654, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4529372', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1730, 'n_words': 374}