From 0049a90f72f6674d2c9064abc7953cebc5e94e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Z=C3=A1rate=20Montero?= Date: Sun, 14 Apr 2024 21:26:58 -0600 Subject: [PATCH] Bump version to 0.3.21. - Fixed custom actions on object_management api. - Better table presentation modifying the dom representation. - Add title to objects actions on object_management --- demo/demoapp/object_management/views.py | 4 ++-- demo/demoapp/templates/object_management.html | 6 +++--- djgentelella/__init__.py | 2 +- djgentelella/static/gentelella/css/custom.css | 11 ++++++----- djgentelella/static/gentelella/js/datatables.js | 10 +++++----- .../static/gentelella/js/obj_api_management.js | 13 +++++++++---- docs/source/object_management.rst | 2 ++ pyproject.toml | 3 +-- 8 files changed, 29 insertions(+), 22 deletions(-) diff --git a/demo/demoapp/object_management/views.py b/demo/demoapp/object_management/views.py index 7ec06a5e..ebd657e8 100644 --- a/demo/demoapp/object_management/views.py +++ b/demo/demoapp/object_management/views.py @@ -3,9 +3,9 @@ from demoapp.forms import ObjectManagementForm -def object_management(response): +def object_management(request): context = { 'create_form': ObjectManagementForm(prefix='create'), 'update_form': ObjectManagementForm(prefix='update'), } - return render(response, 'object_management.html', context=context) + return render(request, 'object_management.html', context=context) diff --git a/demo/demoapp/templates/object_management.html b/demo/demoapp/templates/object_management.html index a1605c47..3d94aa40 100644 --- a/demo/demoapp/templates/object_management.html +++ b/demo/demoapp/templates/object_management.html @@ -58,12 +58,12 @@

{% trans 'List of Objects' %}

