Add meta link

This commit is contained in:
Angus McLeod 2018-09-22 17:48:38 +10:00
parent d58c04a592
commit b4fd0287ed
5 changed files with 40 additions and 1 deletions

View File

@ -4,6 +4,11 @@
{{text-field value=category.custom_fields.donations_github placeholderKey="discourse_donations.cause.github.setting_placeholder"}} {{text-field value=category.custom_fields.donations_github placeholderKey="discourse_donations.cause.github.setting_placeholder"}}
</section> </section>
<section class='field'>
<label>{{i18n 'discourse_donations.cause.meta.setting_label'}}</label>
{{text-field value=category.custom_fields.donations_meta placeholderKey="discourse_donations.cause.meta.setting_placeholder"}}
</section>
<section class='field'> <section class='field'>
<label>{{i18n 'discourse_donations.cause.maintainers.label'}}</label> <label>{{i18n 'discourse_donations.cause.maintainers.label'}}</label>
{{user-selector usernames=category.custom_fields.donations_maintainers}} {{user-selector usernames=category.custom_fields.donations_maintainers}}

View File

@ -33,6 +33,15 @@ createWidget('category-header-widget', {
icon: 'github', icon: 'github',
label: 'discourse_donations.cause.github.label', label: 'discourse_donations.cause.github.label',
href: category.donations_github href: category.donations_github
})),
h('div.donations-meta', this.attach('link', {
href: category.donations_meta,
contents: () => {
return [
h('img.meta-icon', { attributes: { src: 'https://discourse-meta.s3.dualstack.us-west-1.amazonaws.com/original/3X/b/1/b19ba793155a785bbd9707bc0cabbd3a987fa126.png?v=6' }}),
h('span', I18n.t('discourse_donations.cause.meta.label'))
];
}
})) }))
]) ])
]; ];

View File

@ -142,9 +142,21 @@ div.stripe-errors {
margin-right: 5px; margin-right: 5px;
} }
.donations-github a { .donations-github a, .donations-meta a {
color: inherit; color: inherit;
} }
.donations-meta {
.widget-link {
display: flex;
align-items: center;
}
img {
width: 17px;
height: 17px;
margin-right: 4px;
}
}
} }
.donations-category-users { .donations-category-users {

View File

@ -48,6 +48,10 @@ en:
label: "Repository" label: "Repository"
setting_label: "Github" setting_label: "Github"
setting_placeholder: "repoistory url" setting_placeholder: "repoistory url"
meta:
label: "Discussion"
setting_label: "Meta"
setting_placeholder: "topic url"
maintainers: maintainers:
label: "Maintainers" label: "Maintainers"
subscription: subscription:

View File

@ -83,6 +83,14 @@ after_initialize do
'' ''
end end
end end
def donations_meta
if custom_fields['donations_meta']
custom_fields['donations_meta']
else
''
end
end
end end
if SiteSetting.discourse_donations_cause_category if SiteSetting.discourse_donations_cause_category
@ -96,6 +104,7 @@ after_initialize do
ActiveModel::ArraySerializer.new(object.donations_maintainers, each_serializer: BasicUserSerializer).as_json 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_github) { object.donations_github }
add_to_serializer(:basic_category, :donations_meta) { object.donations_meta }
end end
DiscourseEvent.trigger(:donations_ready) DiscourseEvent.trigger(:donations_ready)