diff options
| author | Teddy Wing | 2017-06-15 17:44:55 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-06-15 17:44:55 +0200 | 
| commit | 1d489cef3b9aeb474071b89be6d256e554182863 (patch) | |
| tree | 806f5b015fbeaa51481c7f0d687703d8b7521a2e /lib/html_element.rb | |
| parent | 8e678905af6be3358069a9d51f7af88d3449f014 (diff) | |
| download | chouette-core-1d489cef3b9aeb474071b89be6d256e554182863.tar.bz2 | |
ReferentialDecorator: Handle non-`Link` buttons
Referentials#show has a button "Purger" that isn't a link. Instead, it's
a `<button>` element that opens a modal.
Previously, we only knew how to put `Link`s in the `#action_links`, and
only these could then be rendered in the header bar as buttons.
This change allows us to accept non-Link objects. Since the button is
rather simple, I decided to create a simple `HTMLElement` class to
represent it and output it in the resulting HTML. The class uses the
`#content_tag` `ActionView` helper to render the final HTML.
Update "referentials/show.html.slim" to output the button correctly in
addition to the normal links.
Update `TableBuilderHelper#build_links` to not add anything that's not a
`Link` to the gear menu. This allows us to display the "Purger" button
on the Referentials#show page but not in the table on Workbenches#show.
Refs #3479
Diffstat (limited to 'lib/html_element.rb')
| -rw-r--r-- | lib/html_element.rb | 15 | 
1 files changed, 15 insertions, 0 deletions
| diff --git a/lib/html_element.rb b/lib/html_element.rb new file mode 100644 index 000000000..469fd7565 --- /dev/null +++ b/lib/html_element.rb @@ -0,0 +1,15 @@ +class HTMLElement +  def initialize(tag_name, content = nil, options = nil) +    @tag_name = tag_name +    @content = content +    @options = options +  end + +  def to_html(options = {}) +    ApplicationController.helpers.content_tag( +      @tag_name, +      @content, +      @options.merge(options) +    ) +  end +end | 
