Skip to content

Commit

Permalink
[Shopsys] Sliders extension (#3574)
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMolcik authored Nov 20, 2024
2 parents d830e3e + cccd1f2 commit 32ba352
Show file tree
Hide file tree
Showing 26 changed files with 195 additions and 201 deletions.
30 changes: 2 additions & 28 deletions app/config/graphql/types/ModelType/Slider/SliderItem.types.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,15 @@
SliderItem:
type: object
inherits:
- 'SliderItemDecorator'
config:
fields:
uuid:
type: "Uuid!"
description: "UUID"
name:
type: "String!"
description: "Slider name"
link:
type: "String!"
description: "Target link"
extendedText:
type: "String"
description: "Text below slider"
extendedTextLink:
type: "String"
description: "Target link of text below slider"
gtmId:
type: "String!"
description: "GTM ID"
gtmCreative:
type: "String"
description: "GTM creative"
images:
type: "[Image!]!"
description: "Slider item images"
resolve: '@=query("imagesByEntityPromiseQuery", value, args["type"])'
args:
type:
type: "String"
defaultValue: null
mainImage:
type: "Image!"
description: "Slider item image by params"
resolve: '@=query("mainImageByEntityPromiseQuery", value, args["type"])'
args:
type:
type: "String"
defaultValue: null
1 change: 1 addition & 0 deletions app/config/packages/twig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ twig:
- '@ShopsysFramework/Admin/Form/mailWhitelistFormTheme.html.twig'
- '@ShopsysFramework/Admin/Form/multiLocaleBasicFileuploadFields.html.twig'
- '@ShopsysFramework/Admin/Form/multiLocaleFileuploadFields.html.twig'
- '@ShopsysFramework/Admin/Form/numberSlider.html.twig'
- '@ShopsysFramework/Admin/Form/orderItems.html.twig'
- '@ShopsysFramework/Admin/Form/orderlistFields.html.twig'
- '@ShopsysFramework/Admin/Form/parameterValueConversionList.html.twig'
Expand Down
10 changes: 6 additions & 4 deletions app/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2363,10 +2363,8 @@ type Settings {
}

type SliderItem {
"Text below slider"
extendedText: String
"Target link of text below slider"
extendedTextLink: String
"Slider description"
description: String
"GTM creative"
gtmCreative: String
"GTM ID"
Expand All @@ -2379,6 +2377,10 @@ type SliderItem {
mainImage(type: String = null): Image!
"Slider name"
name: String!
"Opacity level for the background color of the slider description box"
opacity: Float!
"RGB color code for the background of the slider description box"
rgbBackgroundColor: String!
"UUID"
uuid: Uuid!
}
Expand Down
11 changes: 9 additions & 2 deletions app/src/DataFixtures/Demo/SliderItemDataFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,29 @@ public function load(ObjectManager $manager): void
$sliderItemData->domainId = $domainId;
$sliderItemData->hidden = false;
$sliderItemData->gtmId = 'sliderItemTest';
$sliderItemData->sliderExtendedText = t('Terms of promotion', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $locale);
$sliderItemData->sliderExtendedTextLink = 'https://www.shopsys.cz';
$sliderItemData->uuid = Uuid::uuid5(self::UUID_NAMESPACE, 'Terms of promotion' . $domainId)->toString();

$sliderItemData->name = 'Shopsys';
$sliderItemData->link = 'https://www.shopsys.cz';
$sliderItemData->description = t('This slider item promotes our latest offers and updates. Stay tuned for more exciting news and promotions. Click the link to learn more!', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $locale);
$sliderItemData->rgbBackgroundColor = '#4844bd';
$sliderItemData->opacity = 0.8;

$this->sliderItemFacade->create($sliderItemData);

$sliderItemData->name = t('Documentation', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $locale);
$sliderItemData->description = t('Explore our comprehensive documentation to get the most out of our platform. Find guides, tutorials, and detailed information to help you navigate and utilize all features effectively. Click the link to access the full documentation.', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $locale);
$sliderItemData->rgbBackgroundColor = '#808080';
$sliderItemData->opacity = 0.8;
$sliderItemData->link = 'https://docs.shopsys.com';
$sliderItemData->uuid = Uuid::uuid5(self::UUID_NAMESPACE, 'Documentation' . $domainId)->toString();

$this->sliderItemFacade->create($sliderItemData);

$sliderItemData->name = t('Become one of us', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $locale);
$sliderItemData->description = t('Join our team and be part of an innovative company. Explore exciting career opportunities and grow with us!', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $locale);
$sliderItemData->rgbBackgroundColor = '#b3bf45';
$sliderItemData->opacity = 0.8;
$sliderItemData->link = 'https://jobs.shopsys.cz';
$sliderItemData->uuid = Uuid::uuid5(self::UUID_NAMESPACE, 'Become one of us' . $domainId)->toString();

Expand Down
17 changes: 0 additions & 17 deletions app/src/Form/Admin/SliderItemFormTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Shopsys\FrameworkBundle\Model\Slider\SliderItem;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints;

Expand All @@ -23,7 +22,6 @@ class SliderItemFormTypeExtension extends AbstractTypeExtension
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$this->buildExtendedTextAndLinkForm($builder);
$this->buildVisibilityIntervalForm($builder);
$this->buildImagesGroup($builder, $options);
$this->buildGtmForm($builder);
Expand Down Expand Up @@ -88,21 +86,6 @@ private function buildImagesGroup(FormBuilderInterface $builder, array $options)
]);
}

