diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 8189629..821c147 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -48,6 +48,7 @@ */ @import "pages/news"; +@import "pages/categories"; @import "pages/contests"; @import "pages/forums"; @import "pages/teams"; diff --git a/app/assets/stylesheets/pages/_categories.scss b/app/assets/stylesheets/pages/_categories.scss new file mode 100644 index 0000000..af41e0d --- /dev/null +++ b/app/assets/stylesheets/pages/_categories.scss @@ -0,0 +1,18 @@ +/* + Categories List +*/ + +.categories { + + table.categories { + + .actions { + width: 20%; + text-align: right; + + i { + margin-left: em(5); + } + } + } +} \ No newline at end of file diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 9b4afbc..0fc8be0 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -30,6 +30,8 @@ class CategoriesController < ApplicationController @category.update_attribute :sort, @category.id flash[:notice] = t(:articles_category) redirect_to :categories + else + render action: :new end end diff --git a/app/views/categories/edit.html.erb b/app/views/categories/edit.html.erb index 6cfdf34..b3a31f9 100644 --- a/app/views/categories/edit.html.erb +++ b/app/views/categories/edit.html.erb @@ -1,21 +1,14 @@ -

Editing category

+

Editing Category

-<%= form_for @category do |f| %> -
- -
+<%= form_for @category, html: { class: 'square' } do |f| %> + <%= render 'shared/errors', messages: @category.errors.full_messages %> -

- <%= f.label :name %>
+

+ <%= f.label :name %> <%= f.text_field :name %> -

-

- <%= f.submit 'Update' %> -

+
+ +
+ <%= f.submit 'Update Category' %> +
<% end %> - -<%= link_to 'Back', categories_path %> \ No newline at end of file diff --git a/app/views/categories/index.html.erb b/app/views/categories/index.html.erb index 83e4b1f..f580ee4 100644 --- a/app/views/categories/index.html.erb +++ b/app/views/categories/index.html.erb @@ -1,29 +1,30 @@ -

Listing categories

+
+

Listing Categories

-<% Category.new.domains.each do |key, domain| %> -

- <%= h domain %> -

+ <% Category.new.domains.each do |key, domain| %> +

<%=h domain %>

- - - - - - <% @categories.each do |category| %> - <% if category.domain == key %> - - - - +
NameOptions
<%= h category.name %> - <%= link_to 'Edit', edit_category_path(category) %> - <%= link_to 'Up', :controller => :categories, :action => "up", :id => category.id %> - <%= link_to 'Down', :controller => :categories, :action => "down", :id => category.id %> - <%= link_to 'Delete', category, :confirm => 'Are you sure?', :method => :delete %> -
+ + + + + <% @categories.each do |category| %> + <% if category.domain == key %> + + + + + <% end %> <% end %> - <% end %> -
Name
<%=h category.name %> + <%= link_to icon('chevron-up'), controller: :categories, action: "up", id: category.id %> + <%= link_to icon('chevron-down'), controller: :categories, action: "down", id: category.id %> + <%= link_to icon('pencil'), edit_category_path(category) %> + <%= link_to icon('times'), category, :confirm => 'Are you sure?', :method => :delete %> +
-<% end %> + + <% end %> -<%= link_to 'New category', new_category_path %> \ No newline at end of file + <%= link_to 'New Category', new_category_path, class: 'button' %> +
+ \ No newline at end of file diff --git a/app/views/categories/new.html.erb b/app/views/categories/new.html.erb index f37f2c0..0ec56ff 100644 --- a/app/views/categories/new.html.erb +++ b/app/views/categories/new.html.erb @@ -1,27 +1,17 @@

New Category

-
- <%= form_for(@category) do |f| %> -
- -
+<%= form_for(@category, html: { class: 'square' }) do |f| %> + <%= render 'shared/errors', messages: @category.errors.full_messages %> -

- <%= f.label :name %>
- <%= f.text_field :name %> -

-

- <%= f.label :domain %>
- <%= f.select :domain, @category.domains.invert %> -

-

- <%= f.submit 'Create' %> -

- <% end %> -
- -<%= link_to 'Back', categories_path %> +
+ <%= f.label :name %> + <%= f.text_field :name %> +
+
+ <%= f.label :domain %> + <%= f.select :domain, @category.domains.invert %> +
+
+ <%= f.submit 'Create Category' %> +
+<% end %>