diff --git a/app/admin/admin_users.rb b/app/admin/admin_users.rb index 78e454e..3cf039a 100644 --- a/app/admin/admin_users.rb +++ b/app/admin/admin_users.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true ActiveAdmin.register AdminUser do + menu priority: 2 permit_params :email, :password, :password_confirmation index do diff --git a/app/admin/dashboard.rb b/app/admin/dashboard.rb index 0ca8c86..7ebef36 100644 --- a/app/admin/dashboard.rb +++ b/app/admin/dashboard.rb @@ -8,7 +8,7 @@ column do panel 'Recent Flowcharts' do table_for Flowchart.order('id').limit(10) do - column('Title', &:title) + column('Title') { |f| link_to(f.title, admin_flowchart_path(f.id)) } column('Description', &:description) end end @@ -16,7 +16,7 @@ column do panel 'Recent Icons' do table_for FlowchartIcon.order('id').limit(10) do - column('ID', &:id) + column('ID') { |i| link_to(i.id, admin_flowchart_path(i.id)) } column('URL', &:url) end end diff --git a/app/admin/flowchart_icon_helpers.rb b/app/admin/flowchart_icon_helpers.rb index bb8605b..f1fe49f 100644 --- a/app/admin/flowchart_icon_helpers.rb +++ b/app/admin/flowchart_icon_helpers.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true ActiveAdmin.register FlowchartIconHelper, as: 'Icon Connectors' do + menu priority: 6 # See permitted parameters documentation: # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters # diff --git a/app/admin/flowchart_icons.rb b/app/admin/flowchart_icons.rb index 432e2a5..daa682c 100644 --- a/app/admin/flowchart_icons.rb +++ b/app/admin/flowchart_icons.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true ActiveAdmin.register FlowchartIcon, as: 'Icon' do + menu priority: 5 permit_params :url end diff --git a/app/admin/flowchart_nodes.rb b/app/admin/flowchart_nodes.rb index 58aea78..c6fdf62 100644 --- a/app/admin/flowchart_nodes.rb +++ b/app/admin/flowchart_nodes.rb @@ -1,20 +1,22 @@ # frozen_string_literal: true ActiveAdmin.register FlowchartNode do + menu priority: 4 sidebar 'Flowchart Details', only: %i[show edit] do ul do li link_to 'Node Icons', admin_icon_connectors_path('q[flowchart_node_id_eq]' => flowchart_node.id) end end - belongs_to :flowchart - permit_params :id, :text, :header, :next_question, :is_root, :flowchart_id, :deleted, :flowchart_node_id, :flowchart_id, :is_leaf, :breadcrumb_title, + belongs_to :flowchart, optional: true + permit_params :id, :text, :header, :next_question, :is_root, :flowchart_id, :deleted, :flowchart_node_id, :flowchart_id, :is_leaf, :breadcrumb_title, :button_text, flowchart_icon_helpers_attributes: %i[id flowchart_icon_id flowchart_node_id _destroy] controller do def permitted_params - params.permit :authenticity_token, :commit, :_method, :flowchart_id, :id, flowchart_node: [:id, :text, :header, :breadcrumb_title, :next_question, :is_root, :flowchart_id, :flowchart_node_id, :is_leaf, :deleted, :flowchart_id, - flowchart_icon_helpers_attributes: %i[id flowchart_icon_id flowchart_node_id _destroy]] + params.permit :authenticity_token, :commit, :_method, :flowchart_id, :id, + flowchart_node: [:id, :text, :header, :breadcrumb_title, :next_question, :is_root, :flowchart_id, :flowchart_node_id, :is_leaf, :deleted, :flowchart_id, :button_text, + flowchart_icon_helpers_attributes: %i[id flowchart_icon_id flowchart_node_id _destroy]] end end end diff --git a/app/admin/flowcharts.rb b/app/admin/flowcharts.rb index 2586852..9af19ea 100644 --- a/app/admin/flowcharts.rb +++ b/app/admin/flowcharts.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true ActiveAdmin.register Flowchart do + menu priority: 3 sidebar 'Flowchart Details', only: %i[show edit] do ul do li link_to 'Flowchart Nodes', admin_flowchart_flowchart_nodes_path(resource) @@ -8,13 +9,13 @@ end permit_params :id, :title, :description, :root_id, :created_at, :updated_at, :deleted, :height, - flowchart_node_attributes: [:id, :text, :header, :button_text, :next_question, :child_id, :sibling_id, :is_root, :flowchart_id, :flowchart_node_id, :deleted, :_destroy, + flowchart_node_attributes: [:id, :text, :header, :button_text, :next_question, :child_id, :sibling_id, :is_root, :flowchart_id, :flowchart_node_id, :is_leaf, :breadcrumb_title, :deleted, :_destroy, flowchart_icon_helpers_attributes: %i[id flowchart_icon_id flowchart_node_id _destroy]] controller do def permitted_params params.permit :authenticity_token, :commit, flowchart: [:id, :title, :description, :root_id, :created_at, :updated_at, :deleted, :height, - flowchart_nodes_attributes: [:id, :text, :header, :button_text, :next_question, :is_root, :flowchart_id, :flowchart_node_id, :deleted, :_destroy, + flowchart_nodes_attributes: [:id, :text, :header, :button_text, :next_question, :is_root, :flowchart_id, :flowchart_node_id, :is_leaf, :breadcrumb_title, :deleted, :_destroy, flowchart_icon_helpers_attributes: %i[id flowchart_icon_id flowchart_node_id _destroy]]] end end @@ -36,7 +37,7 @@ def permitted_params n.input :text, label: 'Node Text' n.input :next_question, label: 'Node Question' n.input :breadcrumb_title, label: 'Breadcrumb Title' - n.input :parent, label: 'Parent Node', as: :select, collection: FlowchartNode.select(:header).where(flowchart_id: f.object.id) + n.input :flowchart_node_id, label: 'Parent Node', as: :select, collection: FlowchartNode.where(flowchart_id: f.object.id) n.input :is_root, label: 'Root Node?' n.input :is_leaf, label: 'Leaf Node?' n.has_many :flowchart_icon_helpers, new_record: 'Add Icon', allow_destroy: true, heading: 'Node Icons' do |i| diff --git a/app/models/flowchart_icon_helper.rb b/app/models/flowchart_icon_helper.rb index 5274c00..a3cc028 100644 --- a/app/models/flowchart_icon_helper.rb +++ b/app/models/flowchart_icon_helper.rb @@ -19,4 +19,8 @@ class FlowchartIconHelper < ApplicationRecord belongs_to :flowchart_node belongs_to :flowchart_icon + + def display_name + id + end end diff --git a/config/application.rb b/config/application.rb index 0d6cae4..71079aa 100644 --- a/config/application.rb +++ b/config/application.rb @@ -39,15 +39,12 @@ class Application < Rails::Application # Middleware like session, flash, cookies can be added back manually. # Skip views, helpers and assets when generating a new resource. config.api_only = true - puts Rails.env - # Middleware for ActiveAdmin config.middleware.use Rack::MethodOverride config.middleware.use ActionDispatch::Flash config.middleware.use ActionDispatch::Cookies config.middleware.use ActionDispatch::Session::CookieStore - config.middleware.insert_before 0, Rack::Cors do allow do origins '*'