Skip to content

Commit 91019c9

Browse files
IPogorelovaEvanBrightside
authored andcommitted
Bugfix/adminos 253 admin system design edits (Molinos#33)
* edit layout and styles of admin system pages and Adminos Blog * add Back button for log page, add arrow-icon layout for sorting tables order * fix bug with deleted actiontext repo * Article view and controller updated for ordering * edit layout and styles of admin system pages and Adminos Blog * add Back button for log page, add arrow-icon layout for sorting tables order * fix bug with deleted actiontext repo * Article view and controller updated for ordering * ActionText repo actualized * Translations fixed * Exlude self from parent list * Show tags in aricles * delete unused comments
1 parent f0ff032 commit 91019c9

30 files changed

+286
-104
lines changed

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
8585
gem 'mobility'
8686
gem 'mobility-ransack', '~> 0.2.2'
8787
gem 'adminos', github: 'Molinos/adminos'
88-
# gem 'adminos'
8988
gem 'role_model' # from adminos
9089
gem 'webpacker', '~> 3.5' # from adminos
9190
gem 'actiontext', github: 'rails/actiontext', require: 'action_text', ref: 'cfe4674d3637c746cdb3c2b5131e2de498775529' # from adminos
@@ -107,3 +106,4 @@ group :lint do
107106
gem 'rubocop-rails' # from adminos
108107
end
109108
gem 'devise-two-factor' # from adminos
109+
gem 'inline_svg'

Gemfile.lock

+4
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ GEM
211211
image_processing (1.9.0)
212212
mini_magick (>= 4.9.3, < 5)
213213
ruby-vips (>= 2.0.13, < 3)
214+
inline_svg (1.5.2)
215+
activesupport (>= 3.0)
216+
nokogiri (>= 1.6)
214217
jaro_winkler (1.5.3)
215218
jbuilder (2.9.1)
216219
activesupport (>= 4.2.0)
@@ -529,6 +532,7 @@ DEPENDENCIES
529532
guard
530533
guard-livereload (~> 2.5)
531534
image_processing (~> 1.2)
535+
inline_svg
532536
jbuilder (~> 2.5)
533537
listen (>= 3.0.5, < 3.2)
534538
mini_magick

app/assets/images/nav-arrow-blue.svg

+1
Loading

app/controllers/admin/articles_controller.rb

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ class Admin::ArticlesController < Admin::BaseController
1414
def collection
1515
@collection ||= collection_orig.search_for(params[:query])
1616
.page(params[:page]).per(settings.per_page)
17+
.order("#{params[:order_by]} #{params[:direction]}")
1718
end
1819
end

app/helpers/application_helper.rb

+10
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,14 @@ def google_authenticator_qrcode(devise_resource)
77
url = "https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl=#{escaped_data}"
88
image_tag(url, alt: 'Google Authenticator QRCode')
99
end
10+
11+
def company_name
12+
settings.company_name
13+
end
14+
15+
private
16+
17+
def settings
18+
Settings.get
19+
end
1020
end

app/helpers/versions_helper.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module VersionsHelper
22
def version_item(object)
33
case object.item_type
44
when 'Settings'
5-
name = 'Настройки'
5+
name = t('admin.settings.actions.index.header')
66
link = :settings
77
when 'User'
88
name = object.item.email
@@ -14,9 +14,9 @@ def version_item(object)
1414

1515
def version_event(object)
1616
if version_login? object
17-
'Логин'
17+
t('labels.admin.login')
1818
elsif version_registration? object
19-
'Регистрация'
19+
t('labels.admin.sign_up')
2020
else
2121
t "admin.actions.#{object.event}"
2222
end

app/inputs/carrierwave_input.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def input(wrapper_options = nil)
77
out << %{<div class="f-file">}
88
out << @builder.hidden_field("#{attribute_name}_cache")
99
out << %{ <label class="f-file__selection js-file">}
10-
out << %{ <span class="f-file__button">Выбрать</span>}
10+
out << %{ <span class="f-file__button">#{I18n.t('labels.admin.choose')}</span>}
1111
out << @builder.file_field(attribute_name, input_html_options)
1212
out << %{ <span class="f-file__selected"></span>}
1313
out << %{ </label>}
@@ -25,7 +25,7 @@ def remove_field
2525
out << @builder.input_field("remove_#{attribute_name}", as: :boolean)
2626
out << %{ <label class="f-check">}
2727
out << %{ <span class="f-check__box"></span>}
28-
out << %{ <span class="f-check__label">Удалить</span>}
28+
out << %{ <span class="f-check__label">#{I18n.t('labels.admin.destroy')}</span>}
2929
out << %{ </label>}
3030
out << %{</div>}
3131
out.join

app/inputs/checkbox_input.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def input(wrapper_options = nil)
55
out << %{ <label class="f-check" for="#{object_name}_#{attribute_name}">}
66
out << @builder.input_field("#{attribute_name}", as: :boolean)
77
out << %{ <span class="f-check__box"></span>}
8-
out << %{ <span class="f-check__label">Опубликовано</span>}
8+
out << %{ <span class="f-check__label">#{I18n.t('labels.admin.published')}</span>}
99
out << %{ </label>}
1010
out << %{</div>}
1111
out.join.html_safe

app/inputs/cropp_input.rb

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
class CroppInput < SimpleForm::Inputs::Base
2+
def input(wrapper_options = nil)
3+
@version = input_html_options.delete(:version) || :default
4+
@coord_attribute = input_html_options.delete(:coord_attribute) || object.send("#{@version}_#{attribute_name}_attr_coord")
5+
6+
out = []
7+
out << %{<div class="f-file">}
8+
out << %{ <label class="f-file__selection js-file">}
9+
out << %{ <span class="f-file__button">#{I18n.t('labels.admin.choose')}</span>}
10+
out << @builder.file_field(attribute_name, input_html_options)
11+
out << @builder.hidden_field(@coord_attribute)
12+
out << %{ <span class="f-file__selected"></span>}
13+
out << %{ </label>}
14+
out << %{</div>}
15+
out << preview
16+
17+
out.join.html_safe
18+
end
19+
20+
def preview
21+
return unless object.send(attribute_name).attached?
22+
out = []
23+
24+
aspect_ratio = input_html_options.delete(:aspect_ratio) || '16/9'
25+
aspect_ratio = aspect_ratio.split('/').map(&:to_f)
26+
aspect_ratio = aspect_ratio[0] / aspect_ratio[1]
27+
28+
out << %{<div class="row"><div class="col-md-8"><div class="img-container">}
29+
30+
out << template.image_tag(object.send(attribute_name), data: { aspect_ratio: aspect_ratio, preview: ".#{@version}_#{attribute_name}_preview", toggle: 'cropp', coord: @coord_attribute })
31+
32+
out << %{</div></div><div class="col-md-4">}
33+
out << %{<div class="cropper-dimensions">}
34+
out << %{<div class="field">}
35+
out << template.label_tag(:width, I18n.t('labels.admin.image.width'), class: 'control-label')
36+
out << template.number_field_tag(:width, nil, class: 'form-control')
37+
out << %{</div>}
38+
out << %{<div class="field">}
39+
40+
out << template.label_tag(:height, I18n.t('labels.admin.image.height'), class: 'control-label')
41+
out << template.number_field_tag(:height, nil, class: 'form-control')
42+
out << %{</div>}
43+
44+
out << %{</div>}
45+
out << %{<div class="docs-preview clearfix">}
46+
out << %{<p class="figure-caption">#{I18n.t('labels.admin.image.cropped_current')}</p>}
47+
out << %{<div class="img-preview preview-lg #{@version}_#{attribute_name}_preview"></div>}
48+
out << cropped
49+
50+
out << %{</div></div></div>}
51+
out.join
52+
end
53+
54+
def cropped
55+
return if @coord_attribute.blank?
56+
57+
out = []
58+
out << %{<div class="preview-cropped"><figure class="figure">}
59+
60+
out << %{<figcaption class="figure-caption">#{I18n.t('labels.admin.image.cropped_saved')}</figcaption>}
61+
62+
out << template.image_tag(object.send("#{@version}_#{attribute_name}_cropped"))
63+
64+
out << %{</figure></div>}
65+
out.join
66+
end
67+
end

app/javascript/packs/application.js

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
importAll(require.context('../client/img/'));
1111

12-
import "actiontext"
1312
import 'jquery';
1413
import 'adminos/src/js/railsujs.js'
1514
import '../client/css/main.scss'

app/services/export_xlsx.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ def call
1313

1414
def generate_xlsx
1515
headers = [
16-
'Объект',
17-
'Тип',
18-
'Событие',
19-
'Пользователь',
20-
'Дата',
21-
'Изменения'
16+
I18n.t('activerecord.attributes.paper_trail/version.item'),
17+
I18n.t('activerecord.attributes.paper_trail/version.item_type'),
18+
I18n.t('activerecord.attributes.paper_trail/version.event'),
19+
I18n.t('activerecord.attributes.paper_trail/version.whodunnit'),
20+
I18n.t('attributes.created_at'),
21+
I18n.t('admin.paper_trail/version.labels.changes')
2222
]
2323

2424
data = @versions.map do |x|

app/views/admin/articles/_general_fields.slim

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22
= f.input :slug
33
= f.input :published, wrapper: :check
44

5-
.f__fieldset
6-
= f.input :cover, as: :cropp, input_html: { aspect_ratio: '1/5' }
75
.f__fieldset
86
= f.input :cover, as: :cropp, input_html: { coord_attribute: :cover_mobile_coord, version: :mobile, aspect_ratio: '5/2' }
97

108
.f__fieldset
119
= f.input :publish_at
12-
= f.input :tags, as: :select, input_html: { class: 'select2it', multiple: true }
10+
= f.input :tags
1311
= f.association :user, label_method: :email, wrapper: :select, input_html: { class: 'select2it' }
1412

1513
.response-sidebar
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
- if objects.present?
2+
- if controller.respond_to?(:sort)
3+
- if objects.respond_to?(:apply_sortable_order)
4+
- sort = {class: 'with-apply-sortable-order', data: {sortable: url_for(action: :sort)}}
5+
- if objects.first.respond_to?(:move_to)
6+
- sort = {class: 'with-move-to'}
7+
- pagination = capture do
8+
- if collection.respond_to?(:current_page)
9+
= paginate collection, theme: :admin
10+
11+
- attrs = sort || {}
12+
13+
= pagination
14+
.table-list
15+
table.table.table-hover.table-sm
16+
th.table-header_sort colspan=3
17+
= admin_sortable_column :created_at, resource_class.human_attribute_name(:created_at)
18+
i.icon-more-arrow
19+
= inline_svg('nav-arrow-blue.svg')
20+
21+
tbody *attrs
22+
- objects.each do |object|
23+
= render partial: 'object', object: object
24+
= pagination

app/views/admin/base/_form.slim

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
- max_depth = f.object.class.const_get('MAX_DEPTH') rescue 0
1616
- if f.object.respond_to?(:parent) && max_depth > 1
1717
- f.object.parent_id = params[:parent_id] if action_name == 'new'
18-
= f.association :parent, wrapper: :select, input_html: { class: 'select2it' }
18+
= f.association :parent, collection: resource.class.where.not(id: resource.id), wrapper: :select, input_html: { class: 'select2it' }
1919

2020
= render 'fields', f: f
2121

2222
.f-submit.f-submit--fixed
2323
.wrapper
24-
= f.button :submit, 'Сохранить', class: 'btn btn-primary btn--done'
24+
= f.button :submit, t('labels.admin.save'), class: 'btn btn-primary btn--done'
2525
/resource_button_value_main
2626
/= f.button :submit, 'Применить', type: 'button', name: 'stay_in_place', class: 'btn btn-secondary js-save-form'
27-
= f.button :submit, 'Применить', name: 'stay_in_place', class: 'btn btn-secondary'
27+
= f.button :submit, t('labels.admin.apply'), name: 'stay_in_place', class: 'btn btn-secondary'
2828
/resource_button_value_stay
2929
/= link_to resource_button_value_cancel,
3030
polymorphic_path([:admin, resource.class.name.underscore.pluralize]),

app/views/admin/helps/index.slim

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
= admin_page_header I18n.t('admin.helps.actions.index.header')
44
h4 Общие замечания по&nbsp;добавлению и&nbsp;редактированию информации:
55
ul
6-
li Везде, где можно добавить ту&nbsp;или иную сущность (например, страницу), <b>в правой верхней части страницы есть кнопка «добавить»</b>.
7-
li Некоторые типы записей могут быть <b>опубликованы</b> (и&nbsp;будут отображаться на&nbsp;сайте) и&nbsp;<b>заархивированы</b> (сохранятся в&nbsp;базе, их&nbsp;можно редактировать, но&nbsp;они не&nbsp;будут опубликованы на&nbsp;сайте). <b>Состояние опубликованной записи обозначается пиктограммой <i class="icon-eye-open"></i> в&nbsp;правой части списка</b> (отсутствие пиктограммы обозначает&nbsp;то, что запись заархивирована).
8-
li В&nbsp; некоторых списках есть возможность <b>ручной сортировки записей</b> (порядок отображения на&nbsp;сайте и&nbsp;в&nbsp;списках). Иногда требуется вывести какую-то запись раньше предыдущей. Это справедливо, например, для списка страниц. <b>Чтобы переместить запись выше или ниже, достаточно просто перетащить её&nbsp;в&nbsp;нужное место указателем мыши</b> (предварительно нажав левую кнопку мыши, когда указатель находится над пиктограммой <i class="icon-move"></i>).
9-
li В&nbsp; некоторых списках предусмотрены <b>групповые операции</b>&nbsp;— публикация, архивирование и&nbsp;удаление. Чтобы выполнить групповую операцию, необходимо выбрать записи, с&nbsp;которыми будет осуществляться операция&nbsp;— это можно сделать, отметив эти записи галочками в&nbsp;чекбоксах,&nbsp;— а&nbsp;затем выбрать операцию из&nbsp;списка внизу страницы (нажать на&nbsp;соответствующую кнопку). Эти операции можно выполнять также и&nbsp;с&nbsp;отдельными объектами (то&nbsp;есть по&nbsp;одному), чтобы не&nbsp;заходить на&nbsp;страницу редактирования записи.
10-
li Если <b>редактирование записей</b> доступно, то&nbsp;в&nbsp;списке присутствует пиктограмма <i class="icon-edit"></i>. Щелчок по&nbsp;этой пиктограмме открывает страницу редактирования соответствующей записи.
11-
li Все <b>специфичные настройки страниц</b> вынесены в раздел «#{link_to I18n.t('admin.settings.actions.index.header'), edit_admin_settings_path}».
12-
li В&nbsp;случаях, где это предусмотрено оформлением страниц, текстовые поля оснащены <b>WYSIWYG-редактором</b>. Редактор имеет возможность размещения изображений и&nbsp;вставки кода для видео (embedded video) с&nbsp;сервиса YouTube.
13-
h4 Значение пиктограмм:
6+
li=t('admin.helps.hint1_html')
7+
li=t('admin.helps.hint2_html')
8+
li=t('admin.helps.hint3_html')
9+
li=t('admin.helps.hint4_html')
10+
li=t('admin.helps.hint5_html')
11+
li=t('admin.helps.hint6_html')
12+
li=t('admin.helps.hint7_html')
13+
h4 =t('admin.helps.icons_meaning')
1414
ul.legend
1515
li
1616
<i class="icon-edit"></i>

app/views/admin/profiles/_2fa.slim

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
.f__fieldset
2-
.f__legend Двухфакторная аутентификация
2+
.f__legend=t('authentication.two_factor')
33
- if resource.otp_required_for_login
44
.f
55
.f__wrapper
66
.f-field
77
.f-field__label
8-
label.f-label Ключ
8+
label.f-label=t('authentication.key')
99
.f-field__container
1010
.f-field__text =resource.otp.secret
1111
.f-field
@@ -15,10 +15,10 @@
1515
= google_authenticator_qrcode(resource)
1616
.f-field
1717
.f-field__container
18-
= link_to t('authentification.2fa_switch_off'), toggle_two_factor_admin_profile_path, method: :post, class: 'btn btn btn-primary'
18+
= link_to t('authentication.switch_off_2fa'), toggle_two_factor_admin_profile_path, method: :post, class: 'btn btn btn-primary'
1919
- else
2020
.f
2121
.f__wrapper
2222
.f-field
2323
.f-field__container
24-
= link_to t('authentification.2fa_switch_on'), toggle_two_factor_admin_profile_path, method: :post, class: 'btn btn btn-primary'
24+
= link_to t('authentication.switch_on_2fa'), toggle_two_factor_admin_profile_path, method: :post, class: 'btn btn btn-primary'

app/views/admin/profiles/edit.slim

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
- title 'Профиль'
2-
= resource_header 'Профиль'
1+
- title t('admin.profile.actions.index.header')
2+
= resource_header t('admin.profile.actions.index.header')
33

44
= simple_form_for [:admin, resource], url: admin_profile_path, wrapper: :admin, html: { method: :put } do |f|
55
.f
66
.f__wrapper
77
.f__fieldset
88
= f.input :email
9-
= f.input :password, hint: 'Оставьте пустым если не хотите изменить'
10-
= f.input :password_confirmation, hint: 'Повторите пароль'
11-
= f.input :current_password, hint: 'Введите текущий пароль'
9+
= f.input :password, hint: t('admin.profile.labels.form.do_not_change_password')
10+
= f.input :password_confirmation, hint: t('admin.profile.labels.form.repeat_password')
11+
= f.input :current_password, hint: t('admin.profile.labels.form.current_password')
1212
= render '2fa', resource: resource
1313

1414
.f

app/views/admin/settings/edit.slim

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
- title 'Настройки'
2-
= resource_header 'Настройки'
1+
- title t('admin.settings.actions.index.header')
2+
= resource_header t('admin.settings.actions.index.header')
33

44
= simple_form_for [:admin, resource], url: admin_settings_path, wrapper: :admin, html: { method: :put } do |f|
55
/.pill-content

app/views/admin/users/index.slim

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@
99

1010
- list = capture do
1111
= pagination
12+
1213
.table-list
1314
table.table.table-hover.table-sm
1415
thead
1516
tr
16-
th= admin_sortable_column :email, resource_class.human_attribute_name(:email)
17+
th
18+
= admin_sortable_column :email, resource_class.human_attribute_name(:email)
19+
i.icon-more-arrow
20+
= inline_svg('nav-arrow-blue.svg')
21+
1722
th= resource_class.human_attribute_name(:roles)
1823
th
1924
th
@@ -31,3 +36,9 @@
3136
= list
3237
- else
3338
= list
39+
40+
p
41+
= link_to t('admin.paper_trail/versions.labels.actions.save_table'),
42+
admin_users_path(format: :xlsx),
43+
target: '_blank',
44+
class: 'btn btn-primary btn-small button--top'

app/views/admin/versions/index.slim

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
= list
4242

4343
p
44-
= link_to t('versions.save_table'),
44+
= link_to t('admin.paper_trail/versions.labels.actions.save_table'),
4545
admin_versions_path(format: :xlsx),
4646
target: '_blank',
47-
class: 'btn btn-primary btn-small'
47+
class: 'btn btn-primary btn-small button--top'

app/views/admin/versions/show.slim

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
- resource_title
22
- breadcrumbs resource_name
3+
- content_for :topbar_button do
4+
.actions__item
5+
= link_to t('labels.admin.back'), admin_versions_path, class: 'actions__link actions__link--back'
36

47
= resource_header
58

69
.table-list
710
table.table.table-hover.table-sm
811
thead
912
tr
10-
th Поле
11-
th Старое значение
12-
th Новое значение
13+
th= I18n.t('admin.paper_trail/versions.labels.field')
14+
th= I18n.t('admin.paper_trail/versions.labels.old_value')
15+
th= I18n.t('admin.paper_trail/versions.labels.new_value')
1316
tbody
1417
- resource.changeset.each do |field, change|
1518
tr

0 commit comments

Comments
 (0)