Skip to content
This repository has been archived by the owner on Nov 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #48 from Yoast/bugfix/34-error-in-meta-fields-dete…
Browse files Browse the repository at this point in the history
…ction

Bugfix/34 error in meta fields detection
  • Loading branch information
lukvdborne authored Sep 27, 2017
2 parents f428da9 + 269184e commit b48aebb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
22 changes: 20 additions & 2 deletions Ui/Catalog/DataProvider/Product/Form/Modifier/YoastSeo.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,26 @@ public function modifyMeta(array $meta)
*/
protected function setYoastFieldClasses(&$meta)
{
$meta['product-details']['children']['container_name']['children']['name']['arguments']['data']['config']['additionalClasses'] = 'yoastBox-title';
$meta['content']['children']['container_description']['children']['description']['arguments']['data']['config']['additionalClasses'] = 'yoastBox-content';
foreach ($meta as $groupKey => $group) {
if (!isset($group['children'])) {
continue;
}
foreach ($group['children'] as $containerKey => $container) {
if (!isset($container['children'])) {
continue;
}
foreach ($container['children'] as $fieldKey => $field) {
switch ($fieldKey) {
case 'name':
$meta[$groupKey]['children'][$containerKey]['children'][$fieldKey]['arguments']['data']['config']['additionalClasses'] = 'yoastBox-title';
break;
case 'description':
$meta[$groupKey]['children'][$containerKey]['children'][$fieldKey]['arguments']['data']['config']['additionalClasses'] = 'yoastBox-content';
}
}
}
}

$meta['search-engine-optimization']['arguments']['data']['config']['label'] = __('Yoast SEO');
$meta['search-engine-optimization']['children']['container_url_key']['children']['url_key']['arguments']['data']['config']['additionalClasses'] = 'yoastBox-urlKey';
$meta['search-engine-optimization']['children']['container_meta_title']['children']['meta_title']['arguments']['data']['config']['additionalClasses'] = 'yoastBox-metaTitle hidden';
Expand Down
14 changes: 10 additions & 4 deletions view/adminhtml/web/js/maxserv-yoast-seo.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ define([
return this.config.metaTitleIdentifier || '.yoastBox-metaTitle .admin__control-text';
},
getMetaDescriptionIdentifier: function() {
return this.config.metaDescriptionIdentifier || '.yoastBox-metaDescription .admin__control-textarea';
return this.config.metaDescriptionIdentifier || '.yoastBox-metaDescription .admin__control-textarea, .yoastBox-metaDescription .admin__control-text';
},
getMetaKeywordsIdentifier: function() {
return this.config.metaKeywordsIdentifier || '.yoastBox-metaKeywords';
Expand All @@ -112,6 +112,7 @@ define([

this.metaTitleChangedCheckbox = this.metaTitleInputElement.siblings('.admin__field-service').find('input[type=checkbox]');
this.metaDescriptionChangedCheckbox = this.metaDescriptionInputElement.siblings('.admin__field-service').find('input[type=checkbox]');
this.createRedirectCheckbox = $('.yoastBox-urlKey [name="product[url_key_create_redirect]"]');
},
getTemplateElements: function() {
// template input elements
Expand Down Expand Up @@ -215,9 +216,9 @@ define([
$(this.hideInputElements).each(function() {
var $this = $(this);
if ($this.hasClass('admin__field')) {
$this.hide();
$this.addClass('hidden');
} else {
$(this).parents('.admin__field').hide();
$(this).parents('.admin__field').slice(0,1).addClass('hidden');
}
});
},
Expand Down Expand Up @@ -279,7 +280,12 @@ define([
return this.urlKeyInputElement.val();
},
setIdentifierValue: function(value) {
this.urlKeyInputElement.val(value).change();
if (value !== this.urlKeyInputElement.val()) {
if (this.urlKeyInputElement.val() && this.createRedirectCheckbox.length) {
this.createRedirectCheckbox.attr('disabled', false).prop('checked', true);
}
this.urlKeyInputElement.attr('disabled', false).val(value).change();
}
return this;
},
getKeywordValue: function() {
Expand Down
2 changes: 1 addition & 1 deletion view/adminhtml/web/js/maxserv-yoast-seo.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b48aebb

Please sign in to comment.