/**
* @param \Symfony\Component\Form\FormBuilderInterface $builder
*/
private function buildExtendedTextAndLinkForm(FormBuilderInterface $builder): void
{
$builder->add('sliderExtendedText', TextType::class, [
'required' => false,
'label' => t('Text displayed under banner'),
])
->add('sliderExtendedTextLink', UrlType::class, [
'required' => false,
'label' => t('Link of text under banner'),
]);
}

/**
* @param \Symfony\Component\Form\FormBuilderInterface $builder
*/
Expand Down
28 changes: 0 additions & 28 deletions app/src/FrontendApi/Resolver/SliderItem/SliderItemResolverMap.php

This file was deleted.

27 changes: 27 additions & 0 deletions app/src/Migrations/Version20241114072907.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace App\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Shopsys\MigrationBundle\Component\Doctrine\Migrations\AbstractMigration;

class Version20241114072907 extends AbstractMigration
{
/**
* @param \Doctrine\DBAL\Schema\Schema $schema
*/
public function up(Schema $schema): void
{
$this->sql('ALTER TABLE slider_items DROP COLUMN slider_extended_text');
$this->sql('ALTER TABLE slider_items DROP COLUMN slider_extended_text_link');
}

/**
* @param \Doctrine\DBAL\Schema\Schema $schema
*/
public function down(Schema $schema): void
{
}
}
32 changes: 0 additions & 32 deletions app/src/Model/Slider/SliderItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@ class SliderItem extends BaseSliderItem
*/
protected $datetimeVisibleTo;

/**
* @var string|null
* @ORM\Column(type="text",nullable=true)
*/
protected $sliderExtendedText;

/**
* @var string|null
* @ORM\Column(type="text",nullable=true)
*/
protected $sliderExtendedTextLink;

/**
* @var string|null
* @ORM\Column(type="text",nullable=false)
Expand Down Expand Up @@ -69,8 +57,6 @@ public function __construct($sliderItemData)

$this->datetimeVisibleFrom = $sliderItemData->datetimeVisibleFrom;
$this->datetimeVisibleTo = $sliderItemData->datetimeVisibleTo;
$this->sliderExtendedText = $sliderItemData->sliderExtendedText;
$this->sliderExtendedTextLink = $sliderItemData->sliderExtendedTextLink;
$this->gtmId = $sliderItemData->gtmId;
$this->gtmCreative = $sliderItemData->gtmCreative;
$this->uuid = $sliderItemData->uuid ?: Uuid::uuid4()->toString();
Expand All @@ -85,8 +71,6 @@ public function edit($sliderItemData)

$this->datetimeVisibleFrom = $sliderItemData->datetimeVisibleFrom;
$this->datetimeVisibleTo = $sliderItemData->datetimeVisibleTo;
$this->sliderExtendedText = $sliderItemData->sliderExtendedText;
$this->sliderExtendedTextLink = $sliderItemData->sliderExtendedTextLink;
$this->gtmId = $sliderItemData->gtmId;
$this->gtmCreative = $sliderItemData->gtmCreative;
}
Expand Down Expand Up @@ -123,22 +107,6 @@ public function setDatetimeVisibleTo(?DateTime $datetimeVisibleTo): void
$this->datetimeVisibleTo = $datetimeVisibleTo;
}

/**
* @return string|null
*/
public function getSliderExtendedText(): ?string
{
return $this->sliderExtendedText;
}

/**
* @return string|null
*/
public function getSliderExtendedTextLink(): ?string
{
return $this->sliderExtendedTextLink;
}

/**
* @return string
*/
Expand Down
10 changes: 0 additions & 10 deletions app/src/Model/Slider/SliderItemData.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ class SliderItemData extends BaseSliderItemData
*/
public $datetimeVisibleTo;

/**
* @var string|null
*/
public $sliderExtendedText;

/**
* @var string|null
*/
public $sliderExtendedTextLink;

