Browse Source

Intégration système de paramètres Merchant et Section

feature/ticket
Guillaume 3 years ago
parent
commit
3dd94a9f87
16 changed files with 418 additions and 33 deletions
  1. +4
    -1
      config/packages/artgris_file_manager.yaml
  2. +3
    -2
      config/packages/doctrine.yaml
  3. +35
    -0
      migrations/Version20210605195723.php
  4. +33
    -0
      migrations/Version20210606143911.php
  5. +41
    -0
      migrations/Version20210606145644.php
  6. +35
    -0
      migrations/Version20210607084117.php
  7. +12
    -4
      src/Controller/Dashboard/DashboardAdminController.php
  8. +3
    -0
      src/Controller/Site/PageAdminController.php
  9. +112
    -0
      src/Definition/MerchantSettingDefinition.php
  10. +59
    -0
      src/Definition/SectionSettingDefinition.php
  11. +0
    -26
      src/Entity/Merchant/MerchantConfig.php
  12. +3
    -0
      src/Entity/Section/Section.php
  13. +26
    -0
      src/Entity/Setting/MerchantSetting.php
  14. +26
    -0
      src/Entity/Setting/SectionSetting.php
  15. +0
    -0
      templates/admin/dashboard/dashboard.html.twig
  16. +26
    -0
      translations/admin.fr.yaml

+ 4
- 1
config/packages/artgris_file_manager.yaml View File

@@ -1,5 +1,8 @@
artgris_file_manager:
conf:
default:
image:
dir: "../public%app.path_uploads%"
type: 'image'
file:
dir: "../public%app.path_uploads%"
type: 'file'

+ 3
- 2
config/packages/doctrine.yaml View File

@@ -22,7 +22,6 @@ doctrine:
Lc\CaracoleBundle\Model\Credit\CreditConfigInterface: App\Entity\Credit\CreditConfig
Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface: App\Entity\Credit\CreditHistory
Lc\CaracoleBundle\Model\File\DocumentInterface: App\Entity\File\Document
Lc\CaracoleBundle\Model\Merchant\MerchantConfigInterface: App\Entity\Merchant\MerchantConfig
Lc\CaracoleBundle\Model\Merchant\MerchantInterface: App\Entity\Merchant\Merchant
Lc\CaracoleBundle\Model\Newsletter\NewsletterInterface: App\Entity\Newsletter\Newsletter
Lc\CaracoleBundle\Model\Order\OrderPaymentInterface: App\Entity\Order\OrderPayment
@@ -53,4 +52,6 @@ doctrine:
Lc\CaracoleBundle\Model\User\UserMerchantInterface: App\Entity\User\UserMerchant
Lc\CaracoleBundle\Model\User\UserInterface: App\Entity\User\User
Lc\CaracoleBundle\Model\User\UserPointSaleInterface: App\Entity\User\UserPointSale
Lc\CaracoleBundle\Model\User\VisitorInterface: App\Entity\User\Visitor
Lc\CaracoleBundle\Model\User\VisitorInterface: App\Entity\User\Visitor
Lc\CaracoleBundle\Model\Setting\MerchantSettingInterface: App\Entity\Setting\MerchantSetting
Lc\CaracoleBundle\Model\Setting\SectionSettingInterface: App\Entity\Setting\SectionSetting

+ 35
- 0
migrations/Version20210605195723.php View File

@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210605195723 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE merchant_setting (id INT AUTO_INCREMENT NOT NULL, merchant_id INT NOT NULL, name VARCHAR(63) NOT NULL, value LONGTEXT DEFAULT NULL, INDEX IDX_464ACD036796D554 (merchant_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE section_setting (id INT AUTO_INCREMENT NOT NULL, section_id INT NOT NULL, name VARCHAR(63) NOT NULL, value LONGTEXT DEFAULT NULL, INDEX IDX_4D337597D823E37A (section_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE merchant_setting ADD CONSTRAINT FK_464ACD036796D554 FOREIGN KEY (merchant_id) REFERENCES merchant (id)');
$this->addSql('ALTER TABLE section_setting ADD CONSTRAINT FK_4D337597D823E37A FOREIGN KEY (section_id) REFERENCES section (id)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE merchant_setting');
$this->addSql('DROP TABLE section_setting');
}
}

+ 33
- 0
migrations/Version20210606143911.php View File

@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210606143911 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE merchant_setting ADD date DATETIME DEFAULT NULL, CHANGE value text LONGTEXT DEFAULT NULL');
$this->addSql('ALTER TABLE section_setting ADD date DATETIME DEFAULT NULL, CHANGE value text LONGTEXT DEFAULT NULL');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE merchant_setting DROP date, CHANGE text value LONGTEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`');
$this->addSql('ALTER TABLE section_setting DROP date, CHANGE text value LONGTEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`');
}
}

