summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/custom_fields_controller.rb2
-rw-r--r--app/helpers/application_helper.rb8
-rw-r--r--app/helpers/custom_fields_helper.rb9
-rw-r--r--app/views/common/_tabs.html.erb2
-rw-r--r--app/views/custom_fields/_index.html.erb2
-rw-r--r--app/views/custom_fields/index.html.erb10
-rw-r--r--app/views/custom_fields/select_type.html.erb15
7 files changed, 38 insertions, 10 deletions
diff --git a/app/controllers/custom_fields_controller.rb b/app/controllers/custom_fields_controller.rb
index 3f721b145..28178e98b 100644
--- a/app/controllers/custom_fields_controller.rb
+++ b/app/controllers/custom_fields_controller.rb
@@ -77,7 +77,7 @@ class CustomFieldsController < ApplicationController
def build_new_custom_field
@custom_field = CustomField.new_subclass_instance(params[:type], params[:custom_field])
if @custom_field.nil?
- render_404
+ render :action => 'select_type'
end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 25096a11d..363653cd8 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -309,9 +309,13 @@ module ApplicationHelper
end
# Renders tabs and their content
- def render_tabs(tabs)
+ def render_tabs(tabs, selected=params[:tab])
if tabs.any?
- render :partial => 'common/tabs', :locals => {:tabs => tabs}
+ unless tabs.detect {|tab| tab[:name] == selected}
+ selected = nil
+ end
+ selected ||= tabs.first[:name]
+ render :partial => 'common/tabs', :locals => {:tabs => tabs, :selected_tab => selected}
else
content_tag 'p', l(:label_no_data), :class => "nodata"
end
diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb
index 5447130a5..173e0d5f8 100644
--- a/app/helpers/custom_fields_helper.rb
+++ b/app/helpers/custom_fields_helper.rb
@@ -40,8 +40,13 @@ module CustomFieldsHelper
:label => DocumentCategory::OptionName}
]
- def custom_fields_tabs
- CUSTOM_FIELDS_TABS
+ def render_custom_fields_tabs(types)
+ tabs = CUSTOM_FIELDS_TABS.select {|h| types.include?(h[:name]) }
+ render_tabs tabs
+ end
+
+ def custom_field_type_options
+ CUSTOM_FIELDS_TABS.map {|h| [l(h[:label]), h[:name]]}
end
def render_custom_field_format_partial(form, custom_field)
diff --git a/app/views/common/_tabs.html.erb b/app/views/common/_tabs.html.erb
index 8cbcda51a..34fd570ea 100644
--- a/app/views/common/_tabs.html.erb
+++ b/app/views/common/_tabs.html.erb
@@ -1,5 +1,3 @@
-<% selected_tab = params[:tab] ? params[:tab].to_s : tabs.first[:name] %>
-
<div class="tabs">
<ul>
<% tabs.each do |tab| -%>
diff --git a/app/views/custom_fields/_index.html.erb b/app/views/custom_fields/_index.html.erb
index 4752c2519..0b578d6ee 100644
--- a/app/views/custom_fields/_index.html.erb
+++ b/app/views/custom_fields/_index.html.erb
@@ -28,5 +28,3 @@
<% end; reset_cycle %>
</tbody>
</table>
-
-<p><%= link_to l(:label_custom_field_new), new_custom_field_path(:type => tab[:name]), :class => 'icon icon-add' %></p>
diff --git a/app/views/custom_fields/index.html.erb b/app/views/custom_fields/index.html.erb
index b4e87f066..e4464132f 100644
--- a/app/views/custom_fields/index.html.erb
+++ b/app/views/custom_fields/index.html.erb
@@ -1,3 +1,11 @@
+<div class="contextual">
+<%= link_to l(:label_custom_field_new), new_custom_field_path, :class => 'icon icon-add' %>
+</div>
+
<%= title l(:label_custom_field_plural) %>
-<%= render_tabs custom_fields_tabs %>
+<% if @custom_fields_by_type.present? %>
+ <%= render_custom_fields_tabs(@custom_fields_by_type.keys) %>
+<% else %>
+ <p class="nodata"><%= l(:label_no_data) %></p>
+<% end %>
diff --git a/app/views/custom_fields/select_type.html.erb b/app/views/custom_fields/select_type.html.erb
new file mode 100644
index 000000000..fd9c5a210
--- /dev/null
+++ b/app/views/custom_fields/select_type.html.erb
@@ -0,0 +1,15 @@
+<%= title [l(:label_custom_field_plural), custom_fields_path],
+ l(:label_custom_field_new) %>
+
+<% selected = 0 %>
+<%= form_tag new_custom_field_path, :method => 'get' do %>
+ <div class="box">
+ <p><%= l(:label_custom_field_select_type) %>:</p>
+ <p>
+ <% custom_field_type_options.each do |name, type| %>
+ <label style="display:block;"><%= radio_button_tag 'type', type, 1==selected+=1 %> <%= name %></label>
+ <% end %>
+ </p>
+ </div>
+ <p><%= submit_tag l(:label_next).html_safe + " &#187;".html_safe, :name => nil %></p>
+<% end %>