add cause release fields
This commit is contained in:
parent
b7ee6a1b25
commit
44410fa375
|
@ -23,4 +23,14 @@
|
||||||
<label>{{i18n 'discourse_donations.cause.maintainers.setting_label'}}</label>
|
<label>{{i18n 'discourse_donations.cause.maintainers.setting_label'}}</label>
|
||||||
{{input value=category.custom_fields.donations_maintainers_label}}
|
{{input value=category.custom_fields.donations_maintainers_label}}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section class='field'>
|
||||||
|
<label>{{i18n 'discourse_donations.cause.release_latest.label'}}</label>
|
||||||
|
{{input value=category.custom_fields.donations_release_latest}}
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class='field'>
|
||||||
|
<label>{{i18n 'discourse_donations.cause.release_oldest.label'}}</label>
|
||||||
|
{{input value=category.custom_fields.donations_release_oldest}}
|
||||||
|
</section>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { createWidget } from 'discourse/widgets/widget';
|
||||||
import { h } from 'virtual-dom';
|
import { h } from 'virtual-dom';
|
||||||
import { avatarFor } from 'discourse/widgets/post';
|
import { avatarFor } from 'discourse/widgets/post';
|
||||||
import { userPath } from "discourse/lib/url";
|
import { userPath } from "discourse/lib/url";
|
||||||
|
import { iconNode } from "discourse-common/lib/icon-library";
|
||||||
|
|
||||||
function donationDisplay(amount, type) {
|
function donationDisplay(amount, type) {
|
||||||
return h(`div.donations-${type}`, [
|
return h(`div.donations-${type}`, [
|
||||||
|
@ -68,6 +69,44 @@ createWidget('category-header-widget', {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (category.donations_release_oldest) {
|
||||||
|
let releaseArray = category.donations_release_oldest.split('/');
|
||||||
|
let label = releaseArray[releaseArray.length - 1];
|
||||||
|
metadata.push(
|
||||||
|
h('div.donations-release-oldest', [
|
||||||
|
h('span', '>'),
|
||||||
|
this.attach('link', {
|
||||||
|
href: category.donations_release_oldest,
|
||||||
|
icon: 'tag',
|
||||||
|
rawLabel: label,
|
||||||
|
omitSpan: true,
|
||||||
|
attributes: {
|
||||||
|
target: '_blank'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (category.donations_release_latest) {
|
||||||
|
let releaseArray = category.donations_release_latest.split('/');
|
||||||
|
let label = releaseArray[releaseArray.length - 1];
|
||||||
|
metadata.push(
|
||||||
|
h('div.donations-release-latest', [
|
||||||
|
h('span', '<'),
|
||||||
|
this.attach('link', {
|
||||||
|
href: category.donations_release_latest,
|
||||||
|
icon: 'tag',
|
||||||
|
rawLabel: label,
|
||||||
|
omitSpan: true,
|
||||||
|
attributes: {
|
||||||
|
target: '_blank'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (metadata.length) {
|
if (metadata.length) {
|
||||||
contents.push(h('div.donations-category-metadata', metadata));
|
contents.push(h('div.donations-category-metadata', metadata));
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ div.stripe-errors {
|
||||||
}
|
}
|
||||||
|
|
||||||
.donations-category-metadata {
|
.donations-category-metadata {
|
||||||
width: 500px;
|
max-width: 700px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding-bottom: 20px;
|
padding-bottom: 20px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -166,6 +166,15 @@ div.stripe-errors {
|
||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.donations-release-latest, .donations-release-oldest {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
span:first-of-type {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.donations-category-users {
|
.donations-category-users {
|
||||||
|
|
|
@ -58,6 +58,10 @@ en:
|
||||||
setting_label: "Maintainers label"
|
setting_label: "Maintainers label"
|
||||||
amounts:
|
amounts:
|
||||||
setting_label: "Show donation amounts"
|
setting_label: "Show donation amounts"
|
||||||
|
release_latest:
|
||||||
|
label: "Latest Release Supported"
|
||||||
|
release_oldest:
|
||||||
|
label: "Oldest Release Supported"
|
||||||
subscription:
|
subscription:
|
||||||
cancel:
|
cancel:
|
||||||
title: "Cancel Recurring Donation"
|
title: "Cancel Recurring Donation"
|
||||||
|
|
22
plugin.rb
22
plugin.rb
|
@ -113,6 +113,22 @@ after_initialize do
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def donations_release_latest
|
||||||
|
if custom_fields['donations_release_latest']
|
||||||
|
custom_fields['donations_release_latest']
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def donations_release_oldest
|
||||||
|
if custom_fields['donations_release_oldest']
|
||||||
|
custom_fields['donations_release_oldest']
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -124,7 +140,9 @@ after_initialize do
|
||||||
'donations_maintainers',
|
'donations_maintainers',
|
||||||
'donations_maintainers_label',
|
'donations_maintainers_label',
|
||||||
'donations_github',
|
'donations_github',
|
||||||
'donations_meta'
|
'donations_meta',
|
||||||
|
'donations_release_latest',
|
||||||
|
'donations_release_oldest'
|
||||||
].each do |key|
|
].each do |key|
|
||||||
Site.preloaded_category_custom_fields << key if Site.respond_to? :preloaded_category_custom_fields
|
Site.preloaded_category_custom_fields << key if Site.respond_to? :preloaded_category_custom_fields
|
||||||
end
|
end
|
||||||
|
@ -145,6 +163,8 @@ after_initialize do
|
||||||
add_to_serializer(:basic_category, :include_donations_maintainers_label?) { object.donations_maintainers_label.present? }
|
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_github) { object.donations_github }
|
||||||
add_to_serializer(:basic_category, :donations_meta) { object.donations_meta }
|
add_to_serializer(:basic_category, :donations_meta) { object.donations_meta }
|
||||||
|
add_to_serializer(:basic_category, :donations_release_latest) { object.donations_release_latest }
|
||||||
|
add_to_serializer(:basic_category, :donations_release_oldest) { object.donations_release_oldest }
|
||||||
|
|
||||||
DiscourseEvent.trigger(:donations_ready)
|
DiscourseEvent.trigger(:donations_ready)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue