-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
184 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
# lib/generators/backstage/templates/controller.rb | ||
module Backstage | ||
class TermsAndConditionsController < Backstage::BaseController | ||
# Add any resource-specific logic here | ||
def model_class | ||
TermsAndCondition | ||
end | ||
|
||
def permitted_params | ||
params.require(:user).permit(:email, :username, :role, :editor) | ||
end | ||
|
||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module Backstage | ||
class DynamicController < BaseController | ||
#class << self | ||
# attr_accessor :resource_config | ||
#end | ||
|
||
def model_class | ||
Post | ||
end | ||
|
||
def permitted_params | ||
params.require(:user).permit(:email, :username, :role, :editor) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
<% resource.actions.each do |action| %> | ||
<% case action[:name] %> | ||
<% when :view %> | ||
<%= link_to 'View', polymorphic_path([item]), class: "text-blue-600 hover:text-blue-900 mr-2" %> | ||
<%= link_to 'View', backstage.url_for(item), class: "text-blue-600 hover:text-blue-900 mr-2" %> | ||
<% when :edit %> | ||
<%= link_to 'Edit', edit_polymorphic_path([item]), class: "text-green-600 hover:text-green-900 mr-2" %> | ||
<%= link_to 'Edit', "backstage.url_for(item, action: :edit)", class: "text-green-600 hover:text-green-900 mr-2" %> | ||
<% when :delete %> | ||
<%= link_to 'Delete', polymorphic_path([item]), data: {turbo_method: :delete, turbo_confirm: 'Are you sure?' }, class: "text-red-600 hover:text-red-900" %> | ||
<%= link_to 'Delete', backstage.url_for(item), data: {turbo_method: :delete, turbo_confirm: 'Are you sure?' }, class: "text-red-600 hover:text-red-900" %> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
|
||
module Backstage | ||
class Engine < ::Rails::Engine | ||
isolate_namespace Backstage | ||
|
||
initializer "backstage.middleware" do |app| | ||
# app.middleware.use Backstage::ControllerLookupMiddleware | ||
end | ||
|
||
config.to_prepare do | ||
# Backstage.setup_controllers | ||
end | ||
|
||
initializer "backstage.load_config" do |app| | ||
config.after_initialize do | ||
# Load any additional configuration if needed | ||
end | ||
end | ||
|
||
config.after_initialize do |app| | ||
app.reload_routes! | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
require "backstage/config" | ||
|
||
Backstage::Config.configure do | ||
|
||
self.current_user_method = :current_user | ||
|
||
# Configure admin authentication | ||
authenticate_admin do | ||
# Your authentication logic here | ||
# You have access to controller methods and the current user | ||
# For example: | ||
redirect_to "/" unless current_backstage_user && current_backstage_user.admin? | ||
end | ||
|
||
|
||
resource :users do | ||
column :id | ||
column :email | ||
column :username | ||
column :role | ||
column :editor | ||
|
||
scope :all | ||
scope :admins, -> { where(role: 'admin') } | ||
scope :artists | ||
scope :recent, -> { where('created_at > ?', 1.week.ago) } | ||
|
||
filter :email_cont, :string, label: 'Email contains' | ||
filter :username_cont, :string, label: 'Username contains' | ||
filter :role_cont, :select, collection: -> { User.roles.keys } | ||
|
||
filterable_field :username, :string | ||
filterable_field :email, :string | ||
filterable_field :role, :select, collection: -> { [:admin, :artist] } | ||
|
||
form_field :email, :email | ||
form_field :username, :string | ||
form_field :role, :select, collection: -> { User.roles.keys }, include_blank: false | ||
form_field :seller, :boolean | ||
form_field :editor, :check_box | ||
|
||
action :view | ||
action :edit | ||
action :delete | ||
|
||
custom_action :refund, label: 'Refund Invoice' do |invoice| | ||
# Refund logic here | ||
# invoice.refund! | ||
redirect_to backstage.user_path(invoice), notice: 'Invoice refunded successfully' | ||
end | ||
|
||
end | ||
|
||
resource :categories do | ||
column :id | ||
column :name | ||
|
||
filter :name, :string, label: 'Name contains' | ||
|
||
form_field :name_cont, :string | ||
|
||
action :view | ||
action :edit | ||
action :delete | ||
end | ||
|
||
resource :posts do | ||
column :id | ||
column :title | ||
column :author do |post, view| | ||
view.link_to post.user.full_name, view.user_path(post.user) | ||
end | ||
|
||
scope :all | ||
scope :published, -> { where(published: true) } | ||
scope :draft, -> { where(published: false) } | ||
scope :recent, -> { where('created_at > ?', 1.week.ago) } | ||
|
||
filter :title, :string, label: 'Name contains' | ||
|
||
form_field :title_cont, :string | ||
|
||
action :view | ||
action :edit | ||
action :delete | ||
end | ||
|
||
resource :terms_and_conditions do | ||
|
||
column :id | ||
column :title | ||
|
||
form_field :title, :string | ||
form_field :category, :string | ||
form_field :content, :custom, ->(view, form) { view.render("shared/simple_editor", form: form, field: :content) } | ||
|
||
action :view | ||
action :edit | ||
action :delete | ||
end | ||
end |
Oops, something went wrong.