mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +01:00
first pass to distribute settings over tabs
This commit is contained in:
parent
3bf8c461f1
commit
977b57dbb2
5 changed files with 167 additions and 66 deletions
|
|
@ -1,2 +1,18 @@
|
|||
module PreferencesHelper
|
||||
|
||||
def pref(model, pref_name, &block)
|
||||
s = "<label for #{model+pref_name}>#{Preference.human_attribute_name(pref_name)}:</label><br/>"
|
||||
s << yield
|
||||
s << "<br/><br/>"
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,68 +1,79 @@
|
|||
<div id="single_box" class="container context prefscontainer">
|
||||
|
||||
<h2><%= t('preferences.title') %></h2>
|
||||
|
||||
<ul id="prefs">
|
||||
<li><%= User.human_attribute_name('first_name') %>: <span class="highlight"><%= current_user.first_name %></span></li>
|
||||
<li><%= User.human_attribute_name('last_name') %>: <span class="highlight"><%= current_user.last_name %></span></li>
|
||||
<li><%= Preference.human_attribute_name('date_format') %>: <span class="highlight"><%= current_user.prefs.date_format %></span> Your current date: <%= format_date(current_user.time) %></li>
|
||||
<li><%= Preference.human_attribute_name('locale') %>: <span class="highlight"><%= current_user.prefs.locale %></span></li>
|
||||
<li><%= Preference.human_attribute_name('title_date_format') %>: <span class="highlight"><%= current_user.prefs.title_date_format %></span> Your current title date: <%= current_user.time.strftime(current_user.prefs.title_date_format) %></li>
|
||||
<li><%= Preference.human_attribute_name('time_zone') %>: <span class="highlight"><%= current_user.prefs.time_zone %></span> Your current time: <%= current_user.time.strftime('%I:%M %p') %></li>
|
||||
<li><%= Preference.human_attribute_name('week_starts') %>: <span class="highlight"><%= t('date.day_names')[current_user.prefs.week_starts] %></span></li>
|
||||
<li><%= t('preferences.show_number_completed', :number=> "<span class=\"highlight\">#{current_user.prefs.show_number_completed}</span>")%></li>
|
||||
<li><%= Preference.human_attribute_name('show_completed_projects_in_sidebar') %>: <span class="highlight"><%= current_user.prefs.show_completed_projects_in_sidebar %></span></li>
|
||||
<li><%= Preference.human_attribute_name('show_hidden_projects_in_sidebar') %>: <span class="highlight"><%= current_user.prefs.show_hidden_projects_in_sidebar %></span></li>
|
||||
<li><%= Preference.human_attribute_name('show_hidden_contexts_in_sidebar') %>: <span class="highlight"><%= current_user.prefs.show_hidden_contexts_in_sidebar %></span></li>
|
||||
<li><%= Preference.human_attribute_name('show_project_on_todo_done') %>: <span class="highlight"><%= current_user.prefs.show_project_on_todo_done %></span></li>
|
||||
<li><%= t('preferences.staleness_starts_after', :days => "<span class=\"highlight\">#{current_user.prefs.staleness_starts}</span>") %></li>
|
||||
<li><%= Preference.human_attribute_name('due_style') %>: <span class="highlight">
|
||||
<% 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 %>
|
||||
</span></li>
|
||||
<% if current_user.is_admin? %>
|
||||
<li><%= Preference.human_attribute_name('admin_email') %>: <span class="highlight"><%= current_user.prefs.admin_email %></span></li>
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<li><a href="#tabs-1">Profile</a></li>
|
||||
<li><a href="#tabs-2">Authentication</a></li>
|
||||
<li><a href="#tabs-3">Date and time</a></li>
|
||||
<li><a href="#tabs-4">Tracks behavior</a></li>
|
||||
</ul>
|
||||
<div id="tabs-1">
|
||||
<h2>Profile</h2>
|
||||
<% form_tag :action => 'update' do %>
|
||||
<%= pref_with_text_field 'user', 'first_name' %>
|
||||
<%= pref_with_text_field 'user', 'last_name' %>
|
||||
<%= pref_with_select_field('prefs', 'locale', I18n.available_locales.map {|l| l.to_s}) %>
|
||||
<% if current_user.is_admin? %> <%= pref_with_text_field('prefs', 'admin_email') %> <% end %>
|
||||
<% end %>
|
||||
<li><%= Preference.human_attribute_name('refresh') %>: <span class="highlight"><%= current_user.prefs.refresh %></span></li>
|
||||
<li><%= Preference.human_attribute_name('verbose_action_descriptors') %>: <span class="highlight"><%= current_user.prefs.verbose_action_descriptors %></span></li>
|
||||
<li><%= Preference.human_attribute_name('mobile_todos_per_page') %>: <span class="highlight"><%= current_user.prefs.mobile_todos_per_page %></span></li>
|
||||
<li><%= Preference.human_attribute_name('sms_email') %>: <span class="highlight"><%= current_user.prefs.sms_email %></span></li>
|
||||
<li><%= Preference.human_attribute_name('sms_context') %>: <span class="highlight"><%= current_user.prefs.sms_context.nil? ? t('preferences.sms_context_none') : current_user.prefs.sms_context.name %></span></li>
|
||||
</ul>
|
||||
<div class="actions">
|
||||
<%= link_to t('preferences.edit_preferences') + " »", { :controller => 'preferences', :action => 'edit'}, :class => 'edit_link' %>
|
||||
</div>
|
||||
|
||||
<h2><%= t('preferences.token_header') %></h2>
|
||||
<div id="token_area">
|
||||
<div class="description"><%= t('preferences.token_description') %>:</div>
|
||||
<div id="token"><span class="highlight"><%= current_user.token %></span></div>
|
||||
<div class="token_regenerate">
|
||||
<%= button_to t('preferences.generate_new_token'), refresh_token_user_path(current_user),
|
||||
:confirm => t('preferences.generate_new_token_confirm') %>
|
||||
</div>
|
||||
</div>
|
||||
<h2><%= t('preferences.authentication_header') %></h2>
|
||||
<div id="authentication_area">
|
||||
<% if Tracks::Config.auth_schemes.length > 1 %>
|
||||
<p><%= t('preferences.current_authentication_type', :auth_type => "<span class=\"highlight\">#{current_user.auth_type}</span>") %>.</p>
|
||||
<div class="actions">
|
||||
<%= link_to(t('preferences.change_authentication_type') + " »", change_auth_type_user_path(current_user), :class => 'edit_link') %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if current_user.auth_type == 'database' %>
|
||||
<div class="actions">
|
||||
<%= link_to(t('preferences.change_password') + ' »', change_password_user_path(current_user)) %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if current_user.auth_type == 'open_id' %>
|
||||
<p><%= t('preferences.open_id_url') %> <span class="highlight"><%= current_user.open_id_url %></span>.</p>
|
||||
<div class="actions">
|
||||
<%= link_to(t('preferences.change_identity_url') + ' »', change_auth_type_user_path(current_user)) %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div id="tabs-2">
|
||||
<h2>Authentication</h2>
|
||||
|
||||
<br/>
|
||||
|
||||
<label><%= t('preferences.token_header') %></label><br/>
|
||||
<%= t('preferences.token_description') %>: <span class="highlight"><%= current_user.token %></span>
|
||||
<%= button_to t('preferences.generate_new_token'), refresh_token_user_path(current_user),
|
||||
:confirm => t('preferences.generate_new_token_confirm') %>
|
||||
|
||||
<br/>
|
||||
|
||||
<label><%= t('preferences.authentication_header') %></label><br/>
|
||||
<% if Tracks::Config.auth_schemes.length > 1 %>
|
||||
<% form_tag :action => 'update_auth_type' do %>
|
||||
|
||||
<label for="user_auth_type"><%= t('users.label_auth_type') %>:</label><br/>
|
||||
<% Tracks::Config.auth_schemes.each do |scheme| %>
|
||||
<%= radio_button_tag('user[auth_type]', scheme, current_user.auth_type == scheme) %><%=scheme%> <br/>
|
||||
<% end %>
|
||||
|
||||
<div id="open_id" style="display:<%= current_user.auth_type == 'open_id' ? 'block' : 'none' %>">
|
||||
<label for="openid_url"><%= t('users.identity_url') %>:</label><br/>
|
||||
<input type="text" name="openid_url" value="<%= current_user.open_id_url %>" class="open_id" />
|
||||
</div>
|
||||
<%= 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' %>
|
||||
<p><%= t('preferences.open_id_url') %> <span class="highlight"><%= current_user.open_id_url %></span>.</p>
|
||||
<%= link_to(t('preferences.change_identity_url') + ' »', change_auth_type_user_path(current_user)) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div id="tabs-3">
|
||||
<h2>Date and time</h2>
|
||||
<%= 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] }) %>
|
||||
|
||||
</div>
|
||||
<div id="tabs-4">
|
||||
<h2>Tracks behavior</h2>
|
||||
<%= 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]}) } %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
68
app/views/preferences/oldindex.html.erb
Normal file
68
app/views/preferences/oldindex.html.erb
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<div id="single_box" class="container context prefscontainer">
|
||||
|
||||
<h2><%= t('preferences.title') %></h2>
|
||||
|
||||
<ul id="prefs">
|
||||
<li><%= User.human_attribute_name('first_name') %>: <span class="highlight"><%= current_user.first_name %></span></li>
|
||||
<li><%= User.human_attribute_name('last_name') %>: <span class="highlight"><%= current_user.last_name %></span></li>
|
||||
<li><%= Preference.human_attribute_name('date_format') %>: <span class="highlight"><%= current_user.prefs.date_format %></span> Your current date: <%= format_date(current_user.time) %></li>
|
||||
<li><%= Preference.human_attribute_name('locale') %>: <span class="highlight"><%= current_user.prefs.locale %></span></li>
|
||||
<li><%= Preference.human_attribute_name('title_date_format') %>: <span class="highlight"><%= current_user.prefs.title_date_format %></span> Your current title date: <%= current_user.time.strftime(current_user.prefs.title_date_format) %></li>
|
||||
<li><%= Preference.human_attribute_name('time_zone') %>: <span class="highlight"><%= current_user.prefs.time_zone %></span> Your current time: <%= current_user.time.strftime('%I:%M %p') %></li>
|
||||
<li><%= Preference.human_attribute_name('week_starts') %>: <span class="highlight"><%= t('date.day_names')[current_user.prefs.week_starts] %></span></li>
|
||||
<li><%= t('preferences.show_number_completed', :number=> "<span class=\"highlight\">#{current_user.prefs.show_number_completed}</span>")%></li>
|
||||
<li><%= Preference.human_attribute_name('show_completed_projects_in_sidebar') %>: <span class="highlight"><%= current_user.prefs.show_completed_projects_in_sidebar %></span></li>
|
||||
<li><%= Preference.human_attribute_name('show_hidden_projects_in_sidebar') %>: <span class="highlight"><%= current_user.prefs.show_hidden_projects_in_sidebar %></span></li>
|
||||
<li><%= Preference.human_attribute_name('show_hidden_contexts_in_sidebar') %>: <span class="highlight"><%= current_user.prefs.show_hidden_contexts_in_sidebar %></span></li>
|
||||
<li><%= Preference.human_attribute_name('show_project_on_todo_done') %>: <span class="highlight"><%= current_user.prefs.show_project_on_todo_done %></span></li>
|
||||
<li><%= t('preferences.staleness_starts_after', :days => "<span class=\"highlight\">#{current_user.prefs.staleness_starts}</span>") %></li>
|
||||
<li><%= Preference.human_attribute_name('due_style') %>: <span class="highlight">
|
||||
<% 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 %>
|
||||
</span></li>
|
||||
<% if current_user.is_admin? %>
|
||||
<li><%= Preference.human_attribute_name('admin_email') %>: <span class="highlight"><%= current_user.prefs.admin_email %></span></li>
|
||||
<% end %>
|
||||
<li><%= Preference.human_attribute_name('refresh') %>: <span class="highlight"><%= current_user.prefs.refresh %></span></li>
|
||||
<li><%= Preference.human_attribute_name('verbose_action_descriptors') %>: <span class="highlight"><%= current_user.prefs.verbose_action_descriptors %></span></li>
|
||||
<li><%= Preference.human_attribute_name('mobile_todos_per_page') %>: <span class="highlight"><%= current_user.prefs.mobile_todos_per_page %></span></li>
|
||||
<li><%= Preference.human_attribute_name('sms_email') %>: <span class="highlight"><%= current_user.prefs.sms_email %></span></li>
|
||||
<li><%= Preference.human_attribute_name('sms_context') %>: <span class="highlight"><%= current_user.prefs.sms_context.nil? ? t('preferences.sms_context_none') : current_user.prefs.sms_context.name %></span></li>
|
||||
</ul>
|
||||
<div class="actions">
|
||||
<%= link_to t('preferences.edit_preferences') + " »", { :controller => 'preferences', :action => 'edit'}, :class => 'edit_link' %>
|
||||
</div>
|
||||
|
||||
<h2><%= t('preferences.token_header') %></h2>
|
||||
<div id="token_area">
|
||||
<div class="description"><%= t('preferences.token_description') %>:</div>
|
||||
<div id="token"><span class="highlight"><%= current_user.token %></span></div>
|
||||
<div class="token_regenerate">
|
||||
<%= button_to t('preferences.generate_new_token'), refresh_token_user_path(current_user),
|
||||
:confirm => t('preferences.generate_new_token_confirm') %>
|
||||
</div>
|
||||
</div>
|
||||
<h2><%= t('preferences.authentication_header') %></h2>
|
||||
<div id="authentication_area">
|
||||
<% if Tracks::Config.auth_schemes.length > 1 %>
|
||||
<p><%= t('preferences.current_authentication_type', :auth_type => "<span class=\"highlight\">#{current_user.auth_type}</span>") %>.</p>
|
||||
<div class="actions">
|
||||
<%= link_to(t('preferences.change_authentication_type') + " »", change_auth_type_user_path(current_user), :class => 'edit_link') %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if current_user.auth_type == 'database' %>
|
||||
<div class="actions">
|
||||
<%= link_to(t('preferences.change_password') + ' »', change_password_user_path(current_user)) %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if current_user.auth_type == 'open_id' %>
|
||||
<p><%= t('preferences.open_id_url') %> <span class="highlight"><%= current_user.open_id_url %></span>.</p>
|
||||
<div class="actions">
|
||||
<%= link_to(t('preferences.change_identity_url') + ' »', change_auth_type_user_path(current_user)) %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue