diff --git a/app/assets/javascripts/admin/addon/controllers/admin-badges-show.js b/app/assets/javascripts/admin/addon/controllers/admin-badges-show.js index 23341f0d27e..3653af5fb1d 100644 --- a/app/assets/javascripts/admin/addon/controllers/admin-badges-show.js +++ b/app/assets/javascripts/admin/addon/controllers/admin-badges-show.js @@ -56,6 +56,11 @@ export default Controller.extend(bufferedProperty("model"), { return modelQuery && modelQuery.trim().length > 0; }, + @discourseComputed("model.i18n_name") + textCustomizationPrefix(i18n_name) { + return `badges.${i18n_name}.`; + }, + @observes("model.id") _resetSaving: function () { this.set("saving", false); diff --git a/app/assets/javascripts/admin/addon/templates/badges-show.hbs b/app/assets/javascripts/admin/addon/templates/badges-show.hbs index 49741c8bc66..82057b103c1 100644 --- a/app/assets/javascripts/admin/addon/templates/badges-show.hbs +++ b/app/assets/javascripts/admin/addon/templates/badges-show.hbs @@ -4,6 +4,11 @@ {{#if readOnly}} {{input type="text" name="name" value=buffered.name disabled=true}} +

+ {{#link-to "adminSiteText.edit" (concat textCustomizationPrefix "name")}} + {{i18n "admin.badges.read_only_setting_help"}} + {{/link-to}} +

{{else}} {{input type="text" name="name" value=buffered.name}} {{/if}} @@ -64,6 +69,11 @@ {{#if buffered.system}} {{textarea name="description" value=buffered.description disabled=true}} +

+ {{#link-to "adminSiteText.edit" (concat textCustomizationPrefix "description")}} + {{i18n "admin.badges.read_only_setting_help"}} + {{/link-to}} +

{{else}} {{textarea name="description" value=buffered.description}} {{/if}} @@ -73,6 +83,11 @@ {{#if buffered.system}} {{textarea name="long_description" value=buffered.long_description disabled=true}} +

+ {{#link-to "adminSiteText.edit" (concat textCustomizationPrefix "long_description")}} + {{i18n "admin.badges.read_only_setting_help"}} + {{/link-to}} +

{{else}} {{textarea name="long_description" value=buffered.long_description}} {{/if}} diff --git a/app/models/badge.rb b/app/models/badge.rb index 92e02a50a9d..fc89d8d253c 100644 --- a/app/models/badge.rb +++ b/app/models/badge.rb @@ -289,15 +289,15 @@ class Badge < ActiveRecord::Base query.blank? && !system? end + def i18n_name + @i18n_name ||= self.class.i18n_name(name) + end + protected def ensure_not_system self.id = [Badge.maximum(:id) + 1, 100].max unless id end - - def i18n_name - @i18n_name ||= self.class.i18n_name(name) - end end # == Schema Information diff --git a/app/serializers/admin_badge_serializer.rb b/app/serializers/admin_badge_serializer.rb index 15f354ef5a4..fc75706c594 100644 --- a/app/serializers/admin_badge_serializer.rb +++ b/app/serializers/admin_badge_serializer.rb @@ -1,9 +1,13 @@ # frozen_string_literal: true class AdminBadgeSerializer < BadgeSerializer - attributes :query, :trigger, :target_posts, :auto_revoke, :show_posts + attributes :query, :trigger, :target_posts, :auto_revoke, :show_posts, :i18n_name def include_long_description? true end + + def include_i18n_name? + object.system? + end end diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index b1fcd40bc91..7297a38a12c 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -4889,6 +4889,7 @@ en: image: Image icon_help: "Enter a Font Awesome icon name (use prefix 'far-' for regular icons and 'fab-' for brand icons)" image_help: "Enter the URL of the image (overrides icon field if both are set)" + read_only_setting_help: "Customize text" query: Badge Query (SQL) target_posts: Query targets posts auto_revoke: Run revocation query daily