Skip to content

Commit b59ee3a

Browse files
committed
chore: finish admin section
1 parent afd6e2a commit b59ee3a

File tree

13 files changed

+94
-23
lines changed

13 files changed

+94
-23
lines changed

ckanext/theming/themes/bare/templates/admin/config.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@
3939
{%- endcall %}
4040

4141

42-
{% set form_id = ui.util.id() %}
43-
{%- call ui.form_block("POST", action=h.url_for('admin.reset_config'), attrs={"id": form_id}) -%}
44-
{%- endcall %}
42+
{%- with form_id = ui.util.id() -%}
43+
{{ ui.form(method="POST", action=h.url_for('admin.reset_config'), attrs={"id": form_id}) }}
44+
45+
{%- call ui.util.call(ui.confirm_modal, id=modal_id, form_id=form_id) -%}
46+
{{ _('Are you sure you want to reset the config?') }}
47+
{%- endcall %}
48+
{%- endwith %}
4549

46-
{%- call ui.util.call(ui.confirm_modal, id=modal_id, form_id=form_id) -%}
47-
{{ _('Are you sure you want to reset the config?') }}
48-
{%- endcall %}
4950

5051
{%- endblock %}
5152

ckanext/theming/themes/bare/templates/admin/trash.html

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,37 @@
11
{% extends "admin/base.html" %}
22

3+
4+
{% set titles = {
5+
"package": _('Deleted datasets'),
6+
"organization": _('Deleted organizations'),
7+
"group": _('Deleted groups'),
8+
} %}
9+
310
{%- block breadcrumb_content -%}
411
{{ super() }}
512
{{ ui.breadcrumb_item(_("Trash"), h.url_for("admin.trash")) }}
613
{%- endblock %}
714

815

916
{%- block primary_content_inner -%}
10-
{% set modal_id = ui.util.id() %}
11-
{% set form_id = ui.util.id() %}
12-
{%- call ui.form_block("POST", attrs={"id": form_id}) -%}
13-
<input type="hidden" name="action" value="all">
14-
{%- endcall %}
17+
{%- with form_id = ui.util.id(), modal_id = ui.util.id() -%}
18+
{{ ui.modal_handler(_('Purge all'), id=modal_id) }}
19+
{{ ui.form(ui.hidden_input("action", "all"), method="POST", attrs={"id": form_id}) }}
20+
{{ ui.confirm_modal(_('Are you sure you want to purge everything?'), id=modal_id, form_id=form_id) }}
21+
{%- endwith %}
1522

16-
{{ ui.modal_handler(_('Purge all'), id=modal_id) }}
23+
{%- call ui.util.call(ui.accordion_wrapper) -%}
24+
{%- for ent_type, entities in data.items() -%}
25+
{% set entities = entities|list %}
1726

18-
{%- call ui.util.call(ui.confirm_modal, id=modal_id, form_id=form_id) -%}
19-
{{ _('Are you sure you want to purge everything?') }}
20-
{%- endcall %}
27+
{%- call ui.util.call(ui.accordion_item, title=titles[ent_type]) -%}
2128

22-
{% for ent_type, entities in data.items() %}
29+
{%- with form_id = ui.util.id(), modal_id = ui.util.id() -%}
30+
{{ ui.modal_handler(_('Purge'), id=modal_id) }}
31+
{{ ui.form(ui.hidden_input("action", ent_type), method="POST", attrs={"id": form_id}) }}
32+
{{ ui.confirm_modal(_('Are you sure you want to purge everything?'), id=modal_id, form_id=form_id) }}
33+
{%- endwith %}
2334

24-
{%- call ui.util.call(ui.accordion_wrapper) -%}
25-
{%- call ui.util.call(ui.accordion_item, title=_('Deleted datasets') if ent_type == 'package' else _('Deleted organizations') if ent_type == 'organization' else _('Deleted groups'), open=true) -%}
2635
<ul>
2736
{%- for entity in entities -%}
2837
<li>
@@ -31,8 +40,8 @@
3140
{%- endfor %}
3241
</ul>
3342
{%- endcall %}
34-
{%- endcall %}
35-
{% endfor %}
43+
{% endfor %}
44+
{%- endcall %}
3645

3746

3847
{%- endblock %}

ckanext/theming/themes/bare/templates/macros/ui.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,15 @@
7676
{% set code_block = data.code_block %}
7777

7878
{% set form_block = _form.form_block %}
79+
{% set form = _form.form %}
7980
{% set form_start = _form.form_start %}
8081
{% set form_end = _form.form_end %}
8182
{% set form_errors = _form.form_errors %}
8283
{% set field_errors = _form.field_errors %}
8384
{% set form_actions = _form.form_actions %}
8485
{% set submit = _form.submit %}
8586
{% set input = _form.input %}
87+
{% set hidden_input = _form.hidden_input %}
8688
{% set checkbox = _form.checkbox %}
8789
{% set textarea = _form.textarea %}
8890
{% set markdown = _form.markdown %}

ckanext/theming/themes/bare/templates/macros/ui/feedback.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
{%- call ui.util.call(ui.modal, title=title or _("Confirm"), id=id, footer=close_button ~ confirm_button, **kwargs) -%}
6868
{{ content }}
6969
{%- endcall %}
70-
7170
{%- endmacro %}
7271

7372
{%- macro tooltip(content, tooltip) -%}

