From a47170995969099432efba490cb22aee8b6c7f4a Mon Sep 17 00:00:00 2001 From: maebeale Date: Sun, 21 Dec 2025 21:57:52 -0500 Subject: [PATCH] Use AdminDasbhaordCardsHelper rather than define everything in DashboardController --- app/controllers/dashboard_controller.rb | 76 ++----------------------- 1 file changed, 5 insertions(+), 71 deletions(-) diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index a1cc5e672..7e1d6b966 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,5 +1,6 @@ class DashboardController < ApplicationController skip_before_action :authenticate_user!, only: :help + include AdminDashboardCardsHelper def index workshops = Workshop.includes(:sectors, :categories, :windows_type, :main_image, :gallery_images) @@ -31,78 +32,11 @@ def index end def admin - if current_user.super_user? + return redirect_to authenticated_root_path, alert: "You do not have permission." unless current_user.super_user? - @system_cards = [ - { title: "Banners", path: banners_path, icon: "📣", - bg_color: "bg-gray-50", hover_bg_color: "bg-gray-100", text_color: "text-gray-800" }, - { title: "CommunityNews", path: community_news_index_path, icon: "📰", - bg_color: "bg-orange-50", hover_bg_color: "bg-orange-100", text_color: "text-gray-800" }, - { title: "Events", path: events_path, icon: "📆", - bg_color: "bg-blue-50", hover_bg_color: "bg-blue-100", text_color: "text-gray-800" }, - { title: "FAQs", path: faqs_path, icon: "❔", - bg_color: "bg-gray-50", hover_bg_color: "bg-gray-100", text_color: "text-gray-800" }, - { title: "Resources", path: resources_path, icon: "📚", - bg_color: "bg-violet-50", hover_bg_color: "bg-violet-100", text_color: "text-gray-800" }, - { title: "Stories", path: stories_path, icon: "🗣️", - bg_color: "bg-rose-50", hover_bg_color: "bg-rose-100", text_color: "text-gray-800" }, - { title: "Tags matrix", path: tags_matrix_path, icon: "🏷️", - bg_color: "bg-gray-50", hover_bg_color: "bg-gray-100", text_color: "text-gray-800" }, - { title: "Workshops", path: workshops_path, icon: "🎨", - bg_color: "bg-indigo-50", hover_bg_color: "bg-indigo-100", text_color: "text-gray-800" }, - - { title: "Facilitators", path: facilitators_path, icon: "🧑‍🎨", - bg_color: "bg-sky-50", hover_bg_color: "bg-sky-100", text_color: "text-gray-800" }, - { title: "Organizations", path: projects_path, icon: "🏫", - bg_color: "bg-emerald-50", hover_bg_color: "bg-emerald-100", text_color: "text-gray-800" }, - { title: "User accounts", path: users_path, icon: "👥", - bg_color: "bg-gray-50", hover_bg_color: "bg-gray-100", text_color: "text-gray-800" }, - { title: "!!!Forms", path: authenticated_root_path, icon: "📋", - bg_color: "bg-gray-50", hover_bg_color: "bg-gray-100", text_color: "text-gray-800" }, - ] - - @user_content_cards = [ - { title: "Bookmarks tally", path: tally_bookmarks_path, icon: "🔖", - bg_color: "bg-gray-50", hover_bg_color: "bg-gray-100", text_color: "text-gray-800" }, - { title: "Recent portal activity", path: dashboard_recent_activities_path, icon: "🧭", - bg_color: "bg-gray-50", hover_bg_color: "bg-gray-100", text_color: "text-gray-800" }, - { title: "Event Registrations", path: event_registrations_path, icon: "🎟️", - bg_color: "bg-blue-100", hover_bg_color: "bg-blue-200", text_color: "text-blue-800" }, - { title: "Quotes", path: quotes_path, icon: "💬", - bg_color: "bg-gray-50", hover_bg_color: "bg-gray-100", text_color: "text-gray-800" }, - { title: "!!!Vision Seeds", path: authenticated_root_path, icon: "🌱", - bg_color: "bg-gray-50", hover_bg_color: "bg-gray-100", text_color: "text-gray-800" }, - { title: "Story Ideas", path: story_ideas_path, icon: "✍️️", - bg_color: "bg-rose-100", hover_bg_color: "bg-rose-200", text_color: "text-rose-800" }, - { title: "Workshop Variations", path: workshop_variations_path, icon: "🔀", - bg_color: "bg-purple-100", hover_bg_color: "bg-purple-200", text_color: "text-purple-800" }, - { title: "Workshop Ideas", path: workshop_ideas_path, icon: "💡", - bg_color: "bg-indigo-100", hover_bg_color: "bg-indigo-200", text_color: "text-indigo-800" }, - { title: "Workshop Logs", path: workshop_logs_path, icon: "📝", - bg_color: "bg-gray-50", hover_bg_color: "bg-gray-100", text_color: "text-gray-800" }, - { title: "!!!Annual Reports", path: authenticated_root_path, icon: "📊", - bg_color: "bg-gray-50", hover_bg_color: "bg-gray-100", text_color: "text-gray-800" }, - - ] - - - @reference_cards = [ - { title: "!!!Categories", path: authenticated_root_path, icon: "🗂️", - bg_color: "bg-gray-50", hover_bg_color: "bg-gray-100", text_color: "text-gray-800" }, - { title: "!!!Sectors", path: authenticated_root_path, icon: "🏭", - bg_color: "bg-gray-50", hover_bg_color: "bg-gray-100", text_color: "text-gray-800" }, - { title: "!!!Project Statuses", path: authenticated_root_path, icon: "🧮️", - bg_color: "bg-gray-50", hover_bg_color: "bg-gray-100", text_color: "text-gray-800" }, - { title: "WindowsTypes", path: windows_types_path, icon: "🪟", - bg_color: "bg-gray-50", hover_bg_color: "bg-gray-100", text_color: "text-gray-800" }, - # { title: "FormFields", path: authenticated_root_path, icon: "✏️", - # bg_color: "bg-gray-50", text_color: "text-gray-800" }, - # { title: "FormAnswerOptions", path: authenticated_root_path, icon: "🗳️", - # bg_color: "bg-gray-50", text_color: "text-gray-800" }, - ] - else - redirect_to authenticated_root_path, alert: 'You do not have permission.' - end + @system_cards = system_cards + @user_content_cards = user_content_cards + @reference_cards = reference_cards end def recent_activities