Commit 1393384e authored by Tino Goratsch's avatar Tino Goratsch

various fixes and improvements for the social sharing module

parent fe0591f3
......@@ -74,18 +74,27 @@ class ValidateSharingInfoOnValidationInfo
'haystack' => [0, 1],
],
]
)
->addConstraint(
InArrayValidationRule::class,
[
'data' => $event->getFormData(),
'field' => 'share_services',
'message' => $this->translator->t('share', 'select_services'),
'extra' => [
'haystack' => $this->socialServices->getActiveServices(),
],
]
)
);
if (isset($event->getFormData()['share_customize_services'])
&& $event->getFormData()['share_customize_services'] == 1) {
$event
->getValidator()
->addConstraint(
InArrayValidationRule::class,
[
'data' => $event->getFormData(),
'field' => 'share_services',
'message' => $this->translator->t('share', 'select_services'),
'extra' => [
'haystack' => $this->socialServices->getActiveServices(),
],
]
);
}
$event
->getValidator()
->addConstraint(
InArrayValidationRule::class,
[
......
......@@ -79,12 +79,12 @@ class ShareFormFields
),
'customize_services' => $this->formsHelper->yesNoCheckboxGenerator(
'share_customize_services',
$this->hasCustomizedServices(\unserialize($sharingInfo['services'])) ? 1 : 0
$this->hasCustomizedServices($sharingInfo['services']) ? 1 : 0
),
'services' => $this->formsHelper->choicesGenerator(
'share_services',
$this->getAvailableServices(),
$this->getCurrentServices(\unserialize($sharingInfo['services']))
$this->getCurrentServices($sharingInfo['services'])
),
'ratings_active' => $this->formsHelper->yesNoCheckboxGenerator(
'share_ratings_active',
......@@ -123,6 +123,12 @@ class ShareFormFields
$sharingInfo['services'] = $settings['services'];
}
$sharingInfo['services'] = \unserialize($sharingInfo['services']);
if (\is_array($sharingInfo['services']) === false) {
$sharingInfo['services'] = [];
}
return $sharingInfo;
}
......
......@@ -61,9 +61,14 @@ class SocialServices
{
$settings = $this->settings->getSettings(Schema::MODULE_NAME);
$services = \unserialize($settings['services']);
if (\is_array($services) === false) {
$services = [];
}
return \array_intersect(
$this->getAllServices(),
\unserialize($settings['services'])
$services
);
}
......
......@@ -9,9 +9,7 @@
position: relative;
unicode-bidi: bidi-override;
}
.rating:not(.rating_mobile):active .rating__average,
.rating:not(.rating_mobile):focus .rating__average,
.rating:not(.rating_mobile):hover .rating__average {
.rating:hover .rating__average {
visibility: hidden;
}
.rating__average {
......
......@@ -5,6 +5,6 @@
jQuery(document).ready(function ($) {
$('#services').on('change', function () {
$('#fb-credentials-wrapper').toggle($(this).val().indexOf('facebook') !== -1);
$('#fb-credentials-wrapper').toggle($(this).val() && $(this).val().indexOf('facebook') !== -1);
}).triggerHandler('change');
});
......@@ -13,13 +13,9 @@
position: relative;
unicode-bidi: bidi-override;
&:not(.rating_mobile) {
&:active,
&:focus,
&:hover {
.rating__average {
visibility: hidden;
}
&:hover {
.rating__average {
visibility: hidden;
}
}
}
......
......@@ -6,11 +6,9 @@
{javascripts}
{include_js module="share" file="partials/rating"}
{/javascripts}
{if !empty($sharing.services)}
<hr>
{/if}
{/if}
{if !empty($sharing.services)}
<hr>
{load_module module="widget/share/index/index" path=$sharing.path}
{js_libraries enable='shariff'}
{/if}
......@@ -4,7 +4,7 @@
data-ajax-form="true"
data-ajax-form-target-element="#rating-wrapper"
data-ajax-form-loading-overlay="false">
<div class="rating {if $UA_IS_MOBILE === true} rating_mobile{/if}">
<div class="rating">
<div class="rating__average" style="width:{(($rating.average_rating|default:0) * 100 / 5)|round:0}%">
<span class="rating__star"></span>
<span class="rating__star"></span>
......
{include file="asset:System/Partials/form_group.button_group.tpl" options=$share.active required=true label={lang t="share|activate_sharing"}}
<div id="share-services-wrapper">
{include file="asset:System/Partials/form_group.button_group.tpl" options=$share.customize_services required=true label={lang t="share|customize_services"}}
<div id="share-custom-services-wrapper">
{include file="asset:System/Partials/form_group.select.tpl" options=$share.services multiple=true required=true label={lang t="share|active_services"}}
</div>
{if !empty($share.services)}
<div id="share-custom-services-wrapper">
{include file="asset:System/Partials/form_group.select.tpl" options=$share.services multiple=true required=true label={lang t="share|active_services"}}
</div>
{/if}
</div>
{include file="asset:System/Partials/form_group.button_group.tpl" options=$share.ratings_active required=true label={lang t="share|activate_ratings"}}
{if !empty($share.uri_pattern)}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment