Move "Create" button to toolbar on pages with rendered tabs. Thus the button is shown at the top and easily available.

pull/9676/head
Henriette Darge 3 years ago committed by Oliver Günther
parent a15c38f3ac
commit a52105d970
  1. 8
      app/helpers/tabs_helper.rb
  2. 10
      app/views/attribute_help_texts/_tab.html.erb
  3. 45
      app/views/attribute_help_texts/index.html.erb
  4. 9
      app/views/custom_fields/_tab.html.erb
  5. 12
      app/views/custom_fields/index.html.erb

@ -32,13 +32,17 @@ module TabsHelper
# Renders tabs and their content
def render_tabs(tabs, form = nil)
if tabs.any?
selected_tab = tabs.detect { |t| t[:name] == params[:tab] } if params[:tab].present?
render partial: 'common/tabs', locals: { f: form, tabs: tabs, selected_tab: selected_tab || tabs.first }
selected = selected_tab(tabs)
render partial: 'common/tabs', locals: { f: form, tabs: tabs, selected_tab: selected }
else
content_tag 'p', I18n.t(:label_no_data), class: 'nodata'
end
end
def selected_tab(tabs)
tabs.detect { |t| t[:name] == params[:tab] } || tabs.first
end
# Render tabs from the ui/extensible tabs manager
def render_extensible_tabs(key, params = {})
tabs = ::OpenProject::Ui::ExtensibleTabs.enabled_tabs(key).map do |tab|

@ -66,13 +66,3 @@
<% else %>
<%= no_results_box %>
<% end %>
<div class="generic-table--action-buttons">
<%= link_to new_attribute_help_text_path(name: tab[:name]),
{ class: 'attribute-help-texts--create-button button -alt-highlight',
aria: {label: t(:'attribute_help_texts.add_new')},
title: t(:'attribute_help_texts.add_new')} do %>
<%= op_icon('button--icon icon-add') %>
<span class="button--text"><%= t('activerecord.models.attribute_help_text') %></span>
<% end %>
</div>

@ -26,18 +26,33 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See COPYRIGHT and LICENSE files for more details.
++#%>
<%= render_tabs [
{
name: 'WorkPackage',
partial: 'attribute_help_texts/tab',
path: attribute_help_texts_path(tab: 'WorkPackage'),
label: :label_work_package
},
{
name: 'Project',
partial: 'attribute_help_texts/tab',
path: attribute_help_texts_path(tab: 'Project'),
label: Project.model_name.human
}
]
%>
<% tabs = [
{
name: 'WorkPackage',
partial: 'attribute_help_texts/tab',
path: attribute_help_texts_path(tab: 'WorkPackage'),
label: :label_work_package
},
{
name: 'Project',
partial: 'attribute_help_texts/tab',
path: attribute_help_texts_path(tab: 'Project'),
label: Project.model_name.human
}
] %>
<%= toolbar title: t(:'attribute_help_texts.label_plural') do %>
<li class="toolbar-item">
<%= link_to new_attribute_help_text_path(name: selected_tab(tabs)[:name]),
{ class: 'attribute-help-texts--create-button button -alt-highlight',
aria: {label: t(:'attribute_help_texts.add_new')},
title: t(:'attribute_help_texts.add_new')} do %>
<%= op_icon('button--icon icon-add') %>
<span class="button--text"><%= t('activerecord.models.attribute_help_text') %></span>
<% end %>
</li>
<% end %>
<%= render_tabs tabs %>

@ -164,15 +164,6 @@ See COPYRIGHT and LICENSE files for more details.
</table>
</div>
</div>
<div class="generic-table--action-buttons">
<%= link_to new_custom_field_path(type: tab[:name]),
{ class: 'button -alt-highlight',
aria: {label: t(:label_custom_field_new)},
title: t(:label_custom_field_new)} do %>
<%= op_icon('button--icon icon-add') %>
<span class="button--text"><%= t('activerecord.models.custom_field') %></span>
<% end %>
</div>
<% else %>
<%= no_results_box(action_url: new_custom_field_path(type: tab[:name]), display_action: true) %>
<% end %>

@ -26,7 +26,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See COPYRIGHT and LICENSE files for more details.
++#%>
<%= toolbar title: t(:label_custom_field_plural) %>
<%= toolbar title: t(:label_custom_field_plural) do %>
<li class="toolbar-item">
<%= link_to new_custom_field_path(type: selected_tab(custom_fields_tabs)[:name]),
{ class: 'button -alt-highlight',
aria: {label: t(:label_custom_field_new)},
title: t(:label_custom_field_new)} do %>
<%= op_icon('button--icon icon-add') %>
<span class="button--text"><%= t('activerecord.models.custom_field') %></span>
<% end %>
</li>
<% end %>
<%= render_tabs custom_fields_tabs %>

Loading…
Cancel
Save