Fixes
This commit is contained in:
parent
348e65b831
commit
af4f6d07be
@ -8,6 +8,7 @@ use OpenApi\Attributes\JsonContent;
|
||||
use OpenApi\Attributes\RequestBody;
|
||||
use OpenApi\Attributes\Response;
|
||||
use OpenApi\Attributes\Tag;
|
||||
use PSC\Shop\EntityBundle\Entity\Contact as PSCContact;
|
||||
use Plugin\Custom\PSC\CollectLayouter\Dto\SaveContact\Input;
|
||||
use Plugin\Custom\PSC\CollectLayouter\Model\Setting;
|
||||
use PSC\Shop\ContactBundle\Model\Role;
|
||||
@ -25,34 +26,63 @@ use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
class SaveContact extends AbstractController
|
||||
{
|
||||
public function __construct(readonly private \Plugin\Custom\PSC\CollectLayouter\Helper\SaveContact $saveContactHelper,
|
||||
public function __construct(
|
||||
readonly private \Plugin\Custom\PSC\CollectLayouter\Helper\SaveContact $saveContactHelper,
|
||||
private EntityManagerInterface $entityManager,
|
||||
private DocumentManager $documentManager,
|
||||
private SerializerInterface $serializer,
|
||||
private Contact $contactTransformer,
|
||||
private RequestStack $requestStack,
|
||||
private Shop $shopService)
|
||||
{
|
||||
private Shop $shopService
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route(path: '/savecontact/{uuid}', methods: ['PUT'])]
|
||||
#[ParamConverter('data', class: Input::class, converter: 'psc_rest.request_body')]
|
||||
#[Tag('Plugin/Custom/PSC/CollectLayouter')]
|
||||
#[RequestBody(description: 'content',content: new JsonContent(ref: Input::class))]
|
||||
#[RequestBody(description: 'content', content: new JsonContent(ref: Input::class))]
|
||||
#[Response(response: 200, description: 'save config in session', content: new JsonContent(type: 'bool'))]
|
||||
public function save(Input $data, string $uuid): JsonResponse {
|
||||
public function save(Input $data, string $uuid): JsonResponse
|
||||
{
|
||||
|
||||
$product = $this->entityManager->getRepository(Product::class)->findOneBy(['uuid' => $uuid]);
|
||||
|
||||
$productDoc = $this->documentManager->getRepository(\PSC\Shop\EntityBundle\Document\Product::class)->findOneBy(['uid' => $product->getUID()]);
|
||||
$setting = $this->serializer->deserialize($productDoc->getPluginSettingModule('collectlayouter', 'config')?? '{}', Setting::class, 'json');
|
||||
$setting = $this->serializer->deserialize($productDoc->getPluginSettingModule('collectlayouter', 'config') ?? '{}', Setting::class, 'json');
|
||||
|
||||
$contact = new \PSC\Shop\ContactBundle\Model\Contact();
|
||||
if($this->getUser()) {
|
||||
if ($this->getUser()) {
|
||||
$this->contactTransformer->fromDb($contact, $this->getUser());
|
||||
}
|
||||
|
||||
if($contact->getUuid() != "") {
|
||||
if ($contact->getUuid() != "") {
|
||||
$this->saveContactHelper->setSetting($setting);
|
||||
$this->saveContactHelper->setContact($contact);
|
||||
$this->saveContactHelper->setData($data);
|
||||
$this->saveContactHelper->saveData();
|
||||
}
|
||||
|
||||
return $this->json(['success' => true]);
|
||||
}
|
||||
|
||||
#[Route(path: '/savecontactcollect/{uuid}/{contactuuid}', methods: ['PUT'])]
|
||||
#[ParamConverter('data', class: Input::class, converter: 'psc_rest.request_body')]
|
||||
#[Tag('Plugin/Custom/PSC/CollectLayouter')]
|
||||
#[RequestBody(description: 'content', content: new JsonContent(ref: Input::class))]
|
||||
#[Response(response: 200, description: 'save config in session', content: new JsonContent(type: 'bool'))]
|
||||
public function saveCollect(Input $data, string $uuid, string $contactuuid): JsonResponse
|
||||
{
|
||||
|
||||
$product = $this->entityManager->getRepository(Product::class)->findOneBy(['uuid' => $uuid]);
|
||||
|
||||
$productDoc = $this->documentManager->getRepository(\PSC\Shop\EntityBundle\Document\Product::class)->findOneBy(['uid' => $product->getUID()]);
|
||||
$setting = $this->serializer->deserialize($productDoc->getPluginSettingModule('collectlayouter', 'config') ?? '{}', Setting::class, 'json');
|
||||
|
||||
$contactEntity = $this->entityManager->getRepository(PSCContact::class)->findOneBy(['uuid' => $contactuuid]);
|
||||
$contact = new \PSC\Shop\ContactBundle\Model\Contact();
|
||||
$this->contactTransformer->fromDb($contact, $contactEntity);
|
||||
|
||||
if ($contact->getUuid() != "") {
|
||||
$this->saveContactHelper->setSetting($setting);
|
||||
$this->saveContactHelper->setContact($contact);
|
||||
$this->saveContactHelper->setData($data);
|
||||
@ -65,14 +95,15 @@ class SaveContact extends AbstractController
|
||||
#[Route(path: '/savenewcontact/{uuid}', methods: ['PUT'])]
|
||||
#[ParamConverter('data', class: Input::class, converter: 'psc_rest.request_body')]
|
||||
#[Tag('Plugin/Custom/PSC/CollectLayouter')]
|
||||
#[RequestBody(description: 'content',content: new JsonContent(ref: Input::class))]
|
||||
#[RequestBody(description: 'content', content: new JsonContent(ref: Input::class))]
|
||||
#[Response(response: 200, description: 'save config in session', content: new JsonContent(type: 'bool'))]
|
||||
public function saveNew(Input $data, string $uuid): JsonResponse {
|
||||
public function saveNew(Input $data, string $uuid): JsonResponse
|
||||
{
|
||||
|
||||
$product = $this->entityManager->getRepository(Product::class)->findOneBy(['uuid' => $uuid]);
|
||||
|
||||
$productDoc = $this->documentManager->getRepository(\PSC\Shop\EntityBundle\Document\Product::class)->findOneBy(['uid' => $product->getUID()]);
|
||||
$setting = $this->serializer->deserialize($productDoc->getPluginSettingModule('collectlayouter', 'config')?? '{}', Setting::class, 'json');
|
||||
$setting = $this->serializer->deserialize($productDoc->getPluginSettingModule('collectlayouter', 'config') ?? '{}', Setting::class, 'json');
|
||||
|
||||
$contact = new \PSC\Shop\ContactBundle\Model\Contact();
|
||||
$shop = new \PSC\Component\ApiBundle\Model\Shop();
|
||||
@ -93,3 +124,4 @@ class SaveContact extends AbstractController
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -88,7 +88,7 @@ class DesignerController extends AbstractController
|
||||
$token = null;
|
||||
if ($contactUuid) {
|
||||
$user = $contactRepository->findOneBy(['uuid' => $contactUuid]);
|
||||
$token = $JWTTokenManager->create($user);
|
||||
$token = $JWTTokenManager->create($this->getUser());
|
||||
}
|
||||
/** @var Setting $settings */
|
||||
$settings = $this->serializer->deserialize($productDoc->getPluginSettingModule('collectlayouter', 'config') ?? '{}', Setting::class, 'json');
|
||||
|
||||
@ -121,7 +121,7 @@
|
||||
$('.loadingScreen').removeClass('hidden');
|
||||
$.ajax({
|
||||
method: 'PUT',
|
||||
url: '/apps/api/plugin/custom/psc/collectlayouter/{% if mode == 3 %}savenewcontact{% else %}savecontact{% endif %}/' + productUUId,
|
||||
url: '/apps/api/plugin/custom/psc/collectlayouter/{% if mode == 3 %}savenewcontact{% else %}savecontactcollect{% endif %}/' + productUUId + (contactUuid? '/' + contactUuid:''),
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({
|
||||
contactUuid: contactUuid,
|
||||
@ -213,7 +213,7 @@
|
||||
|
||||
$('#customerForm').html('');
|
||||
$.ajax({
|
||||
url: "/apps/api/plugin/custom/psc/collectlayouter/{% if mode == 3 %}newform{% else %}form{% endif %}/" + productUUId,
|
||||
url: "/apps/api/plugin/custom/psc/collectlayouter/{% if mode == 3 %}newform{% else %}form{% endif %}/" + productUUId + (contactUuid? '/' + contactUuid:''),
|
||||
contentType: "application/json",
|
||||
headers: {
|
||||
"Authorization": "Bearer {{ jwt }}"
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
Binary file not shown.
Loading…
Reference in New Issue
Block a user