/**
* @var \Shopsys\FrameworkBundle\Component\FileUpload\ImageUploadData
*/
Expand Down
2 changes: 0 additions & 2 deletions app/src/Model/Slider/SliderItemDataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ protected function fillFromSliderItem(BaseSliderItemData $sliderItemData, BaseSl

$sliderItemData->datetimeVisibleFrom = $sliderItem->getDatetimeVisibleFrom();
$sliderItemData->datetimeVisibleTo = $sliderItem->getDatetimeVisibleTo();
$sliderItemData->sliderExtendedText = $sliderItem->getSliderExtendedText();
$sliderItemData->sliderExtendedTextLink = $sliderItem->getSliderExtendedTextLink();
$sliderItemData->gtmId = $sliderItem->getGtmId();
$sliderItemData->gtmCreative = $sliderItem->getGtmCreative();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,14 @@ public function testGetSliderItems(): void
[
'name' => t('Shopsys', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $firstDomainLocale),
'link' => 'https://www.shopsys.cz',
'extendedText' => t('Terms of promotion', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $firstDomainLocale),
'extendedTextLink' => 'https://www.shopsys.cz',
],
[
'name' => t('Documentation', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $firstDomainLocale),
'link' => 'https://docs.shopsys.com',
'extendedText' => t('Terms of promotion', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $firstDomainLocale),
'extendedTextLink' => 'https://www.shopsys.cz',
],
[
'name' => t('Become one of us', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $firstDomainLocale),
'link' => 'https://jobs.shopsys.cz',
'extendedText' => t('Terms of promotion', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $firstDomainLocale),
'extendedTextLink' => 'https://www.shopsys.cz',
],
];

Expand All @@ -47,8 +41,6 @@ public function testGetSliderItems(): void
[
'name',
'link',
'extendedText',
'extendedTextLink',
],
$sliderItem,
array_shift($expectedSliderItemsData),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ query SliderItemsQuery ($imageType: String) {
uuid
name
link
extendedText
extendedTextLink
images (type: $imageType) {
url
name
Expand Down
12 changes: 9 additions & 3 deletions app/translations/dataFixtures.cs.po
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,9 @@ msgstr "Ergonomie"
msgid "Expect delivery by the end of next month"
msgstr "Očekávejte dodávku koncem příštího měsíce"

msgid "Explore our comprehensive documentation to get the most out of our platform. Find guides, tutorials, and detailed information to help you navigate and utilize all features effectively. Click the link to access the full documentation."
msgstr "Prozkoumejte naši komplexní dokumentaci, abyste získali maximum z naší platformy. Najdete zde průvodce, návody a podrobné informace, které vám pomohou efektivně se orientovat a využívat všechny funkce. Klikněte na odkaz pro přístup k celé dokumentaci."

msgid "Extension rod plastic TM-4610"
msgstr "Nástavec tyčový plast TM-4610"

Expand Down Expand Up @@ -1075,6 +1078,9 @@ msgstr "JURA Impressa J9 TFT Carbon"
msgid "Job at Shopsys"
msgstr "Práce v Shopsys"

msgid "Join our team and be part of an innovative company. Explore exciting career opportunities and grow with us!"
msgstr "Přidejte se k nám a buďte součástí inovativní společnosti. Objevte vzrušující kariérní příležitosti a rosťte s námi!"

msgid "Kabel HDMI A - HDMI A M/M 2m gold-plated connectors High Speed HD"
msgstr "Kabel HDMI A - HDMI A M/M 2m zlacene konektory High Speed HD"

Expand Down Expand Up @@ -1780,9 +1786,6 @@ msgstr "Obchodní podmínky obchodních domů"
msgid "Terms and conditions of eshop"
msgstr "Obchodní podmínky e-shopu"

msgid "Terms of promotion"
msgstr "Pravidla akce"

msgid "Thank you for your order no. {number} placed at {date}"
msgstr "Děkujeme za objednávku č. {number} ze dne {date}"

Expand Down Expand Up @@ -1831,6 +1834,9 @@ msgstr "Konec nemotornému odkládání hrnců na novou kuchyňskou linku nebo n
msgid "This product is not an independently functional unit and may require professional installation."
msgstr "Přenosný pevný disk GT SuperSpeed USB 3.0 se inspiruje dlouhou historií sportovních vozů"

msgid "This slider item promotes our latest offers and updates. Stay tuned for more exciting news and promotions. Click the link to learn more!"
msgstr "Tenhle posuvník propaguje naše nejnovější nabídky a aktualizace. Buďte v obraze a sledujte další vzrušující novinky a akce. Klikněte na odkaz a dozvíte se více!"

msgid "Ticket for 100 CZK"
msgstr "Poukázka na 100 CZK"

Expand Down
Loading

0 comments on commit 32ba352

Please sign in to comment.