Add antenna setting error view

This commit is contained in:
KMY 2023-05-24 12:55:31 +09:00
parent 29cf3b83bf
commit aa430a96b4
5 changed files with 8 additions and 2 deletions
app
config/locales

View file

@ -220,7 +220,7 @@ class Antenna < ApplicationRecord
private
def validate_limit
errors.add(:base, I18n.t('scheduled_statuses.over_total_limit', limit: LIMIT)) if account.antennas.count >= LIMIT
errors.add(:base, I18n.t('antennas.errors.over_limit', limit: LIMIT)) if account.antennas.count >= LIMIT
end
def validate_stl_limit
@ -228,6 +228,6 @@ class Antenna < ApplicationRecord
stls = account.antennas.where(stl: true).where.not(id: id)
errors.add(:base, I18n.t('scheduled_statuses.over_total_limit', limit: LIMIT)) if list_id.zero? ? stls.any? { |tl| tl.list_id.zero? } : stls.any? { |tl| tl.list_id != 0 }
errors.add(:base, I18n.t('antennas.errors.over_stl_limit', limit: 1)) if list_id.zero? ? stls.any? { |tl| tl.list_id.zero? } : stls.any? { |tl| tl.list_id != 0 }
end
end

View file

@ -2,6 +2,7 @@
= t('antennas.edit.title')
= simple_form_for @antenna, url: antenna_path(@antenna), method: :put do |f|
= render 'shared/error_messages', object: @antenna
= render 'antenna_fields', f: f, lists: @lists
.actions

View file

@ -2,6 +2,7 @@
= t('antennas.new.title')
= simple_form_for @antenna, url: antennas_path do |f|
= render 'shared/error_messages', object: @antenna
= render 'antenna_fields', f: f, lists: @lists
.actions

View file

@ -1032,6 +1032,8 @@ en:
empty_contexts: No contexts! You must set any context filters
invalid_context: None or invalid context supplied
invalid_list_owner: This list is not yours
over_limit: You have exceeded the limit of %{limit} antennas
over_stl_limit: You have exceeded the limit of %{limit} stl antennas
remove_list_with_antenna: Cannot remove list because this list is related to antenna.
index:
contexts: Antennas in %{contexts}

View file

@ -999,6 +999,8 @@ ja:
errors:
empty_contexts: 絞り込み条件が1つも指定されていないため無効です除外条件はカウントされません
invalid_list_owner: これはあなたのリストではありません
over_limit: 所持できるアンテナ数 %{limit}を超えています
over_stl_limit: 所持できるSTLモード付きアンテナ数 (ホーム/リストそれぞれにつき%{limit}) を超えています
remove_list_with_antenna: アンテナが関連付けられているリストは削除できません
edit:
accounts_hint: ローカルアカウントの場合は「@info」、リモートアカウントの場合は「@info@example.com」の形式で指定します。サーバーが認識していないアカウントは保存時に自動的に削除されます。