-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content blocks should be editable in settings UI #82
Conversation
|
||
def displayable_content_block(content_block, class_string = '', id_string = '') | ||
return if content_block.value.blank? | ||
raw("<div id='#{id_string}' class='#{class_string}'>#{content_block.value}</div>") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe:
content_tag :div, content_block.value, id: id_string, class: class_string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of passing the class and id, how about we pass options: {}
and pass it through to the content_tag?
828c031
to
5195eaa
Compare
@@ -0,0 +1 @@ | |||
@import 'batch_edit/batch_edit'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings
5195eaa
to
8196b60
Compare
@@ -24,6 +24,9 @@ Metrics/LineLength: | |||
Exclude: | |||
- 'app/controllers/catalog_controller.rb' | |||
|
|||
Metrics/AbcSize: | |||
Exclude: | |||
- 'app/helpers/content_block_helper.rb' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of excluding this, maybe we can figure out how to simplify those methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the editable_content_block
method in particular, which has a score of 16 (the threshold is 15). Extracting form_for
into its own method, like you suggested, may do the trick. I'll have a go at this later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Killed this method.
8196b60
to
6866e25
Compare
6866e25
to
d0f27f0
Compare
@@ -4,6 +4,15 @@ | |||
let!(:site) do | |||
assign(:site, Site.create!(application_name: "MyString", institution_name: "My Inst Name")) | |||
end | |||
let(:announcement_text) { ContentBlock.find_or_create_by(name: ContentBlock::ANNOUNCEMENT)} | |||
let(:marketing_text) { ContentBlock.find_or_create_by(name: ContentBlock::MARKETING)} | |||
let(:featured_researcher) { ContentBlock.find_or_create_by(name: ContentBlock::RESEARCHER)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/SpaceInsideBlockBraces: Space missing inside }.
c419570
to
0015b01
Compare
|
||
def instance | ||
first || create | ||
end | ||
end | ||
|
||
def announcement_text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO these methods do not belong on the site model. You should extract this stuff into a Form object which is responsible for saving the site and any content blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to defer creating a new form object, if at all possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're getting ContentBlock
from sufia, I imagine? Instead of adding our own accessors here, would it make sense to set up the expected AR associations to that model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cbeer Correct, that model is provided by Sufia. Do you have something like the following in mind?
class Site < ActiveRecord::Base
# ...
has_many :content_blocks
# ...
class << self
delegate :account, ..., :content_blocks, to: :instance
delegate :announcement_text, :marketing_text, :featured_researcher, to: :content_blocks
# ...
end
end
If so, I'll need to create some convenience methods in Sufia (#announcement_text
, #marketing_text
, #featured_researcher
) first.
0015b01
to
21c2df1
Compare
21c2df1
to
d38bc66
Compare
Fixes #74