浏览代码

Repository base & form ajout de produit & ckinder css & vuejs

reduction
Fab 4 年前
父节点
当前提交
dcf75c2ccf
共有 21 个文件被更改,包括 687 次插入39 次删除
  1. +154
    -5
      ShopBundle/Controller/Admin/AdminController.php
  2. +34
    -0
      ShopBundle/Form/ProductType.php
  3. +28
    -11
      ShopBundle/Model/ProductFamily.php
  4. +36
    -0
      ShopBundle/Repository/BaseRepository.php
  5. +64
    -0
      ShopBundle/Repository/ProductCategoryRepository.php
  6. +10
    -7
      ShopBundle/Resources/config/easy_admin/base.yaml
  7. +10
    -1
      ShopBundle/Resources/public/css/backend/custom.css
  8. +0
    -0
      ShopBundle/Resources/public/js/backend/plugin/jquery-ui.min.js
  9. +6
    -0
      ShopBundle/Resources/public/js/backend/plugin/vue.min.js
  10. +5
    -3
      ShopBundle/Resources/public/js/backend/script/custom.js
  11. +39
    -0
      ShopBundle/Resources/public/js/backend/script/setup-ckfinder.js
  12. +48
    -2
      ShopBundle/Resources/public/js/backend/script/utils.js
  13. +33
    -0
      ShopBundle/Resources/public/js/backend/script/vueapp.js
  14. +0
    -5
      ShopBundle/Resources/public/js/backend/setup-ckfinder.js
  15. +4
    -1
      ShopBundle/Resources/translations/EasyAdminBundle.fr.yaml
  16. +3
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  17. +72
    -0
      ShopBundle/Resources/views/backend/default/edit_productfamily.html.twig
  18. +3
    -0
      ShopBundle/Resources/views/backend/default/list_association.html.twig
  19. +67
    -0
      ShopBundle/Resources/views/backend/form/ckeditor_widget.html.twig
  20. +13
    -4
      ShopBundle/Resources/views/backend/form/ckfinder_widget.html.twig
  21. +58
    -0
      ShopBundle/Resources/views/backend/form/custom_bootstrap_4.html.twig

+ 154
- 5
ShopBundle/Controller/Admin/AdminController.php 查看文件

@@ -2,15 +2,29 @@

namespace Lc\ShopBundle\Controller\Admin;

use App\Entity\ProductCategory;
use Doctrine\DBAL\Types\TextType;
use Doctrine\ORM\EntityRepository;
use EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController;
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
use FOS\UserBundle\Model\UserManagerInterface;
use Lc\ShopBundle\Context\MerchantInterface;
use Lc\ShopBundle\Context\ProductCategoryInterface;
use Lc\ShopBundle\Context\SortableInterface;
use Lc\ShopBundle\Context\StatusInterface;
use Lc\ShopBundle\Context\TaxRateInterface;
use Lc\ShopBundle\Context\TreeInterface;
use Lc\ShopBundle\Form\AbstractEditPositionType;
use Lc\ShopBundle\Form\ChoiceProductCategoryType;
use Lc\ShopBundle\Form\PriceType;
use Lc\ShopBundle\Form\ProductType;
use Lc\ShopBundle\Form\Widget\PriceWidgetType;
use Lc\ShopBundle\Repository\BaseRepository;
use Lc\ShopBundle\Repository\ProductCategoryRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Security;

@@ -19,6 +33,7 @@ class AdminController extends EasyAdminController
protected $security;
protected $userManager;


public function __construct(Security $security, UserManagerInterface $userManager)
{
$this->security = $security;
@@ -33,9 +48,9 @@ class AdminController extends EasyAdminController
$dqlFilter = sprintf(str_replace('currentMerchant', $this->getUser()->getMerchant()->getId(), $dqlFilter));
}

if (new $entityClass instanceof StatusInterface) {
if($dqlFilter) $dqlFilter .= sprintf(' AND entity.status > 0');
else $dqlFilter .= sprintf(' entity.status > 0');
if (new $entityClass instanceof StatusInterface && strpos($dqlFilter, 'entity.status') === false) {
if ($dqlFilter) $dqlFilter .= sprintf(' AND entity.status > = 0');
else $dqlFilter .= sprintf(' entity.status > = 0');
}

$queryBuilder = parent::createListQueryBuilder($entityClass, $sortDirection, $sortField, $dqlFilter);
@@ -85,6 +100,7 @@ class AdminController extends EasyAdminController
parent::updateEntity($entity);
}


public function persistEntity($entity)
{

@@ -101,7 +117,7 @@ class AdminController extends EasyAdminController
$total = $this->em->getRepository($this->entity['class'])->count(array('status' => 1, 'parent' => null));
$entity->setPosition($total);
}
}else{
} else {
$total = $this->em->getRepository($this->entity['class'])->count(array('status' => 1));
$entity->setPosition($total);
}
@@ -139,10 +155,23 @@ class AdminController extends EasyAdminController
$this->setUpdated($entity);



parent::persistEntity($entity);
}

public function updateProductFamilyEntity($entity)
{

$prodductFamilyRequest = $this->request->request->get('productfamily');

if ($taxRateId = intval($prodductFamilyRequest['taxRate']) > 0) {
$repo = $this->em->getRepository(TaxRateInterface::class);
$entity->setTaxRate($repo->find($taxRateId));
}

$this->setUpdated($entity);
parent::updateEntity($entity);
}

public function setUpdated($entity)
{

@@ -200,6 +229,8 @@ class AdminController extends EasyAdminController

$this->dispatch(EasyAdminEvents::PRE_LIST);
$entity = null;

//Replace this with query builder function, do not use finAll of easyAdmin
if ($this->request->query->get('id')) {
$id = $this->request->query->get('id');
$this->entity['list']['dql_filter'] = "entity.parent = " . $id;
@@ -207,6 +238,10 @@ class AdminController extends EasyAdminController
$easyadmin = $this->request->attributes->get('easyadmin');
$entity = $easyadmin['item'];
}

if ($this->entity['list']['dql_filter']) $this->entity['list']['dql_filter'] .= sprintf(' AND entity.status = 1');
else $this->entity['list']['dql_filter'] .= sprintf(' entity.status = 1');

$fields = $this->entity['list']['fields'];
$paginator = $this->findAll($this->entity['class'], $this->request->query->get('page', 1), 500, $this->request->query->get('sortField'), $this->request->query->get('sortDirection'), $this->entity['list']['dql_filter']);

@@ -226,14 +261,22 @@ class AdminController extends EasyAdminController
$class = $this->entity['class'];
$repo = $this->em->getRepository($class);

$latsPos = 0;
foreach ($positionForm->get('entities')->getData() as $elm) {
$this->dispatch(EasyAdminEvents::PRE_UPDATE, ['entity' => $entity]);
$entity = $repo->find($elm['id']);
$entity->setPosition($elm['position']);
$this->em->persist($entity);
$this->dispatch(EasyAdminEvents::POST_UPDATE, ['entity' => $entity]);
$latsPos = $elm['position'];

}
//to do récupérer les élements hors ligne et incrémenter position
foreach ($repo->findAllOfflineAndDelete() as $offlineEntity) {
$latsPos++;
$offlineEntity->setPosition($latsPos);
$this->em->persist($offlineEntity);
}
$this->em->flush();

$this->addFlash('success', 'Position modifié', array(), 'mweb');
@@ -254,5 +297,111 @@ class AdminController extends EasyAdminController
return $this->executeDynamicMethod('render<EntityName>Template', ['sortable', "@LcShop/backend/default/sortable.html.twig", $parameters]);
}

private $taxRateClass;
private $choicesTaxRateParam;

