Skip to content
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

Add vertical option for inclusion-exclusion #10

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions app/views/panel_partials/_inclusion_exclusion.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down
10 changes: 10 additions & 0 deletions lib/wulin_master/components/panel/panel_relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------------------------
Expand All @@ -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