Page 1 of 1

CSWeb: Cannot delete a dictionary when we have more than 10 dictionaries.

Posted: May 13th, 2024, 3:22 pm
by lestcape
When i have more that 10 dictionaries added to CSWeb 8.0.0, I cannot delete the latest dictionaries that are in a position after the top 10, but i can delete the first ones.

Reorder dictionaries or change the visible rows of the table do not help.

When i click the trash item, inside the dictionaries rows that i can not delete, the popup dialog is not displayed. So, this is not a problem in the php side. It should be a problem in the javascript side.

Thanks in advance.

Re: CSWeb: Cannot delete a dictionary when we have more than 10 dictionaries.

Posted: May 13th, 2024, 4:26 pm
by aaronw
Thanks for the report. It will be fixed in the next release. Let me know if you need a workaround in the meantime.

Re: CSWeb: Cannot delete a dictionary when we have more than 10 dictionaries.

Posted: May 13th, 2024, 4:52 pm
by lestcape
Well thanks. I can not find a workaround for this yet.

I think that the problem is in data.twig file, and is because of that:
$(".delete-button-class").on("click", function (event) {

The Datatablet create and removed the internal elements when you change the page. So, you really only connect the items that are visible when the page is loaded to that event. You need to be connected to the datatable change event instead or connect the click in some element at the top. For example:

$(".dictionary-data-table").on("click", function (event) {

And then find the real row that was clicked.

The problem is that modify the data.twig don't change the resulted rendered page. I'm missing something. How can i really change the resulted rendered page?

If you have already a workaround, please sendme the file that i need to change.

Thanks again!!

Re: CSWeb: Cannot delete a dictionary when we have more than 10 dictionaries.

Posted: May 13th, 2024, 5:59 pm
by lestcape
I have fixed the problem with this code, that is the more efficient way to fix that (you don' t overload the page with a lot of event listener):

Code: Select all

$("#dictionary-data-table").on("click", function (event) {
    if ($(event.target).hasClass('delete-button-class') || $(event.target).closest(".delete-button-class").length) {
        tr = $(event.target).closest("tr");
        var dictionaryName = $(tr).data("dictname");
        var dictionaryLabel = $(tr).data("dictlabel");
        var modalText = 'Do you want to delete the "' + dictionaryLabel + ' (' + dictionaryName + ')" dictionary, or the data in it?';
        $("#delete-modal").find('.modal-body').text(modalText);
        $("#delete-modal").modal("show");
    }
});
The missing thing was that i need to delete the twig cache (I never worked with twig before).

Please note that there are another issue more. The problem is when you have x+1 elements in the datatable and you paginate the datatable at x elements. In this case when you delete the x+1 element, the empty page remain there and is not removed. That is a little difficult to be fixed, because you need to take on account that you are using a datatable not an html table. That means refresh the datatable after remove the row element:

https://stackoverflow.com/questions/185 ... emove-done

So, instead of:

Code: Select all

$(tr).remove();
Should be:

Code: Select all

var dt = $("#dictionary-data-table").DataTable();
dt.row($(tr)).remove().draw();

Re: CSWeb: Cannot delete a dictionary when we have more than 10 dictionaries.

Posted: May 15th, 2024, 1:41 pm
by savy
Your observation is correct. Sorry for the inconvenience. We fixed the issue now and will publish it in our next release. The page redraw fix was addressed with this fix.

Code: Select all

                                const dataTable = $('#dictionary-data-table').DataTable();
                                let currentPage = dataTable.page();
                                dataTable.row($(tr)).remove();
                                const newTotalPages = dataTable.page.info().pages;
                                currentPage = currentPage !== 0 && currentPage >= newTotalPages ?  newTotalPages -1 : currentPage ;
                                dataTable.page(currentPage).draw('page');

Re: CSWeb: Cannot delete a dictionary when we have more than 10 dictionaries.

Posted: May 15th, 2024, 7:07 pm
by lestcape
Oh no, thanks for all your work done and for shared your software witch the rest of us. It would be perfect if CSPro were free software and made with free software (we can also help more that way), but at least CSWeb is free software. So. I'm happy to help a little.

Re: CSWeb: Cannot delete a dictionary when we have more than 10 dictionaries.

Posted: February 25th, 2025, 1:10 am
by msoni
Hello
Greetings

I am facing the similar issue in deleting the data and dictionary from CSWeb specially when the number of dictionaries are greater than 10.

I found a similar post on the CSPro forum where you suggested that you have fixed this issue. See link of that communication below.

viewtopic.php?p=18116&hilit=delete+app+ ... Web#p18116

Please suggest what I should do to resolve this at my end as I can not access CSWeb configuration files. Shall i tell our IT person to upgrade CSWeb?

Thanks and Regards
Manoj

Re: CSWeb: Cannot delete a dictionary when we have more than 10 dictionaries.

Posted: February 25th, 2025, 11:35 am
by Gregory Martin
You'll have to have your IT person modify the data.twig file that I've attached. Unzip that file and put the file here: templates/data.twig

Then clear the var/cache directory and it should work.
data-twig.zip

Re: CSWeb: Cannot delete a dictionary when we have more than 10 dictionaries.

Posted: February 25th, 2025, 11:56 am
by msoni
Thank you and i will contact our IT person and will do and hope this should work.

Regards
Manoj