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

Cut element renders in preview frame #2123

Closed
robinboening opened this issue Jun 8, 2021 · 2 comments
Closed

Cut element renders in preview frame #2123

robinboening opened this issue Jun 8, 2021 · 2 comments

Comments

@robinboening
Copy link
Contributor

Steps to reproduce

  1. Create an element on a Page
  2. Cut that element from the Page

Expected behavior

I expect to not see that cut element rendered in the Preview frame

Actual behavior

I see the cut element rendered in the preview frame.

System configuration

  • Alchemy Version: main branch
@robinboening robinboening changed the title Cut element rendered in preview frame Cut element renders in preview frame Jun 8, 2021
@tvdeyen
Copy link
Member

tvdeyen commented Jun 25, 2021

The cut element will only be removed after it has been pasted somewhere.

def paste_element_from_clipboard
@source_element = Element.find(element_from_clipboard["id"])
element = Element.copy(@source_element, {
parent_element_id: create_element_params[:parent_element_id],
page_version_id: @page_version.id,
})
if element_from_clipboard["action"] == "cut"
@cut_element_id = @source_element.id
@clipboard.delete_if { |item| item["id"] == @source_element.id.to_s }
@source_element.destroy
end
element
end

So it does not get lost if the user forget about pasting it or accidentally cut it. Not sure if we want to change that.

Since the preview frame is not a live-preview, but only gets reloaded after a persisted change, we would need to destroy the element and then reload the preview. We could theoretically remove the element from the iframes DOM, but there might be much more involved with that.

You could give it a try, though

@robinboening
Copy link
Contributor Author

robinboening commented Jun 25, 2021

Right, this is a much bigger thing than I expected.

I think another approach could be to update the element by removing the page_id and position (which feels like actually cutting it off from that page) and update the preview frame. The issue followed by this is how to handle those intentionally "orphaned" elements afterwards.

One crazy thing (that needs a lot more thinking though) could be to allow the admin user to see/manage a new route admin/elements/index to actually see a list of elements, filterable (👀 #2091) by many different things like: name, assigned page vs unused, language, tags, ... and what not.

I'll stop now since this brainstorming is going too far :)
Lets close it for now. I think it's not worth the time right now.

@tvdeyen tvdeyen closed this as completed Dec 27, 2021
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