Module: Card::Set::Type::Set::SettingLists::HtmlFormat

Extended by:
AbstractFormat
Defined in:
card/tmpsets/set/mod036-card-mod-rules/type/set/setting_lists.rb,
card/tmpsets/set/mod037-card-mod-rules/type/set/setting_lists.rb

Constant Summary collapse

SETTING_OPTIONS =
[["Common", :common_rules],
["All", :all_rules],
["Field", :field_related_rules],
["Recent", :recent_rules]].freeze
COMMON_SETTINGS =
%i[create read update delete structure default guide].freeze
FIELD_SETTINGS =
%i[default help].freeze

Instance Method Summary collapse

Instance Method Details

#category_setting_list(cat) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/setting_lists.rb', line 36

def category_setting_list cat
  case cat
  when :all, :all_rules
    card.visible_setting_codenames.sort
  when :recent, :recent_rules
    recent_settings
  when :common, :common_rules
    card.visible_setting_codenames & COMMON_SETTINGS
  when :field_related, :field_related_rules
    field_related_settings
  when :nest_editor_field_related
    nest_editor_field_related_settings
  end
end


56
57
58
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/setting_lists.rb', line 56

def field_related_settings
  field_settings # card.visible_setting_codenames &
end

#field_settingsObject



23
24
25
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/setting_lists.rb', line 23

def field_settings
  %i[default help input_type content_options content_option_view]
end

#group_setting_list(group) ⇒ Object



32
33
34
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/setting_lists.rb', line 32

def group_setting_list group
  card.visible_settings(group).map(&:codename) if Card::Setting.groups[group]
end


51
52
53
54
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/setting_lists.rb', line 51

def nest_editor_field_related_settings
  field_settings
  #  & card.visible_settings(nil, card.prototype_default_type_id).map(&:codename)
end

#recent_settingsObject



60
61
62
63
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/setting_lists.rb', line 60

def recent_settings
  recent_settings = Card[:recent_settings].item_cards.map(&:codename)
  recent_settings.map(&:to_sym) & card.visible_setting_codenames
end

#setting_list(val) ⇒ Object

Parameters:

  • val

    setting category, setting group or single setting



28
29
30
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/setting_lists.rb', line 28

def setting_list val
  category_setting_list(val) || group_setting_list(val) || [val]
end

#setting_optionsObject



17
18
19
20
21
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/setting_lists.rb', line 17

def setting_options
  [["Categories", SETTING_OPTIONS],
   ["Groups", Card::Setting.group_names.keys],
   ["Single rules", card.visible_setting_codenames]]
end

#view: all_rules_listObject



65
66
67
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/setting_lists.rb', line 65

view :all_rules_list do
  pill_rule_list card.visible_setting_codenames.sort
end

#view: common_rules_listObject



75
76
77
78
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/setting_lists.rb', line 75

view :common_rules_list do
  settings = card.visible_setting_codenames & COMMON_SETTINGS # "&" = set intersection
  pill_rule_list settings
end


80
81
82
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/setting_lists.rb', line 80

view :field_related_rules_list do
  pill_rule_list field_related_settings
end

#view: recent_rules_listObject



69
70
71
72
73
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/setting_lists.rb', line 69

view :recent_rules_list do
  recent_settings = Card[:recent_settings].item_cards.map(&:codename)
  settings = recent_settings.map(&:to_sym) & card.visible_setting_codenames
  pill_rule_list settings
end