Allow cmtool helpers to be used in other namespaces

This commit is contained in:
2015-10-05 10:36:52 +02:00
parent 6b6a7405ba
commit 7dc12ca3e8
4 changed files with 77 additions and 65 deletions
+13 -2
View File
@@ -131,16 +131,27 @@ module Cmtool
end
def edit_td(obj)
path = case obj
when Array then edit_polymorphic_path(obj)
when SimplyStored::Couch then edit_polymorphic_path([cmtool, obj])
else obj
end
content_tag(
:td,
link_to((content_tag(:span, '', class: [:edit, 'fa fa-lg fa-pencil'])), cmtool.url_for([:edit, obj]), class: 'tiny warning button'),
link_to((content_tag(:span, '', class: [:edit, 'fa fa-lg fa-pencil'])), path, class: 'tiny warning button'),
class: [:action, :edit]
)
end
def destroy_td(obj)
path = case obj
when Array then polymorphic_path(obj)
when SimplyStored::Couch then polymorphic_path([cmtool, obj])
else obj
end
content_tag(
:td,
link_to(content_tag(:span, '', class: [:destroy, 'fa fa-lg fa-trash']), cmtool.url_for(obj), method: :delete, class: 'tiny alert button', data: {confirm: are_you_sure(obj) }),
link_to(content_tag(:span, '', class: [:destroy, 'fa fa-lg fa-trash']), path, method: :delete, class: 'tiny alert button', data: {confirm: are_you_sure(obj) }),
class: [:action, :destroy]
)
end