card-mod-edit 0.13.4 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad39ba7845e2d7fd8394001d9125e7426e420a95ecf6c7823d7ff543f815dab1
4
- data.tar.gz: 2cd4afb37e71c18dea734522a10ef27f93f92a3cd86c578b28f8950cfc4df2f9
3
+ metadata.gz: 171bd7cab880ed08678d825d73145ebf76423e6d11fbfd42bf3e236c24969cff
4
+ data.tar.gz: 27b1cb3244658743ccbd2f6efd07b7f84edf1db46a41c3a87050c338edb27b7f
5
5
  SHA512:
6
- metadata.gz: cdd76b927bf903fc880861a4f12fa7a923b8e8f3e9d71cb2ed4c2c520d6b51a647646720cb1a83805bb22afaf262489e42671983e3ad7777b0cbf83675ec4c1c
7
- data.tar.gz: a18cca0f8fe57f1c8ed00bfcb5bafb5d3029cd6083acf733b1fbfb4eb541edc915ebc3b98cfc558c16dbacbc009a4569b8e23754f7456bda775150ae8bc7d160
6
+ metadata.gz: 59e57dea79faaf966db928719062959af44c83eebf5405feef675faaa3c91763f61f261d9c524baf7d744baa0140c6345809f469d3927ce1318062474e50937d
7
+ data.tar.gz: aba8cb501a6037186d34e6e6dd506c341391f1100b7c100085281a9864a1db96a53b57c936e1568595db7bf02b94837df842871bdb80fc89903f27b637a01393
@@ -9,7 +9,7 @@ format :html do
9
9
  def edit_form
10
10
  voo.hide :edit_type_row
11
11
  form_opts = edit_form_opts.reverse_merge success: edit_success
12
- card_form(:update, form_opts) do
12
+ card_form :update, form_opts do
13
13
  [
14
14
  edit_view_hidden,
15
15
  _render_edit_type_row(home_view: :edit_type_row),
@@ -20,7 +20,7 @@ format :html do
20
20
  # the slot wrap. Id think this would probably best be handled as an
21
21
  # option to #wrap that triggers a new heir voo
22
22
  _render_content_formgroups,
23
- _render_edit_buttons
23
+ _render(voo.buttons_view || :edit_buttons)
24
24
  ]
25
25
  end
26
26
  end
@@ -1,12 +1,13 @@
1
1
  format :html do
2
2
  view :edit_inline, perms: :update, unknown: true, cache: :never, wrap: :slot do
3
+ add_name_context
3
4
  voo.hide :name_formgroup, :type_formgroup
4
5
  with_nest_mode :edit do
5
6
  card_form :update, success: edit_success do
6
7
  [
7
8
  edit_view_hidden,
8
9
  _render_content_formgroups,
9
- _render_edit_inline_buttons
10
+ _render(voo.buttons_view || :edit_inline_buttons)
10
11
  ]
11
12
  end
12
13
  end
@@ -18,9 +19,7 @@ format :html do
18
19
 
19
20
  view :edit_inline_buttons do
20
21
  button_formgroup do
21
- wrap_with "div", class: "d-flex" do
22
- [standard_save_button, cancel_in_place_button, delete_button]
23
- end
22
+ [standard_save_button, cancel_in_place_button, delete_button]
24
23
  end
25
24
  end
26
25
 
data/set/all/edit_name.rb CHANGED
@@ -12,7 +12,7 @@ format :html do
12
12
  def name_form success_view=nil
13
13
  card_form({ action: :update, id: card.id },
14
14
  { "data-main-success": JSON(redirect: true, view: ""),
15
- "data-update-origin": "true",
15
+ "data-slotter-mode": "update-origin",
16
16
  class: "_rename-form",
17
17
  success: edit_name_success(success_view) }) do
18
18
  [_render_name_formgroup,
data/set/all/edit_type.rb CHANGED
@@ -26,9 +26,8 @@ format :html do
26
26
  view: :edit_form,
27
27
  assign: true,
28
28
  slot: { show: :type_form }),
29
- class: "live-type-field slotter",
30
- 'data-remote': true,
31
- 'data-slot-selector': ".card-slot.edit_form-view"
29
+ class: "_live-type-field",
30
+ 'data-remote': true
32
31
  end
33
32
 
34
33
  view :type_formgroup do
@@ -95,19 +94,13 @@ format :html do
95
94
 
96
95
  visible_cardtype_groups.each_pair.with_object(groups) do |(name, items), grps|
97
96
  if name == "Custom"
