From 977b57dbb29a25f53f5cbf2623aec165fa8551b3 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Wed, 27 Jul 2011 17:19:05 +0200 Subject: [PATCH] first pass to distribute settings over tabs --- app/helpers/preferences_helper.rb | 16 +++ app/views/preferences/index.html.erb | 139 +++++++++++++----------- app/views/preferences/oldindex.html.erb | 68 ++++++++++++ config/environment.rb | 2 +- public/javascripts/application.js | 8 +- 5 files changed, 167 insertions(+), 66 deletions(-) create mode 100644 app/views/preferences/oldindex.html.erb diff --git a/app/helpers/preferences_helper.rb b/app/helpers/preferences_helper.rb index 8838ec68..a56e75c6 100644 --- a/app/helpers/preferences_helper.rb +++ b/app/helpers/preferences_helper.rb @@ -1,2 +1,18 @@ module PreferencesHelper + + def pref(model, pref_name, &block) + s = "
" + s << yield + s << "

" + s + end + + def pref_with_select_field(model, pref_name, collection = [ [t('preferences.is_true'),true], [t('preferences.is_false'), false] ]) + pref(model, pref_name) { select(model, pref_name, collection) } + end + + def pref_with_text_field(model, pref_name, nowrap_label = false) + pref(model, pref_name) { text_field(model, pref_name) } + end + end diff --git a/app/views/preferences/index.html.erb b/app/views/preferences/index.html.erb index 138aef73..8c9c85eb 100644 --- a/app/views/preferences/index.html.erb +++ b/app/views/preferences/index.html.erb @@ -1,68 +1,79 @@ -
- -

<%= t('preferences.title') %>

- - -
- <%= link_to t('preferences.edit_preferences') + " »", { :controller => 'preferences', :action => 'edit'}, :class => 'edit_link' %> -
- -

<%= t('preferences.token_header') %>

-
-
<%= t('preferences.token_description') %>:
-
<%= current_user.token %>
-
- <%= button_to t('preferences.generate_new_token'), refresh_token_user_path(current_user), - :confirm => t('preferences.generate_new_token_confirm') %> -
-
-

<%= t('preferences.authentication_header') %>

-
- <% if Tracks::Config.auth_schemes.length > 1 %> -

<%= t('preferences.current_authentication_type', :auth_type => "#{current_user.auth_type}") %>.

-
- <%= link_to(t('preferences.change_authentication_type') + " »", change_auth_type_user_path(current_user), :class => 'edit_link') %> -
- <% end %> - <% if current_user.auth_type == 'database' %> -
- <%= link_to(t('preferences.change_password') + ' »', change_password_user_path(current_user)) %> -
- <% end %> - <% if current_user.auth_type == 'open_id' %> -

<%= t('preferences.open_id_url') %> <%= current_user.open_id_url %>.

-
- <%= link_to(t('preferences.change_identity_url') + ' »', change_auth_type_user_path(current_user)) %>
- <% end %> +
+

Authentication

+ +
+ +
+ <%= t('preferences.token_description') %>: <%= current_user.token %> + <%= button_to t('preferences.generate_new_token'), refresh_token_user_path(current_user), + :confirm => t('preferences.generate_new_token_confirm') %> + +
+ +
+ <% if Tracks::Config.auth_schemes.length > 1 %> + <% form_tag :action => 'update_auth_type' do %> + +
+ <% Tracks::Config.auth_schemes.each do |scheme| %> + <%= radio_button_tag('user[auth_type]', scheme, current_user.auth_type == scheme) %><%=scheme%>
+ <% end %> + +
+
+ +
+ <%= submit_tag t('users.auth_change_submit') %> <%= link_to t('common.cancel'), preferences_path %> + <%= observe_field( :user_auth_type, :function => "$('#open_id')[0].style.display = value == 'open_id' ? 'block' : 'none'") %> + <% end %> + <% end %> + + <% if current_user.auth_type == 'database' %> + <%= link_to(t('preferences.change_password') + ' »', change_password_user_path(current_user)) %> + <% end %> + <% if current_user.auth_type == 'open_id' %> +

