mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-17 12:48:08 +01:00
replace old prototype/jrails code for periodic checks and start work on autocomplete and edit projects
Signed-off-by: Reinier Balt <lrbalt@gmail.com>
This commit is contained in:
parent
69c811e365
commit
c834403340
24 changed files with 588 additions and 53 deletions
|
|
@ -136,7 +136,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
def for_autocomplete(coll, substr)
|
||||
filtered = coll.find_all{|item| item.name.downcase.include? substr.downcase}
|
||||
return filtered.map {|item| "#{item.name}|#{item.id}"}.join("\n")
|
||||
return "[{" + filtered.map {|item| "\"value\"=\"#{item.name}\", \"id\"=\"#{item.id}\""}.join("},{") + "}]"
|
||||
end
|
||||
|
||||
# Uses RedCloth to transform text using either Textile or Markdown Need to
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class ContextsController < ApplicationController
|
|||
format.rss &render_contexts_rss_feed
|
||||
format.atom &render_contexts_atom_feed
|
||||
format.text { render :action => 'index', :layout => false, :content_type => Mime::TEXT }
|
||||
format.autocomplete { render :text => for_autocomplete(@active_contexts + @hidden_contexts, params[:q])}
|
||||
format.autocomplete { render :text => for_autocomplete(@active_contexts + @hidden_contexts, params[:term])}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -86,12 +86,17 @@ class LoginController < ApplicationController
|
|||
return unless should_expire_sessions?
|
||||
# Get expiry time (allow ten seconds window for the case where we have none)
|
||||
expiry_time = session['expiry_time'] || Time.now + 10
|
||||
<<<<<<< HEAD
|
||||
@time_left = expiry_time - Time.now
|
||||
if @time_left < (10*60) # Session will time out before the next check
|
||||
@msg = 'login.session_time_out'
|
||||
else
|
||||
@msg = ""
|
||||
end
|
||||
=======
|
||||
time_left = expiry_time - Time.now
|
||||
@session_expired = ( time_left < (10*60) ) # Session will time out before the next check
|
||||
>>>>>>> replace old prototype/jrails code for periodic checks and start work on autocomplete and edit projects
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<%= stylesheet_link_tag 'standard','superfish','niftyCorners', 'jquery-ui-1.8.5.custom', :cache => true %>
|
||||
<%= stylesheet_link_tag "print", :media => "print" %>
|
||||
<%= javascript_include_tag 'jquery-1.4.2.min', 'jquery-ui-1.8.5.custom.min', 'jquery.truncator', 'jquery.jeditable.mini', 'jquery.cookie', :cache => 'jquery-all' %>
|
||||
<%= javascript_include_tag 'jquery-1.4.2.min', 'jquery-ui-1.8.5.custom.min', 'jquery.truncator',
|
||||
'jquery.jeditable.mini', 'jquery.cookie', 'jquery.blockUI', :cache => 'jquery-all' %>
|
||||
<%= javascript_include_tag 'hoverIntent','superfish','application',
|
||||
'accesskey-hints','niftycube','swfobject', :cache => 'tracks' %>
|
||||
<%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %>
|
||||
|
|
@ -19,6 +20,10 @@
|
|||
<% if @prefs.refresh != 0 -%>
|
||||
setup_auto_refresh(<%= @prefs["refresh"].to_i*60000 %>);
|
||||
<% end -%>
|
||||
<% unless @controller_name == 'feed' or session['noexpiry'] == "on" -%>
|
||||
setup_periodic_check("<%=url_for(:controller => "login", :action => "check_expiry")%>", 5*60);
|
||||
<% end -%>
|
||||
setup_periodic_check("<%=check_deferred_todos_path(:format => 'js')%>", 10*60, 'POST');
|
||||
</script>
|
||||
<link rel="shortcut icon" href="<%= url_for(:controller => 'favicon.ico') %>" />
|
||||
<%= auto_discovery_link_tag(:rss, {:controller => "todos", :action => "index", :format => 'rss', :token => "#{current_user.token}"}, {:title => t('layouts.next_actions_rss_feed')}) %>
|
||||
|
|
@ -84,13 +89,6 @@
|
|||
</div>
|
||||
|
||||
<div id="content" class="<%= @controller.controller_name %>">
|
||||
<% unless @controller_name == 'feed' or session['noexpiry'] == "on" -%>
|
||||
<%= periodically_call_remote( :url => {:controller => "login", :action => "check_expiry"},
|
||||
:frequency => (5*60)) %>
|
||||
<% end -%>
|
||||
<%= periodically_call_remote( :url => check_deferred_todos_path(:format => 'js'),
|
||||
:method => :post,
|
||||
:frequency => (10*60)) %>
|
||||
<%= yield %>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
unless @msg == ""
|
||||
page.replace_html "info", content_tag("div", t(@msg, :link => link_to(t('login.log_in_again'), :controller => "login", :action => "login"), "class" => "warning"))
|
||||
if @session_expired
|
||||
page << "console.log('expired');"
|
||||
page << "$('div#navcontainer').hide();"
|
||||
page << "theHtml = \'<div class=\"warning\">" +
|
||||
t('login.session_time_out', :link => link_to(
|
||||
t('login.log_in_again'), :controller => "login", :action => "login"),
|
||||
"class" => "warning")
|
||||
page << "$('div#content').html(theHtml);"
|
||||
end
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
project = project_form
|
||||
%>
|
||||
|
||||
<% form_remote_tag(:url => project_path(project), :html => { :id => dom_id(project, 'edit_form'), :class => "inline-form "+dom_id(project, 'edit_form')+"-edit-project-form", :method => :put }) do -%>
|
||||
<%# form_remote_tag(:url => project_path(project), :html => { :id => dom_id(project, 'edit_form'), :class => "inline-form "+dom_id(project, 'edit_form')+"-edit-project-form", :method => :put }) do -%>
|
||||
<div id="error_status"><%= error_messages_for("project") %></div>
|
||||
<%= source_view_tag( @source_view ) -%>
|
||||
|
||||
|
|
@ -40,5 +40,5 @@ project = project_form
|
|||
</div>
|
||||
<br/><br/>
|
||||
|
||||
<% end -%>
|
||||
<%# end -%>
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,9 @@
|
|||
<% else -%>
|
||||
'<%= project.default_tags -%>' as the default tags.
|
||||
<% end -%>
|
||||
<%= link_to_remote(
|
||||
"Edit Project Settings",
|
||||
<a class ="project_edit_settings" id="link_edit_<%=dom_id(project)-%>" href="<%=url_for(:controller => 'projects', :action => 'edit', :id => project.id)%>">Edit Project Settings</a>
|
||||
<%#= link_to_remote(
|
||||
"",
|
||||
:url => {:controller => 'projects', :action => 'edit', :id => project.id},
|
||||
:method => 'get',
|
||||
:with => "'_source_view=#{@source_view}'",
|
||||
|
|
|
|||
11
app/views/projects/edit.js.erb
Normal file
11
app/views/projects/edit.js.erb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
newHtml = "<%= escape_javascript(render(:partial => 'project_form', :locals => { :project_form => @project })) %>"
|
||||
$('div#<%=dom_id(@project, 'edit')%>').html(newHtml);
|
||||
$('div#<%=dom_id(@project)%>').hide();
|
||||
$('div#<%=dom_id(@project, 'edit')%>').show();
|
||||
|
||||
$('input.project-name').focus();
|
||||
|
||||
<%#*page[dom_id(@project, 'edit')].replace_html :partial => 'project_form', :locals => { :project_form => @project }%>
|
||||
<%#*page[@project].hide%>
|
||||
<%#*page[dom_id(@project, 'edit')].show%>
|
||||
<%#*page[dom_id(@project, 'edit_form')].find('input.project-name').focus%>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
page[dom_id(@project, 'edit')].replace_html :partial => 'project_form', :locals => { :project_form => @project }
|
||||
page[@project].hide
|
||||
page[dom_id(@project, 'edit')].show
|
||||
page[dom_id(@project, 'edit_form')].find('input.project-name').focus
|
||||
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
<label for="todo_context_name"><%= Todo.human_attribute_name('context') %></label>
|
||||
<input id="todo_context_name" name="context_name" autocomplete="off" tabindex="4" size="30" type="text" value="<%= @initial_context_name %>" />
|
||||
<div class="page_name_auto_complete" id="context_list" style="display:none"></div>
|
||||
|
||||
<label for="tag_list"><%= Todo.human_attribute_name('tags') + ' (' + t('shared.separate_tags_with_commas') + ')' %></label>
|
||||
<%= text_field_tag "tag_list", @default_tags, :size => 30, :tabindex => 5 %>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue