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

Feature request: remove component #454

Open
nerdoc opened this issue Oct 26, 2022 · 3 comments
Open

Feature request: remove component #454

nerdoc opened this issue Oct 26, 2022 · 3 comments

Comments

@nerdoc
Copy link
Contributor

nerdoc commented Oct 26, 2022

Hi Adam,
a feature that could be easily integrated and would greatly enhance Unicorn is a client side "remove component" action.
In many cases unicorn components are list elements or table rows that include action buttons like "Delete". You have examples for that using parent components that remove that row and rerender the whole list. This unnecessarily over-complicates the situation, as in IMHO many cases no parent component is needed - just a <ul> or <table> element.
What e.g. the Tetra framework does, is to provide a self.client._remove_component() method, that just removes the whole element from the DOM at the client side.
So a simple component delete action would just be:

class MyComponentView(UnicornView)
    def delete():
        self.client._remove_component()

and the template:

<tr>
  <td>...</td>
  <td>
      <button ... u:click="delete()">Delete</button>
  </td>
</tr>

Adding client side Js functions that can be called from the backend would be generally a huge benefit. (already there)
But the delete() action is the most important.

@nerdoc
Copy link
Contributor Author

nerdoc commented Oct 26, 2022

Maybe just the client side must be implemented here, as self.call() in the backend is already there.

@adamghill
Copy link
Owner

0.58.0 of Unicorn adds a Unicorn.deleteComponent method to remove a component from internal component store. I could extend this to remove the actual DOM element as well if that would be useful.

@nerdoc
Copy link
Contributor Author

nerdoc commented Jan 8, 2024

I think this is what would be expected then, yes.

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

No branches or pull requests

2 participants