lib/labels/views/label/label_variable_fields.rb
# Multi label: get variables from all sub-labels and assemble.
Multi label: get variables from all sub-labels and assemble.
Multi label : get variables from all sub - labels and assemble .
def rules_for_multiple(repo, obj, as_labels)
          count = 0
          xml_vars = []
          vartypes = []
          repo.sub_label_ids(obj.id).each do |sub_label_id|
            sub_label = repo.find_label(sub_label_id)
            doc       = Nokogiri::XML(sub_label.variable_xml)
            sub_xml_vars = doc.css('variable_field_count').map do |var|
              "F#{var.text.sub(/f/i, '').to_i + count}"
            end
            count += sub_xml_vars.length
            xml_vars += sub_xml_vars
            vartypes += clean_up_compound_variable_names(doc.css('variable variable_type'))
          end
          combos = Hash[xml_vars.zip(vartypes)]
          rules = {}
          yield rules
          xml_vars.each do |v|
            rules[:fields][v.to_sym] = if as_labels
                                         { renderer: :label, with_value: combos[v] }
                                       else
                                         { caption: "#{v} (#{combos[v]})" }
                                       end
          end
          [obj, rules, xml_vars]
        end
def rules_for_multiple ( repo , obj , as_labels ) count = 0 xml_vars = [ ] vartypes = [ ] repo . sub_label_ids ( obj . id ) . each do | sub_label_id | sub_label = repo . find_label ( sub_label_id ) doc = Nokogiri :: XML ( sub_label . variable_xml ) sub_xml_vars = doc . css ( 'variable_field_count' ) . map do | var | "F#{var.text.sub(/f/i, '').to_i + count}" end count += sub_xml_vars . length xml_vars += sub_xml_vars vartypes += clean_up_compound_variable_names ( doc . css ( 'variable variable_type' ) ) end combos = Hash [ xml_vars . zip ( vartypes ) ] rules = { } yield rules xml_vars . each do | v | rules [ :fields ] [ v . to_sym ] = if as_labels { renderer : :label , with_value : combos [ v ] } else { caption : "#{v} (#{combos[v]})" } end end [ obj , rules , xml_vars ] end
Multi label: get variables from all sub-labels and assemble.
Multi label : get variables from all sub - labels and assemble .
repo
<not_specific>
obj
<not_specific>
as_labels
<not_specific>