app/helpers/cmsedit_helper.rb in drg_cms-0.5.10 vs app/helpers/cmsedit_helper.rb in drg_cms-0.5.10.7

- old
+ new

@@ -99,11 +99,11 @@ caption << '&nbsp;' + fa_icon('caret-down lg') + DcFilter.menu_filter(self) # add filter OFF link s = session[@form['table']] if s and s[:filter] caption << '&nbsp;&nbsp;' + dc_link_to(nil,'remove lg', {controller: 'cmsedit', - filter: 'off', table: @form['table']}, { title: t('drgcms.filter_off')+s[:filter]}) + filter: 'off', table: @form['table']}, { title: DcFilter.title4_filter_off(s[:filter]) }) end caption # new when action == 'new' then caption = yaml['caption'] || 'drgcms.new' @@ -159,11 +159,11 @@ #{ select(nil, 'filter_field1', options_for_select(choices, field_name), { include_blank: true }) } #{ select(nil, 'filter_oper', options_for_select(choices4_operators, operators_value)) } </td> <td class="dc-link dc-animate drgcms_popup_submit" data-url="#{url}">#{fa_icon('check-square-o')} #{t('drgcms.filter_on')}</td> - <td class="dc-link dc-animate">#{dc_link_to('drgcms.filter_off','close', {action: 'index', filter: 'off', :table => @form['table']}) }</td> + <td class="dc-link dc-animate">#{dc_link_to('drgcms.filter_off','close', {action: :index, filter: 'off', table: @form['table'], formname: params['formname']}) }</td> </table> </div> EOT html.html_safe end @@ -186,11 +186,12 @@ ############################################################################ def dc_link_or_ajax(yaml, parms) #:nodoc: rest = {} rest['method'] = yaml['method'] || yaml['request'] || 'get' rest['caption'] = yaml['caption'] || yaml['text'] - rest['class'] = (yaml['type'] == 'link' ? 'dc-link' : 'dc-link-ajax') + ' dc-animate' +# rest['class'] = (yaml['type'] == 'link' ? 'dc-link' : 'dc-link-ajax') + ' dc-animate' + rest['class'] = 'dc-animate' rest['title'] = yaml['title'] dc_deprecate "Form: result_set:action:text directive will be deprecated. Use caption instead of text." if yaml['text'] if yaml['type'] == 'link' dc_link_to(yaml['caption'], yaml['icon'], parms, rest ) @@ -371,59 +372,59 @@ ############################################################################ # Creates column for each field of result set document. ############################################################################ def dc_columns_for_result(document) html = '' - if (columns = @form['result_set']['columns']) - columns.each do |k,v| - session[:form_processing] = "result_set:columns: #{k}=#{v}" + return html unless @form['result_set']['columns'] +# + @form['result_set']['columns'].each do |k,v| + session[:form_processing] = "result_set:columns: #{k}=#{v}" # convert shortcut to hash - v = {'name' => v} if v.class == String + v = {'name' => v} if v.class == String # eval - value = if v['eval'] - if v['eval'].match('dc_name4_id') - a = v['eval'].split(',') - if a.size == 3 - dc_name4_id(a[1], a[2], nil, document[ v['name'] ]) - else - dc_name4_id(a[1], a[2], a[3], document[ v['name'] ]) - end - elsif v['eval'].match('dc_name4_value') - dc_name4_value( @form['table'], v['name'], document[ v['name'] ] ) - elsif v['eval'].match('eval ') -# evaluate with specified parameters + value = if v['eval'] + if v['eval'].match('dc_name4_id') + a = v['eval'].split(',') + if a.size == 3 + dc_name4_id(a[1], a[2], nil, document[ v['name'] ]) else - if v['params'] - if v['params'] == 'document' # pass document as parameter when all - eval( "#{v['eval']} document") - else # list of fields delimeted by , - params = v['params'].chomp.split(',').inject('') do |result,e| - result << (e.match(/\.|\:|\(/) ? e : "document['#{e.strip}']") + ',' - end - params.chomp!(',') - eval( "#{v['eval']} #{params}") + dc_name4_id(a[1], a[2], a[3], document[ v['name'] ]) + end + elsif v['eval'].match('dc_name4_value') + dc_name4_value( @form['table'], v['name'], document[ v['name'] ] ) + elsif v['eval'].match('eval ') +# evaluate with specified parameters + else + if v['params'] + if v['params'] == 'document' # pass document as parameter when all + eval( "#{v['eval']} document") + else # list of fields delimeted by , + params = v['params'].chomp.split(',').inject('') do |result,e| + result << (e.match(/\.|\:|\(/) ? e : "document['#{e.strip}']") + ',' end - else - eval( "#{v['eval']} '#{document[ v['name'] ]}'") + params.chomp!(',') + eval( "#{v['eval']} #{params}") end + else + eval( "#{v['eval']} '#{document[ v['name'] ]}'") end + end # as field - elsif document.respond_to?(v['name']) - dc_format_value(document.send( v['name'] ), v['format']) + elsif document.respond_to?(v['name']) + dc_format_value(document.send( v['name'] ), v['format']) # as hash (dc_dummy) - elsif document.class == Hash - document[ v['name'] ] + elsif document.class == Hash + document[ v['name'] ] # error - else - "!!! #{v['name']}" - end -# - td = '<td ' - td << dc_style_or_class('class',v['td_class'],value,document) - td << dc_style_or_class('style',v['td_style'] || v['style'],value,document) - html << "#{td}>#{value}</td>" + else + "!!! #{v['name']}" end +# + td = '<td ' + td << dc_style_or_class('class',v['td_class'],value,document) + td << dc_style_or_class('style',v['td_style'] || v['style'],value,document) + html << "#{td}>#{value}</td>" end html.html_safe end ############################################################################ @@ -584,10 +585,23 @@ end c.html_safe end ############################################################################ +# Create background div and table definitions for result set. +############################################################################ +def dc_background_for_result + html = '<div class="dc-result-div" ' + html << (@form['result_set']['table_style'] ? "style=\"overflow-x: scroll;\" >" : '>') + html << "\n" +# + html << "<table class=\"dc-result #{@form['result_set']['table_class']}\" " + html << (@form['result_set']['table_style'] ? "style=\"#{@form['result_set']['table_style']}\" >" : '>') + html.html_safe +end + +############################################################################ # Checks if value is defined and sets default. If values are sent it also checks # if value is found in values. If not it will report error and set value to default. # Subroutine of dc_fields_for_tab. ############################################################################ def dc_check_and_default(value, default, values=nil) #:nodoc: @@ -733,10 +747,12 @@ end html << '</ul>' html << tdata end # add last_updated_at hidden field so controller can check if record was updated in during editing - html << hidden_field(nil, :last_updated_at, :value => @record.updated_at.to_i) if @record.respond_to?(:updated_at) + html << hidden_field(nil, :last_updated_at, value: @record.updated_at.to_i) if @record.respond_to?(:updated_at) + # add form time stamp to prevent double form submit + html << hidden_field(nil, :form_time_stamp, value: Time.now.to_i) html.html_safe end ############################################################################ # Returns username for id. Subroutine of dc_document_statistics