+ 41
- 0
migrations/Version20210606145644.php View File

@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210606145644 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE merchant_setting ADD file_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE merchant_setting ADD CONSTRAINT FK_464ACD0393CB796C FOREIGN KEY (file_id) REFERENCES file (id)');
$this->addSql('CREATE INDEX IDX_464ACD0393CB796C ON merchant_setting (file_id)');
$this->addSql('ALTER TABLE section_setting ADD file_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE section_setting ADD CONSTRAINT FK_4D33759793CB796C FOREIGN KEY (file_id) REFERENCES file (id)');
$this->addSql('CREATE INDEX IDX_4D33759793CB796C ON section_setting (file_id)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE merchant_setting DROP FOREIGN KEY FK_464ACD0393CB796C');
$this->addSql('DROP INDEX IDX_464ACD0393CB796C ON merchant_setting');
$this->addSql('ALTER TABLE merchant_setting DROP file_id');
$this->addSql('ALTER TABLE section_setting DROP FOREIGN KEY FK_4D33759793CB796C');
$this->addSql('DROP INDEX IDX_4D33759793CB796C ON section_setting');
$this->addSql('ALTER TABLE section_setting DROP file_id');
}
}

+ 35
- 0
migrations/Version20210607084117.php View File

@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210607084117 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE merchant_config');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE merchant_config (id INT AUTO_INCREMENT NOT NULL, merchant_id INT NOT NULL, created_by_id INT NOT NULL, updated_by_id INT NOT NULL, image_id INT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, dev_alias VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, name VARCHAR(63) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, value LONGTEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, INDEX IDX_3CA56895896DBBDE (updated_by_id), INDEX IDX_3CA568956796D554 (merchant_id), INDEX IDX_3CA568953DA5256D (image_id), INDEX IDX_3CA56895B03A8386 (created_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('ALTER TABLE merchant_config ADD CONSTRAINT FK_3CA568953DA5256D FOREIGN KEY (image_id) REFERENCES file (id)');
$this->addSql('ALTER TABLE merchant_config ADD CONSTRAINT FK_3CA568956796D554 FOREIGN KEY (merchant_id) REFERENCES merchant (id)');
$this->addSql('ALTER TABLE merchant_config ADD CONSTRAINT FK_3CA56895896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE merchant_config ADD CONSTRAINT FK_3CA56895B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
}
}

+ 12
- 4
src/Controller/Dashboard/DashboardAdminController.php View File

@@ -24,10 +24,11 @@ class DashboardAdminController extends CaracDashboardController
MenuItem::linkToCrud('user_index', '', User::class),
]
);
yield MenuItem::subMenu('account', 'user')->setSubItems(

yield MenuItem::subMenu('setting', 'circle')->setSubItems(
[
MenuItem::linkToRoute('account_profile', '', 'sov_admin_account_profile'),
MenuItem::linkToRoute('account_password', '', 'sov_admin_account_password'),
MenuItem::linkToRoute('setting_merchant', 'circle', 'carac_admin_setting_merchant'),
MenuItem::linkToRoute('setting_section', 'circle', 'carac_admin_setting_section'),
]
);

@@ -38,11 +39,18 @@ class DashboardAdminController extends CaracDashboardController
MenuItem::linkToCrud('admin_tva', 'circle', TaxRate::class),
]
);

yield MenuItem::subMenu('account', 'user')->setSubItems(
[
MenuItem::linkToRoute('account_profile', '', 'sov_admin_account_profile'),
MenuItem::linkToRoute('account_password', '', 'sov_admin_account_password'),
]
);
}

public function index(): Response
{
return $this->render('admin/dashboard.html.twig');
return $this->render('admin/dashboard/dashboard.html.twig');
}

