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

Move logic from link dialog - Javascript onto the server #2756

Closed

Conversation

sascha-karnatz
Copy link
Contributor

@sascha-karnatz sascha-karnatz commented Feb 27, 2024

What is this pull request for?

  1. Use our default page selector also in link dialog. Let the controller resolve the page url and prefill the page selector to reduce the amount of necessary Javascript.
  2. Moved the link dialog partials into view components to make it easier to maintain and extend the link dialog view
  3. add new anchor select - component

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 February 27, 2024 16:36
@sascha-karnatz sascha-karnatz force-pushed the link-detail-improvements branch 2 times, most recently from 5d72127 to 2277f0f Compare February 28, 2024 09:08
Use our default page selector also in link dialog. Let the controller resolve the page url and prefill the page selector to reduce the amount of necessary Javascript.
@sascha-karnatz sascha-karnatz force-pushed the link-detail-improvements branch 2 times, most recently from a66e49b to 51cff27 Compare February 29, 2024 14:18
@sascha-karnatz sascha-karnatz force-pushed the link-detail-improvements branch 3 times, most recently from e258364 to 856b036 Compare February 29, 2024 16:04
Try to migrate the link dialog partials into view component to make it easier extendable and lesser repetitive.

In a later commit it will be configurable to allow other plugins to add their own tabs.
@sascha-karnatz sascha-karnatz force-pushed the link-detail-improvements branch from 856b036 to 5eb35f8 Compare February 29, 2024 16:21
app/views/alchemy/admin/pages/link.html.erb Dismissed Show dismissed Hide dismissed
Remove the custom logic to initialize and selecting the correct tab and instead pre-configer the link dialog template. The handling of the anchor is still tricky and will be resolved in the next commit.
@sascha-karnatz sascha-karnatz force-pushed the link-detail-improvements branch from e094c8b to fa0755b Compare March 1, 2024 07:40
add an anchor select component to fetch the anchors from the API or from the preview of the page editor. The selected anchor will be attached at the url.
@sascha-karnatz sascha-karnatz force-pushed the link-detail-improvements branch from db50800 to f83191d Compare March 1, 2024 12:05
@sascha-karnatz sascha-karnatz marked this pull request as ready for review March 1, 2024 12:06
@sascha-karnatz sascha-karnatz changed the title Replace page selector in link dialog Move logic from link dialog - Javascript onto the server Mar 1, 2024

get pageId() {
return this.selection ? JSON.parse(this.selection)["id"] : undefined
}
Copy link
Member

Choose a reason for hiding this comment

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

do we need this?

raise ArgumentError, "The tab needs to have a title"
end

def type
Copy link
Member

Choose a reason for hiding this comment

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

def name

<sl-tab-panel name="overlay_tab_file_link">
<%= render partial: 'file_link' %>
</sl-tab-panel>
<% tabs = [Alchemy::Admin::Pages::InternalTab, Alchemy::Admin::Pages::AnchorTab, Alchemy::Admin::Pages::ExternalTab, Alchemy::Admin::Pages::FileTab] %>
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to have this configurable

<%= render partial: 'file_link' %>
</sl-tab-panel>
<% tabs = [Alchemy::Admin::Pages::InternalTab, Alchemy::Admin::Pages::AnchorTab, Alchemy::Admin::Pages::ExternalTab, Alchemy::Admin::Pages::FileTab] %>
<% tabs.each do |tab| %>
Copy link
Member

Choose a reason for hiding this comment

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

Alchemy::Admin::LinkDialogTabs.each do |tab|

@@ -670,6 +670,7 @@ en:
delete_user: "Delete this user"
edit_user: "Edit the user´s properties."
"No users found": "No users found."
url: "Url"
Copy link
Member

Choose a reason for hiding this comment

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

URL

@@ -95,7 +95,7 @@

within "[name='overlay_tab_external_link']" do
expect(page).to have_selector("#external_link")
fill_in("URL", with: "https://example.com")
fill_in("Url", with: "https://example.com")
Copy link
Member

Choose a reason for hiding this comment

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

revert

@@ -48,64 +66,10 @@ class window.Alchemy.LinkDialog extends Alchemy.Dialog
target: $("##{@link_type}_link_target").val()
false

# Initializes the select2 based Page select
initPageSelect: ->
Copy link
Member

Choose a reason for hiding this comment

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

This should maybe be its separate PR that builds on top of the remaining commits?

@@ -164,6 +164,9 @@ def destroy

def link
@url = params[:url]
@tab = params[:tab]
@title = params[:title]
Copy link
Member

Choose a reason for hiding this comment

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

@link_title = params[:link_title]

@@ -164,6 +164,9 @@ def destroy

def link
@url = params[:url]
@tab = params[:tab]
@title = params[:title]
@target = params[:target]
Copy link
Member

Choose a reason for hiding this comment

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

@link_target = params[:link_target]

@@ -1,6 +1,6 @@
<sl-tab-group id="overlay_tabs">
<% tabs = [Alchemy::Admin::Pages::InternalTab, Alchemy::Admin::Pages::AnchorTab, Alchemy::Admin::Pages::ExternalTab, Alchemy::Admin::Pages::FileTab] %>
<% tabs.each do |tab| %>
<%= render tab.new(@url) %>
<%= render tab.new(@url, @tab, @title, @target) %>
Copy link
Member

Choose a reason for hiding this comment

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

tab.new(@url, selected: @tab, link_title: @link_title, link_target: @link_target)

@sascha-karnatz sascha-karnatz marked this pull request as draft March 4, 2024 11:13
@sascha-karnatz
Copy link
Contributor Author

I extracting part of these PR into multiple, smaller Pull Requests.

@sascha-karnatz
Copy link
Contributor Author

Closed in favor of #2796

@sascha-karnatz sascha-karnatz deleted the link-detail-improvements branch May 2, 2024 09:28
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