diff --git a/Gemfile b/Gemfile index 253331323..f6d14f9d5 100644 --- a/Gemfile +++ b/Gemfile @@ -33,6 +33,7 @@ group :development, :test do gem 'minitest', '~> 5.1' gem 'capybara-screenshot' gem 'html5_validator' + gem 'byebug' end # Jquery stuff diff --git a/Gemfile.lock b/Gemfile.lock index 5f8091755..e9c777b8f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -95,6 +95,7 @@ GEM bootstrap-switch-rails (3.3.2) browser (0.8.0) builder (3.2.2) + byebug (9.0.6) capybara (2.4.4) mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -343,6 +344,7 @@ DEPENDENCIES bootstrap-sass bootstrap-switch-rails browser + byebug capybara capybara-screenshot capybara-webkit @@ -389,3 +391,6 @@ DEPENDENCIES will_paginate will_paginate-bootstrap yaml_db! + +BUNDLED WITH + 1.14.3 diff --git a/app/controllers/visualizations_controller.rb b/app/controllers/visualizations_controller.rb index 1d9b1192b..60e21e4e3 100644 --- a/app/controllers/visualizations_controller.rb +++ b/app/controllers/visualizations_controller.rb @@ -6,6 +6,13 @@ class VisualizationsController < ApplicationController after_action :allow_iframe, only: [:show, :displayVis] + before_action :set_vis_list + + def set_vis_list + # A list of all current visualizations + @all_vis = ['Map', 'Timeline', 'Scatter', 'Bar', 'Histogram', 'Pie', 'Table', 'Summary', 'Photos'] + end + # GET /visualizations # GET /visualizations.json def index @@ -40,18 +47,28 @@ def index end end + def param_vis_check(params) + param_vis = nil + unless params[:vis].nil? + vis_name = params[:vis].capitalize + param_vis = @all_vis.include?(vis_name) ? vis_name : nil + end + param_vis + end + # GET /visualizations/1 # GET /visualizations/1.json def show @visualization = Visualization.find(params[:id]) @project = Project.find_by_id(@visualization.project_id) tmp = JSON.parse(@visualization.data) + param_vis = param_vis_check(params) # The finalized data object @data = { savedData: @visualization.data, savedGlobals: @visualization.globals, - defaultVis: tmp['defaultVis'], + defaultVis: param_vis || tmp['defaultVis'], relVis: tmp['relVis'] } @@ -339,17 +356,16 @@ def displayVis rel_vis = which_vis(has_time_data, has_loc_data, has_pics, field_count, format_data) - # A list of all current visualizations - all_vis = ['Map', 'Timeline', 'Scatter', 'Bar', 'Histogram', 'Pie', 'Table', 'Summary', 'Photos'] - # Defaut vis if one exists for the project default_vis = @project.default_vis.nil? ? 'none' : @project.default_vis + param_vis = param_vis_check(params) + # The finalized data object @data = { projectName: @project.title, projectID: @project.id, fields: data_fields, dataPoints: format_data, metadata: metadata, relVis: rel_vis, - allVis: all_vis, defaultVis: default_vis, + allVis: @all_vis, defaultVis: param_vis || default_vis, precision: @project.precision, savedGlobals: @project.globals, hasTimeData: time_count != 0 }