98
- custom_grouped_types grps
97
+ groups[name] = custom_types
99
98
  else
100
99
  standard_grouped_types grps, name, items
101
100
  end
102
101
  end
103
102
  end
104
103
 
105
- def custom_grouped_types groups
106
- Auth.createable_types.each do |type|
107
- groups["Custom"] << type unless ::Card::Set::Self::Cardtype::GROUP_MAP[type]
108
- end
109
- end
110
-
111
104
  def standard_grouped_types groups, name, items
112
105
  items.each do |i|
113
106
  groups[name] << i if raw_type_options.include?(i)
@@ -115,6 +108,6 @@ format :html do
115
108
  end
116
109
 
117
110
  def visible_cardtype_groups
118
- ::Card::Set::Self::Cardtype::GROUP
111
+ All::CardtypeGroups::GROUP
119
112
  end
120
113
  end
data/set/all/editing.rb CHANGED
@@ -38,9 +38,7 @@ format :html do
38
38
 
39
39
  view :edit_buttons do
40
40
  button_formgroup do
41
- wrap_with "div", class: "d-flex" do
42
- [standard_submit_button, edit_cancel_button, delete_button]
43
- end
41
+ [standard_submit_button, edit_cancel_button, delete_button]
44
42
  end
45
43
  end
46
44
 
@@ -82,7 +80,7 @@ format :html do
82
80
  # frame do
83
81
  # # with_nest_mode :edit do
84
82
  # nested_fields.map do |name, _options|
85
- # nest Card.fetch(name.to_name.trait(:self)),
83
+ # nest Card.fetch(name.to_name.field(:self)),
86
84
  # view: :titled, title: name, rule_view: view,
87
85
  # hide: :set_label, show: :rule_navbar
88
86
  # end
data/set/all/form.rb CHANGED
@@ -31,8 +31,8 @@ format :html do
31
31
  end
32
32
 
33
33
  def wrap_content_formgroup &block
34
- formgroup("Content", input: :content, help: false,
35
- class: classy("card-editor"), &block)
34
+ formgroup "Content", input: :content, help: false,
35
+ class: classy("card-editor"), &block
36
36
  end
37
37
 
38
38
  def button_formgroup &block
data/set/all/formgroup.rb CHANGED
@@ -1,23 +1,31 @@
1
1
  format :html do
2
- # a formgroup has a label, an input and help text
2
+ view :read_form do
3
+ edit_field_configs.map do |field, args|
4
+ args[:view] = :read_formgroup
5
+ nest field, args
6
+ end
7
+ end
8
+
9
+ view :read_formgroup, template: :haml, unknown: true, wrap: :slot
10
+
11
+ # a formgroup has a label (with helptext) and an input
3
12
  def formgroup title, opts={}, &block
13
+ input = opts[:input]
4
14
  wrap_with :div, formgroup_div_args(opts[:class]) do
5
- formgroup_body title, opts, &block
15
+ [formgroup_label(input, title, opts[:help]),
16
+ editor_wrap(input, &block)]
6
17
  end
7
18
  end
8
19
 
9
- def formgroup_body title, opts, &block
10
- label = formgroup_label opts[:input], title
11
- editor_body = editor_wrap opts[:input], &block
12
- help_text = formgroup_help_text opts[:help]
13
- "#{label}<div>#{help_text} #{editor_body}</div>"
14
- end
20
+ def formgroup_label input, title, help
21
+ parts = [formgroup_title(title), formgroup_help(help)].compact
22
+ return unless parts.present?
15
23
 
16
- def formgroup_label input, title
17
- return if voo&.hide?(:title) || title.blank?
24
+ form.label (input || :content), raw(parts.join("\n"))
25
+ end
18
26
 
19
- label_type = input || :content
20
- form.label label_type, title
27
+ def formgroup_title title
28
+ title if voo&.show?(:title) && title.present?
21
29
  end
22
30
 
23
31
  def formgroup_div_args html_class
@@ -27,11 +35,15 @@ format :html do
27
35
  div_args
28
36
  end
29
37
 
30
- def formgroup_help_text text=nil
31
- return "" if text == false
38
+ def formgroup_help text=nil
39
+ return unless voo&.show?(:help) && text != false
32
40
 
33
41
  class_up "help-text", "help-block"
34
- voo.help = text if voo && text.to_s != "true"
42
+ formgroup_voo_help text
35
43
  _render_help
36
44
  end
45
+
46
+ def formgroup_voo_help text
47
+ voo.help = text if voo && text.present? && text.to_s != "true"
48
+ end
37
49
  end
