Create tabs for ban modal

This commit is contained in:
Karina Kwiatek 2022-07-02 12:03:07 +02:00 committed by Karina Kwiatek
parent 1f3681ef50
commit a0877b102a
4 changed files with 40 additions and 19 deletions

View file

@ -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

View file

@ -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'

View file

@ -0,0 +1 @@
Ban history here.

View file

@ -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 <strong>%{reason}</strong>"
banned_temporarily_html: "This user is currently banned until <strong>%{until}</strong> for <strong>%{reason}</strong>"
banned_by_html: "This ban was instated by <strong>%{user}</strong> on <strong>%{on}</strong>"
unban: "Unban"
services:
index:
title: "Service Settings"