/*public function configureMenuItems(): iterable

+ 3
- 0
src/Controller/Site/PageAdminController.php View File

@@ -8,7 +8,9 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\ImageManagerField;
use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Form\Common\FileManagerType;

class PageAdminController extends AbstractAdminController
{
@@ -25,6 +27,7 @@ class PageAdminController extends AbstractAdminController
[
FormField::addPanel('general'),
TextField::new('title'),
ImageManagerField::new('image'),
NumberField::new('position')->hideOnForm(),
StatusField::new('status'),
CKEditorField::new('description'),

+ 112
- 0
src/Definition/MerchantSettingDefinition.php View File

@@ -0,0 +1,112 @@
<?php

namespace App\Definition;

use Lc\CaracoleBundle\Definition\AbstractSettingDefinition;
use Lc\CaracoleBundle\Definition\MerchantSettingDefinitionInterface;

class MerchantSettingDefinition extends AbstractSettingDefinition implements MerchantSettingDefinitionInterface
{
const CATEGORY_GENERAL = 'general';
const CATEGORY_EMAIL = 'email';

const SETTING_EXAMPLE_TEXT = 'exampleText';
const SETTING_EXAMPLE_TEXTAREA = 'exampleTextarea';
const SETTING_EXAMPLE_TEXTAREA_ADVANCED = 'exampleTextareaAdvanced';
const SETTING_EXAMPLE_TEXT2 = 'exampleText2';
const SETTING_EXAMPLE_SELECT = 'exampleSelect';
const SETTING_EXAMPLE_RADIO = 'exampleRadio';
const SETTING_EXAMPLE_DATE = 'exampleDate';
const SETTING_EXAMPLE_TIME = 'exampleTime';
const SETTING_EXAMPLE_FILE = 'exampleFile';
const SETTING_EXAMPLE_IMAGE = 'exampleImage';


public function __construct()
{
// général
$this
->addSettingText(
[
'name' => self::SETTING_EXAMPLE_TEXT,
'category' => self::CATEGORY_GENERAL,
'default' => 'caracole !'
]
)
->addSettingTextarea(
[
'name' => self::SETTING_EXAMPLE_TEXTAREA,
'category' => self::CATEGORY_GENERAL,
'default' => 'test'
]
)
->addSettingTextareaAdvanced(
[
'name' => self::SETTING_EXAMPLE_TEXTAREA_ADVANCED,
'category' => self::CATEGORY_GENERAL
]
)
->addSettingSelect(
[
'name' => self::SETTING_EXAMPLE_SELECT,
'category' => self::CATEGORY_GENERAL,
'choices' => [
'Select 1' => 1,
'Select 2' => 2,
]
]
)
->addSettingRadio(
[
'name' => self::SETTING_EXAMPLE_RADIO,
'category' => self::CATEGORY_GENERAL,
'choices' => [
'Radio 1' => 1,
'Radio 2' => 2,
]
]
)
->addSettingDate(
[
'name' => self::SETTING_EXAMPLE_DATE,
'category' => self::CATEGORY_GENERAL
]
)
->addSettingTime(
[
'name' => self::SETTING_EXAMPLE_TIME,
'category' => self::CATEGORY_GENERAL
]
)
->addSettingFile(
[
'name' => self::SETTING_EXAMPLE_FILE,
'category' => self::CATEGORY_GENERAL
]
)
->addSettingImage(
[
'name' => self::SETTING_EXAMPLE_IMAGE,
'category' => self::CATEGORY_GENERAL
]
);

// email
$this
->addSettingText(
[
'name' => self::SETTING_EXAMPLE_TEXT2,
'category' => self::CATEGORY_EMAIL
]
);
}

public function getCategories()
{
return [
self::CATEGORY_GENERAL,
self::CATEGORY_EMAIL,
];
}

}

+ 59
- 0
src/Definition/SectionSettingDefinition.php View File

@@ -0,0 +1,59 @@
<?php

namespace App\Definition;

use App\Entity\Section\Section;
use Lc\CaracoleBundle\Definition\AbstractSettingDefinition;
use Lc\CaracoleBundle\Definition\SectionSettingDefinitionInterface;

class SectionSettingDefinition extends AbstractSettingDefinition implements SectionSettingDefinitionInterface
{
const CATEGORY_GENERAL = 'general';
const CATEGORY_CONFIGURATION = 'configuration';
const CATEGORY_SPECIFIC = 'specific';

const SETTING_EXAMPLE_TEXT = 'exampleText';
const SETTING_EXAMPLE_TEXT2 = 'exampleText2';
const SETTING_EXAMPLE_SPECIFIC_SECTION = 'exampleSpecificSection';

public function __construct()
{
// général
$this
->addSettingText(
[
'name' => self::SETTING_EXAMPLE_TEXT,
'category' => self::CATEGORY_GENERAL
]
);

// configuration
$this
->addSettingText(
[
'name' => self::SETTING_EXAMPLE_TEXT2,
'category' => self::CATEGORY_CONFIGURATION
]
);

// spécifique
$this
->addSettingText(
[
'name' => self::SETTING_EXAMPLE_SPECIFIC_SECTION,
'category' => self::CATEGORY_SPECIFIC,
'section' => Section::SECTION_LUNCH
]
);
}

public function getCategories()
{
return [
self::CATEGORY_GENERAL,
self::CATEGORY_CONFIGURATION,
self::CATEGORY_SPECIFIC,
];
}

}

+ 0
- 26
src/Entity/Merchant/MerchantConfig.php View File

@@ -1,26 +0,0 @@
<?php

namespace App\Entity\Merchant;

use Lc\CaracoleBundle\Model\Merchant\MerchantConfigModel;
use Lc\CaracoleBundle\Repository\Merchant\MerchantConfigRepository;
use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;

/**
* @ORM\Entity(repositoryClass=MerchantConfigRepository::class)
*/
class MerchantConfig extends MerchantConfigModel implements MerchantInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;

