Add global property to Doodads
This commit is contained in:
parent
c289af85e9
commit
becdda766d
@ -31,6 +31,7 @@ p
|
|||||||
h1
|
h1
|
||||||
font-size: 7vmin
|
font-size: 7vmin
|
||||||
margin-bottom: 0
|
margin-bottom: 0
|
||||||
|
padding-left: .33em
|
||||||
font-family: "Press Start 2P", "Anton", Impact, fantasy, sans-serif
|
font-family: "Press Start 2P", "Anton", Impact, fantasy, sans-serif
|
||||||
|
|
||||||
// h2
|
// h2
|
||||||
@ -76,9 +77,9 @@ header
|
|||||||
border-radius: 0 13em 0 0
|
border-radius: 0 13em 0 0
|
||||||
font-size: 2em
|
font-size: 2em
|
||||||
> h1
|
> h1
|
||||||
padding-top: .6em
|
|
||||||
align-self: start
|
align-self: start
|
||||||
text-indent: .4em
|
// padding-top: .6em
|
||||||
|
// text-indent: .4em
|
||||||
|
|
||||||
|
|
||||||
#home-headline, .home-headline
|
#home-headline, .home-headline
|
||||||
|
|||||||
@ -6,6 +6,7 @@ class ApplicationController < ActionController::Base
|
|||||||
# skip_before_action :verify_authenticity_token
|
# skip_before_action :verify_authenticity_token
|
||||||
after_action :flash_to_http_header
|
after_action :flash_to_http_header
|
||||||
before_action :get_footer_tokens
|
before_action :get_footer_tokens
|
||||||
|
before_action :get_global_doodads
|
||||||
|
|
||||||
if (Rails.env.development? || Rails.env.test?)
|
if (Rails.env.development? || Rails.env.test?)
|
||||||
include Pundit::Authorization
|
include Pundit::Authorization
|
||||||
@ -43,6 +44,10 @@ class ApplicationController < ActionController::Base
|
|||||||
@footer_tokens = policy_scope(Token)
|
@footer_tokens = policy_scope(Token)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_global_doodads
|
||||||
|
@global_doodads = policy_scope(Doodad).where(is_global: true)
|
||||||
|
end
|
||||||
|
|
||||||
def flash_to_http_header
|
def flash_to_http_header
|
||||||
return unless request.xhr?
|
return unless request.xhr?
|
||||||
return if flash.empty?
|
return if flash.empty?
|
||||||
|
|||||||
@ -68,6 +68,6 @@ class DoodadsController < ApplicationController
|
|||||||
|
|
||||||
# Only allow a list of trusted parameters through.
|
# Only allow a list of trusted parameters through.
|
||||||
def doodad_params
|
def doodad_params
|
||||||
params.require(:doodad).permit(:body, :user_id, :is_public)
|
params.require(:doodad).permit(:body, :user_id, :is_public, :is_global)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
= f.input :body
|
= f.input :body
|
||||||
= f.hidden_field :user_id
|
= f.hidden_field :user_id
|
||||||
= f.input :is_public
|
= f.input :is_public
|
||||||
|
= f.input :is_global
|
||||||
|
|
||||||
.form-actions
|
.form-actions
|
||||||
= f.button :submit
|
= f.button :submit
|
||||||
|
|||||||
@ -9,6 +9,10 @@
|
|||||||
%p
|
%p
|
||||||
%b Is public:
|
%b Is public:
|
||||||
= @doodad.is_public
|
= @doodad.is_public
|
||||||
|
%p
|
||||||
|
%b Is global:
|
||||||
|
= @doodad.is_global
|
||||||
|
|
||||||
|
|
||||||
= link_to 'Edit', edit_doodad_path(@doodad) if policy(@doodad).edit?
|
= link_to 'Edit', edit_doodad_path(@doodad) if policy(@doodad).edit?
|
||||||
\|
|
\|
|
||||||
|
|||||||
@ -4,3 +4,6 @@
|
|||||||
%h3 Tokens
|
%h3 Tokens
|
||||||
- @footer_tokens.each do |token|
|
- @footer_tokens.each do |token|
|
||||||
= link_to token.name, token
|
= link_to token.name, token
|
||||||
|
.global-doodads
|
||||||
|
%h1 Global Doodads
|
||||||
|
= render @global_doodads
|
||||||
|
|||||||
5
db/migrate/20231122115709_add_is_global_to_doodads.rb
Normal file
5
db/migrate/20231122115709_add_is_global_to_doodads.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class AddIsGlobalToDoodads < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
add_column :doodads, :is_global, :boolean, default: false
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2023_11_21_150256) do
|
ActiveRecord::Schema.define(version: 2023_11_22_115709) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@ -30,6 +30,7 @@ ActiveRecord::Schema.define(version: 2023_11_21_150256) do
|
|||||||
t.boolean "is_public"
|
t.boolean "is_public"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
|
t.boolean "is_global", default: false
|
||||||
t.index ["user_id"], name: "index_doodads_on_user_id"
|
t.index ["user_id"], name: "index_doodads_on_user_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user