card-mod-rules 0.14.2 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/assets/script/rules.js.coffee +52 -0
  3. data/assets/style/rules.scss +143 -0
  4. data/data/files/mod_rules_script_asset_output/file.js +2 -0
  5. data/data/files/mod_rules_script_local_machine_output/file.js +31 -0
  6. data/data/real.yml +27 -0
  7. data/locales/de.yml +1 -0
  8. data/locales/en.yml +1 -0
  9. data/set/abstract/virtual_set.rb +3 -0
  10. data/set/all/cardtype_groups.rb +1 -2
  11. data/set/all/related_sets.rb +2 -18
  12. data/set/all/set_select.rb +58 -0
  13. data/set/right/right.rb +7 -0
  14. data/set/right/self.rb +8 -0
  15. data/set/right/type.rb +7 -0
  16. data/set/right/type_plus_right.rb +9 -2
  17. data/set/rule/bar_view.rb +21 -32
  18. data/set/rule/bridge_rules_editor.rb +1 -1
  19. data/set/rule/editor.rb +29 -7
  20. data/set/rule/quick_editor/quick_edit.haml +2 -2
  21. data/set/rule/quick_editor.rb +1 -1
  22. data/set/rule/rule_form/rule_form.haml +1 -3
  23. data/set/rule/rule_form/rule_set_radio.rb +16 -13
  24. data/set/rule/rule_form/set_selection.rb +3 -20
  25. data/set/rule/rule_form.rb +19 -3
  26. data/set/self/cardtype.rb +0 -2
  27. data/set/self/recent_settings.rb +2 -0
  28. data/set/type/cardtype.rb +1 -1
  29. data/set/type/set/html_views/filtered_rule_lists.rb +23 -0
  30. data/set/type/set/html_views/rule_lists.rb +80 -22
  31. data/set/type/set/html_views/setting_filter.rb +38 -0
  32. data/set/type/set/html_views.rb +4 -31
  33. data/set/type/set/setting_categories.rb +67 -0
  34. data/set/type/set.rb +10 -4
  35. data/set/type/setting/core.haml +11 -0
  36. data/set/type/setting.rb +3 -1
  37. data/set/type_plus_right/set/setting.rb +12 -0
  38. data/set/type_plus_right/set/structure.rb +10 -0
  39. metadata +25 -14
  40. data/assets/script/script_rules.js.coffee +0 -23
  41. data/set/rule/rule_form/form_elements.rb +0 -52
  42. data/set/type/set/html_views/group_panel.haml +0 -14
  43. data/set/type/set/rules_filter.rb +0 -60
  44. data/set/type/set/setting_lists.rb +0 -76
