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

Restrict Node select to the site/language of the page being edited #2277

Merged
merged 1 commit into from
Apr 21, 2022

Conversation

dbwinger
Copy link
Contributor

What is this pull request for?

Restrict Node results to the current Site/Language in the EssenceNode editor.

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

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.

I am not sure we want that as a default. There is the query_params feature you could use for this.

@dbwinger
Copy link
Contributor Author

dbwinger commented Apr 11, 2022

I am not sure we want that as a default. There is the query_params feature you could use for this.

If we don't want it as the default, are you suggesting that we add the language_id in the element definition under settings -> query_params? Since the element definitions aren't evaluated during runtime, and therefore we can't include the actual current language of the request there, I suppose we could use something like the string 'current' in that setting to indicate the current language should be used? Also, everything in query_params ends up in the filter param, which currently gets fed to @nodes.ransack, which I don't believe expects a parameter like language_id.

Am I misunderstanding your suggestion or the code?

@tvdeyen
Copy link
Member

tvdeyen commented Apr 19, 2022

I am not sure we want that as a default. There is the query_params feature you could use for this.

If we don't want it as the default, are you suggesting that we add the language_id in the element definition under settings -> query_params? Since the element definitions aren't evaluated during runtime, and therefore we can't include the actual current language of the request there, I suppose we could use something like the string 'current' in that setting to indicate the current language should be used? Also, everything in query_params ends up in the filter param, which currently gets fed to @nodes.ransack, which I don't believe expects a parameter like language_id.

Am I misunderstanding your suggestion or the code?

You are right. This is not possible right now. Very tricky situation. I am currently a bit hesitant about restricting this, but maybe these are edge cases. Who wants to link display a menu of a foreign language? @mamhoff @robinboening wdyt?

@robinboening
Copy link
Contributor

I am currently a bit hesitant about restricting this, but maybe these are edge cases. Who wants to link display a menu of a foreign language?

It does sound like an edge case to me and I don't see why anyone wanted to render a menu of another language. I could rather see how one could make a case where they want to render a menu of another site (same language) though. Still an edge case.

I don't see this restriction as a bad thing, but let me ask you if/how the benefits of the restriction outweigh the loss of flexibility?

@tvdeyen
Copy link
Member

tvdeyen commented Apr 21, 2022

It does sound like an edge case to me and I don't see why anyone wanted to render a menu of another language. I could rather see how one could make a case where they want to render a menu of another site (same language) though. Still an edge case.

Another site is another language. Even if the name is the same, the language id is different.

@robinboening
Copy link
Contributor

It does sound like an edge case to me and I don't see why anyone wanted to render a menu of another language. I could rather see how one could make a case where they want to render a menu of another site (same language) though. Still an edge case.

Another site is another language. Even if the name is the same, the language id is different.

Technically, yes. But from a less technical editor's perspective english is english. However, it would still be an edge case and right now a very theoretical one. So I think the suggested scopes ain't bad.

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.

Ok, let's go with it.

@tvdeyen tvdeyen merged commit 40abf67 into AlchemyCMS:main Apr 21, 2022
@dbwinger dbwinger deleted the restrict-nodes-to-language branch April 21, 2022 14:14
dbwinger added a commit to dbwinger/alchemy_cms that referenced this pull request Apr 21, 2022
@dbwinger dbwinger mentioned this pull request Apr 21, 2022
3 tasks
tvdeyen added a commit that referenced this pull request Apr 22, 2022
tvdeyen added a commit that referenced this pull request Apr 26, 2022
Restrict Node select to the site/language of the page being edited
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.

3 participants