ckanext/theming/themes/bare/templates/macros/ui/form.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
{%- macro form_block(method, action, enctype, include_csrf=true) -%}
1+
{%- macro form_block() -%}
2+
{{ ui.form(caller(), *varargs, **kwargs) }}
3+
{%- endmacro %}
4+
5+
{%- macro form(content, method, action, enctype, include_csrf=true) -%}
26
{{ ui.form_start(method, action, enctype, **kwargs) }}
37
{{ h.csrf_input() if include_csrf and method|upper != "GET" }}
4-
{{ caller() }}
8+
{{ content }}
59
{{ ui.form_end() }}
610
{%- endmacro %}
711

@@ -52,6 +56,10 @@
5256
</div>
5357
{%- endmacro %}
5458

59+
{%- macro hidden_input(name, value) -%}
60+
<input {{ ui.util.attrs(kwargs) }} type="hidden" name="{{ name }}" value="{{ value }}">
61+
{%- endmacro %}
62+
5563
{% macro checkbox(name, id, label, value="on", checked=false, errors=[], required=false) %}
5664
{{ ui.input(name, id=id, label=label, value=value, type="checkbox", errors=errors, required=required, attrs={"checked": ""}, **kwargs) }}
5765
{% endmacro %}

ckanext/theming/themes/bs5/templates/macros/ui.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@
7979

8080
{# Form macros #}
8181
{% set form_block = _form.form_block %}
82+
{% set form = _form.form %}
8283
{% set form_start = _form.form_start %}
8384
{% set form_end = _form.form_end %}
8485
{% set form_errors = _form.form_errors %}
8586
{% set field_errors = _form.field_errors %}
8687
{% set form_actions = _form.form_actions %}
8788
{% set input = _form.input %}
89+
{% set hidden_input = _form.hidden_input %}
8890
{% set checkbox = _form.checkbox %}
8991
{% set textarea = _form.textarea %}
9092
{% set markdown = _form.markdown %}

ckanext/theming/themes/bs5/templates/macros/ui/form.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
{{ ui.form_end() }}
88
{%- endmacro %}
99

10+
{%- macro form(content, method, action, enctype, include_csrf=true) -%}
11+
{{ ui.form_start(method, action, enctype, **kwargs) }}
12+
{{ h.csrf_input() if include_csrf and method|upper != "GET" }}
13+
{{ content }}
14+
{{ ui.form_end() }}
15+
{%- endmacro %}
16+
1017
{%- macro form_actions(content) -%}
1118
<div {{ ui.util.attrs(kwargs) }} class="mb-3">
1219
{{ content }}
@@ -68,6 +75,10 @@ <h4 class="alert-heading">{{ _('Form Errors') }}</h4>
6875
</div>
6976
{%- endmacro %}
7077

78+
{%- macro hidden_input(name, value) -%}
79+
<input {{ ui.util.attrs(kwargs) }} type="hidden" name="{{ name }}" value="{{ value }}">
80+
{%- endmacro %}
81+
7182
{% macro checkbox(name, id, label="", value="on", checked=false, errors=[], required=false) %}
7283
{%- set id = id or "field-" ~ name if name else "" -%}
7384

ckanext/theming/themes/bulma/templates/macros/ui.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@
7979

8080
{# Form macros #}
8181
{% set form_block = _form.form_block %}
82+
{% set form = _form.form %}
8283
{% set form_start = _form.form_start %}
8384
{% set form_end = _form.form_end %}
8485
{% set form_errors = _form.form_errors %}
8586
{% set field_errors = _form.field_errors %}
8687
{% set form_actions = _form.form_actions %}
8788
{% set input = _form.input %}
89+
{% set hidden_input = _form.hidden_input %}
8890
{% set checkbox = _form.checkbox %}
8991
{% set textarea = _form.textarea %}
9092
{% set markdown = _form.markdown %}

ckanext/theming/themes/bulma/templates/macros/ui/form.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
{{ ui.form_end() }}
88
{%- endmacro %}
99

10+
{%- macro form(content, method, action, enctype, include_csrf=true) -%}
11+
{{ ui.form_start(method, action, enctype, **kwargs) }}
12+
{{ h.csrf_input() if include_csrf and method|upper != "GET" }}
13+
{{ content }}
14+
{{ ui.form_end() }}
15+
{%- endmacro %}
16+
1017
{%- macro form_actions(content) -%}
1118
<div {{ ui.util.attrs(kwargs) }} class="field is-grouped">
1219
{{ content }}
@@ -53,6 +60,10 @@
5360
</div>
5461
{%- endmacro %}
5562

63+
{%- macro hidden_input(name, value) -%}
64+
<input {{ ui.util.attrs(kwargs) }} type="hidden" name="{{ name }}" value="{{ value }}">
65+
{%- endmacro %}
66+
5667
{% macro checkbox(name, id, label="", value="on", checked=false, errors=[], required=false) %}
5768
{%- set id = id or "field-" ~ name if name else "" -%}
5869

ckanext/theming/themes/pico/templates/macros/ui.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@
7979

8080
{# Form macros #}
8181
{% set form_block = _form.form_block %}
82+
{% set form = _form.form %}
8283
{% set form_start = _form.form_start %}
8384
{% set form_end = _form.form_end %}
8485
{% set form_errors = _form.form_errors %}
8586
{% set field_errors = _form.field_errors %}
8687
{% set form_actions = _form.form_actions %}
8788
{% set input = _form.input %}
89+
{% set hidden_input = _form.hidden_input %}
8890
{% set checkbox = _form.checkbox %}
8991
{% set textarea = _form.textarea %}
9092
{% set markdown = _form.markdown %}

0 commit comments

Comments
 (0)