Method: WidgetList::List#build_column_input

Defined in:
lib/widget_list.rb

#build_column_input(column, row = '') ⇒ Object

Parameters:

  • column (String)

    (the name)

  • row (Fixnum) (defaults to: '')

    (the id or pointer in the loop to fetch the data)



3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
# File 'lib/widget_list.rb', line 3091

def build_column_input(column, row='')
  content = ''

  inputManager = @items['inputs'][column]
  case inputManager['type']
    when "checkbox"


      input = {}
      input['name']         = 'widget_check_name'
      input['id']           = 'widget_check_id'
      input['check_all']    = false
      input['value']        = ''
      input['checked']      = ''
      input['onclick']      = ''
      input['input_class']  = 'widgetlist-checkbox-input'

      input['class_handle'] = ''

      input = WidgetList::Widgets::populate_items(inputManager['items'],input)

      onClick    = []
      checkAllId = ''

      #
      # Get a value. Assumes it is a column initially.
      #
      # @note headers are ignored and would fail as row would be null
      #
      if @results.key?(input['value'].upcase) && !@results[input['value'].upcase][row].to_s.empty?
        input['value'] = @results[ input['value'].upcase ][row]
      end

      if input.key?('disabled_if') && input['disabled_if'].class.name == 'Proc'
        row_tmp = {}
        @results.map { |column| column }.each { |col|
          row_tmp[ col[0] ] = col[1][row]
        }

        if input['disabled_if'].call(row_tmp)
          input['disabled'] = true
        end
      end

      #
      # Append class handle
      #
      input['input_class'] = "#{input['input_class']} #{input['class_handle']}"

      if input['check_all']
        checkAllId = input['id']
        if $_SESSION.key?('list_checks') && !$_SESSION['list_checks'].nil? && $_SESSION['list_checks'].key?('check_all_' + @sqlHash.to_s  + @items['name'].to_s + @sequence.to_s)
          input['checked'] = true
        end

        #
        # Set header class
        #
        if @items['headerClass'].class.name == 'Array' && @items['headerClass'].key?('checkbox')
          if $_SESSION['list_checks'].key?('check_all_' + @sqlHash.to_s  + @items['name'].to_s + @sequence.to_s)
            input['checked'] = true
          end
        end
      else
        input['input_class'] = "#{input['input_class']} #{input['class_handle']} #{input['class_handle']}_list"
      end

      #
      # Setup onclick action
      #
      if input['onclick'].empty?
        listJumpUrl = {}
        listJumpUrl['BUTTON_VALUE']        = @items['buttonVal']
        listJumpUrl['LIST_COL_SORT']       = @items['LIST_COL_SORT']
        listJumpUrl['LIST_COL_SORT_ORDER'] = @items['LIST_COL_SORT_ORDER']
        listJumpUrl['LIST_FILTER_ALL']     = @items['LIST_FILTER_ALL']
        listJumpUrl['ROW_LIMIT']           = @items['ROW_LIMIT']
        listJumpUrl['LIST_SEQUENCE']       = @sequence
        listJumpUrl['LIST_NAME']           = @items['name']
        listJumpUrl['SQL_HASH']            = @sqlHash
        listJumpUrl['list_action']         = 'ajax_widgetlist_checks'

        onClick << "AjaxMaintainChecks(this, '#{input['class_handle']}', '#{@items['name']}', '" + WidgetList::Utils::build_url(@items['pageId'],listJumpUrl,(!$_REQUEST.key?('BUTTON_VALUE'))) + "', '#{checkAllId}');"
      end

      input['onclick'] = onClick.join(' ')

      #
      # Checkbox is checked or not per query value
      #
      if ! @items['checkedFlag'].empty?
        if @items['checkedFlag'].key?(column)
          input['checked'] =  !!@results[ @items['checkedFlag'][column].upcase ][row]
        end
      end

      #
      # Checkbox is checked or not per session (overwrites query)
      #
      if $_SESSION.key?('list_checks') && !$_SESSION['list_checks'].nil? && $_SESSION['list_checks'].key?(@items['name'] + @sqlHash + input['value'].to_s)
        input['checked'] = true
      end

      content = WidgetList::Widgets::widget_check(input)

    #todo never implemented

    when "text"
      a=1
    #content = WidgetInput()

    when "select"
      a=1
    #content = WidgetSelect()

  end

  return content
end