Skip to content

Commit

Permalink
WIP autosave
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Lecavelier committed Oct 16, 2013
1 parent 532d323 commit 44f2a3a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
13 changes: 3 additions & 10 deletions app/controllers/admin/content_controller.rb
Expand Up @@ -108,18 +108,11 @@ def autosave
end

if @article.save
render(:update) do |page|
page.replace_html('autosave', hidden_field_tag('article[id]', @article.id))
page.replace_html('preview_link', link_to(_("Preview"), {:controller => '/articles', :action => 'preview', :id => @article.id}, {:target => 'new', :class => 'btn info'}))
page.replace_html('destroy_link', link_to_destroy_draft(@article))
if params[:article][:published_at] and params[:article][:published_at].to_time.to_i < Time.now.to_time.to_i and @article.parent_id.nil?
page.replace_html('publish', calendar_date_select('article', 'published_at', {:class => 'span7'})) if @article.state.to_s.downcase == "draft"
end
@must_update_calendar = (params[:article][:published_at] and params[:article][:published_at].to_time.to_i < Time.now.to_time.to_i and @article.parent_id.nil?)
respond_to do |format|
format.js
end

return true
end
render :text => nil
end

protected
Expand Down
3 changes: 2 additions & 1 deletion app/views/admin/content/_form.html.erb
Expand Up @@ -202,7 +202,8 @@
<%= text_field 'article', 'keywords', {:autocomplete => 'off', :class => 'input-block-level'} %>
<p class='alert alert-warning'><%=t(".tags_explaination") %></p>
</div>
<%= auto_complete_field 'article_keywords', { :url => { :action => "auto_complete_for_article_keywords"}, :method => 'get', :tokens => ','}%>
<%#= auto_complete_field 'article_keywords', { :url => { :action => "auto_complete_for_article_keywords"}, :method => 'get', :tokens => ','}%>

</div>
<%= get_post_types %>
</div>
4 changes: 4 additions & 0 deletions app/views/admin/content/autosave.js.erb
@@ -0,0 +1,4 @@
$('#autosave').replaceWith('<%= hidden_field_tag('articles[id]', @article.id %>')
$('#preview_link').replaceWith('<%= url_for({:controller => '/articles', :action => 'preview', :id => @article.id}, {:target => 'new', :class => 'btn info'}) %>')
$('#destroy_link').replaceWith('<%= link_to_destroy_draft(@article) %>')
$('#publish').replaceWith('<%= calendar_date_select('article', 'published_at', {:class => 'span7'}) %>')

0 comments on commit 44f2a3a

Please sign in to comment.