<%= t('preferences.open_id_url') %> <%= current_user.open_id_url %>.

+ <%= link_to(t('preferences.change_identity_url') + ' »', change_auth_type_user_path(current_user)) %> + <% end %>
+
+

Date and time

+ <%= pref_with_text_field('prefs', 'date_format') %> + <%= pref_with_text_field('prefs', 'title_date_format') %> + <%= pref('prefs', 'time_zone') { time_zone_select('prefs','time_zone') } %> + + <%= pref_with_select_field('prefs', "week_starts", (0..6).to_a.map {|num| [t('date.day_names')[num], num] }) %> + +
+
+

Tracks behavior

+ <%= pref_with_select_field('prefs', "due_style", [[t('models.preference.due_styles')[0],Preference.due_styles[:due_in_n_days]],[t('models.preference.due_styles')[1],Preference.due_styles[:due_on]]]) %> + <%= pref_with_select_field('prefs', "show_completed_projects_in_sidebar") %> + <%= pref_with_select_field('prefs', "show_hidden_projects_in_sidebar") %> + <%= pref_with_select_field('prefs', "show_hidden_contexts_in_sidebar") %> + <%= pref_with_select_field('prefs', "show_project_on_todo_done") %> + <%= pref_with_text_field('prefs', 'staleness_starts') %> + <%= pref_with_text_field('prefs', 'show_number_completed') %> + <%= pref_with_text_field('prefs', 'refresh') %> + <%= pref_with_select_field('prefs', "verbose_action_descriptors") %> + <%= pref_with_text_field('prefs', "mobile_todos_per_page") %> + <%= pref_with_text_field('prefs', "sms_email") %> + <%= pref('prefs', "sms_context") { select('prefs', 'sms_context_id', current_user.contexts.map{|c| [c.name, c.id]}) } %> +
diff --git a/app/views/preferences/oldindex.html.erb b/app/views/preferences/oldindex.html.erb new file mode 100644 index 00000000..138aef73 --- /dev/null +++ b/app/views/preferences/oldindex.html.erb @@ -0,0 +1,68 @@ +
+ +

<%= t('preferences.title') %>

+ +
    +
  • <%= User.human_attribute_name('first_name') %>: <%= current_user.first_name %>
  • +
  • <%= User.human_attribute_name('last_name') %>: <%= current_user.last_name %>
  • +
  • <%= Preference.human_attribute_name('date_format') %>: <%= current_user.prefs.date_format %> Your current date: <%= format_date(current_user.time) %>
  • +
  • <%= Preference.human_attribute_name('locale') %>: <%= current_user.prefs.locale %>
  • +
  • <%= Preference.human_attribute_name('title_date_format') %>: <%= current_user.prefs.title_date_format %> Your current title date: <%= current_user.time.strftime(current_user.prefs.title_date_format) %>
  • +
  • <%= Preference.human_attribute_name('time_zone') %>: <%= current_user.prefs.time_zone %> Your current time: <%= current_user.time.strftime('%I:%M %p') %>
  • +
  • <%= Preference.human_attribute_name('week_starts') %>: <%= t('date.day_names')[current_user.prefs.week_starts] %>
  • +
  • <%= t('preferences.show_number_completed', :number=> "#{current_user.prefs.show_number_completed}")%>
  • +
  • <%= Preference.human_attribute_name('show_completed_projects_in_sidebar') %>: <%= current_user.prefs.show_completed_projects_in_sidebar %>
  • +
  • <%= Preference.human_attribute_name('show_hidden_projects_in_sidebar') %>: <%= current_user.prefs.show_hidden_projects_in_sidebar %>
  • +
  • <%= Preference.human_attribute_name('show_hidden_contexts_in_sidebar') %>: <%= current_user.prefs.show_hidden_contexts_in_sidebar %>
  • +
  • <%= Preference.human_attribute_name('show_project_on_todo_done') %>: <%= current_user.prefs.show_project_on_todo_done %>
  • +
  • <%= t('preferences.staleness_starts_after', :days => "#{current_user.prefs.staleness_starts}") %>
  • +
  • <%= Preference.human_attribute_name('due_style') %>: + <% if prefs.due_style == Preference.due_styles[:due_in_n_days] %> + <%= t('models.preference.due_styles')[0] %> + <% else %> + <%= t('models.preference.due_styles')[1] %> + <% end %> +
  • + <% if current_user.is_admin? %> +
  • <%= Preference.human_attribute_name('admin_email') %>: <%= current_user.prefs.admin_email %>
  • + <% end %> +
  • <%= Preference.human_attribute_name('refresh') %>: <%= current_user.prefs.refresh %>
  • +
  • <%= Preference.human_attribute_name('verbose_action_descriptors') %>: <%= current_user.prefs.verbose_action_descriptors %>
  • +
  • <%= Preference.human_attribute_name('mobile_todos_per_page') %>: <%= current_user.prefs.mobile_todos_per_page %>
  • +
  • <%= Preference.human_attribute_name('sms_email') %>: <%= current_user.prefs.sms_email %>
  • +
  • <%= Preference.human_attribute_name('sms_context') %>: <%= current_user.prefs.sms_context.nil? ? t('preferences.sms_context_none') : current_user.prefs.sms_context.name %>
  • +
+
+ <%= link_to t('preferences.edit_preferences') + " »", { :controller => 'preferences', :action => 'edit'}, :class => 'edit_link' %> +
+ +

<%= t('preferences.token_header') %>

+
+
<%= t('preferences.token_description') %>:
+
<%= current_user.token %>
+
+ <%= button_to t('preferences.generate_new_token'), refresh_token_user_path(current_user), + :confirm => t('preferences.generate_new_token_confirm') %> +
+
+

<%= t('preferences.authentication_header') %>

+
+ <% if Tracks::Config.auth_schemes.length > 1 %> +

<%= t('preferences.current_authentication_type', :auth_type => "#{current_user.auth_type}") %>.

+
+ <%= link_to(t('preferences.change_authentication_type') + " »", change_auth_type_user_path(current_user), :class => 'edit_link') %> +
+ <% end %> + <% if current_user.auth_type == 'database' %> +
+ <%= link_to(t('preferences.change_password') + ' »', change_password_user_path(current_user)) %> +
+ <% end %> + <% if current_user.auth_type == 'open_id' %> +

<%= t('preferences.open_id_url') %> <%= current_user.open_id_url %>.

+
+ <%= link_to(t('preferences.change_identity_url') + ' »', change_auth_type_user_path(current_user)) %> +
+ <% end %> +
+
diff --git a/config/environment.rb b/config/environment.rb index bb4e50fc..3be292b1 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -70,7 +70,7 @@ Rails::Initializer.run do |config| # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de - + # See Rails::Configuration for more options if ( SITE_CONFIG['authentication_schemes'].include? 'cas') #requires rubycas-client gem to be installed diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 71ba9e5e..044397e3 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -641,6 +641,12 @@ var UsersPage = { } } +var PreferencesPage = { + setup_behavior: function() { + $( "#tabs" ).tabs(); + } +} + var ProjectListPage = { update_state_count: function(state, count) { $('#'+state+'-projects-count').html(count); @@ -1238,7 +1244,7 @@ $(document).ready(function() { TodoItemsContainer.setup_container_toggles(); /* enable page specific behavior */ - $([ 'IntegrationsPage', 'NotesPage', 'ProjectListPage', 'ContextListPage', + $([ 'PreferencesPage', 'IntegrationsPage', 'NotesPage', 'ProjectListPage', 'ContextListPage', 'FeedsPage', 'RecurringTodosPage', 'TodoItems', 'TracksPages', 'TracksForm', 'SearchPage', 'UsersPage' ]).each(function() { eval(this+'.setup_behavior();');