Skip to content

Commit

Permalink
Merge branch 'release/0.4.1'
Browse files Browse the repository at this point in the history
* release/0.4.1:
  #285 add eye to password input
  fix bug with inflections
  #303 add message if no unviewed
  #304 add deputies
  • Loading branch information
kalashnikovisme committed Aug 27, 2015
2 parents 0524456 + 382954c commit eb4f2ec
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 49 deletions.
10 changes: 10 additions & 0 deletions app/assets/javascripts/application.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,20 @@ $ ->
init_datetimepickers = ->
$('.datepicker').datetimepicker()

init_eye_password_button = ->
$('a.eye').click (e) ->
e.preventDefault()
$password_input = $(@).parents('.row-fluid').first().children().children('.password_foundation').first()
if $password_input.prop('type') == 'password'
$password_input.prop('type', 'text')
else
$password_input.prop('type', 'password')

init_select2()
init_link_class()
init_blank_adding()
init_tabs()
init_eye_password_button()

$('a.add_fields').click ->
setTimeout init_datetimepickers, 500
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/web/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,7 @@ input[type=checkbox] {
margin-left: 100px;
}
}

.eye {
padding-top: 10px;
}
7 changes: 7 additions & 0 deletions app/helpers/web/admin/unviewed_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@ module Web::Admin::UnviewedHelper
def unviewed_tab_title(model_name, count)
"#{t("activerecord.models.#{model_name}").pluralize(:ru)} / #{count}"
end

# FIXME refactor
def no_any_unviewed?(unviewed)
unviewed.keys.each do |key|
return false if unviewed[key.to_s.pluralize(:en).to_sym].total_count
end
end
end
34 changes: 0 additions & 34 deletions app/inputs/date_picker_foundation_input.rb

This file was deleted.

22 changes: 22 additions & 0 deletions app/inputs/password_foundation_input.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class PasswordFoundationInput < SimpleForm::Inputs::StringInput
def input(wrapper_options)
value = object.send(attribute_name) if object.respond_to? attribute_name
input_html_options[:type] = 'password'

button = template.content_tag :div, class: 'small-1 columns input' do
template.content_tag :a, href: '#', class: 'button postfix eye', type: 'button' do
template.content_tag :span, '', class: 'fa fa-eye'
end
end
password_input = template.content_tag :div, class: 'small-11 columns input' do
super(wrapper_options)
end
template.content_tag :div, class: 'row-fluid' do
password_input + button
end
end

def input_html_classes
super.push '' # 'form-control'
end
end
26 changes: 17 additions & 9 deletions app/views/web/admin/unviewed/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
- tabs = Concerns::NotificatableItems.items
- title
#tabs
%ul.nav.nav-tabs{ role: :tablist }
- if no_any_unviewed?(@unviewed)
%h2
= t('.there_is_not_any_unviewed_record')
- else
#tabs
%ul.nav.nav-tabs{ role: :tablist }
- tabs.each do |tab|
- pluralize_tab = tab.to_s.pluralize(:en)
- total_count = @unviewed[pluralize_tab.to_sym].total_count
- if total_count > 0
%li
= link_to unviewed_tab_title(tab, total_count), "##{pluralize_tab}"
- tabs.each do |tab|
- pluralize_tab = tab.to_s.pluralize(:en)
%li
= link_to unviewed_tab_title(tab, @unviewed[pluralize_tab.to_sym].total_count), "##{pluralize_tab}"
- tabs.each do |tab|
- pluralize_tab = tab.to_s.pluralize
%div{ id: pluralize_tab }
= render "web/admin/#{pluralize_tab}/#{pluralize_tab}_list", pluralize_tab.to_sym => @unviewed[pluralize_tab.to_sym]
- pluralize_tab = tab.to_s.pluralize
- total_count = @unviewed[pluralize_tab.to_sym].total_count
- if total_count > 0
%div{ id: pluralize_tab }
= render "web/admin/#{pluralize_tab}/#{pluralize_tab}_list", pluralize_tab.to_sym => @unviewed[pluralize_tab.to_sym]
2 changes: 1 addition & 1 deletion app/views/web/users/account/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
= f.input :patronymic, as: :string
= f.input :last_name, as: :string
= f.input :email, as: :string
= f.input :password, as: :string
= f.input :password, as: :password_foundation
= f.input :motto, as: :string
= f.input :ticket, as: :string
= f.input :mobile_phone, as: :string
Expand Down
1 change: 1 addition & 0 deletions config/initializers/inflections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
inflect.plural /да$/i, 'ды'
inflect.plural /нт$/i, 'нты'
inflect.plural /ий$/i, 'ие'
inflect.plural /ментарий$/i, 'ментарии'
end
1 change: 1 addition & 0 deletions config/locales/ru/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ru:
unviewed:
index:
title: Непросмотренные
there_is_not_any_unviewed_record: Нет ни одной непросмотренной записи
trash:
name: Имя
title: Корзина
Expand Down
24 changes: 19 additions & 5 deletions lib/position_list.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module PositionList
class << self
include RussianCases
# FIXME слишком большая функция
def list
positions_structure = YAML.load_file("#{Rails.root}/lib/yaml/positions.yml").with_indifferent_access[:positions]
Expand All @@ -13,11 +14,24 @@ def list
collection = collection.visible if branch.camelize.constantize == Team
if positions.is_a? Array
positions.each do |p|
collection.each do |instance|
full_name = "#{p.mb_chars.capitalize.to_s} #{instance.decorate.full_title(:genitive)}"
unless non_existent.include? full_name
full_name = exceptions[full_name] if exceptions[full_name]
positions_list << full_name
if p.is_a? String
collection.each do |instance|
full_name = "#{p.mb_chars.capitalize.to_s} #{instance.decorate.full_title(:genitive)}"
unless non_existent.include? full_name
full_name = exceptions[full_name] if exceptions[full_name]
positions_list << full_name
end
end
elsif p.is_a? Hash
deputy_position_names = p[:deputy]
deputy_position_names.each do |name|
collection.each do |instance|
full_name = "Заместитель #{genitive(name)} #{instance.decorate.full_title(:genitive)}"
unless non_existent.include? full_name
full_name = exceptions[full_name] if exceptions[full_name]
positions_list << full_name
end
end
end
end
end
Expand Down
6 changes: 6 additions & 0 deletions lib/yaml/positions.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
positions:
activity_line:
- руководитель
- deputy:
- руководитель
team:
- руководитель
- пресс-секретарь
- deputy:
- руководитель
team/departament:
activity_line:
- куратор
Expand All @@ -12,7 +16,9 @@ positions:
- куратор
exceptions:
"Руководитель отделений": Куратор местных отделений
"Заместитель руководителя отделений": Заместитель куратора местных отделений
"Руководитель президиума": Председатель
"Заместитель руководителя президиума": Заместитель председателя
"Молодёжное информационное агентство": Молодёжного информационного агентства
non_existent:
- "Пресс-секретарь президиума"
Expand Down
1 change: 1 addition & 0 deletions lib/yaml/russian_cases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ cases:
'клуб доброго инициатора': клуба доброго инициатора
'разработчики ит-проектов миц': команды разработчиков ИТ-проектов МИЦ
'отделения': отделений
'руководитель': руководителя
dative:
'местное отделение': местном отделении
'первичная организация': первичной организации
Expand Down

0 comments on commit eb4f2ec

Please sign in to comment.