From a0877b102afce1e07715708d5d2576556a24ea6d Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 2 Jul 2022 12:03:07 +0200 Subject: [PATCH] Create tabs for ban modal --- app/views/modal/_ban.haml | 30 ++++++++++++++++-------------- app/views/modal/ban/_controls.haml | 14 ++++++++++++++ app/views/modal/ban/_history.haml | 1 + config/locales/views.en.yml | 14 +++++++++----- 4 files changed, 40 insertions(+), 19 deletions(-) create mode 100644 app/views/modal/ban/_controls.haml create mode 100644 app/views/modal/ban/_history.haml diff --git a/app/views/modal/_ban.haml b/app/views/modal/_ban.haml index f6467375..b23f5833 100644 --- a/app/views/modal/_ban.haml +++ b/app/views/modal/_ban.haml @@ -11,20 +11,22 @@ = bootstrap_form_tag(url: '/mod/ban', html: { method: :post, novalidate: :novalidate }) do |f| = f.hidden_field :user, value: user.screen_name - if current_ban.nil? - .modal-body - = f.check_box :ban, label: t('.is_banned'), checked: user.banned? - #ban-controls{ class: user.banned? ? '' : 'd-none' } - = f.check_box :permaban, label: t('.is_permanent'), checked: user.permanently_banned? - #ban-controls-time{ class: user.permanently_banned? ? 'd-none' : '' } - .form-row - = f.number_field :duration, label: '', inputmode: :numeric, required: true, wrapper: { class: 'col-md-2' } - .form-check.form-check-inline.mt-3 - - for unit in %i[hours days weeks months] - = f.radio_button :duration_unit, unit, label: unit, checked: true - = f.text_field :reason, placeholder: t('.reason') - .modal-footer - %button.btn.btn-default{ name: 'stop-time', type: :button, data: { dismiss: :modal } }= t 'views.actions.close' - = f.submit t('.hammertime'), class: 'btn btn-primary', name: 'hammer-time' + - if user.bans.count > 1 + %div{ role: :tabpanel } + %ul.nav.nav-tabs.mt-1{ role: :tablist } + %li.nav-item{ role: 'presentation' } + %a.nav-link.active{ href: '#ban-controls', aria: { controls: 'ban-controls' }, data: { toggle: :tab }, role: :tab } + = t '.tabs.controls' + %li.nav-item{ role: 'presentation' } + %a.nav-link{ href: '#ban-history', aria: { controls: 'ban-history' }, data: { toggle: :tab }, role: :tab } + = t '.tabs.history' + .tab-content + .tab-pane.active{ role: :tabpanel, id: 'ban-controls' } + = render 'modal/ban/controls', f: f, user: user + .tab-pane{ role: :tabpanel, id: 'ban-history' } + = render 'modal/ban/history', user: user + - else + = render 'modal/ban/controls', f: f, user: user - else = f.hidden_field :ban, value: '0' .modal-body diff --git a/app/views/modal/ban/_controls.haml b/app/views/modal/ban/_controls.haml new file mode 100644 index 00000000..6ebc9d90 --- /dev/null +++ b/app/views/modal/ban/_controls.haml @@ -0,0 +1,14 @@ +.modal-body + = f.check_box :ban, label: t('.is_banned'), checked: user.banned? + #ban-controls{ class: user.banned? ? '' : 'd-none' } + = f.check_box :permaban, label: t('.is_permanent'), checked: user.permanently_banned? + #ban-controls-time{ class: user.permanently_banned? ? 'd-none' : '' } + .form-row + = f.number_field :duration, label: '', inputmode: :numeric, required: true, wrapper: { class: 'col-md-2' } + .form-check.form-check-inline.mt-3 + - for unit in %i[hours days weeks months] + = f.radio_button :duration_unit, unit, label: unit, checked: true + = f.text_field :reason, placeholder: t('.reason') +.modal-footer + %button.btn.btn-default{ name: 'stop-time', type: :button, data: { dismiss: :modal } }= t 'views.actions.close' + = f.submit t('.hammertime'), class: 'btn btn-primary', name: 'hammer-time' \ No newline at end of file diff --git a/app/views/modal/ban/_history.haml b/app/views/modal/ban/_history.haml new file mode 100644 index 00000000..9e4398b8 --- /dev/null +++ b/app/views/modal/ban/_history.haml @@ -0,0 +1 @@ +Ban history here. \ No newline at end of file diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index fa1fe488..18ada9bf 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -83,14 +83,18 @@ en: title: "Save account changes" ban: title: "Ban Control Center" - reason: "Reason" - is_banned: "Ban?" - is_permanent: "Permanently?" - hammertime: "Hammer Time" - unban: "Unban" + controls: + reason: "Reason" + is_banned: "Ban?" + is_permanent: "Permanently?" + hammertime: "Hammer Time" + tabs: + controls: "Ban" + history: "History" banned_permanently_html: "This user is currently permanently banned for %{reason}" banned_temporarily_html: "This user is currently banned until %{until} for %{reason}" banned_by_html: "This ban was instated by %{user} on %{on}" + unban: "Unban" services: index: title: "Service Settings"