-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[New Feature] Multilingual: Propagating existing associations if desired #21321
Conversation
the json files need corrections for cs. Can be tested and commented nevertheless. ;) |
JGLOBAL_ASSOCIATIONS_PROPAGATE_BUTTON="Propagate" | ||
JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED="Failed propagating associations. You may have to select or create them manually." | ||
JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE="All existing associations have been set. If some are missing you may have to select or create them manually." | ||
JGLOBAL_ASSOCIATIONS_PROPAGATE_TIP="Propagates this selected item existing associations." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please correct to
"Propagates this item's existing associations."
@@ -281,6 +281,10 @@ JGLOBAL_ARTICLE_ORDER_DESC="The order that articles will show in." | |||
JGLOBAL_ARTICLE_ORDER_LABEL="Article Order" | |||
JGLOBAL_ARTICLES="Articles" | |||
JGLOBAL_ASSOC_NOT_POSSIBLE="To define associations, please make sure the item language is not set to 'All'." | |||
JGLOBAL_ASSOCIATIONS_PROPAGATE_BUTTON="Propagate" | |||
JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED="Failed propagating associations. You may have to select or create them manually." | |||
JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE="All existing associations have been set. If some are missing you may have to select or create them manually." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How likely is it that an association will be missing? Seems odd to me to have that on a success message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will happen when there is no item associated in a specific language. See image above where there is nothing for Spanish
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so in that case nothing is missing as it doesnt exist
The first sentence is more than enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message is also informing the user that an association for one or more language(s) may be missing. It may be what the user wants but it also may not be.
In that case the user can select an item or create one directly in this interface.
This is important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats not the role of a success message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is only a success message for what could be propagated.
@@ -281,6 +281,10 @@ JGLOBAL_ARTICLE_ORDER_DESC="The order that articles will show in." | |||
JGLOBAL_ARTICLE_ORDER_LABEL="Article Order" | |||
JGLOBAL_ARTICLES="Articles" | |||
JGLOBAL_ASSOC_NOT_POSSIBLE="To define associations, please make sure the item language is not set to 'All'." | |||
JGLOBAL_ASSOCIATIONS_PROPAGATE_BUTTON="Propagate" | |||
JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED="Failed propagating associations. You may have to select or create them manually." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be "will" not "may"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some one may not want to create associations for a specific language.
Change to ?
If desired, you will have to select or create them manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then they havent failed and this isnt a failure message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Propagate has failed (for an unknown reason. It may be the case for a 3rd party component which is badly coded). It does not mean the user lost the possibility to associate items by selecting/creating them.
I am now waiting for tests. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok change to your suggestion of "If desired, you will have to select or create them manually.
Testing this and my only issue is with the messages The propagate button says
But you always get this message
The code should check to see if there any associations to propagate and if not then the message should be
And if there are associations to propagate then the message should be
|
Restarted drone who failed on js. |
JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED="Failed propagating associations. You may have to select or create them manually." | ||
JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_ALL="All existing associations have been set." | ||
JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_NONE="No associations exist to propagate." | ||
JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_SOME="Some associations have been set: %s" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to
Associations have been set for: %s
Much better now. I am also getting a missing string JGLOBAL_ASSOCIATIONS_PROPAGATE_TIP |
done |
I have tested this item ✅ successfully on eabc256 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/21321. |
One more tester. |
$associations[$lang]->title = $categoryTable->title; | ||
} | ||
|
||
$message = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove. Not necessary as it will be assigned later in the if statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting for other comments from you before changing. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repeat this change in the other files.
@@ -169,6 +176,23 @@ function jSelectNewsfeed_" . $this->id . "(id, title, object) { | |||
. '</a>'; | |||
} | |||
|
|||
// Propagate contact button |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update comment.
@Quy |
@Quy @franz-wohlkoenig @brianteeman |
@infograf768 have read Instructions a few Times but didn't understand really what is to test. So i need Time. |
I have tested this item ✅ successfully on b902d37 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/21321. |
Ready to Commit after two successful tests. |
@mbabker |
@@ -101,6 +101,7 @@ | |||
<?php echo $this->form->getInput('extension'); ?> | |||
<input type="hidden" name="task" value="" /> | |||
<input type="hidden" name="forcedLanguage" value="<?php echo $input->get('forcedLanguage', '', 'cmd'); ?>" /> | |||
<?php echo '<input id="token" type="hidden" name="' . JSession::getFormToken() . '" value="1" />'; ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line shouldn't be necessary, this is exactly what the JHtml call immediately below does.
@@ -120,5 +120,6 @@ | |||
</div> | |||
<input type="hidden" name="task" value="" /> | |||
<input type="hidden" name="forcedLanguage" value="<?php echo $input->get('forcedLanguage', '', 'cmd'); ?>" /> | |||
<?php echo '<input id="token" type="hidden" name="' . JSession::getFormToken() . '" value="1" />'; ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
@@ -138,6 +138,7 @@ | |||
<input type="hidden" name="task" value="" /> | |||
<input type="hidden" name="return" value="<?php echo $input->getCmd('return'); ?>" /> | |||
<input type="hidden" name="forcedLanguage" value="<?php echo $input->get('forcedLanguage', '', 'cmd'); ?>" /> | |||
<?php echo '<input id="token" type="hidden" name="' . JSession::getFormToken() . '" value="1" />'; ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
@@ -232,6 +232,7 @@ | |||
|
|||
<input type="hidden" name="task" value="" /> | |||
<input type="hidden" name="forcedLanguage" value="<?php echo $input->get('forcedLanguage', '', 'cmd'); ?>" /> | |||
<?php echo '<input id="token" type="hidden" name="' . JSession::getFormToken() . '" value="1" />'; ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
@@ -107,5 +107,6 @@ | |||
</div> | |||
<input type="hidden" name="task" value="" /> | |||
<input type="hidden" name="forcedLanguage" value="<?php echo $input->get('forcedLanguage', '', 'cmd'); ?>" /> | |||
<?php echo '<input id="token" type="hidden" name="' . JSession::getFormToken() . '" value="1" />'; ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
var currentLang = jQuery('#jform_language').find(":selected").val(); | ||
|
||
// Find the token so that it can be sent in the Ajax request as well | ||
var token = jQuery("#token").attr("name"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of finding the token in this way, the API added in #14952 should be used instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean using
var token = jQuery('meta[name=csrf-token]').val();
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, that does not work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the layouts, you have to add a JHtml::_('jquery.token');
call, then you don't even need to find the token and manually include it when using jQuery.ajax because that PHP call will set up jQuery to include the token automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works.
var token = Joomla.getOptions('csrf.token', '');
Is that OK, @mbabker ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not add the <?php echo JHtml::_('jquery.token'); ?>
Just deleted the extraneous lines in the edit.php and used
var token = Joomla.getOptions('csrf.token', '');
As I did not know what would be the consequences
Can we go with that?
@mbabker |
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
window.injectAssociations = function(result, callbackFunctionPrefix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really bad. Please name this as Joomla.injectAssociations
. Global variables, functions etc are as bad in Javascipt as they are in PHP 👎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess Robbie used this as we have above existing
window.hideAssociation
and
window.showAssociationMessage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I found what has to be modifed to fit as both the functions use window.
It is not the purpose of this patch to also correct the existing ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dgrammatiko
Do you agree with my statement?
If yes, I will do the patch right now
@dgrammatiko @franz-wohlkoenig @jreys |
I have tested this item ✅ successfully on 888a280 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/21321. |
@mbabker Can you now merge? |
@mbabker |
💩 |
Branch merged to 3.9-dev via 11153f7 |
Thanks. |
Pull Request for Issue #21250
Summary of Changes
This adds a "Propagate" button in the Associations tab when editing a contact, category, article, menu item, newsfeed.
This button will display when an association is selected in a Content Language field, offering the option to Propagate the associations defined for that item to the other Content Languages.
The button will display ONLY when there are more than 2 Content Languages defined for the site.
A message will display with the results obtained.
It is B/C as it will not break anything and one is totally free to choose or not to use the button, thus keeping the possibility to Clear/Select/Create any associations as before.
Using it prevents breaking existing associations when the wrong items are chosen for some fields.
A big thank you to Robbie Jackson for the long work to get this new functionality.
Target Milestone: 3.9.0
Testing Instructions
Create a Multilingual site with 3 or more languages.
Create items in each type: (contact, category, article, menu item, newsfeed) for 2 of these languages and associate them in each case.
Create a new item for each type, select another language than the ones which are already associated.
Save (NOT save and close) this item.
Display the Association tab.
You will see, as usual (here for 4 Content Languages)
I do have already associations set for English and French.
I select for English the item which I know is associated.
The button displays (Better tip welcome)
Clicking on the button will give
Result: the already associated category in French is added in the French field.
As we have no association set for Spanish, the field remains empty.
The message displays (it is the same in all cases except if there is an Ajax error)
All existing associations have been set. If some are missing you may have to select or create them manually.
If we have already associated all fields, clicking on Propagate will just display the message.
If we change an association in one of the fields and click Propagate, it is the associations from that language item that will be propagated and therefore replace the ones existing.
Documentation Changes Required
Yes