From 25a1103f622aba0097d3b2d870eaa446518c94d5 Mon Sep 17 00:00:00 2001 From: stephanie-warmenhoven Date: Wed, 6 May 2020 17:37:57 -0700 Subject: [PATCH] [#1737] Refactored and rubocop --- app/controllers/concerns/moments_concern.rb | 4 --- app/controllers/moments_controller.rb | 1 - app/helpers/moments_form_helper.rb | 30 ++++++++------------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/app/controllers/concerns/moments_concern.rb b/app/controllers/concerns/moments_concern.rb index 824d2b8c14..152283c6de 100644 --- a/app/controllers/concerns/moments_concern.rb +++ b/app/controllers/concerns/moments_concern.rb @@ -11,10 +11,6 @@ def publishing? params[:publishing] == '1' end - def display? - params[:display] == true - end - def saving_as_draft? !publishing? end diff --git a/app/controllers/moments_controller.rb b/app/controllers/moments_controller.rb index c14f540a8f..72bdd22aea 100644 --- a/app/controllers/moments_controller.rb +++ b/app/controllers/moments_controller.rb @@ -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 diff --git a/app/helpers/moments_form_helper.rb b/app/helpers/moments_form_helper.rb index 8705e30478..007a907cd9 100644 --- a/app/helpers/moments_form_helper.rb +++ b/app/helpers/moments_form_helper.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true - module MomentsFormHelper include MoodsHelper include CategoriesHelper @@ -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 @@ -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 @@ -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