[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." |
brianteeman
Jul 31, 2018
Member
Please correct to
"Propagates this item's existing associations."
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." |
brianteeman
Jul 31, 2018
Member
How likely is it that an association will be missing? Seems odd to me to have that on a success message.
How likely is it that an association will be missing? Seems odd to me to have that on a success message.
infograf768
Jul 31, 2018
Author
Member
It will happen when there is no item associated in a specific language. See image above where there is nothing for Spanish
It will happen when there is no item associated in a specific language. See image above where there is nothing for Spanish
brianteeman
Jul 31, 2018
Member
so in that case nothing is missing as it doesnt exist
The first sentence is more than enough
so in that case nothing is missing as it doesnt exist
The first sentence is more than enough
infograf768
Jul 31, 2018
•
Author
Member
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.
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.
brianteeman
Jul 31, 2018
Member
thats not the role of a success message.
thats not the role of a success message.
infograf768
Jul 31, 2018
Author
Member
It is only a success message for what could be propagated.
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." |
brianteeman
Jul 31, 2018
Member
Shouldn't this be "will" not "may"?
Shouldn't this be "will" not "may"?
infograf768
Jul 31, 2018
•
Author
Member
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.
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.
brianteeman
Jul 31, 2018
Member
then they havent failed and this isnt a failure message
then they havent failed and this isnt a failure message
infograf768
Jul 31, 2018
Author
Member
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.
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.
brianteeman
Jul 31, 2018
Member
ok change to your suggestion of "If desired, you will have to select or create them manually.
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" |
brianteeman
Jul 31, 2018
Member
Please change to
Associations have been set for: %s
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 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; |
Quy
Aug 1, 2018
Contributor
Remove. Not necessary as it will be assigned later in the if statement.
Remove. Not necessary as it will be assigned later in the if statement.
infograf768
Aug 1, 2018
Author
Member
Waiting for other comments from you before changing. 👍
Waiting for other comments from you before changing.
Quy
Aug 1, 2018
Contributor
Repeat this change in the other files.
Repeat this change in the other files.
@@ -169,6 +176,23 @@ function jSelectNewsfeed_" . $this->id . "(id, title, object) { | |||
. '</a>'; | |||
} | |||
|
|||
// Propagate contact button |
Quy
Aug 1, 2018
Contributor
Update comment.
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 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" />'; ?> |
mbabker
Aug 2, 2018
Contributor
This line shouldn't be necessary, this is exactly what the JHtml call immediately below does.
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" />'; ?> |
mbabker
Aug 2, 2018
Contributor
Same as above.
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" />'; ?> |
mbabker
Aug 2, 2018
Contributor
Same as above.
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" />'; ?> |
mbabker
Aug 2, 2018
Contributor
Same as above.
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" />'; ?> |
mbabker
Aug 2, 2018
Contributor
Same as above.
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"); |
mbabker
Aug 2, 2018
Contributor
Instead of finding the token in this way, the API added in #14952 should be used instead.
Instead of finding the token in this way, the API added in #14952 should be used instead.
infograf768
Aug 2, 2018
Author
Member
You mean using
var token = jQuery('meta[name=csrf-token]').val();
instead?
You mean using
var token = jQuery('meta[name=csrf-token]').val();
instead?
infograf768
Aug 2, 2018
Author
Member
hmm, that does not work
hmm, that does not work
mbabker
Aug 2, 2018
Contributor
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.
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.
mbabker
Aug 2, 2018
Contributor
Yes.
Yes.
infograf768
Aug 2, 2018
•
Author
Member
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?
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) |
dgrammatiko
Aug 2, 2018
Contributor
This is really bad. Please name this as Joomla.injectAssociations
. Global variables, functions etc are as bad in Javascipt as they are in PHP 👎
This is really bad. Please name this as Joomla.injectAssociations
. Global variables, functions etc are as bad in Javascipt as they are in PHP
infograf768
Aug 2, 2018
Author
Member
I guess Robbie used this as we have above existing
window.hideAssociation
and
window.showAssociationMessage
I guess Robbie used this as we have above existing
window.hideAssociation
and
window.showAssociationMessage
infograf768
Aug 2, 2018
Author
Member
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.
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.
@dgrammatiko @franz-wohlkoenig @jreys |
I have tested this item This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/21321. |
@mbabker Can you now merge? |
8bacca9
into
joomla:staging
@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