public function getId(): ?int
{
return $this->id;
}
}

+ 3
- 0
src/Entity/Section/Section.php View File

@@ -19,6 +19,9 @@ class Section extends SectionModel implements SectionInterface
*/
private $id;

const SECTION_MARKET = 'market' ;
const SECTION_LUNCH = 'lunch' ;

public function getId(): ?int
{
return $this->id;

+ 26
- 0
src/Entity/Setting/MerchantSetting.php View File

@@ -0,0 +1,26 @@
<?php

namespace App\Entity\Setting;

use Lc\CaracoleBundle\Model\Setting\MerchantSettingInterface;
use Lc\CaracoleBundle\Model\Setting\MerchantSettingModel;
use Lc\CaracoleBundle\Repository\Setting\MerchantSettingRepository;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity(repositoryClass=MerchantSettingRepository::class)
*/
class MerchantSetting extends MerchantSettingModel implements MerchantSettingInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;

public function getId(): ?int
{
return $this->id;
}
}

+ 26
- 0
src/Entity/Setting/SectionSetting.php View File

@@ -0,0 +1,26 @@
<?php

namespace App\Entity\Setting;

use Lc\CaracoleBundle\Model\Setting\SectionSettingInterface;
use Lc\CaracoleBundle\Model\Setting\SectionSettingModel;
use Lc\CaracoleBundle\Repository\Setting\SectionSettingRepository;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity(repositoryClass=SectionSettingRepository::class)
*/
class SectionSetting extends SectionSettingModel implements SectionSettingInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;

public function getId(): ?int
{
return $this->id;
}
}

templates/admin/dashboard.html.twig → templates/admin/dashboard/dashboard.html.twig View File


+ 26
- 0
translations/admin.fr.yaml View File

@@ -0,0 +1,26 @@
setting_definition:
merchant:
categories:
general: Général
email: Email
settings:
exampleText: Texte
exampleText2: Texte 2
exampleChoice: Choix
exampleTextarea: Textarea
exampleTextareaAdvanced: Textarea avancé
exampleSelect: Select
exampleRadio: Radio
exampleDate: Exemple date
exampleTime: Exemple time
exampleFile: Exemple fichier
exampleImage: Exemple image
section:
categories:
general: Général
configuration: Configuration
specific: Spécifique
settings:
exampleText: Texte
exampleText2: Texte 2
exampleSpecificSection: Section spécifique

Loading…
Cancel
Save