data/set/all/new.rb CHANGED
@@ -2,30 +2,49 @@ format :html do
2
2
  delegate :autoname?, to: :card
3
3
 
4
4
  view :new, perms: :create, unknown: true, cache: :never do
5
- new_view_frame_and_form new_form_opts
6
- end
7
-
8
- view :new_content_form, wrap: :slot, unknown: true, cache: :never do
9
- with_nest_mode :edit do
10
- create_form
11
- end
5
+ framed_create_form new_form_opts
12
6
  end
13
7
 
14
8
  view :new_in_modal, perms: :create, unknown: true, cache: :never,
15
9
  wrap: { modal: { footer: "", size: :edit_modal_size,
16
10
  title: :new_in_modal_title,
17
11
  menu: :new_modal_menu } } do
18
- _render_new_content_form
12
+ voo.buttons_view ||= :new_in_modal_buttons
13
+ wrap do
14
+ create_form "data-slot-selector": "modal-origin",
15
+ "data-slot-error-selector": ".card-slot"
16
+ end
17
+ end
18
+
19
+ view :simple_new, perms: :create, unknown: true, wrap: :slot, cache: :never do
20
+ create_form
19
21
  end
20
22
 
21
- def create_form
22
- form_opts = new_in_modal_form_opts.reverse_merge(success: new_in_modal_success)
23
- buttons = form_opts.delete(:buttons) || _render_new_buttons
23
+ view :new_fields, perms: :create, unknown: true, cache: :never do
24
+ wrap true, class: "w-100" do
25
+ [
26
+ new_view_hidden,
27
+ new_view_name,
28
+ new_view_type,
29
+ _render_content_formgroups,
30
+ _render(voo.buttons_view || :new_buttons)
31
+ ]
32
+ end
33
+ end
34
+
35
+ def with_create_context
36
+ with_nest_mode :edit do
37
+ voo.title ||= new_view_title if new_name_prompt?
38
+ voo.show :help
39
+ yield
40
+ end
41
+ end
24
42
 
25
- voo.title ||= new_view_title if new_name_prompt?
26
- voo.show :help
27
- card_form(:create, form_opts) do
28
- create_form_with_alert_guide buttons
43
+ def create_form form_opts={}
44
+ with_create_context do
45
+ card_form :create, form_opts do
46
+ create_form_with_alert_guide
47
+ end
29
48
  end
30
49
  end
31
50
 
@@ -39,45 +58,27 @@ format :html do
39
58
  end
40
59
  end
41
60
 
42
- def new_view_frame_and_form form_opts={}
43
- buttons = form_opts.delete(:buttons) || _render_new_buttons
44
- form_opts = form_opts.reverse_merge(success: new_success)
61
+ def framed_create_form form_opts={}
62
+ form_opts.reverse_merge! success: new_success
45
63
 
46
- with_nest_mode :edit do
47
- voo.title ||= new_view_title if new_name_prompt?
48
- voo.show :help
64
+ with_create_context do
49
65
  frame_and_form :create, form_opts do
50
- create_form_with_alert_guide buttons
66
+ create_form_with_alert_guide
51
67
  end
52
68
  end
53
69
  end
54
70
 
55
- def create_form_with_alert_guide buttons
71
+ def create_form_with_alert_guide
56
72
  wrap_with :div, class: "d-flex justify-content-between" do
57
- [(wrap_with(:div, class: "w-100") do
58
- [
59
- new_view_hidden,
60
- new_view_name,
61
- new_view_type,
62
- _render_content_formgroups,
63
- buttons
64
- ]
65
- end),
66
- (alert_guide if voo.show?(:guide))]
73
+ [_render_new_fields, (alert_guide if voo.show?(:guide))]
67
74
  end
68
75
  end
69
76
 
70
- def new_view_hidden; end
71
-
72
- def new_in_modal_form_opts
73
- { "data-slot-selector": "modal-origin", "data-slot-error-selector": ".card-slot",
74
- buttons: _render_new_in_modal_buttons }
75
- end
76
-
77
77
  def new_form_opts
78
78
  { "data-main-success": JSON(redirect: true) }
79
79
  end
80
80
 
81
+ # LOCALIZE
81
82
  def new_view_title
