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

Add a new dialog class to replace the old one #2858

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sascha-karnatz
Copy link
Contributor

@sascha-karnatz sascha-karnatz commented May 2, 2024

Add a new dialog class with the same signature and the same properties as the old Dialog implementation. The new one is using the shoelace web components and is working with promises to allow the calling method to react to the user input in the dialog.

Checklist

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have added tests to cover this change

@sascha-karnatz sascha-karnatz force-pushed the dialog-success-promise branch 4 times, most recently from 4f4c5a8 to 04bebcc Compare May 3, 2024 13:27
app/assets/stylesheets/alchemy/shoelace.scss Outdated Show resolved Hide resolved
app/javascript/alchemy_admin/dialog.js Outdated Show resolved Hide resolved
app/javascript/alchemy_admin/dialog.js Outdated Show resolved Hide resolved
app/javascript/alchemy_admin/dialog.js Outdated Show resolved Hide resolved
app/javascript/alchemy_admin/dialog.js Outdated Show resolved Hide resolved
app/javascript/alchemy_admin/dialog.js Outdated Show resolved Hide resolved
@tvdeyen tvdeyen added this to the 7.2 milestone May 6, 2024
@sascha-karnatz sascha-karnatz changed the title WIP: Add a new dialog class to replace the old one Add a new dialog class to replace the old one May 6, 2024
app/javascript/alchemy_admin/dialog.js Outdated Show resolved Hide resolved
app/javascript/alchemy_admin/dialog.js Outdated Show resolved Hide resolved
Copy link

codecov bot commented May 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.93%. Comparing base (bbc4172) to head (c4413e7).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2858   +/-   ##
=======================================
  Coverage   95.93%   95.93%           
=======================================
  Files         229      229           
  Lines        6222     6222           
=======================================
  Hits         5969     5969           
  Misses        253      253           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sascha-karnatz sascha-karnatz marked this pull request as ready for review May 7, 2024 08:00
@sascha-karnatz sascha-karnatz requested a review from a team as a code owner May 7, 2024 08:00
@sascha-karnatz sascha-karnatz force-pushed the dialog-success-promise branch 3 times, most recently from c7e3773 to 9a600f2 Compare May 7, 2024 10:11
@tvdeyen
Copy link
Member

tvdeyen commented May 7, 2024

We need a remote form watcher that handles re-rendering of forms with validation errors

See

watch_remote_forms: ->
form = $('[data-remote="true"]', @dialog_body)
form.bind "ajax:success", (event) =>
xhr = event.detail[2]
content_type = xhr.getResponseHeader('Content-Type')
if content_type.match(/javascript/)
return
else
@dialog_body.html(xhr.responseText)
@init()
return
form.bind "ajax:error", (event, b, c) =>
statusText = event.detail[1]
xhr = event.detail[2]
@show_error(xhr, statusText)
return

dialog validation errors
dialog.validation.errors.not.shown.mp4

@sascha-karnatz sascha-karnatz marked this pull request as draft May 7, 2024 17:55
Add a new dialog class with the same signature and the same properties as the old Dialog implementation. The new one is using the shoelace web components and is working with promises to allow the calling method to react to the user input in the dialog.
Try to extract the logic to render the content of the dialog and the error handing into a separate component.
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.

None yet

2 participants