Module: D3C3Rails::Generators

Includes:
ActionView::Helpers::JavaScriptHelper, ActionView::Helpers::TagHelper, RailsJavaScriptHelpers
Included in:
Holder
Defined in:
lib/d3c3-rails/generators.rb

Overview

Generator methods for dialogs

Instance Method Summary collapse

Instance Method Details

#graph_generate(name, options = {}) ⇒ TrueClass

Create a new graph

Parameters:

  • name (String)

    name of graph (maps to DOM ID)

  • options (Hash) (defaults to: {})

    graph options

Returns:

  • (TrueClass)


17
18
19
20
21
# File 'lib/d3c3-rails/generators.rb', line 17

def graph_generate(name, options={})
  options[:bindto] = "##{name}"
  self << "d3c3_rails.actions.generate('#{name}', #{format_type_to_js(options)});"
  true
end

#graph_hide(name, column_names = []) ⇒ TrueClass

Hide columns in graph

Parameters:

  • name (String)

    name of graph

  • column_names (Array<String>) (defaults to: [])

    columns to hide

Returns:

  • (TrueClass)


55
56
57
# File 'lib/d3c3-rails/generators.rb', line 55

def graph_hide(name, column_names=[])
  graph_perform(:hide, name, column_names)
end

#graph_load(name, options = {}) ⇒ TrueClass

Load data into graph

Parameters:

  • name (String)

    name of graph

  • options (Hash) (defaults to: {})

    load options

Returns:

  • (TrueClass)


28
29
30
# File 'lib/d3c3-rails/generators.rb', line 28

def graph_load(name, options={})
  graph_perform(:load, name, options)
end

#graph_perform(action, name, options = {}) ⇒ TrueClass

Perform action on graph

Parameters:

  • action (String)

    graph API method

  • name (String)

    name of graph

  • options (Object) (defaults to: {})

    API method parameters

Returns:

  • (TrueClass)


65
66
67
68
# File 'lib/d3c3-rails/generators.rb', line 65

def graph_perform(action, name, options={})
  self << "d3c3_rails.actions.get('#{name}').#{action}(#{format_type_to_js(options)});"
  true
end

#graph_show(name, column_names = []) ⇒ TrueClass

Show columns in graph

Parameters:

  • name (String)

    name of graph

  • column_names (Array<String>) (defaults to: [])

    columns to show

Returns:

  • (TrueClass)


46
47
48
# File 'lib/d3c3-rails/generators.rb', line 46

def graph_show(name, column_names=[])
  graph_perform(:show, name, column_names)
end

#graph_unload(name, options = {}) ⇒ TrueClass

Unload data from graph

Parameters:

  • name (String)

    name of graph

  • options (Hash) (defaults to: {})

    unload options

Returns:

  • (TrueClass)


37
38
39
# File 'lib/d3c3-rails/generators.rb', line 37

def graph_unload(name, options={})
  graph_perform(:unload, name, options)
end