Skip to content

Commit

Permalink
Merge branch 'release/0.2.14'
Browse files Browse the repository at this point in the history
* release/0.2.14:
  #115 some fixes for articles
  • Loading branch information
kalashnikovisme committed Jun 22, 2015
2 parents cb8c60f + 507d654 commit 528be95
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/web/foundation/main_navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
display: block !important;
z-index: 5;
top: -10px;
width: 1024px;
width: 270px;
background: $topbar-bg-color;
padding: 0 rem-calc(30) rem-calc(30);
.menu-title {
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/web/admin/articles_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
class Web::Admin::ArticlesController < Web::Admin::ApplicationController
def index
@articles = Kaminari.paginate_array(Article.presented.decorate).page params[:page]
@articles = {}
@articles[:confirmed] = Kaminari.paginate_array(Article.confirmed.decorate).page params[:page]
@articles[:inactive] = Kaminari.paginate_array(Article.inactive.decorate).page params[:page]
@articles[:unviewed] = Kaminari.paginate_array(Article.unviewed.decorate).page params[:page]
@tag = Tag.new
end

Expand Down
5 changes: 4 additions & 1 deletion app/scopes/article_scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ module ArticleScopes

included do
scope :removed, -> { where state: :removed }
scope :presented, -> { where.not(state: :removed).order('id ASC')}
scope :presented, -> { where.not(state: :removed).order('id DESC')}
scope :confirmed, -> { where(state: :confirmed).order('id DESC') }
scope :inactive, -> { where(state: :inactive).order('id DESC') }
scope :unviewed, -> { where(state: :unviewed).order('id DESC') }
end
end
2 changes: 1 addition & 1 deletion app/views/layouts/web/shared/_navbar.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@
.category-column
.menu-title
= @first_category.name
- @first_category.articles.each do |article|
- @first_category.articles.confirmed.each do |article|
= link_to article.title, article_path(article)
2 changes: 1 addition & 1 deletion app/views/web/admin/articles/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
= simple_form_for [:admin, @article_form], input_html: { class: 'form-horizontal' } do |f|
= f.input :title, as: :string
= f.input :body, as: :ckeditor
= f.input :state, as: :hidden, input_html: { value: :confirmed }
= f.input :state_event, as: :state_event
= f.input :view
= f.association :category, collection: @categories, prompt: t('helpers.links.select'), label: t(model_class.human_attribute_name :category_id)
= f.association :attachments
Expand Down
12 changes: 10 additions & 2 deletions app/views/web/admin/articles/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
- model_class = Article
- tabs = [ :confirmed, :inactive, :unviewed ]
- title model_class.model_name.human.pluralize(:ru), :admin
.page-header
%h1
=t model_class.model_name.human.pluralize(:ru)
= link_to "#{t 'helpers.links.new'}", new_admin_article_path, class: 'btn btn-primary'
= render 'articles_list', articles: @articles
= link_to "#{t 'helpers.links.new'}", new_admin_article_path, class: 'btn btn-primary'
#tabs
%ul.nav.nav-tabs{ role: :tablist }
- tabs.each do |tab|
%li
= link_to tab_title(model_class, tab, @articles[tab].total_count), "##{tab}"
- tabs.each do |tab|
%div{ id: tab }
= render 'articles_list', articles: @articles[tab]
= link_to t('.new', default: t('helpers.links.new')), new_admin_article_path, class: 'btn btn-primary'
7 changes: 7 additions & 0 deletions config/locales/ru/models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ ru:
unviewed: Новые
confirmed: Подтверждённые
declined: Отклонённые
article:
state:
states:
unviewed: Новые
confirmed: Подтверждённые
inactive: Неактивные
removed: Удалённые
errors:
models:
member:
Expand Down

0 comments on commit 528be95

Please sign in to comment.