public function createProductFamilyEntityFormBuilder($entity, $view)
{

$formBuilder = parent::createEntityFormBuilder($entity, $view);


$class = $this->em->getClassMetadata(ProductCategoryInterface::class);
$this->taxRateClass = $this->em->getClassMetadata(TaxRateInterface::class);

//$formBuilder = $this->get('form.factory')->createBuilder(ProductType::class, $entity);*/
$formBuilder->add('price', MoneyType::class, array(
'block_prefix' => 'lc_tax_price',
'attr' => array(
'class' => 'lc-price'
)
));
$formBuilder->add('priceWithTax', MoneyType::class, array(
'attr' => array(
'class' => 'lc-price-with-tax'
),
'required' => false,
'mapped' => false
));


//CHOICE qui permet de sélectionner une taxe
//ça c'est du lourd fais très attention faudra refactorer
$this->getUser()->getMerchant()->getTaxRate();
$choicesTaxRate['TVA valeur par défaut'] = 0;
foreach ($this->em->getRepository($this->taxRateClass->name)->findAll() as $tax) {
$choicesTaxRate[$tax->getTitle()] = $tax->getId();
$this->choicesTaxRateParam[$tax->getId()] = $tax->getValue();
}
//là mon ami je kiffe symfo !!!!!
$this->choicesTaxRateParam[0] = $this->getUser()->getMerchant()->getTaxRate()->getValue();


$formBuilder->add('taxRate', ChoiceType::class, array(
'choices' => $choicesTaxRate,
'mapped' => false,
'choice_attr' => function ($choice, $key, $value) {
return ['data-tax-rate-value' => $this->choicesTaxRateParam[$choice]];
},

));

$formBuilder->add('unit', ChoiceType::class, array(
'choices' => array(
'pièce' => 'piece',
'g' => 'g',
'kg' => 'kg',
'ml' => 'mL',
'l' => 'L'

),
));
$formBuilder->add('behaviorCountStock', ChoiceType::class, array(
'choices' => array(
'Gèrer le stock par déclinaison' => 'by-product',
'Gèrer le stock par produit' => 'by-product-family'
),
'multiple' => false,
'expanded' => true

));
$formBuilder->add('productCategories', EntityType::class, array(
'multiple' => true,
'expanded' => true,
'class' => $class->name,
'query_builder' => function (EntityRepository $repo) {
return $repo->createQueryBuilder('e')
->where('e.parent is NOT NULL')
->andWhere('e.status > 0')
->orderBy('e.status', "DESC");
}
)
);

return $formBuilder;
}


public function createEntityFormBuilder($entity, $view)
{

$formBuilder = parent::createEntityFormBuilder($entity, $view);

$id = (null !== $entity->getId()) ? $entity->getId() : 0;
if ($entity instanceof TreeInterface) {
$formBuilder->add('parent', EntityType::class, array(
'class' => $this->entity['class'],
'query_builder' => function (EntityRepository $repo) use ($id) {
return $repo->createQueryBuilder('e')
->where('e.parent is NULL')
->andWhere('e.status >= 0')
->orderBy('e.status', "DESC");
},
'required' => false,
)
);
}
return $formBuilder;
}
}


+ 34
- 0
ShopBundle/Form/ProductType.php 查看文件

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

namespace Lc\ShopBundle\Form;

use CKSource\Bundle\CKFinderBundle\Form\Type\CKFinderFileChooserType;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Lc\ShopBundle\Context\ProductFamilyInterface;
use Lc\ShopBundle\Context\TaxRateInterface;
use function PHPSTORM_META\type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class ProductType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title')
->add('image', CKFinderFileChooserType::class, array(
'block_name' => 'ckfinder_file_chooser_widget'
))
->add('description', CKEditorType::class)
->add('supplier')
->add('productCategories');
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => ProductFamilyInterface::class,
]);
}
}

+ 28
- 11
ShopBundle/Model/ProductFamily.php 查看文件

@@ -20,7 +20,7 @@ abstract class ProductFamily extends AbstractDocumentEntity
/**
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface", inversedBy="productFamilies")
*/
protected $productCategory;
protected $productCategories;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\TaxRateInterface")
@@ -43,6 +43,11 @@ abstract class ProductFamily extends AbstractDocumentEntity
*/
protected $step;

