diff --git a/assets/javascripts/discourse/connectors/category-custom-settings/donations_category_settings.hbs b/assets/javascripts/discourse/connectors/category-custom-settings/donations_category_settings.hbs
index 595c1a0..cb8a7c0 100644
--- a/assets/javascripts/discourse/connectors/category-custom-settings/donations_category_settings.hbs
+++ b/assets/javascripts/discourse/connectors/category-custom-settings/donations_category_settings.hbs
@@ -1,4 +1,9 @@
{{#if siteSettings.discourse_donations_cause_category}}
+
+
+ {{input type="checkbox" checked=category.custom_fields.donations_show_amounts}}
+
+
{{text-field value=category.custom_fields.donations_github placeholderKey="discourse_donations.cause.github.setting_placeholder"}}
@@ -13,4 +18,9 @@
{{user-selector usernames=category.custom_fields.donations_maintainers}}
+
+
+
+ {{input value=category.custom_fields.donations_maintainers_label}}
+
{{/if}}
diff --git a/assets/javascripts/discourse/widgets/donations-category-header-widget.js.es6 b/assets/javascripts/discourse/widgets/donations-category-header-widget.js.es6
index 5c15ad4..731378a 100644
--- a/assets/javascripts/discourse/widgets/donations-category-header-widget.js.es6
+++ b/assets/javascripts/discourse/widgets/donations-category-header-widget.js.es6
@@ -29,12 +29,14 @@ createWidget('category-header-widget', {
])
];
- let metadata = [
- donationDisplay(category.donations_total || 0, 'total')
- ];
+ let metadata = [];
- if (Discourse.SiteSettings.discourse_donations_cause_month) {
- metadata.push(donationDisplay(category.donations_month || 0, 'month'));
+ if (category.donations_show_amounts) {
+ metadata.push(donationDisplay(category.donations_total || 0, 'total'));
+
+ if (Discourse.SiteSettings.discourse_donations_cause_month) {
+ metadata.push(donationDisplay(category.donations_month || 0, 'month'));
+ }
}
if (category.donations_github) {
@@ -85,8 +87,11 @@ createWidget('category-header-widget', {
};
if (category.donations_maintainers.length) {
+ let maintainersLabel = category.donations_maintainers_label ||
+ I18n.t('discourse_donations.cause.maintainers.label');
+
users.push(h('div.donations-maintainers', [
- h('div.donations-maintainers-title', I18n.t('discourse_donations.cause.maintainers.label')),
+ h('div.donations-maintainers-title', maintainersLabel),
category.donations_maintainers.map(user => {
if (user) {
return avatarFor('medium', {
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 8fd108a..984bab2 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -55,6 +55,9 @@ en:
setting_placeholder: "topic url"
maintainers:
label: "Maintainers"
+ setting_label: "Maintainers label"
+ amounts:
+ setting_label: "Show donation amounts"
subscription:
cancel:
title: "Cancel Recurring Donation"
diff --git a/plugin.rb b/plugin.rb
index 7f16e2a..ea4bcb5 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -35,6 +35,8 @@ after_initialize do
end
end
+ Category.register_custom_field_type('donations_show_amounts', :boolean)
+
class ::Category
def donations_cause
SiteSetting.discourse_donations_causes_categories.split('|').include? self.id.to_s
@@ -48,6 +50,14 @@ after_initialize do
end
end
+ def donations_show_amounts
+ if custom_fields['donations_show_amounts'] != nil
+ custom_fields['donations_show_amounts']
+ else
+ true
+ end
+ end
+
def donations_month
if custom_fields['donations_month']
custom_fields['donations_month']
@@ -76,11 +86,19 @@ after_initialize do
end
end
+ def donations_maintainers_label
+ if custom_fields['donations_maintainers_label']
+ custom_fields['donations_maintainers_label']
+ else
+ nil
+ end
+ end
+
def donations_github
if custom_fields['donations_github']
custom_fields['donations_github']
else
- ''
+ nil
end
end
@@ -88,25 +106,26 @@ after_initialize do
if custom_fields['donations_meta']
custom_fields['donations_meta']
else
- ''
+ nil
end
end
end
- if SiteSetting.discourse_donations_cause_category
- add_to_serializer(:basic_category, :donations_cause) { object.donations_cause }
- add_to_serializer(:basic_category, :donations_total) { object.donations_total }
- add_to_serializer(:basic_category, :donations_month) { object.donations_month }
- add_to_serializer(:basic_category, :include_donations_month?) { SiteSetting.discourse_donations_cause_month }
- add_to_serializer(:basic_category, :donations_backers) {
- ActiveModel::ArraySerializer.new(object.donations_backers, each_serializer: BasicUserSerializer).as_json
- }
- add_to_serializer(:basic_category, :donations_maintainers) {
- ActiveModel::ArraySerializer.new(object.donations_maintainers, each_serializer: BasicUserSerializer).as_json
- }
- add_to_serializer(:basic_category, :donations_github) { object.donations_github }
- add_to_serializer(:basic_category, :donations_meta) { object.donations_meta }
- end
+ add_to_serializer(:basic_category, :donations_cause) { object.donations_cause }
+ add_to_serializer(:basic_category, :donations_total) { object.donations_total }
+ add_to_serializer(:basic_category, :include_donations_total?) { object.donations_show_amounts }
+ add_to_serializer(:basic_category, :donations_month) { object.donations_month }
+ add_to_serializer(:basic_category, :include_donations_month?) { object.donations_show_amounts && SiteSetting.discourse_donations_cause_month }
+ add_to_serializer(:basic_category, :donations_backers) {
+ ActiveModel::ArraySerializer.new(object.donations_backers, each_serializer: BasicUserSerializer).as_json
+ }
+ add_to_serializer(:basic_category, :donations_maintainers) {
+ ActiveModel::ArraySerializer.new(object.donations_maintainers, each_serializer: BasicUserSerializer).as_json
+ }
+ add_to_serializer(:basic_category, :donations_maintainers_label) { object.donations_maintainers_label }
+ add_to_serializer(:basic_category, :include_donations_maintainers_label?) { object.donations_maintainers_label.present? }
+ add_to_serializer(:basic_category, :donations_github) { object.donations_github }
+ add_to_serializer(:basic_category, :donations_meta) { object.donations_meta }
DiscourseEvent.trigger(:donations_ready)
end