Module: Card::Set::Rule::Editor::HtmlFormat

Extended by:
AbstractFormat
Defined in:
tmpsets/set/mod022-rules/rule/editor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#rule_contextObject

Returns the value of attribute rule_context.



9
10
11
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 9

def rule_context
  @rule_context
end

Instance Method Details

#closed_rule_content(rule_card) ⇒ Object



115
116
117
118
119
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 115

def closed_rule_content rule_card
  return "" unless rule_card

  nest rule_card, { view: :closed_content }, set_context: card.name.trunk_name
end

#current_rule(force_reload = true) ⇒ Object



11
12
13
14
15
16
17
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 11

def current_rule force_reload=true
  @current_rule = nil if force_reload
  @current_rule ||= begin
    rule = determine_current_rule
    reload_rule rule
  end
end

#current_set_keyObject



172
173
174
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 172

def current_set_key
  card.new_card? ? Card.quick_fetch(:all).name.key : card.rule_set_key
end

#determine_current_ruleObject



19
20
21
22
23
24
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 19

def determine_current_rule
  existing = find_existing_rule_card
  return existing if existing

  Card.new name: "#{Card[:all].name}+#{card.rule_user_setting_name}"
end


127
128
129
130
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 127

def link_to_all_rules
  link_to_card card.rule_setting_name, "all #{card.rule_setting_title} rules",
               class: "setting-link", target: "wagn_setting"
end


132
133
134
135
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 132

def link_to_closed_rule
  link_to_view :closed_rule, card.rule_setting_title,
               class: "close-rule-link"
end


110
111
112
113
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 110

def link_to_open_rule
  setting_title = card.name.tag.tr "*", ""
  link_to_view :open_rule, setting_title, class: "edit-rule-link"
end


121
122
123
124
125
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 121

def open_rule_setting_links
  wrap_with :div, class: "rule-setting" do
    [link_to_closed_rule, link_to_all_rules]
  end
end

#quick_editorObject



79
80
81
82
83
84
85
86
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 79

def quick_editor
  if card.right.codename == :default
    @edit_rule_success = {}
    rules_type_formgroup
  else
    rule_content_formgroup
  end
end

#quick_formObject



52
53
54
55
56
57
58
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 52

def quick_form
  card_form :update,
            "data-slot-selector": ".set-info.card-slot",
            success: { view: :quick_edit_success }  do
    quick_editor
  end
end

#reload_rule(rule) ⇒ Object



137
138
139
140
141
142
143
144
145
146
147
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 137

def reload_rule rule
  return rule unless (card_args = params[:card])

  if card_args[:name] && card_args[:name].to_name.key != rule.key
    Card.new card_args
  else
    rule = rule.refresh
    rule.assign_attributes card_args
    rule.include_set_modules
  end
end

#rule_content_containerObject



104
105
106
107
108
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 104

def rule_content_container
  wrap_with :div, class: "rule-content-container" do
    wrap_with(:span, class: "closed-content content") { yield }
  end
end

#rule_content_formgroupObject



166
167
168
169
170
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 166

def rule_content_formgroup
  formgroup "content", editor: "content", help: false do
    content_field true
  end
end

#rule_set_descriptionObject



149
150
151
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 149

def rule_set_description
  card.rule_set.follow_label
end

#rules_type_formgroupObject



153
154
155
156
157
158
159
160
161
162
163
164
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 153

def rules_type_formgroup
  return unless card.right.rule_type_editable

  success = @edit_rule_success
  wrap_type_formgroup do
    type_field(
      href: path(mark: success[:id], view: success[:view], type_reload: true),
      class: "type-field rule-type-field live-type-field",
      "data-remote" => true
    )
  end
end

#set_info(notify_change = nil) ⇒ Object



60
61
62
63
64
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 60

def set_info notify_change=nil
  wrap true, class: "set-info" do
    haml :set_info, notify_change: notify_change
  end
end

#setting_titleObject



96
97
98
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 96

def setting_title
  card.name.tag.tr "*", ""
end

#short_help_textObject



100
101
102
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 100

def short_help_text
  "<div class=\"help-text\">#{card.short_help_text}</div>"
end

#show_rule_set(set) ⇒ Object



42
43
44
45
46
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 42

def show_rule_set set
  wrap_with :div, class: "rule-set" do
    %(<label>Applies to</label> #{link_to_card set.name, set.label}:)
  end
end

#undo_buttonObject



66
67
68
69
70
71
72
73
# File 'tmpsets/set/mod022-rules/rule/editor.rb', line 66

def undo_button
  link_to "undo", method: :post, rel: "nofollow", class: "btn btn-secondary ml-2 btn-sm btn-reduced-padding slotter",
                  remote: true,
                  "data-slot-selector": ".card-slot.quick_edit-view",
                  path: { action: :update,
                          revert_actions: [card.last_action_id],
                          revert_to: :previous }
end