From 4a18586f0a94c9a8cca6c48b599c51dfcb2ae1ce Mon Sep 17 00:00:00 2001 From: jouhri Date: Tue, 7 Apr 2020 13:49:21 +0200 Subject: [PATCH] Add vertical option for inclusion-exclusion --- .../panel_partials/_inclusion_exclusion.html.haml | 12 ++++++++---- lib/wulin_master/components/panel/panel_relation.rb | 10 ++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/views/panel_partials/_inclusion_exclusion.html.haml b/app/views/panel_partials/_inclusion_exclusion.html.haml index dd32928e..553c15c6 100644 --- a/app/views/panel_partials/_inclusion_exclusion.html.haml +++ b/app/views/panel_partials/_inclusion_exclusion.html.haml @@ -2,11 +2,15 @@ .panel_btns.center-align{:"data-inclusion-grid" => panel.inclusion_grid, :"data-exclusion-grid" => panel.exclusion_grid } - component_names = panel.screen.components.map(&:name) - if component_names.index(panel.inclusion_grid) < component_names.index(panel.exclusion_grid) - %i#add_btn.material-icons.disabled arrow_back - %i#remove_btn.material-icons.disabled arrow_forward + %i#add_btn.material-icons.disabled + = panel.vertical ? 'arrow_upward' : 'arrow_back' + %i#remove_btn.material-icons.disabled + = panel.vertical ? 'arrow_downward' : 'arrow_forward' - else - %i#add_btn.material-icons.disabled arrow_forward - %i#remove_btn.material-icons.disabled arrow_back + %i#add_btn.material-icons.disabled + = panel.vertical ? 'arrow_upward' : 'arrow_forward' + %i#remove_btn.material-icons.disabled + = panel.vertical ? 'arrow_downward' : 'arrow_back' :javascript $(function(){ diff --git a/lib/wulin_master/components/panel/panel_relation.rb b/lib/wulin_master/components/panel/panel_relation.rb index 96011d89..fd492829 100644 --- a/lib/wulin_master/components/panel/panel_relation.rb +++ b/lib/wulin_master/components/panel/panel_relation.rb @@ -29,6 +29,12 @@ def exclusion_grid(grid_klass, options = {}) relations_pool[options[:screen]] ||= {} relations_pool[options[:screen]].merge!(exclusion_grid: grid_name) end + + def vertical(value, options = {}) + return unless options[:screen] + relations_pool[options[:screen]] ||= {} + relations_pool[options[:screen]].merge!(vertical: value) + end end # ----------------------------- Instance Methods ------------------------------------ @@ -39,5 +45,9 @@ def inclusion_grid def exclusion_grid params["screen"] ? self.class.relations_pool[params["screen"]][:exclusion_grid] : nil end + + def vertical + params["screen"] ? self.class.relations_pool[params["screen"]][:vertical] : nil + end end end