mod/edit/set/all/edit_inline.rb
format :html do
view :edit_inline, perms: :update, unknown: true, cache: :never, wrap: :slot do
add_name_context
voo.hide :name_formgroup, :type_formgroup
with_nest_mode :edit do
card_form :update, success: edit_success do
[
edit_view_hidden,
_render_content_formgroups,
_render(voo.buttons_view || :edit_inline_buttons)
]
end
end
end
view :edit_name_row do
edit_row "Name", card.name, :name_form
end
view :edit_inline_buttons do
button_formgroup do
[standard_save_button, cancel_in_place_button, delete_button]
end
end
# TODO: better styling for this so that is reusable
# At the moment it is used for the name and type field in the board
# (with fixed 50px width for the title column) and
# for password and email for accounts (with fixed 75px width for the title column)
# The view is very similar to labeled but with fixed edit link on the right
# and a fixed width for the labels so that the content column is aligned
# There is also the problem that label and content are not vertically aligned
view :edit_row do
edit_row render_title, render_core, :edit_inline
end
def edit_row title, content, edit_view
class_up "card-slot", "d-flex form-group"
wrap true, class: :row do
haml :edit_row, title: title,
content: content,
edit_link: edit_inline_link(edit_view)
end
end
def edit_inline_link view=:edit_inline, align: :left
align = align == :left ? "ms-2" : "ms-auto"
link_to_view view, menu_icon, class: "#{align} edit-link", "data-cy": "edit-link"
end
def cancel_in_place_button args={}
args.reverse_merge! class: "cancel-button btn-sm", href: path
cancel_button args
end
end