{data: "name", name: "name", title: gettext("Name"), type: "string", visible: true}, {data: "last_time", name: "last_time", title: gettext("Last Time"), type: "date", render: DataTable.render.datetime(), "dateformat": document.datetime_format, visible: true}, - {data: "born_date", name: "born_date", title: gettext("Born date"), type: "date", render: DataTable.render.date(), + {data: "born_date", name: "born_date", title: gettext("Born Date"), type: "date", render: DataTable.render.date(), "dateformat": document.date_format, visible: true}, {data: "field_autocomplete", name: "field_autocomplete", title: "Autocomplete", type: "select2", visible: true, url: "{% url 'countrybasename-list' %}", render: selectobjprint({display_name: "text"}) }, - {data: "float_number", name: "float_number", title: gettext("Float number"), type: "string", visible: true }, - {data: "m2m_autocomplete", name: "m2m_autocomplete", title: gettext("M2M autocomplete"), type: "select2", visible: true, + {data: "float_number", name: "float_number", title: gettext("Float Number"), type: "string", visible: true }, + {data: "m2m_autocomplete", name: "m2m_autocomplete", title: gettext("M2M Autocomplete"), type: "select2", visible: true, url: "{% url 'countrybasename-list' %}", multiple: true, render: gt_print_list_object("text")}, {data: "actions", name: "actions", title: gettext("Actions"), type: "string", visible: true } diff --git a/djgentelella/__init__.py b/djgentelella/__init__.py index 35e8cf2d..ca81af42 100644 --- a/djgentelella/__init__.py +++ b/djgentelella/__init__.py @@ -1 +1 @@ -__version__ = '0.3.20' +__version__ = '0.3.21' diff --git a/djgentelella/static/gentelella/css/custom.css b/djgentelella/static/gentelella/css/custom.css index 1cea4fa4..52b76b68 100755 --- a/djgentelella/static/gentelella/css/custom.css +++ b/djgentelella/static/gentelella/css/custom.css @@ -1454,11 +1454,7 @@ td.details { .example_alt_pagination div.dataTables_info { width: 40% } -.paging_full_numbers { - width: 400px; - height: 22px; - line-height: 22px -} + .paging_full_numbers a:active { outline: none } @@ -4652,3 +4648,8 @@ input-group > .custom-file { margin: 0; opacity: 0; } + +.no-export-col i { + margin: 0em 1.2em; + font-size: 1.3em; +} diff --git a/djgentelella/static/gentelella/js/datatables.js b/djgentelella/static/gentelella/js/datatables.js index 5091cc8c..51030453 100644 --- a/djgentelella/static/gentelella/js/datatables.js +++ b/djgentelella/static/gentelella/js/datatables.js @@ -181,12 +181,12 @@ function objshowlink(data, type, row, meta){ return data ? ' '+data.display_name+ '': ''; }; function objShowBool(data, type, row, meta){ return data ? '': ''; }; -document.table_default_dom = "<'row mb-3'<'col-sm-12 col-md-12 mb-1 d-flex align-items-center justify-content-center'f>" + - "<'col-sm-6 col-md-6 mt-1 d-flex align-items-center justify-content-start'B>" + - "<'col-sm-6 col-md-6 mt-1 d-flex align-items-center 'l>>" + +document.table_default_dom = "<'row mb-1'<'col-sm-4 col-md-4 d-flex align-items-center justify-content-start'f>" + + "<'col-sm-4 col-md-4 d-flex align-items-center justify-content-center'B>" + + "<'col-sm-3 col-md-3 d-flex align-items-center justify-content-end 'l>>" + "<'row'<'col-sm-12'tr>><'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>"; - +$.fn.dataTable.Buttons.defaults.dom.button.className="btn btn-sm"; function gtCreateDataTable(id, url, table_options={}){ const options = Object.assign({}, { @@ -215,7 +215,7 @@ function gtCreateDataTable(id, url, table_options={}){ action: function ( e, dt, node, config ) {clearDataTableFilters(dt, id)}, text: '', titleAttr: gettext('Clear Filters'), - className: 'btn-sm mr-4' + className: 'btn-outline-secondary mr-4' }, ], ajax: { diff --git a/djgentelella/static/gentelella/js/obj_api_management.js b/djgentelella/static/gentelella/js/obj_api_management.js index 36777caa..ee92f2f6 100644 --- a/djgentelella/static/gentelella/js/obj_api_management.js +++ b/djgentelella/static/gentelella/js/obj_api_management.js @@ -504,7 +504,8 @@ function ObjectCRUD(uniqueid, objconfig={}){ relation_render: {}, headers: {'X-CSRFToken': getCookie('csrftoken'), 'Content-Type': 'application/json'}, btn_class: { - create: 'btn-sm mr-4' + create: 'btn-outline-success mr-4', + clear_filters: 'btn-outline-secondary mr-4' }, icons: { create: '', @@ -620,7 +621,7 @@ function ObjectCRUD(uniqueid, objconfig={}){ action: this.create(this), text: this.config.icons.create, titleAttr: gettext('Create'), - className: this.config.create + className: this.config.btn_class.create }) } if(this.can_list){ @@ -628,7 +629,7 @@ function ObjectCRUD(uniqueid, objconfig={}){ action: function ( e, dt, node, config ) {clearDataTableFilters(dt, instance.config.datatable_element)}, text: this.config.icons.clear, titleAttr: gettext('Clear Filters'), - className: this.header_btn_class + className: this.config.btn_class.clear_filters }) } if(!config.datatable_inits.hasOwnProperty("buttons")){ @@ -639,6 +640,7 @@ function ObjectCRUD(uniqueid, objconfig={}){ { 'name': "detail", 'action': 'detail', + 'title': gettext('Detail'), 'url': null, 'i_class': this.config.icons.detail, } @@ -649,6 +651,7 @@ function ObjectCRUD(uniqueid, objconfig={}){ { 'name': "update", 'action': 'update', + 'title': gettext("Update"), 'url': null, 'i_class': this.config.icons.update, } @@ -659,6 +662,7 @@ function ObjectCRUD(uniqueid, objconfig={}){ { 'name': 'destroy', 'action': 'destroy', + 'title': gettext('Delete'), 'url': null, 'i_class': this.config.icons.destroy, } @@ -692,6 +696,7 @@ function ObjectCRUD(uniqueid, objconfig={}){ if(display_in_column){ let params = "'"+instance.uniqueid+"', '"+action.name+"', "+meta.row; edittext += ''; } } @@ -762,7 +767,7 @@ function ObjectCRUD(uniqueid, objconfig={}){ } ).then(response_manage_type_data(instance, error_fn, instance.error_text)) .then(instance.success(instance)) - .catch(instance.error(instance)); + .catch(error => instance.handle_error(instance, error)); } }, 'retrieve_data': function(url, method, success){ diff --git a/docs/source/object_management.rst b/docs/source/object_management.rst index af3c30dc..bf10e262 100644 --- a/docs/source/object_management.rst +++ b/docs/source/object_management.rst @@ -184,6 +184,7 @@ in the actions column so you must called in another column. { 'name': "mycustomaction", // Action identification, must be unique 'action': 'mycustomaction', // Name of the function to call to process the action. + 'title': 'Human descriptor', // Tittle display when mouse is over 'in_action_column': false, // The action must be displayed in the actions column 'i_class': 'fa fa-plus', // clase a utilizar para el ícono de la acción. } @@ -209,6 +210,7 @@ Additionally, if you don't want to provide a function and instead prefer to make 'in_action_column': false, // The action must be displayed in the actions column 'i_class': 'fa fa-plus', // clase a utilizar para el ícono de la acción. 'method': 'POST', + 'title': '' // Display when mouse is over the icon 'data_fn': function(data){ return data; }, // Preprocess data before send to server, it's required return data 'error_fn' function(errors) {} // Optional manage the form errors if exists } diff --git a/pyproject.toml b/pyproject.toml index fede77e8..394756d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ name = "djgentelella" # Required # # For a discussion on single-sourcing the version, see # https://packaging.python.org/guides/single-sourcing-package-version/ -version = "0.3.20" # Required +version = "0.3.21" # Required # This is a one-line description or tagline of what your project does. This # corresponds to the "Summary" metadata field: @@ -82,7 +82,6 @@ classifiers = [# Optional "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 4", - "Framework :: Django :: 5", # Pick your license as you wish "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", "Operating System :: OS Independent",