/**
* @ORM\Column(type="float", nullable=true)
*/
protected $weight;

/**
* @ORM\Column(type="float", nullable=true)
*/
@@ -65,7 +70,7 @@ abstract class ProductFamily extends AbstractDocumentEntity

public function __construct()
{
$this->productCategory = new ArrayCollection();
$this->productCategories = new ArrayCollection();
}

public function getMerchant(): ?Merchant
@@ -83,15 +88,15 @@ abstract class ProductFamily extends AbstractDocumentEntity
/**
* @return Collection|ProductCategory[]
*/
public function getProductCategory(): Collection
public function getProductCategories(): Collection
{
return $this->productCategory;
return $this->productCategories;
}

public function addProductCategory(ProductCategory $productCategory): self
{
if (!$this->productCategory->contains($productCategory)) {
$this->productCategory[] = $productCategory;
if (!$this->productCategories->contains($productCategory)) {
$this->productCategories[] = $productCategory;
}

return $this;
@@ -99,8 +104,8 @@ abstract class ProductFamily extends AbstractDocumentEntity

public function removeProductCategory(ProductCategory $productCategory): self
{
if ($this->productCategory->contains($productCategory)) {
$this->productCategory->removeElement($productCategory);
if ($this->productCategories->contains($productCategory)) {
$this->productCategories->removeElement($productCategory);
}

return $this;
@@ -144,12 +149,24 @@ abstract class ProductFamily extends AbstractDocumentEntity

public function getStep(): ?float
{
return $this->price;
return $this->step;
}

public function setStep(?float $price): self
public function setStep(?float $step): self
{
$this->price = $price;
$this->step = $step;

return $this;
}

public function getWeight(): ?float
{
return $this->weight;
}

public function setWeight(?float $weight): self
{
$this->weight = $weight;

return $this;
}

+ 36
- 0
ShopBundle/Repository/BaseRepository.php 查看文件

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

namespace Lc\ShopBundle\Repository;

use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryInterface;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\ManagerRegistry;
use Symfony\Component\Form\Exception\LogicException;

class BaseRepository extends EntityRepository implements ServiceEntityRepositoryInterface
{
/**
* @param string $entityClass The class name of the entity this repository manages
*/
public function __construct(EntityManager $entityManager, $entityClass)
{


parent::__construct($entityManager, $entityManager->getClassMetadata($entityClass));
}

public function findAllOfflineAndDelete()
{

return $this->createQueryBuilder('e')
->andWhere('e.status < = 0')
->orderBy('e.status', "DESC")
->getQuery()
->getResult();

}


}

+ 64
- 0
ShopBundle/Repository/ProductCategoryRepository.php 查看文件

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

namespace Lc\ShopBundle\Repository;

use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\QueryBuilder;
use Lc\ShopBundle\Context\ProductCategoryInterface;

/**
* @method ProductCategoryInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method ProductCategoryInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method ProductCategoryInterface[] findAll()
* @method ProductCategoryInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ProductCategoryRepository extends BaseRepository
{
public function __construct(EntityManager $entityManager)
{

parent::__construct($entityManager, ProductCategoryInterface::class);
}


public static function adminQueryBuilderForTree(BaseRepository $e): QueryBuilder
{

return $e->createQueryBuilder('e')
->where('e.parent is NULL')
->andWhere('e.status >= 0')
->orderBy('e.position', 'ASC');
}



// /**
// * @return ProductCategory[] Returns an array of ProductCategory objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->orderBy('p.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?ProductCategory
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

+ 10
- 7
ShopBundle/Resources/config/easy_admin/base.yaml 查看文件

@@ -1,4 +1,5 @@
easy_admin:
translation_domain: 'lcshop'
design:
templates:
list: '@LcShop/backend/default/list.html.twig'
@@ -8,17 +9,19 @@ easy_admin:
favicon: '/assets/img/backend/favicon-pdl.png'
js:
- '/bundles/cksourceckfinder/ckfinder/ckfinder.js'
- '/bundles/lcshop/js/backend/setup-ckfinder.js'
- '/bundles/lcshop/js/backend/jquery-ui.min.js'
- '/bundles/lcshop/js/backend/utils.js'
- '/bundles/lcshop/js/backend/custom.js'
- '/bundles/lcshop/js/backend/plugin/vue.min.js'
- '/bundles/lcshop/js/backend/plugin/jquery-ui.min.js'
- '/bundles/lcshop/js/backend/script/setup-ckfinder.js'
- '/bundles/lcshop/js/backend/script/utils.js'
- '/bundles/lcshop/js/backend/script/custom.js'
- '/bundles/lcshop/js/backend/script/vueapp.js'
css:
- '/bundles/lcshop/css/backend/custom.css'

form_theme:
- '@EasyAdmin/form/bootstrap_4.html.twig'
- '@FOSCKEditor/Form/ckeditor_widget.html.twig'
- '@CKSourceCKFinder/Form/fields.html.twig'
- '@LcShop/backend/form/custom_bootstrap_4.html.twig'
- '@LcShop/backend/form/ckeditor_widget.html.twig'
- '@LcShop/backend/form/ckfinder_widget.html.twig'
list:
max_results: 30
actions:

+ 10
- 1
ShopBundle/Resources/public/css/backend/custom.css 查看文件

@@ -9,4 +9,13 @@

.ui-sortable-helper{ display: table;}
.ui-state-highlight{background: #eee}
.lc-sortable div:last-child{display: none;}
.lc-sortable div:last-child{display: none;}


.lc-ckfinder-wrap{width: 240px; height: 170px; position: relative;}
.lc-ckfinder-wrap .lc-ckfinder-illu-wrap{position:relative; : 100%; height: 139px; display: flex; align-items: center; justify-content: center; background: #eee; background-size: contain;}
.lc-ckfinder-wrap .lc-ckfinder-illu{width: 100%; height: 100%; background-size: contain; position: absolute; top: 0; left: 0;z-index: 1; background-repeat: no-repeat; background-position: center center; }
.lc-ckfinder-wrap .lc-ckfinder-illu-wrap i{font-size: 5rem;}
.lc-ckfinder-wrap .lc-ckfinder-remove{border: 0px; font-size: 1.8rem; position: absolute;z-index: 2; color:#dc3545; top: -20px; right: -20px; background: 0; display: none;}

.lc-ckfinder-wrap .lc-ckfinder-button{width: 100%; bottom: 0px; left: 0; position: absolute;}

ShopBundle/Resources/public/js/backend/jquery-ui.min.js → ShopBundle/Resources/public/js/backend/plugin/jquery-ui.min.js 查看文件


+ 6
- 0
ShopBundle/Resources/public/js/backend/plugin/vue.min.js
文件差异内容过多而无法显示
查看文件


ShopBundle/Resources/public/js/backend/custom.js → ShopBundle/Resources/public/js/backend/script/custom.js 查看文件

@@ -1,6 +1,8 @@
jQuery(document).ready(function () {
custom_switch_merchants();
setSortableList();
initLcSortableList();
initLcCkEditor();
initLcTaxPriceWidget()
});

function custom_switch_merchants() {
@@ -9,7 +11,7 @@ function custom_switch_merchants() {
});
}

function setSortableList() {
function initLcSortableList() {

$('.lc-sortable tbody').sortable({
placeholder: "ui-state-highlight"
@@ -24,7 +26,7 @@ function setSortableList() {
var newForm = prototype.replace(/__name__/g, index);

// Replace '__name__' in the prototype's HTML to
//$(li).find('div:last-child').remove();
$(li).find('div:last-child').remove();

$(li).append(newForm);
$(li).find('#form_entities_' + index + '_id').val($(li).data('id'));

+ 39
- 0
ShopBundle/Resources/public/js/backend/script/setup-ckfinder.js 查看文件

@@ -0,0 +1,39 @@
$(window).on('load', function () {

$('.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'});
}
});

ShopBundle/Resources/public/js/backend/utils.js → ShopBundle/Resources/public/js/backend/script/utils.js 查看文件

@@ -2,6 +2,52 @@
* Created by fab on 30/12/17.
*/


function initLcTaxPriceWidget(){
lcTaxPriceEvent() ;
$('#productfamily_price').change(lcTaxPriceEvent);
$('#productfamily_priceWithTax').change(lcTaxPriceEventWithTax);
}

function lcTaxPriceEvent(){
//Je ne suis pas forcémnet fan de l'appeler par l'id, à discuter
taxRate = $('#productfamily_taxRate').find('option:selected').data('tax-rate-value');
if(typeof taxRate == 'undefined') {
taxRate = 0 ;
}

$('#productfamily_priceWithTax').val(getPriceWithTax($('#productfamily_price').val(), taxRate));

}

function lcTaxPriceEventWithTax() {
taxRate = $('#productfamily_taxRate').find('option:selected').data('tax-rate-value');
if(typeof taxRate == 'undefined') {
taxRate = 0 ;
}
$('#productfamily_price').val(getPrice($('#productfamily_priceWithTax').val(), taxRate));

}
/*
function opendistrib_products_event_price(){
taxRateSelected = $('#product-id_tax_rate').find('option:selected').data('tax-rate-value');
$('#product-price').val(getPrice($('#product-price-with-tax').val(), taxRateSelected));

//formattage des prix
$('#product-price-with-tax').val(parseFloat($('#product-price-with-tax').val()).toFixed(2));
}
*/



function initLcCkEditor(){
var elements = $( '.lc-ckeditor' );

for ( var i = 0; i < elements.length; ++i ) {
CKEDITOR.replace( elements[ i ], {"toolbar":[{"name":"styles","items":["Bold","Italic","BulletedList","Link","imageUpload","ckfinder"]}],"language":"fr"} );
}
}

/**
* Retourne un prix sans taxe sur base du prix avec tax
*
@@ -10,7 +56,7 @@
* @returns {string}
*/
function getPrice(priceWithTax, taxRate) {
return parseFloat(parseFloat(priceWithTax) / (taxRate + 1)).toFixed(2);
return parseFloat(parseFloat(priceWithTax) / ((taxRate/100) + 1)).toFixed(2);
}

/**
@@ -21,7 +67,7 @@ function getPrice(priceWithTax, taxRate) {
* @returns {string}
*/
function getPriceWithTax(priceWithoutTax, taxRate) {
return parseFloat(parseFloat(priceWithoutTax) * (taxRate + 1)).toFixed(2);
return parseFloat(parseFloat(priceWithoutTax) * ((taxRate/100) + 1)).toFixed(2);
}

/**

+ 33
- 0
ShopBundle/Resources/public/js/backend/script/vueapp.js 查看文件

@@ -0,0 +1,33 @@
var app = new Vue({
delimiters: ['${', '}'],
el: '#lc-product-family-edit',
data: {
currentSection: 'general',
unit: null,
sectionsArray: [
{
name: 'general',
nameDisplay: 'Général'
},
{
name: 'price',
nameDisplay: 'Prix de commande'
},
{
name: 'product',
nameDisplay: 'Déclinaisons'
}
]
},
methods: {
changeSection: function (section) {
this.currentSection = section.name;
}
},
mounted() {

//loadCkEditor();
}

});


+ 0
- 5
ShopBundle/Resources/public/js/backend/setup-ckfinder.js 查看文件

@@ -1,5 +0,0 @@
$(document).on('ready', function () {
if ($('.field-ckfinder_file_chooser').length > 0) {
CKFinder.config({connectorPath: '/ckfinder/connector'});
}
});

+ 4
- 1
ShopBundle/Resources/translations/EasyAdminBundle.fr.yaml 查看文件

@@ -1 +1,4 @@
list.page_title: niche
list.page_title: niche
edit:
product:
title: NICHE

+ 3
- 0
ShopBundle/Resources/translations/lcshop.fr.yaml 查看文件

@@ -0,0 +1,3 @@
product:
title: Titre
titleHelp: Un message d'aide

+ 72
- 0
ShopBundle/Resources/views/backend/default/edit_productfamily.html.twig 查看文件

@@ -0,0 +1,72 @@
{% extends '@EasyAdmin/default/edit.html.twig' %}

{% block entity_form %}
{{ form_start(form) }}
<div class="lc-vue-js-container" id="lc-product-family-edit">
<div id="nav-params">
<button type="button" v-for="section in sectionsArray"
:class="'btn '+((currentSection == section.name) ? 'btn-primary' : 'btn-default')"
@click="changeSection(section)">
${ section.nameDisplay }
<span class="glyphicon glyphicon-triangle-bottom"></span>
</button>
</div>
<div class="form">
<div v-show="currentSection == 'general'" class="panel panel-default">
{{ form_row(form.title) }}
{{ form_row(form.image) }}
{{ form_row(form.description) }}

{{ form_row(form.supplier) }}
{{ form_row(form.productCategories) }}
</div>
<div v-show="currentSection == 'price'" class="panel panel-default">
{{ form_row(form.taxRate) }}

{{ form_row(form.unit, {"attr":{'v-model': 'unit'}}) }}

<div v-if="unit == 'piece'" class="form-group fiel-step">
{{ form_label(form.weight) }}
<div class="form-widget">
{{ form_widget(form.weight) }}
</div>
</div>
<div v-else class="form-group fiel-step">
{{ form_label(form.step) }}
<div class="form-widget">
{{ form_widget(form.step) }}
</div>
</div>
{#{% do form.step.setRendered %}#}

<div class="form-group fiel-step">
{{ form_label(form.price) }}
<div class="form-widget">
<div class="row m-0">
<div class="col-xs-6 mr-4">
{{ form_label(form.price) }}
{{ form_widget(form.price) }}
</div>
<div class="col-xs-6 ">
{{ form_label(form.priceWithTax) }}
{{ form_widget(form.priceWithTax) }}
</div>
</div>
</div>
</div>

{{ form_row(form.behaviorCountStock) }}
{{ form_row(form.productCategories) }}
</div>
<div v-show="currentSection == 'product'" class="panel panel-default">
{{ form_row(form.products) }}

</div>
</div>

</div>
{{ form_end(form) }}

{% endblock entity_form %}

{% block delete_form %}{% endblock %}

+ 3
- 0
ShopBundle/Resources/views/backend/default/list_association.html.twig 查看文件

@@ -0,0 +1,3 @@
{% for val in value %}
<span class="badge badge-secondary">{{ val }}</span>
{% endfor %}

+ 67
- 0
ShopBundle/Resources/views/backend/form/ckeditor_widget.html.twig 查看文件

@@ -0,0 +1,67 @@
{% block ckeditor_widget %}

<textarea class="lc-ckeditor" {{ block('widget_attributes') }}>{{ value }}</textarea>

{% if enable and not async %}
{{ block('_ckeditor_javascript') }}
{% endif %}

{% endblock %}

{% block ckeditor_javascript %}
{% if enable and async %}
{{ block('_ckeditor_javascript') }}
{% endif %}
{% endblock %}

{% block _ckeditor_javascript %}
{% if autoload %}
<script type="text/javascript">
var CKEDITOR_BASEPATH = "{{ ckeditor_base_path(base_path) }}";
</script>
<script type="text/javascript" src="{{ ckeditor_js_path(js_path) }}"></script>
{% if jquery %}
<script type="text/javascript" src="{{ ckeditor_js_path(jquery_path) }}"></script>
{% endif %}
{% endif %}
{#<script type="text/javascript">
{% if jquery %}
$(function () {
{% endif %}

{% if require_js %}
require(['ckeditor'], function() {
{% endif %}

{{ ckeditor_destroy(id) }}

{% for plugin_name, plugin in plugins %}
{{ ckeditor_plugin(plugin_name, plugin) }}
{% endfor %}

{% for style_name, style in styles %}
{{ ckeditor_styles_set(style_name, style) }}
{% endfor %}

{% for template_name, template in templates %}
{{ ckeditor_template(template_name, template) }}
{% endfor %}

{% block ckeditor_widget_extra %}{% endblock ckeditor_widget_extra %}

{{ ckeditor_widget(id, config, {
auto_inline: auto_inline,
inline: inline,
input_sync: input_sync,
filebrowsers: filebrowsers
}) }}

{% if require_js %}
});
{% endif %}

{% if jquery %}
});
{% endif %}
</script>#}
{% endblock %}

+ 13
- 4
ShopBundle/Resources/views/backend/form/ckfinder_widget.html.twig 查看文件

@@ -1,4 +1,13 @@
{% block _product_ck_finder_widget %}
{# ... #}
<a href="...">More information</a>
{% endblock %}
{% block ckfinder_file_chooser_widget %}
<div class="lc-ckfinder-wrap">
<button type="button" class="lc-ckfinder-remove">
<i class="fa fa-fw fa-times"></i>
</button>
<div class="lc-ckfinder-illu-wrap">
<div class="lc-ckfinder-illu"></div>
<i class="fa fa-fw fa-image"></i>
</div>
<input class="lc-ckfinder-field" type="hidden" name="{{ full_name }}" value="{{ value }}" />
<button type="button" id="{{ button_id }}" class="btn btn-secondary lc-ckfinder-button" {% for attrname, attrvalue in button_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ button_text }}</button>
</div>
{% endblock %}

+ 58
- 0
ShopBundle/Resources/views/backend/form/custom_bootstrap_4.html.twig 查看文件

@@ -0,0 +1,58 @@
{% use '@EasyAdmin/form/bootstrap_4.html.twig' %}

{% block form_widget -%}
{{ parent() }}

{% set transHelp = label|lower~"Help" %}
{% if transHelp|trans({}, 'lcshop') != transHelp %}
<span class="lc-edit-help-block"><span
class="glyphicon glyphicon-info-sign"></span>{{ transHelp|trans({}, 'lcshop') }}</span>
<span class="glyphicon glyphicon-info-sign info-tooltip" data-toggle="tooltip" data-position="bottom"
title=""></span>
{% endif %}

{% endblock form_widget %}

{% block form_row -%}
{% set _field_type = easyadmin.field.fieldType|default('default') %}
<div class="form-group {% if (not compound or force_error|default(false)) and not valid %}has-error{% endif %} field-{{ block_prefixes|slice(-2)|first }}">
{{- form_label(form) -}}
<div class="form-widget">
{% set has_prepend_html = easyadmin.field.prepend_html|default(null) is not null %}
{% set has_append_html = easyadmin.field.append_html|default(null) is not null %}
{% set has_input_groups = has_prepend_html or has_append_html %}

{% if has_input_groups %}
<div class="input-group">{% endif %}
{% if has_prepend_html %}
<div class="input-group-prepend">
<span class="input-group-text">{{ easyadmin.field.prepend_html|raw }}</span>
</div>
{% endif %}

{{- form_widget(form) -}}

{% if has_append_html %}
<div class="input-group-append">
<span class="input-group-text">{{ easyadmin.field.append_html|raw }}</span>
</div>
{% endif %}
{% if has_input_groups %}</div>{% endif %}

{% if _field_type in ['datetime', 'datetime_immutable', 'date', 'date_immutable', 'dateinterval', 'time', 'time_immutable', 'birthday'] and easyadmin.field.nullable|default(false) %}
<div class="nullable-control">
<label>
<input type="checkbox" {% if data is null %}checked="checked"{% endif %}>
{{ 'label.nullable_field'|trans({}, 'EasyAdminBundle') }}
</label>
</div>
{% endif %}

{% if easyadmin.field.help|default(form.vars.help) != '' %}
<small class="form-help">{{ easyadmin.field.help|default(form.vars.help)|trans(domain = form.vars.translation_domain)|raw }}</small>
{% endif %}

{{- form_errors(form) -}}
</div>
</div>
{%- endblock form_row %}

正在加载...
取消
保存