Skip to content

Commit

Permalink
[ifmeorg#1737] Refactored and rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Warmenhoven authored and AlineRibeiro committed May 7, 2020
1 parent cd797ea commit 473909b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
4 changes: 0 additions & 4 deletions app/controllers/concerns/moments_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ def publishing?
params[:publishing] == '1'
end

def display?
params[:display] == true
end

def saving_as_draft?
!publishing?
end
Expand Down
1 change: 0 additions & 1 deletion app/controllers/moments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def show
show_with_comments(@moment)
@resources = ResourceRecommendations.new(@moment).call
@resources_tags = resources_url_tags(@moment)
@moment.resource_recommendations?
end

# GET /moments/new
Expand Down
30 changes: 11 additions & 19 deletions app/helpers/moments_form_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true

module MomentsFormHelper
include MoodsHelper
include CategoriesHelper
Expand All @@ -17,8 +16,7 @@ def edit_moment_props
private

def moment_input_props(field, type, label, group = false)
{ id: "moment_#{field}",
type: type,
{ id: "moment_#{field}", type: type,
name: "moment[#{field}]#{group ? '[]' : ''}",
label: t(label) }
end
Expand Down Expand Up @@ -46,8 +44,7 @@ def quick_create_props(model_relation, form_props)
model_name, 'quickCreate', "#{model_name.pluralize}.plural", true
)
.merge(placeholder: t('common.form.search_by_keywords'),
checkboxes: checkboxes_for(model_relation),
formProps: form_props)
checkboxes: checkboxes_for(model_relation), formProps: form_props)
end

def moment_category
Expand All @@ -64,34 +61,29 @@ def moment_strategy

def moment_comment
moment_input_props('comment', 'switch', 'comment.allow_comments')
.merge(value: true,
uncheckedValue: false, checked: @moment.comment,
.merge(value: true, uncheckedValue: false, checked: @moment.comment,
info: t('comment.hint'), dark: true)
end

def moment_publishing
{ id: 'moment_publishing', type: 'switch',
label: t('moments.form.draft_question'),
dark: true, name: 'publishing',
value: '0', uncheckedValue: '1',
checked: !@moment.published? }
label: t('moments.form.draft_question'), dark: true, name: 'publishing',
value: '0', uncheckedValue: '1', checked: !@moment.published? }
end

def moment_bookmarked
moment_input_props('bookmarked', 'switch', 'moments.bookmark')
.merge(
value: true,
uncheckedValue: false,
checked: @moment.bookmarked,
dark: true
value: true, uncheckedValue: false,
checked: @moment.bookmarked, dark: true
)
end

def moment_display_resources
moment_input_props('resource_recommendations', 'switch', 'moments.resource_recommendations')
.merge(value: true,
uncheckedValue: false, checked: @moment.resource_recommendations,
dark: true)
moment_input_props('resource_recommendations', 'switch',
'moments.resource_recommendations')
.merge(value: true, uncheckedValue: false,
checked: @moment.resource_recommendations, dark: true)
end

def moment_form_inputs
Expand Down

0 comments on commit 473909b

Please sign in to comment.