Commit 19330e123c400387596877e0fc0330dbf0754753

Authored by Fabio Teixeira
Committed by David Silva
1 parent 88f89eff
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Call html_structure as callback

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
lib/database_helper.rb
... ... @@ -43,17 +43,13 @@ class DatabaseHelper &lt; DynamicTableHelper
43 43 end
44 44  
45 45 def self.database_as_tables(list_databases, disabled=false)
46   - return database_html_structure(
47   - {:database_description_id => "", :version => ""}, disabled
48   - ) if list_databases.nil?
49   -
50   - lambdas_list = []
51   -
52   - list_databases.each do |database|
53   - lambdas_list << database_html_structure(database, disabled)
  46 + model_list = if list_databases.blank?
  47 + [{:database_description_id => "", :version => ""}]
  48 + else
  49 + list_databases
54 50 end
55 51  
56   - lambdas_list
  52 + models_as_tables model_list, "database_html_structure", disabled
57 53 end
58 54  
59 55 def self.database_html_structure(database_data, disabled)
... ... @@ -83,6 +79,6 @@ class DatabaseHelper &lt; DynamicTableHelper
83 79 end
84 80  
85 81 def self.add_dynamic_table
86   - database_as_tables(nil).call
  82 + database_as_tables(nil).first.call
87 83 end
88 84 end
89 85 \ No newline at end of file
... ...
lib/dynamic_table_helper.rb
... ... @@ -133,4 +133,12 @@ class DynamicTableHelper
133 133  
134 134 row_data
135 135 end
  136 +
  137 + def self.models_as_tables models, callback, disabled=false
  138 + lambdas_list = []
  139 +
  140 + models.map do |model|
  141 + send(callback, model, disabled)
  142 + end
  143 + end
136 144 end
137 145 \ No newline at end of file
... ...
lib/software_language_helper.rb
... ... @@ -42,16 +42,13 @@ class SoftwareLanguageHelper &lt; DynamicTableHelper
42 42 end
43 43  
44 44 def self.language_as_tables(list_languages, disabled=false)
45   - return language_html_structure(
46   - {:programming_language_id => "", :version => ""}, disabled
47   - ) if list_languages.nil?
48   -
49   - lambdas_list = []
50   -
51   - list_languages.each do |language|
52   - lambdas_list << language_html_structure(language, disabled)
  45 + model_list = if list_languages.blank?
  46 + [{:programming_language_id => "", :version => ""}]
  47 + else
  48 + list_languages
53 49 end
54   - lambdas_list
  50 +
  51 + models_as_tables model_list, "language_html_structure", disabled
55 52 end
56 53  
57 54 def self.language_html_structure(language_data, disabled)
... ... @@ -81,6 +78,6 @@ class SoftwareLanguageHelper &lt; DynamicTableHelper
81 78 end
82 79  
83 80 def self.add_dynamic_table
84   - language_as_tables(nil).call
  81 + language_as_tables(nil).first.call
85 82 end
86 83 end
... ...