Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buttons created by components, buttons acting out of component and refresh datatable #243

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Franziskhan
Copy link
Contributor

@Franziskhan Franziskhan commented Jul 19, 2021

Hello Adam,

I have found three issues while using Unicorn, so may I ask you about them, please?
You find my code in add-flavor, add-taste and very far button components (.hmtl + .py), and you can see them executed in Dynamic Load errors page.

  1. Buttons created by components: Try to add a new flavor (use button "Create New Flavor"). You see appear them in the datatable with an "Add taste" button on the side, that adds new tastes to the database. Try to click on "Add Taste" on a Flavor you created with my button, and you will see that it wont work until you refresh page.

  2. Buttons acting out of component: You see the very far button "Create New Flavor in a very far datatable" in the bottom on the page? It should do the same as the "Create New flavor" above, but the problem is that it belongs to another component, because for design reasons I wish to have the button located in the bottom of the page.
    This is just an extreme example, but actually in order to have a good looking page sometimes we need to locate buttons away from their component location. So, buttons of a component that acts on other components could be a solution? Or maybe being able to choose where to locate component items.

  3. Refresh Datatable: When you launch the page the datatable is refreshed by a javascript called "dt_refresh".
    However, once DOM and components are loaded, refresh_dt no longer works (try to execute the javascript via the button "Refresh datatable", in the top of the page).
    Javascripts continue to work, as the alert message can confirm , but the dt refresh does not.

Do you have any idea on how to solve these problems?
Hope that the example I made for showing you the issues and my explanations are clear and simple.

Thanks for all the support you give and all the work you do.

add very far button
reso più chiaro l'out component
rimosso admin lte commentato (confusing)
@adamghill
Copy link
Owner

Ok, lots of things going on in here. 😄

One thing that I noticed was that parent=view wasn't passed into the child components. I made that change here: https://github.com/adamghill/django-unicorn/pull/248/files#diff-b18ca2300b358cbf87177dc4e193890d59a44a122446da83d07c0f747edb4993R55. I was also thinking that the very far button might be able to use parent to access another component like: https://github.com/adamghill/django-unicorn/pull/248/files#diff-b18ca2300b358cbf87177dc4e193890d59a44a122446da83d07c0f747edb4993R61. Then, you could do something like https://github.com/adamghill/django-unicorn/pull/248/files#diff-33d55661d582d7b40004a10a338a78742e6d8238afce44d05246d8039b99b85bR9.

However, there are still some things going on from what I can tell. I'm not sure if maybe there is some conflict with loading the datatable? Let me know if that helps in any way, though. I'll keep trying to see if I can figure out what any other issues might be.

@Franziskhan
Copy link
Contributor Author

Franziskhan commented Jul 23, 2021

Thanks for the reply.

I tried to define the parent-child components and change very_farbutton.py as you suggested, but unfortunately this does not solve the problem, the very far button still does not work.
However I think the idea I had is the same you had, to activate a component through another component.

For the other two points can't tell much, know very little about javascripts and nearly nothing about Unicorn source code.
Add flavor button adds a new unicorn item (add taste) in the page, but does not consider them until the whole component is loaded again.
It's like Unicorn load components in the page only once, and then they cannot be changed until the page is refreshed.

These are just my ideas, as I said I don't know the source code so can't tell how much sense they have.

Anyway thanks for support.

@adamghill
Copy link
Owner

Re: Refresh datatable button: I get an error from datatable (https://datatables.net/manual/tech-notes/3) that mentions that re-initializing the database with options after the first initialization won't work. Not sure if there is another a way to "refresh" the datatable's data without re-constructing it?

It's like Unicorn load components in the page only once, and then they cannot be changed until the page is refreshed.

You are right about this, I'm afraid. For child components, I don't have a good solution to adding new child components to a parent component dynamically. I've spent the past day or so experimenting with a few ways it could work, but I don't have a good solution yet unfortunately. Sorry about that, but I'll keep you updated once I have a better answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants