Skip to content

Commit

Permalink
Merge pull request #2575 from chikeabuah/2568
Browse files Browse the repository at this point in the history
Change vis tab through URL
  • Loading branch information
pat-son authored Jan 27, 2017
2 parents 145c550 + dfa31fb commit f3887d5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ group :development, :test do
gem 'minitest', '~> 5.1'
gem 'capybara-screenshot'
gem 'html5_validator'
gem 'byebug'
end

# Jquery stuff
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -343,6 +344,7 @@ DEPENDENCIES
bootstrap-sass
bootstrap-switch-rails
browser
byebug
capybara
capybara-screenshot
capybara-webkit
Expand Down Expand Up @@ -389,3 +391,6 @@ DEPENDENCIES
will_paginate
will_paginate-bootstrap
yaml_db!

BUNDLED WITH
1.14.3
26 changes: 21 additions & 5 deletions app/controllers/visualizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']
}

Expand Down Expand Up @@ -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 }

Expand Down

0 comments on commit f3887d5

Please sign in to comment.