Skip to content

Commit

Permalink
[#6118] move add button to datatable
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi committed Apr 30, 2024
1 parent 4fc42e6 commit 4a11723
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
this.ckan.module('tabledesigner_datatables_add', function($, _) {
return {
initialize: function() {
var defn = $(this)[0].el;
var editText = defn.data('edit-text');
var editUrl = defn.data('edit-url');

const table = $('#dtprv').DataTable();
table.button().add(0, {
text: editText,
action: function ( e, dt, button, config ){
window.parent.location = editUrl;
}
});
}
}
});
this.ckan.module('tabledesigner_datatables_edit', function($, _) {
return {
initialize: function() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{% ckan_extends %}
{% block page %}
{{ super() }}
{% if resource.url_type == 'tabledesigner' %}
{% if
resource.url_type == 'tabledesigner'
and h.check_access('datastore_upsert', {'resource_id': resource.id}) %}
<div
data-module="tabledesigner_datatables_delete"
data-edit-text="{{ _('Delete rows') }}"
Expand All @@ -12,5 +14,10 @@
data-edit-text="{{ _('Edit row') }}"
data-edit-url="{{ h.url_for('tabledesigner.edit_row', id=package.name, resource_id=resource.id) }}"
></div>
<div
data-module="tabledesigner_datatables_add"
data-edit-text="{{ _('Add row') }}"
data-edit-url="{{ h.url_for('tabledesigner.add_row', id=package.name, resource_id=resource.id) }}"
></div>
{% endif %}
{% endblock %}

0 comments on commit 4a11723

Please sign in to comment.