From 970f38ac7ca2ebd62faf1b31b377f13901488412 Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Wed, 6 Sep 2023 16:33:22 -0400 Subject: [PATCH 1/7] fix data dictionary link from dataset page --- .../canada/templates/public/package/snippets/resource_item.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/canada/templates/public/package/snippets/resource_item.html b/ckanext/canada/templates/public/package/snippets/resource_item.html index 4d7ce4f54..787a9510c 100644 --- a/ckanext/canada/templates/public/package/snippets/resource_item.html +++ b/ckanext/canada/templates/public/package/snippets/resource_item.html @@ -78,7 +78,7 @@ {% endif %} {% if can_edit and not is_activity_archive %}
  • {% link_for _('Edit resource'), named_route=pkg.type ~ '_resource.edit', id=pkg.name, resource_id=res.id, class_='dropdown-item', icon='pencil' %}
  • - {% block resource_item_explore_inner scoped %}{% endblock %} + {% block resource_item_explore_inner scoped %}{{ super() }}{% endblock %}
  • {% link_for _('Views'), named_route=pkg.type ~ '_resource.views', id=pkg.name, resource_id=res.id, class_='dropdown-item', icon='chart-bar' %} {% endif %} {% endblock %} From 6ddbb58b3132c5020a64284a3c905592dbbb6def Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Mon, 11 Sep 2023 09:37:12 -0400 Subject: [PATCH 2/7] related resources 2.9 fix --- .../internal/scheming/package/snippets/resource_form.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ckanext/canada/templates/internal/scheming/package/snippets/resource_form.html b/ckanext/canada/templates/internal/scheming/package/snippets/resource_form.html index e69b3087d..0546bba9a 100644 --- a/ckanext/canada/templates/internal/scheming/package/snippets/resource_form.html +++ b/ckanext/canada/templates/internal/scheming/package/snippets/resource_form.html @@ -20,7 +20,7 @@ {% endif %}
    - {%- if (not data.related_type) or c.action=='new_resource' -%} + {%- if (not data.related_type) or c.action=='new' -%}
    {{ _("Metadata Fields for Resources Only (Not for Related Items)") }} @@ -36,7 +36,7 @@
    {% endif %} - {%- if data.related_type or c.action=='new_resource' -%} + {%- if data.related_type or c.action=='new' -%}
    {{ _("Metadata Fields for Related Items Only") }} From 9ef90e9049fc25e9c036ea0c9b2fb59d36581c02 Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Mon, 11 Sep 2023 16:43:34 -0400 Subject: [PATCH 3/7] related resources 2.9 fix 2 --- .../internal/scheming/package/snippets/resource_form.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ckanext/canada/templates/internal/scheming/package/snippets/resource_form.html b/ckanext/canada/templates/internal/scheming/package/snippets/resource_form.html index 0546bba9a..560b7da18 100644 --- a/ckanext/canada/templates/internal/scheming/package/snippets/resource_form.html +++ b/ckanext/canada/templates/internal/scheming/package/snippets/resource_form.html @@ -20,7 +20,7 @@ {% endif %}
    - {%- if (not data.related_type) or c.action=='new' -%} + {%- if (not data.related_type) or c.action.endswith('new') -%}
    {{ _("Metadata Fields for Resources Only (Not for Related Items)") }} @@ -36,7 +36,7 @@
    {% endif %} - {%- if data.related_type or c.action=='new' -%} + {%- if data.related_type or c.action.endswith('new') -%}
    {{ _("Metadata Fields for Related Items Only") }} From dd61a7d9326c2e465f6d1d88baefb11aa1a02339 Mon Sep 17 00:00:00 2001 From: Jesse Vickery Date: Wed, 13 Sep 2023 15:07:18 +0000 Subject: [PATCH 4/7] fix(views): added missing confirm action pages; - Added missing confirm member delete. - Added missing confirm datastore table delete. - Added missing flash for datastore table delete. --- .../internal/user/edit_user_form.html | 2 +- .../canada/confirm_datastore_delete.html | 18 ++++++++++++++++++ .../organization/confirm_delete_member.html | 6 +++--- .../templates/public/user/confirm_delete.html | 18 ++++++++++++++++++ .../templates/public/user/edit_user_form.html | 2 +- ckanext/canada/view.py | 19 ++++++++++++++++++- 6 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 ckanext/canada/templates/public/canada/confirm_datastore_delete.html create mode 100644 ckanext/canada/templates/public/user/confirm_delete.html diff --git a/ckanext/canada/templates/internal/user/edit_user_form.html b/ckanext/canada/templates/internal/user/edit_user_form.html index 9fd1c0574..3764a8fec 100644 --- a/ckanext/canada/templates/internal/user/edit_user_form.html +++ b/ckanext/canada/templates/internal/user/edit_user_form.html @@ -43,7 +43,7 @@
    {% block delete_button %} {% if h.check_access('user_delete', {'id': data.id}) %} - {% block delete_button_text %}{{ _('Delete') }}{% endblock %} + {% block delete_button_text %}{{ _('Delete') }}{% endblock %} {% endif %} {% endblock %} {% block generate_button %} diff --git a/ckanext/canada/templates/public/canada/confirm_datastore_delete.html b/ckanext/canada/templates/public/canada/confirm_datastore_delete.html new file mode 100644 index 000000000..398c8dd1a --- /dev/null +++ b/ckanext/canada/templates/public/canada/confirm_datastore_delete.html @@ -0,0 +1,18 @@ +{% extends "page.html" %} + +{% block subtitle %}{{ _("Confirm Delete") }}{% endblock %} + +{% block primary_content_inner %} +
    + {% block form %} +

    {{ _('Are you sure you want to delete this DataStore table and Data Dictionary?') }}

    +

    +

    + + + +
    +

    + {% endblock %} +
    +{% endblock %} diff --git a/ckanext/canada/templates/public/organization/confirm_delete_member.html b/ckanext/canada/templates/public/organization/confirm_delete_member.html index 1afe10a47..cf71e2a53 100644 --- a/ckanext/canada/templates/public/organization/confirm_delete_member.html +++ b/ckanext/canada/templates/public/organization/confirm_delete_member.html @@ -5,10 +5,10 @@ {% block primary_content_inner %}
    {% block form %} -

    {{ _('Are you sure you want to delete member - {name}?').format(name=c.user_dict.name) }}

    +

    {{ _('Are you sure you want to delete member - {name}?').format(name=user_dict.name) }}

    -

    - + +
    diff --git a/ckanext/canada/templates/public/user/confirm_delete.html b/ckanext/canada/templates/public/user/confirm_delete.html new file mode 100644 index 000000000..fd7233b39 --- /dev/null +++ b/ckanext/canada/templates/public/user/confirm_delete.html @@ -0,0 +1,18 @@ +{% extends "page.html" %} + +{% block subtitle %}{{ _("Confirm Delete") }}{% endblock %} + +{% block primary_content_inner %} +
    + {% block form %} +

    {{ _('Are you sure you want to delete user - {name}?').format(name=user_dict.name) }}

    +

    +

    + + + +
    +

    + {% endblock %} +
    +{% endblock %} diff --git a/ckanext/canada/templates/public/user/edit_user_form.html b/ckanext/canada/templates/public/user/edit_user_form.html index 2cdff6659..a71ff2c14 100644 --- a/ckanext/canada/templates/public/user/edit_user_form.html +++ b/ckanext/canada/templates/public/user/edit_user_form.html @@ -46,7 +46,7 @@
    {% block delete_button %} {% if h.check_access('user_delete', {'id': data.id}) %} - {% block delete_button_text %}{{ _('Delete') }}{% endblock %} + {% block delete_button_text %}{{ _('Delete') }}{% endblock %} {% endif %} {% endblock %} {% block generate_button %} diff --git a/ckanext/canada/view.py b/ckanext/canada/view.py index 71e9ef76b..2965f1f80 100644 --- a/ckanext/canada/view.py +++ b/ckanext/canada/view.py @@ -600,6 +600,9 @@ def ckanadmin_publish_datasets(): @canada_views.route('/dataset//delete-datastore-table/', methods=['GET', 'POST']) def delete_datastore_table(id, resource_id): + if u'cancel' in request.form: + return h.redirect_to(u'xloader.resource_data', id=id, resource_id=resource_id) + if request.method == 'POST': lc = LocalCKAN(username=g.user) @@ -610,12 +613,26 @@ def delete_datastore_table(id, resource_id): ) except NotAuthorized: return abort(403, _(u'Unauthorized to delete resource %s') % resource_id) - # FIXME else: render confirmation page for non-JS users + + h.flash_notice(_(u'DataStore table and Data Dictionary deleted for resource %s') % resource_id) + return h.redirect_to( 'xloader.resource_data', id=id, resource_id=resource_id ) + else: + # TODO: Remove + # ckan 2.9: Adding variables that were removed from c object for + # compatibility with templates in existing extensions + g.resource_id = resource_id + g.package_id = id + + extra_vars = { + u"resource_id": resource_id, + u"package_id": id + } + return render(u'canada/confirm_datastore_delete.html', extra_vars) @canada_views.route('/help', methods=['GET']) From a465d96504e207742b7e719caba765cb77178d34 Mon Sep 17 00:00:00 2001 From: Jesse Vickery Date: Wed, 13 Sep 2023 20:02:17 +0000 Subject: [PATCH 5/7] feat(templates): loading icon for datatables; - Added html loading icon and behavior for datatables. --- .../canada/public/css/canada_datatables.css | 28 +++++++++++++++++ .../public/static/js/canada_datatables.js | 31 +++++++++++++++++++ .../public/datatables/datatables_view.html | 15 +++++++++ 3 files changed, 74 insertions(+) create mode 100644 ckanext/canada/public/css/canada_datatables.css create mode 100644 ckanext/canada/public/static/js/canada_datatables.js diff --git a/ckanext/canada/public/css/canada_datatables.css b/ckanext/canada/public/css/canada_datatables.css new file mode 100644 index 000000000..0e7418643 --- /dev/null +++ b/ckanext/canada/public/css/canada_datatables.css @@ -0,0 +1,28 @@ +/*#################### +## Datatables Views ## +######################*/ +div#dtprv_processing.dataTables_processing{ + z-index: 9999 !important; + top: 0 !important; + left: 0 !important; + width: 100% !important; + height: 100% !important; + margin: 0 !important; + /* see static/js/canada_datatables for dynamic styles */ +} +div#dtprv_processing.dataTables_processing > div:last-child{ + position: absolute !important; + left: 50% !important; + transform: translate(-50%, -50%) !important; + pointer-events: none !important; + /* see static/js/canada_datatables for dynamic styles */ +} +div#dtprv_processing.dataTables_processing > div:last-child > div{ + background-color: #335075 !important; + pointer-events: none !important; +} +/*##################### +## END ## +## Datatables Views ## +## END ## +#######################*/ diff --git a/ckanext/canada/public/static/js/canada_datatables.js b/ckanext/canada/public/static/js/canada_datatables.js new file mode 100644 index 000000000..70591416d --- /dev/null +++ b/ckanext/canada/public/static/js/canada_datatables.js @@ -0,0 +1,31 @@ +window.addEventListener('load', function(){ + + $(document).on('preInit.dt', function(_event, _settings){ + + $('body.dt-view').css('visibility', 'visible'); + $('#dtprv_processing').css({ + 'background-color': 'rgba(255, 255, 255, 1)', + 'display': 'block', + 'pointer-events': 'all', + }); + $('#dtprv_processing > div').css('top', '15%'); + + }); + + $(document).on('init.dt', function(){ + + $('#dtprv_processing').css({ + 'background-color': 'rgba(255, 255, 255, 0.65)', + 'pointer-events': 'none', + }); + $('#dtprv_processing > div').css('top', '50%'); + + }); + + $(document).on('processing.dt', function(_event, _settings, _processing){ + + $('#dtprv_processing').css('display', _processing ? 'block' : 'none'); + + }); + +}); diff --git a/ckanext/canada/templates/public/datatables/datatables_view.html b/ckanext/canada/templates/public/datatables/datatables_view.html index 5b12fb32f..269ed765c 100644 --- a/ckanext/canada/templates/public/datatables/datatables_view.html +++ b/ckanext/canada/templates/public/datatables/datatables_view.html @@ -1,5 +1,14 @@ {% ckan_extends %} +{% block page %} + {{ super() }} +
    +
    +
    +
    +
    +{% endblock %} + {%- block datatable_column_label -%} {%- set label = 'label_' + h.lang() -%} {%- set description = 'notes_' + h.lang() -%} @@ -61,4 +70,10 @@ {%- endblock -%} {% block google_analytics_footer %}{%- endblock -%} {{ super() }} + {% endblock %} + +{%- block styles %} + {{ super() }} + +{%- endblock -%} From 5e125778ab3816a6ad0fa06887e83773e942c677 Mon Sep 17 00:00:00 2001 From: Jesse Vickery Date: Thu, 14 Sep 2023 20:35:28 +0000 Subject: [PATCH 6/7] feat(templates): use webassets; - Used webassets. --- ckanext/canada/plugins.py | 1 + .../public/{css => datatables}/canada_datatables.css | 0 .../{static/js => datatables}/canada_datatables.js | 0 ckanext/canada/public/datatables/webassets.yml | 9 +++++++++ .../templates/public/datatables/datatables_view.html | 4 ++-- 5 files changed, 12 insertions(+), 2 deletions(-) rename ckanext/canada/public/{css => datatables}/canada_datatables.css (100%) rename ckanext/canada/public/{static/js => datatables}/canada_datatables.js (100%) create mode 100644 ckanext/canada/public/datatables/webassets.yml diff --git a/ckanext/canada/plugins.py b/ckanext/canada/plugins.py index fe3fdb60c..80dc1b089 100755 --- a/ckanext/canada/plugins.py +++ b/ckanext/canada/plugins.py @@ -448,6 +448,7 @@ def update_config(self, config): p.toolkit.add_template_directory(config, 'templates/public') p.toolkit.add_public_directory(config, 'public') p.toolkit.add_resource('public/static/js', 'js') + p.toolkit.add_resource('public/datatables', 'canada_datatables') config['ckan.auth.public_user_details'] = False config['recombinant.definitions'] = """ ckanext.canada:tables/ati.yaml diff --git a/ckanext/canada/public/css/canada_datatables.css b/ckanext/canada/public/datatables/canada_datatables.css similarity index 100% rename from ckanext/canada/public/css/canada_datatables.css rename to ckanext/canada/public/datatables/canada_datatables.css diff --git a/ckanext/canada/public/static/js/canada_datatables.js b/ckanext/canada/public/datatables/canada_datatables.js similarity index 100% rename from ckanext/canada/public/static/js/canada_datatables.js rename to ckanext/canada/public/datatables/canada_datatables.js diff --git a/ckanext/canada/public/datatables/webassets.yml b/ckanext/canada/public/datatables/webassets.yml new file mode 100644 index 000000000..e67a446c0 --- /dev/null +++ b/ckanext/canada/public/datatables/webassets.yml @@ -0,0 +1,9 @@ +css: + contents: + - canada_datatables.css + output: canada_datatables/%(version)s_canada_datatables.css + +js: + contents: + - canada_datatables.js + output: canada_datatables/%(version)s_canada_datatables.js diff --git a/ckanext/canada/templates/public/datatables/datatables_view.html b/ckanext/canada/templates/public/datatables/datatables_view.html index 269ed765c..2ae3d89d7 100644 --- a/ckanext/canada/templates/public/datatables/datatables_view.html +++ b/ckanext/canada/templates/public/datatables/datatables_view.html @@ -70,10 +70,10 @@ {%- endblock -%} {% block google_analytics_footer %}{%- endblock -%} {{ super() }} - + {% asset 'canada_datatables/js' %} {% endblock %} {%- block styles %} {{ super() }} - + {% asset 'canada_datatables/css' %} {%- endblock -%} From 5f1ddfe5fddfe7f8d02c319bb0aed7635e1a6ce3 Mon Sep 17 00:00:00 2001 From: Jesse Vickery Date: Fri, 15 Sep 2023 14:17:39 +0000 Subject: [PATCH 7/7] feat(assets): moved datatables assets out of public; - Moved datatables assets to `assets` directory. --- .../canada/{public => assets}/datatables/canada_datatables.css | 0 .../canada/{public => assets}/datatables/canada_datatables.js | 0 ckanext/canada/{public => assets}/datatables/webassets.yml | 0 ckanext/canada/plugins.py | 2 +- 4 files changed, 1 insertion(+), 1 deletion(-) rename ckanext/canada/{public => assets}/datatables/canada_datatables.css (100%) rename ckanext/canada/{public => assets}/datatables/canada_datatables.js (100%) rename ckanext/canada/{public => assets}/datatables/webassets.yml (100%) diff --git a/ckanext/canada/public/datatables/canada_datatables.css b/ckanext/canada/assets/datatables/canada_datatables.css similarity index 100% rename from ckanext/canada/public/datatables/canada_datatables.css rename to ckanext/canada/assets/datatables/canada_datatables.css diff --git a/ckanext/canada/public/datatables/canada_datatables.js b/ckanext/canada/assets/datatables/canada_datatables.js similarity index 100% rename from ckanext/canada/public/datatables/canada_datatables.js rename to ckanext/canada/assets/datatables/canada_datatables.js diff --git a/ckanext/canada/public/datatables/webassets.yml b/ckanext/canada/assets/datatables/webassets.yml similarity index 100% rename from ckanext/canada/public/datatables/webassets.yml rename to ckanext/canada/assets/datatables/webassets.yml diff --git a/ckanext/canada/plugins.py b/ckanext/canada/plugins.py index 80dc1b089..a13443432 100755 --- a/ckanext/canada/plugins.py +++ b/ckanext/canada/plugins.py @@ -448,7 +448,7 @@ def update_config(self, config): p.toolkit.add_template_directory(config, 'templates/public') p.toolkit.add_public_directory(config, 'public') p.toolkit.add_resource('public/static/js', 'js') - p.toolkit.add_resource('public/datatables', 'canada_datatables') + p.toolkit.add_resource('assets/datatables', 'canada_datatables') config['ckan.auth.public_user_details'] = False config['recombinant.definitions'] = """ ckanext.canada:tables/ati.yaml