Skip to content

Commit

Permalink
chart title optional
Browse files Browse the repository at this point in the history
  • Loading branch information
stellasylee committed Dec 13, 2020
1 parent 8c3fbe1 commit f2daa8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/models/visualization.rb
Expand Up @@ -6,9 +6,14 @@ class Visualization < ApplicationRecord
validates :x_axis_title, presence: true
validates :y_axis_title, presence: true
validates :chart_type, presence: true
before_validation :x_axis_title_default, :y_axis_title_default
before_validation :chart_title_default, :x_axis_title_default, :y_axis_title_default

private
def chart_title_default
if chart_title.empty?
self.chart_title = "Visualization"
end
end
def x_axis_title_default
if x_axis_title.empty?
self.x_axis_title = "Variable"
Expand Down
2 changes: 1 addition & 1 deletion app/views/visualizations/_form.html.erb
Expand Up @@ -71,7 +71,7 @@

<div class="chart-details form-row">
<div class="viz-form-group">
<label for="chart_title">Chart Title <span style="color:red;">*</span></label>
<label for="chart_title">Chart Title</label>
<%= f.text_field :chart_title, class: 'form-control' %>
</div>

Expand Down

0 comments on commit f2daa8f

Please sign in to comment.