@@ -1,23 +0,0 @@
1
- $(window).ready ->
2
- # permissions mod
3
- $('body').on 'click', '.perm-vals input', ->
4
- $(this).slot().find('#inherit').attr('checked',false)
5
-
6
- $('body').on 'click', '.perm-editor #inherit', ->
7
- slot = $(this).slot()
8
- slot.find('.perm-group input:checked').attr('checked', false)
9
- slot.find('.perm-indiv input').val('')
10
-
11
- # rstar mod
12
- $('body').on 'click', '._rule-submit-button', ->
13
- f = $(this).closest('form')
14
- checked = f.find('.set-editor input:checked')
15
- if checked.val()
16
- if checked.attr('warning')
17
- confirm checked.attr('warning')
18
- else
19
- true
20
- else
21
- f.find('.set-editor').addClass('attention')
22
- $(this).notify 'To what Set does this Rule apply?'
23
- false
@@ -1,52 +0,0 @@
1
- format :html do
2
- #### DEPRECATED
3
-
4
- def rule_set_selection
5
- wrap_with :div, class: "set-list" do
6
- [rule_set_formgroup, related_set_formgroup]
7
- end
8
- end
9
-
10
- def rule_set_formgroup
11
- tag = @rule_context.rule_user_setting_name
12
- narrower = []
13
- option_list "Set" do
14
- rule_set_options.map do |set_name, state|
15
- rule_set_radio_button set_name, tag, state, narrower
16
- end
17
- end
18
- end
19
-
20
- def related_set_formgroup
21
- related_sets = related_sets_in_context
22
- return "" unless related_sets&.present?
23
-
24
- tag = @rule_context.rule_user_setting_name
25
- option_list "related set" do
26
- related_rule_radios related_sets, tag
27
- end
28
- end
29
-
30
- def related_sets_in_context
31
- set_context = @rule_context.rule_set_name
32
- set_context && Card.fetch(set_context).prototype.related_sets
33
- end
34
-
35
- def option_list title, &block
36
- formgroup title, input: "set", class: "col-xs-6", help: false do
37
- wrap_with :ul do
38
- wrap_each_with(:li, class: "radio", &block)
39
- end
40
- end
41
- end
42
-
43
- def related_rule_radios related_sets, tag
44
- related_sets.map do |set_name, _label|
45
- rule_name = "#{set_name}+#{tag}"
46
- state = Card.exists?(rule_name) ? :exists : nil
47
- rule_radio set_name, state do
48
- radio_button :name, rule_name
49
- end
50
- end
51
- end
52
- end
@@ -1,14 +0,0 @@
1
- - heading_id = "heading-#{group_key}"
2
- - collapse_id = "collapse-#{card.name.safe_key}-#{group_key}"
3
- .card
4
- .card-header{ role: "tab", id: heading_id }
5
- %h5.mb-0
6
- = link_to (t("rules_#{group_key}") || group_key.to_s),
7
- href: "##{collapse_id}",
8
- "data-toggle": "collapse", "aria-expanded": "false",
9
- "data-parent": "#accordion", "aria-controls": collapse_id
10
- .panel-collapse.collapse{ id: collapse_id,
11
- role: "tabpanel",
12
- "aria-labelledby": heading_id }
13
- .card-body
14
- = bar_rule_list card.visible_settings(group_key).map(&:codename)
@@ -1,60 +0,0 @@
1
- format :html do
2
- def rules_filter view, selected_setting=nil, set_options=nil, path_opts={}
3
- form_tag path(path_opts.merge(view: view)),
4
- remote: true, method: "get", role: "filter",
5
- "data-slot-selector": ".card-slot.rule-list",
6
- class: classy("nodblclick slotter form-inline slim-select2 m-2") do
7
- output [
8
- label_tag(:view, icon_tag("filter_list"), class: "mr-2"),
9
- setting_select(selected_setting),
10
- set_select(set_options)
11
- ].flatten
12
- end
13
- end
14
-
15
- def set_select set_options
16
- return filter_text.html_safe unless set_options
17
-
18
- [content_tag(:span, "rules that apply to set ...", class: "mx-2 small"),
19
- set_select_tag(set_options)]
20
- end
21
-
22
- def setting_select selected=nil
23
- select_tag(:group, grouped_options_for_select(setting_options, selected),
24
- class: "_submit-on-select form-control",
25
- "data-select2-id": "#{unique_id}-#{Time.now.to_i}")
26
- end
27
-
28
- def filter_text
29
- wrap_with :span, class: "mx-2 small" do
30
- "rules that apply to #{_render_set_label.downcase}" # LOCALIZE
31
- end
32
- end
33
-
34
- def set_select_tag set_options=:related
35
- select_tag(:mark, set_select_options(set_options),
36
- class: "_submit-on-select form-control _close-rule-overlay-on-select",
37
- "data-minimum-results-for-search": "Infinity",
38
- "data-select2-id": "#{unique_id}-#{Time.now.to_i}")
39
- end
40
-
41
- def selected_set
42
- params[:set]
43
- end
44
-
45
- def set_select_options set_options
46
- options =
47
- if set_options == :related
48
- related_set_options
49
- else
50
- [[card.label, card.name.url_key]]
51
- end
52
- options_for_select(options, selected_set)
53
- end
54
-
55
- def related_set_options
56
- card.related_sets(true).map do |name, label|
57
- [label, name.to_name.url_key]
58
- end
59
- end
60
- end
@@ -1,76 +0,0 @@
1
- format :html do
2
- SETTING_OPTIONS = [["Common", :common_rules],
3
- ["All", :all_rules],
4
- ["Field", :field_related_rules],
5
- ["Recent", :recent_rules]].freeze
6
-
7
- COMMON_SETTINGS = %i[create read update delete structure default guide].freeze
8
- FIELD_SETTINGS = %i[default help].freeze
9
-
10
- def setting_options
11
- [["Categories", SETTING_OPTIONS],
12
- ["Groups", Card::Setting.groups.keys],
13
- ["Single rules", card.visible_setting_codenames]]
14
- end
15
-
16
- def field_settings
17
- %i[default help input_type content_options content_option_view]
18
- end
19
-
20
- # @param val setting category, setting group or single setting
21
- def setting_list val
22
- category_setting_list(val) || group_setting_list(val) || [val]
23
- end
24
-
25
- def group_setting_list group
26
- card.visible_settings(group).map(&:codename) if Card::Setting.groups[group]
27
- end
28
-
29
- def category_setting_list cat
30
- case cat
31
- when :all, :all_rules
32
- card.visible_setting_codenames.sort
33
- when :recent, :recent_rules
34
- recent_settings
35
- when :common, :common_rules
36
- card.visible_setting_codenames & COMMON_SETTINGS
37
- when :field_related, :field_related_rules
38
- field_related_settings
39
- when :nest_editor_field_related
40
- nest_editor_field_related_settings
41
- end
42
- end
43
-
44
- def nest_editor_field_related_settings
45
- field_settings
46
- # & card.visible_settings(nil, card.prototype_default_type_id).map(&:codename)
47
- end
48
-
49
- def field_related_settings
50
- field_settings # card.visible_setting_codenames &
51
- end
52
-
53
- def recent_settings
54
- recent_settings = Card[:recent_settings].item_cards.map(&:codename)
55
- recent_settings.map(&:to_sym) & card.visible_setting_codenames
56
- end
57
-
58
- view :all_rules_list do
59
- pill_rule_list card.visible_setting_codenames.sort
60
- end
61
-
62
- view :recent_rules_list do
63
- recent_settings = Card[:recent_settings].item_cards.map(&:codename)
64
- settings = recent_settings.map(&:to_sym) & card.visible_setting_codenames
65
- pill_rule_list settings
66
- end
67
-
68
- view :common_rules_list do
69
- settings = card.visible_setting_codenames & COMMON_SETTINGS # "&" = set intersection
70
- pill_rule_list settings
71
- end
72
-
73
- view :field_related_rules_list do
74
- pill_rule_list field_related_settings
75
- end
76
- end