Skip to content

Commit

Permalink
Bump version to 0.3.21.
Browse files Browse the repository at this point in the history
- Fixed custom actions on object_management api.
- Better table presentation modifying the dom representation.
- Add title to objects actions on object_management
  • Loading branch information
luisza committed Apr 15, 2024
1 parent 0242f8e commit 0049a90
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 22 deletions.
4 changes: 2 additions & 2 deletions demo/demoapp/object_management/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 3 additions & 3 deletions demo/demoapp/templates/object_management.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ <h3 class="heading-1"><span> {% trans 'List of Objects' %} </span></h3>
{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 }

Expand Down
2 changes: 1 addition & 1 deletion djgentelella/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.3.20'
__version__ = '0.3.21'
11 changes: 6 additions & 5 deletions djgentelella/static/gentelella/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -4652,3 +4648,8 @@ input-group > .custom-file {
margin: 0;
opacity: 0;
}

.no-export-col i {
margin: 0em 1.2em;
font-size: 1.3em;
}
10 changes: 5 additions & 5 deletions djgentelella/static/gentelella/js/datatables.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ function objshowlink(data, type, row, meta){ return data ? '<a href="'+data.url+
function objnode(data, type, row, meta){ return data ? '<'+data.tagName+' href="'+data.url+'" '+data.extraattr+' class="'+(data.class!=undefined ? data.class : 'link')+'"> '+data.display_name+ '</'+data.tagName+'>': ''; };
function objShowBool(data, type, row, meta){ return data ? '<i class="fa fa-check-circle" title="' + data + '">': '<i class="fa fa-times-circle" title="' + 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({}, {
Expand Down Expand Up @@ -215,7 +215,7 @@ function gtCreateDataTable(id, url, table_options={}){
action: function ( e, dt, node, config ) {clearDataTableFilters(dt, id)},
text: '<i class="fa fa-eraser" aria-hidden="true"></i>',
titleAttr: gettext('Clear Filters'),
className: 'btn-sm mr-4'
className: 'btn-outline-secondary mr-4'
},
],
ajax: {
Expand Down
13 changes: 9 additions & 4 deletions djgentelella/static/gentelella/js/obj_api_management.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<i class="fa fa-plus" aria-hidden="true"></i>',
Expand Down Expand Up @@ -620,15 +621,15 @@ 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){
this.table_actions.unshift({
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")){
Expand All @@ -639,6 +640,7 @@ function ObjectCRUD(uniqueid, objconfig={}){
{
'name': "detail",
'action': 'detail',
'title': gettext('Detail'),
'url': null,
'i_class': this.config.icons.detail,
}
Expand All @@ -649,6 +651,7 @@ function ObjectCRUD(uniqueid, objconfig={}){
{
'name': "update",
'action': 'update',
'title': gettext("Update"),
'url': null,
'i_class': this.config.icons.update,
}
Expand All @@ -659,6 +662,7 @@ function ObjectCRUD(uniqueid, objconfig={}){
{
'name': 'destroy',
'action': 'destroy',
'title': gettext('Delete'),
'url': null,
'i_class': this.config.icons.destroy,
}
Expand Down Expand Up @@ -692,6 +696,7 @@ function ObjectCRUD(uniqueid, objconfig={}){
if(display_in_column){
let params = "'"+instance.uniqueid+"', '"+action.name+"', "+meta.row;
edittext += '<i onclick="javascript:call_obj_crud_event('+params+');"';
edittext += 'title="'+action.title+'"';
edittext += ' class="'+instance.object_actions[x].i_class+'" ></i>';
}
}
Expand Down Expand Up @@ -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){
Expand Down
2 changes: 2 additions & 0 deletions docs/source/object_management.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand All @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 0049a90

Please sign in to comment.