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

Page Select Component #2582

Merged
merged 5 commits into from
Sep 27, 2023

Conversation

sascha-karnatz
Copy link
Contributor

@sascha-karnatz sascha-karnatz commented Sep 19, 2023

What is this pull request for?

  • extend Alchemy html element
  • add page select web component
  • add page select view component
  • remove alchemyPageSelect - function

Upgrade

If you use the alchemyPageSelect- function before, you have to upgrade to the new alchemy-page-select web component, which contains the same feature set.

Replace these code block:

<%= f.text_field :page_id,  id: "page_input" %>
<script>
  $('#page_input').alchemyPageSelect({
    placeholder: "<%= Alchemy.t(:search_page) %>",
    url: "<%= alchemy.api_pages_path %>",
    <% if page %>
    initialSelection: {
      id: <%= page.id %>,
      text: "<%= page.name %>"
    }
    <% end %>
  })
</script>

with the ViewComponent (which is a wrapper for the web component):

<%= render Alchemy::Admin::PageSelect.new(page) do %>
  <%= f.text_field :page_id,  id: "page_input" %>
<% end %>

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 marked this pull request as draft September 19, 2023 14:08
@sascha-karnatz sascha-karnatz force-pushed the update_javascript/page_select branch 8 times, most recently from 2487803 to 25802ef Compare September 22, 2023 06:41
app/views/alchemy/admin/nodes/_form.html.erb Show resolved Hide resolved
app/views/alchemy/admin/nodes/_form.html.erb Show resolved Hide resolved
app/javascript/alchemy_admin/components/page_select.js Outdated Show resolved Hide resolved
app/javascript/alchemy_admin/components/page_select.js Outdated Show resolved Hide resolved
app/javascript/alchemy_admin/components/page_select.js Outdated Show resolved Hide resolved
app/javascript/alchemy_admin/components/page_select.js Outdated Show resolved Hide resolved
app/components/alchemy/admin/page_select.rb Outdated Show resolved Hide resolved
@sascha-karnatz sascha-karnatz force-pushed the update_javascript/page_select branch from 78b34a4 to d362717 Compare September 22, 2023 13:16
@sascha-karnatz sascha-karnatz marked this pull request as ready for review September 22, 2023 13:16
@sascha-karnatz sascha-karnatz force-pushed the update_javascript/page_select branch from d362717 to 932d7c4 Compare September 22, 2023 13:21
app/javascript/alchemy_admin/utils/string.js Outdated Show resolved Hide resolved
app/javascript/alchemy_admin/utils/string.js Outdated Show resolved Hide resolved
app/views/alchemy/admin/nodes/_form.html.erb Outdated Show resolved Hide resolved
app/views/alchemy/admin/nodes/_form.html.erb Show resolved Hide resolved
app/views/alchemy/admin/nodes/_form.html.erb Show resolved Hide resolved
spec/views/alchemy/ingredients/page_editor_spec.rb Outdated Show resolved Hide resolved
The boolean values are attributes without an value like the default HTML standard e.g. disabled or checked. Also attributes with dashes are now casted to underscore.
@sascha-karnatz sascha-karnatz force-pushed the update_javascript/page_select branch from 932d7c4 to 947d502 Compare September 26, 2023 10:02
Add page select component, which wraps the select2 initialization. The jquery - dependencies is only necessary for testing purposes to import jquery, which otherwise only available via Sprockets.
Add a view component to make it easier to use the page select web component in erb views.
Use the new web component to create the page selects. It was necessary to encapsulate the node form mechanic into an own component.
It is now replaced by the alchemy-page-select - web component. The page.hbs file is still in use, because there is another page selector in the Alchemy Link Dialog.
@sascha-karnatz sascha-karnatz force-pushed the update_javascript/page_select branch from 947d502 to 2435410 Compare September 26, 2023 19:31
Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor 🍰

@tvdeyen tvdeyen merged commit b85bd1b into AlchemyCMS:main Sep 27, 2023
14 checks passed
@sascha-karnatz sascha-karnatz deleted the update_javascript/page_select branch September 27, 2023 13:10
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