Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Category creation on Content creation page (UJS way). Induced som…
…e refactorisation in Categories views and model
- Loading branch information
Showing
8 changed files
with
120 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
<%= error_messages_for 'category' %> | ||
<div> | ||
<h2><label for="category_name"><%= _("Name")%></label> </h2> | ||
<p class='input_text_title'> | ||
<%= text_field :category, :name, :class => 'medium' %> | ||
</p> | ||
</div> | ||
<div> | ||
<h3><label for="category_keywords" class="content block"><%= _("Keywords") %></label></h3> | ||
<p class='input_text_title'> | ||
<%= text_field :category, :keywords, :class => 'medium' %> | ||
</p> | ||
</div> | ||
<div> | ||
<h3><label for="category_description" class="content block"><%= _("Description") %></label></h3> | ||
<p class='input_text_title'> | ||
<%= text_area :category, :description, :rows => 5, :class => 'medium' %> | ||
</p> | ||
</div> | ||
<%= form_tag :action=>"edit", :id => @category.id do %> | ||
<%= error_messages_for 'category' %> | ||
<div> | ||
<h2><label for="category_name"><%= _("Name")%></label> </h2> | ||
<p class='input_text_title'> | ||
<%= text_field :category, :name, :class => 'medium' %> | ||
</p> | ||
</div> | ||
<div> | ||
<h3><label for="category_keywords" class="content block"><%= _("Keywords") %></label></h3> | ||
<p class='input_text_title'> | ||
<%= text_field :category, :keywords, :class => 'medium' %> | ||
</p> | ||
</div> | ||
<div> | ||
<h3><label for="category_description" class="content block"><%= _("Description") %></label></h3> | ||
<p class='input_text_title'> | ||
<%= text_area :category, :description, :rows => 5, :class => 'medium' %> | ||
</p> | ||
</div> | ||
<%= cancel_or_save %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<div class="top-layer"> | ||
<div class="concrete"> | ||
<h1><%= _("%s Category", controller.action_name.capitalize) %></h1> | ||
<%= render 'form' %> | ||
</div> | ||
<script type="text/javascript"> | ||
<!-- Rewrite cancel link to close that form --> | ||
$$('.concrete a').each(function(cancel_link) { | ||
cancel_link.observe('click', function(event) { | ||
$$('.top-layer').each(function(layer) { layer.remove(); }); | ||
event.stop(); | ||
}); | ||
<!-- Ok, it's just for Mister Perfect --> | ||
cancel_link.writeAttribute('href', '#close_form'); | ||
<!-- Intercepts form submission --> | ||
$$('.concrete form').each(function(cat_form) { | ||
cat_form.observe('submit', function(event) { | ||
cat_form.request({ | ||
method: 'post', | ||
onSuccess: function(transport) { | ||
$$('.top-layer').each(function(layer) { layer.remove(); }); | ||
var response = transport.responseText; | ||
var categories = $('categories'); | ||
categories.replace(response); | ||
$$('#article_form .new_category').each(function(cat_link){ cat_link.observe('click', bind_new_category_overlay); }); | ||
} | ||
}); | ||
event.stop(); | ||
}); | ||
}); | ||
}); | ||
</script> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class='widget-content' id="categories"> | ||
<%- article_categories = @article ? @article.categories.map(&:id) : [] -%> | ||
<%- Category.all.each do |cat| %> | ||
<%= check_box_tag('categories[]', cat.id, (@article.categories.map(&:id).include? cat.id), :id => "category_#{h(cat.id)}") %> | ||
<%= label_tag "category_#{h(cat.id)}", h(cat.name) %><br /> | ||
<% end -%> | ||
<%= link_to _("New Category"), {:controller => 'admin/categories', :action => 'new' }, :class => 'new_category' %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters