diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/nodes_controller.rb | 5 | ||||
| -rw-r--r-- | app/models/node.rb | 2 | ||||
| -rw-r--r-- | app/views/nodes/new.html.erb | 2 |
3 files changed, 7 insertions, 2 deletions
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 6fd000b..b56d779 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb | |||
| @@ -49,6 +49,11 @@ class NodesController < ApplicationController | |||
| 49 | 49 | ||
| 50 | redirect_to(edit_node_path(@node)) | 50 | redirect_to(edit_node_path(@node)) |
| 51 | else | 51 | else |
| 52 | @selected_kind = CccConventions::NODE_KINDS.key?(params[:kind]) ? params[:kind] : "generic" | ||
| 53 | if params[:parent_id].present? | ||
| 54 | @parent_id = params[:parent_id] | ||
| 55 | @parent_name = Node.find(@parent_id).title | ||
| 56 | end | ||
| 52 | render :new | 57 | render :new |
| 53 | end | 58 | end |
| 54 | end | 59 | end |
diff --git a/app/models/node.rb b/app/models/node.rb index f15c908..7675ab6 100644 --- a/app/models/node.rb +++ b/app/models/node.rb | |||
| @@ -17,7 +17,7 @@ class Node < ApplicationRecord | |||
| 17 | after_save :update_unique_names_of_children | 17 | after_save :update_unique_names_of_children |
| 18 | 18 | ||
| 19 | # Validations | 19 | # Validations |
| 20 | validates_length_of :slug, :within => 1..255, :unless => -> { parent_id.nil? } | 20 | validates_length_of :slug, :within => 1..255, :unless => -> { parent_id.nil? || slug.blank? } |
| 21 | validates_presence_of :slug, :unless => -> { parent_id.nil? } | 21 | validates_presence_of :slug, :unless => -> { parent_id.nil? } |
| 22 | validates_uniqueness_of :slug, :scope => :parent_id, :unless => -> { parent_id.nil? } | 22 | validates_uniqueness_of :slug, :scope => :parent_id, :unless => -> { parent_id.nil? } |
| 23 | validates_presence_of :parent_id, :unless => -> { Node.root.nil? } | 23 | validates_presence_of :parent_id, :unless => -> { Node.root.nil? } |
diff --git a/app/views/nodes/new.html.erb b/app/views/nodes/new.html.erb index 71f2fbf..afc632f 100644 --- a/app/views/nodes/new.html.erb +++ b/app/views/nodes/new.html.erb | |||
| @@ -25,7 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | <div class="node_description">Title</div> | 26 | <div class="node_description">Title</div> |
| 27 | <div class="node_content"> | 27 | <div class="node_content"> |
| 28 | <%= text_field_tag :title %> | 28 | <%= text_field_tag :title, nil, required: true %> |
| 29 | <span class="field_hint">A URL slug will be generated from this automatically. You can review or adjust it afterward under the "metadata" section's Slug field.</span> | 29 | <span class="field_hint">A URL slug will be generated from this automatically. You can review or adjust it afterward under the "metadata" section's Slug field.</span> |
| 30 | </div> | 30 | </div> |
| 31 | 31 | ||
