Skip to content

Commit b6aa7ab

Browse files
committed
refactor(communities): Allow hiding custom fields on About page.
1 parent b193eab commit b6aa7ab

4 files changed

Lines changed: 55 additions & 20 deletions

File tree

site/kcworks/config/custom_fields.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
{
161161
"section": "Linked Commons Group",
162162
"hidden": False,
163+
"show_on_about": False,
163164
"description": "Information about a Commons group that owns the collection",
164165
"fields": [
165166
{

templates/semantic-ui/invenio_communities/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
{%- block css %}
1717
{{ super() }}
1818
{% if community %}
19-
<link rel="stylesheet" type="text/css" href="/collections/{{community.slug}}/community-theme-{{ community.revision_id }}.css">
19+
<link rel="stylesheet" type="text/css" href="/communities/{{ community.slug }}/community-theme-{{ community.revision_id }}.css">
2020
{% endif %}
2121
{%- endblock css %}
Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,74 @@
1+
{%- if theme.mainHeaderBackgroundColor %}
12
.page-subheader-outer {
2-
background-color: {{ theme.mainHeaderBackgroundColor }} !important;
3+
background-color: {{ theme.mainHeaderBackgroundColor }} !important;
34
}
5+
{%- endif %}
46

7+
{%- if theme.secondaryColor or theme.secondaryTextColor %}
58
.theme-secondary, .ui.secondary.button {
6-
background-color: {{ theme.secondaryColor }} !important;
7-
color: {{ theme.secondaryTextColor }} !important;
9+
{% if theme.secondaryColor %}background-color: {{ theme.secondaryColor }} !important;{% endif %}
10+
{% if theme.secondaryTextColor %}color: {{ theme.secondaryTextColor }} !important;{% endif %}
811
}
912

1013
.invenio-page-body .ui.search.button {
11-
background-color: {{ theme.secondaryColor }} !important;
12-
color: {{ theme.secondaryTextColor }} !important;
14+
{% if theme.secondaryColor %}background-color: {{ theme.secondaryColor }} !important;{% endif %}
15+
{% if theme.secondaryTextColor %}color: {{ theme.secondaryTextColor }} !important;{% endif %}
1316
}
17+
{%- endif %}
1418

19+
{%- if theme.primaryTextColor %}
1520
.theme-primary a, .theme-primary h1, .theme-primary h2, .theme-primary p {
1621
color: {{ theme.primaryTextColor }} !important;
1722
}
23+
{%- endif %}
1824

25+
{%- if theme.secondaryColor %}
1926
.theme-primary.pointing.menu .item.active {
2027
border-color: {{ theme.secondaryColor }} !important;
2128
}
29+
{%- endif %}
2230

31+
{%- if theme.primaryColor %}
2332
.theme-primary-menu .item.active {
2433
background-color: {{ theme.primaryColor }} !important;
2534
}
35+
{%- endif %}
2636

27-
.theme-primary .item, .theme-primary-menu, .page-subheader-outer{
28-
font-family: {{ theme.font.family }} !important;
29-
font-weight: {{ theme.font.weight }} !important;
30-
font-size: {{ theme.font.size }};
37+
{%- if theme.font.family or theme.font.weight or theme.font.size %}
38+
.theme-primary .item, .theme-primary-menu, .page-subheader-outer {
39+
{% if theme.font.family %}font-family: {{ theme.font.family }} !important;{% endif %}
40+
{% if theme.font.weight %}font-weight: {{ theme.font.weight }} !important;{% endif %}
41+
{% if theme.font.size %}font-size: {{ theme.font.size }};{% endif %}
3142
}
43+
{%- endif %}
3244

45+
{%- if theme.primaryColor %}
3346
.theme-primary {
3447
background-color: {{ theme.primaryColor }} !important;
3548
}
3649

37-
.theme-primary-text a {
50+
.theme-primary-text a,
51+
.theme-primary-text h1 {
3852
color: {{ theme.primaryColor }} !important;
3953
}
54+
{%- endif %}
4055

56+
{%- if theme.tertiaryColor or theme.tertiaryTextColor %}
4157
.theme-tertiary, .ui.tertiary.button {
42-
background-color: {{ theme.tertiaryColor }} !important;
43-
color: {{ theme.tertiaryTextColor }};
58+
{% if theme.tertiaryColor %}background-color: {{ theme.tertiaryColor }} !important;{% endif %}
59+
{% if theme.tertiaryTextColor %}color: {{ theme.tertiaryTextColor }};{% endif %}
4460
}
61+
{%- endif %}
4562

46-
.invenio-accordion-field .title, .ui.primary.button{
47-
background-color: {{ theme.primaryColor }} !important;
48-
color: {{ theme.primaryTextColor }} !important;
63+
{%- if theme.primaryColor or theme.primaryTextColor %}
64+
.invenio-accordion-field .title, .ui.primary.button {
65+
{% if theme.primaryColor %}background-color: {{ theme.primaryColor }} !important;{% endif %}
66+
{% if theme.primaryTextColor %}color: {{ theme.primaryTextColor }} !important;{% endif %}
4967
}
68+
{%- endif %}
5069

70+
{%- if theme.font.weight %}
5171
.theme-font h1 {
52-
font-weight: {{theme.font.weight}} !important;
53-
}
72+
font-weight: {{ theme.font.weight }} !important;
73+
}
74+
{%- endif %}

templates/semantic-ui/invenio_communities/details/about/index.html

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,26 @@ <h3 class="ui header">{{ _("Awards") }}</h3>
6565
</div>
6666
{% endif %}
6767

68+
{# Custom-fields sections and fields may set `show_on_about: False` in
69+
`COMMUNITIES_CUSTOM_FIELDS_UI` to be excluded from this page while
70+
still appearing in the community settings form. The default is True. #}
6871
{% set custom_fields = community.ui.custom_fields %}
69-
{% for section_cfg in custom_fields_ui if custom_fields %}
72+
{% for section_cfg in custom_fields_ui
73+
if custom_fields and section_cfg.get("show_on_about", True) %}
7074
{% set section_fields = section_cfg.fields %}
75+
{% set ns = namespace(any_visible=false) %}
76+
{% for field_cfg in section_fields %}
77+
{% if custom_fields.get(field_cfg.field)
78+
and field_cfg.get("show_on_about", True) %}
79+
{% set ns.any_visible = true %}
80+
{% endif %}
81+
{% endfor %}
7182

83+
{% if ns.any_visible %}
7284
<div class="communities-detail-about-section communities-detail-custom-fields-section">
7385
<h3>{{ section_cfg.section }}</h3>
7486

75-
{% for field_cfg in section_fields %}
87+
{% for field_cfg in section_fields if field_cfg.get("show_on_about", True) %}
7688
{% set field_value = custom_fields.get(field_cfg.field) %}
7789
{% if field_value and field_cfg.template %}
7890
{% include field_cfg.template %}
@@ -83,6 +95,7 @@ <h3>{{ section_cfg.section }}</h3>
8395
{% endfor %}
8496

8597
</div>
98+
{% endif %}
8699

87100
{%- endfor %}
88101
</div>

0 commit comments

Comments
 (0)