82
83
  output(
83
84
  "New",
@@ -95,6 +96,8 @@ format :html do
95
96
 
96
97
  def new_in_modal_success; end
97
98
 
99
+ def new_view_hidden; end
100
+
98
101
  # NAME HANDLING
99
102
 
100
103
  def new_view_name
@@ -150,34 +153,32 @@ format :html do
150
153
 
151
154
  view :new_type_formgroup do
152
155
  wrap_type_formgroup do
153
- type_field class: "type-field live-type-field",
154
- href: path(view: :new),
156
+ type_field class: "type-field _live-type-field slotter",
157
+ href: path(view: :new_fields),
155
158
  "data-remote" => true
156
159
  end
157
160
  end
158
161
 
159
162
  view :new_buttons do
160
163
  button_formgroup do
161
- [standard_create_button, standard_cancel_button(cancel_button_new_args)]
164
+ [standard_create_button, standard_cancel_button(href: cancel_create_path)]
162
165
  end
163
166
  end
164
167
 
165
168
  view :new_in_modal_buttons do
169
+ class_up "button-form-group", "d-flex"
166
170
  button_formgroup do
167
- wrap_with "div", class: "d-flex" do
168
- [standard_save_and_close_button(text: "Submit"), modal_cancel_button]
169
- end
171
+ [standard_save_and_close_button(text: "Submit"), modal_cancel_button]
170
172
  end
171
173
  end
172
174
 
173
175
  # path to redirect to after canceling a new form
174
- def cancel_button_new_args
175
- href = case
176
- when main? then path_to_previous
177
- when voo&.home_view then path(view: voo.home_view)
178
- else path(view: :unknown)
179
- end
180
- { href: href }
176
+ def cancel_create_path
177
+ if main?
178
+ path_to_previous
179
+ else
180
+ path view: (voo&.home_view || :unknown)
181
+ end
181
182
  end
182
183
 
183
184
  def standard_create_button
@@ -0,0 +1,5 @@
1
+ .form-group
2
+ %label
3
+ = render_title
4
+ .read-formgroup-content
5
+ = render_core
@@ -14,7 +14,7 @@ format do
14
14
  def template_link_set_name
15
15
  name = voo.nest_name.to_name
16
16
  if name.absolute?
17
- name.trait_name :self
17
+ name.field_name :self
18
18
  else
19
19
  template_link_set_name_for_relative_name name
20
20
  end
@@ -24,9 +24,9 @@ format do
24
24
  name = name.stripped.gsub(/^\+/, "")
25
25
 
26
26
  if (type = on_type_set)
27
- [type, name].to_name.trait_name :type_plus_right
27
+ [type, name].to_name.field_name :type_plus_right
28
28
  else
29
- name.to_name.trait_name :right
29
+ name.to_name.field_name :right
30
30
  end
31
31
  end
32
32
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: card-mod-edit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.4
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan McCutchen
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-09-24 00:00:00.000000000 Z
13
+ date: 2021-12-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: card
@@ -18,14 +18,28 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.103.4
21
+ version: 1.104.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 1.103.4
28
+ version: 1.104.0
29
+ - !ruby/object:Gem::Dependency
30
+ name: card-mod-rules
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - '='
34
+ - !ruby/object:Gem::Version
35
+ version: 0.14.0
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - '='
41
+ - !ruby/object:Gem::Version
42
+ version: 0.14.0
29
43
  description: ''
30
44
  email:
31
45
  - info@decko.org
@@ -43,7 +57,6 @@ files:
43
57
  - set/all/edit_content.rb
44
58
  - set/all/edit_inline.rb
45
59
  - set/all/edit_name.rb
46
- - set/all/edit_name_confirmation.haml
47
60
  - set/all/edit_name_skip_referers.haml
48
61
  - set/all/edit_type.rb
49
62
  - set/all/editing.rb
@@ -55,6 +68,7 @@ files:
55
68
  - set/all/new.rb
56
69
  - set/all/overlay_guide.haml
57
70
  - set/all/overlay_guide.rb
71
+ - set/all/read_formgroup.haml
58
72
  - set/all/template_nest.rb
59
73
  - set/right/input_type.rb
60
74
  - set/self/input_type.rb
@@ -86,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
100
  - !ruby/object:Gem::Version
87
101
  version: '0'
88
102
  requirements: []
89
- rubygems_version: 3.1.6
103
+ rubygems_version: 3.2.15
90
104
  signing_key:
91
105
  specification_version: 4
92
106
  summary: Edit handling
@@ -1,7 +0,0 @@
1
- %h5
2
- = t :core_rename_confirm
3
- %em
4
- = safe_name
5
- ?
6
- %p._rename-reference-confirm{ data: { referer_count: referer_count } }
7
- = t :core_rename_reference_confirm, count: referer_count