Browse Source

Correctif sur status

master
Fab 4 years ago
parent
commit
89a4401604
9 changed files with 57 additions and 63 deletions
  1. +7
    -2
      ShopBundle/Controller/Admin/AdminController.php
  2. +2
    -3
      ShopBundle/EventSubscriber/EditEventSubscriber.php
  3. +2
    -1
      ShopBundle/Form/MerchantConfigType.php
  4. +0
    -1
      ShopBundle/Model/AbstractDocumentEntity.php
  5. +28
    -1
      ShopBundle/Model/MerchantConfig.php
  6. +6
    -3
      ShopBundle/Resources/public/js/backend/script/default/init-common.js
  7. +0
    -48
      ShopBundle/Resources/public/js/backend/script/default/init-edit.js
  8. +7
    -1
      ShopBundle/Resources/translations/lcshop.fr.yaml
  9. +5
    -3
      ShopBundle/Twig/FrontendTwigExtension.php

+ 7
- 2
ShopBundle/Controller/Admin/AdminController.php View File

@@ -89,7 +89,6 @@ class AdminController extends EasyAdminController

protected function commonQueryFilter($entityClass, $queryBuilder)
{

if (new $entityClass instanceof FilterMultipleMerchantsInterface) {
$queryBuilder->andWhere(':currentMerchant MEMBER OF entity.merchants')
->setParameter(':currentMerchant', $this->getUser()->getMerchant()->getId());
@@ -287,12 +286,18 @@ class AdminController extends EasyAdminController
$passedOptions = $child->getConfig()->getOptions();
$classImplements = class_implements($passedOptions['class']);

if (in_array('Lc\ShopBundle\Context\FilterMerchantInterface', $classImplements)) {
$isFilterMerchantInterface = in_array('Lc\ShopBundle\Context\FilterMerchantInterface', $classImplements) ;
$isFilterMultipleMerchantsInterface = in_array('Lc\ShopBundle\Context\FilterMultipleMerchantsInterface', $classImplements) ;

if ($isFilterMerchantInterface || $isFilterMultipleMerchantsInterface) {

if (in_array('Lc\ShopBundle\Context\StatusInterface', $classImplements)) {
$statusInterface = true;
}
$propertyMerchant = 'merchant';
if($isFilterMultipleMerchantsInterface) {
$propertyMerchant .= 's' ;
}

$form->add($child->getName(), EntityType::class, array(
'class' => $this->em->getClassMetadata($passedOptions['class'])->getName(),

+ 2
- 3
ShopBundle/EventSubscriber/EditEventSubscriber.php View File

@@ -55,9 +55,8 @@ class EditEventSubscriber implements EventSubscriberInterface
}


public function updateCommonProperty(GenericEvent $event){

dump($event);
public function updateCommonProperty(GenericEvent $event)
{
/* $this->setUpdated($entity);
$this->setAddressCreatedBy($entity) ;*/
}

+ 2
- 1
ShopBundle/Form/MerchantConfigType.php View File

@@ -15,6 +15,7 @@ use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Vich\UploaderBundle\Form\Type\VichImageType;

class MerchantConfigType extends AbstractType
{
@@ -48,7 +49,7 @@ class MerchantConfigType extends AbstractType
]);
}
elseif($merchantConfig->getFieldType() == 'image') {
$form->add('value', CKFinderFileChooserType::class, [
$form->add('imageFile', VichImageType::class, [
'label' => $merchantConfig->getLabel(),
]);
}

+ 0
- 1
ShopBundle/Model/AbstractDocumentEntity.php View File

@@ -7,7 +7,6 @@ use Gedmo\Mapping\Annotation as Gedmo;
use Lc\ShopBundle\Context\SluggableInterface;
use Lc\ShopBundle\Context\SortableInterface;
use Lc\ShopBundle\Context\StatusInterface;
use Lc\ShopBundle\Model\AbstractEntity;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;


+ 28
- 1
ShopBundle/Model/MerchantConfig.php View File

@@ -3,11 +3,14 @@
namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;

/**
* @ORM\MappedSuperclass()
* @Vich\Uploadable
*/
abstract class MerchantConfig
abstract class MerchantConfig extends AbstractEntity
{
/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="merchantConfigs")
@@ -25,6 +28,12 @@ abstract class MerchantConfig
*/
protected $value;

/**
* @Vich\UploadableField(mapping="images", fileNameProperty="value")
* @var File
*/
protected $imageFile;

public static $availableOptions = [] ;

public function getMerchant(): ?Merchant
@@ -63,6 +72,24 @@ abstract class MerchantConfig
return $this;
}

public function setImageFile(File $image = null)
{
$this->imageFile = $image;

// VERY IMPORTANT:
// It is required that at least one field changes if you are using Doctrine,
// otherwise the event listeners won't be called and the file is lost
if ($image) {
// if 'updatedAt' is not defined in your entity, use another property
$this->updatedAt = new \DateTime('now');
}
}

public function getImageFile()
{
return $this->imageFile;
}

public static function getAvailableOptions(): array
{
return static::$availableOptions ;

+ 6
- 3
ShopBundle/Resources/public/js/backend/script/default/init-common.js View File

@@ -45,14 +45,17 @@ function initAdminLtePlugin() {
checkForm()
})


if ($('.select2, select.form-control').length) {
$('form .form-widget>select.form-control, .select2').each(function (i, elm) {
setSelect2($(elm))
if(!$(this).hasClass('disable-select2')) {
setSelect2($(elm)) ;
}
});

$('form .form-inline>select.form-control').each(function (i, elm) {
setSelect2($(elm))
if(!$(this).hasClass('disable-select2')) {
setSelect2($(elm)) ;
}
});
}


+ 0
- 48
ShopBundle/Resources/public/js/backend/script/default/init-edit.js View File

@@ -1,7 +1,5 @@
jQuery(document).ready(function () {

initLcCkEditor();
initCkFinder();
//generateNotice('error', 'Ceci est une notice');
$('.action-delete').on('click', function(e) {
e.preventDefault();
@@ -21,11 +19,7 @@ function checkForm(){
$('form').addClass('form-sent');
//Panel vues js
if($('form').find('.panel').length){
log('here');

$('form').find('.panel').each(function(i, panel){
log(i);
log($(panel).find(':invalid').length);
if($(panel).find(':invalid').length){
$('#nav-params').find('.nav-item:eq('+i+')').addClass('has-invalid');
}else{
@@ -35,47 +29,6 @@ function checkForm(){
}
}

function initCkFinder(){

$('.lc-ckfinder-wrap').each(function(){
$widget = $(this);

if($widget.find('.lc-ckfinder-field').val() !== ''){
$widget.find('.lc-ckfinder-illu').css('background-image', "url('"+$widget.find('.lc-ckfinder-field').val()+"')");
$widget.find('.lc-ckfinder-remove').show();
}

$widget.find('.lc-ckfinder-button').on( 'click', function( e ) {
e.preventDefault();
CKFinder.popup( {
chooseFiles: true,
onInit: function( finder ) {
finder.on( 'files:choose', function( evt ) {
var file = evt.data.files.first();
$widget.find('.lc-ckfinder-illu').css('background-image', "url('"+file.getUrl()+"')");
$widget.find('.lc-ckfinder-remove').show();
$widget.find('.lc-ckfinder-field').val(file.getUrl());
} );
finder.on( 'file:choose:resizedImage', function( evt ) {
var output = document.getElementById( '{{ id }}' );
output.value = evt.data.resizedUrl;
} );
}
} );
} );
$widget.find('.lc-ckfinder-remove').on('click', function () {
$widget.find('.lc-ckfinder-remove').hide();
$widget.find('.lc-ckfinder-illu').css('background-image', 'none');
$widget.find('.lc-ckfinder-field').val("");
})
});

if ($('.field-ckfinder_file_chooser').length > 0) {
CKFinder.config({connectorPath: '/ckfinder/connector'});
}
}


/* CKEditor */

function initLcCkEditor(){
@@ -95,7 +48,6 @@ function initLcCkEditor(){
],
"language": "fr"
});
CKFinder.setupCKEditor(editor);
}
}
}

+ 7
- 1
ShopBundle/Resources/translations/lcshop.fr.yaml View File

@@ -67,7 +67,7 @@ field:
company: Société
siret: N° SIRET
tva: N° TVA
price: Prix de vente
price: Prix
priceWithTax: Prix de vente TTC
username: Nom d'utilisateur
email: E-mail
@@ -115,6 +115,7 @@ field:
merchantConfigs: Configuration
taxRate: Règle de taxe
value: Valeur
behaviorAddToCart: Ajout au panier

ProductFamily:
taxRateInherited: Utiliser la TVA par défaut
@@ -147,6 +148,11 @@ field:
product: Par déclinaisons
taxRate: TVA
unit: Unité
behaviorAddToCartOptions:
simple: Simple
multiple: Multiple


action:
new: Créer %entity_label%
switchMerchant: Votre hub

+ 5
- 3
ShopBundle/Twig/FrontendTwigExtension.php View File

@@ -70,14 +70,16 @@ class FrontendTwigExtension extends AbstractExtension
if (substr($path, 0, 1) === '/') $path = substr($path, 1);

if ($path) {
if (strpos($path, $this->getFileManagerFolder()) === false) {
$path = $this->getFileManagerFolder() . '/' . $path;
$fileManagerFolder = substr($this->getFileManagerFolder(), 1) ;

if (strpos($path, $fileManagerFolder) === false) {
$path = $fileManagerFolder . '/' . $path;
}

return $this->liipCacheHelper->getBrowserPath($path, $thumb);
} else {

return $this->liipCacheHelper->getBrowserPath('assets/img/frontend/' . $default, $thumb);
return $this->liipCacheHelper->getBrowserPath($this->getFileManagerFolder() . '/' . $default, $thumb);
}
}


Loading…
Cancel
Save