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\RequestBody;
|
||||||
use OpenApi\Attributes\Response;
|
use OpenApi\Attributes\Response;
|
||||||
use OpenApi\Attributes\Tag;
|
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\Dto\SaveContact\Input;
|
||||||
use Plugin\Custom\PSC\CollectLayouter\Model\Setting;
|
use Plugin\Custom\PSC\CollectLayouter\Model\Setting;
|
||||||
use PSC\Shop\ContactBundle\Model\Role;
|
use PSC\Shop\ContactBundle\Model\Role;
|
||||||
@ -25,14 +26,15 @@ use Symfony\Component\Serializer\SerializerInterface;
|
|||||||
|
|
||||||
class SaveContact extends AbstractController
|
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 EntityManagerInterface $entityManager,
|
||||||
private DocumentManager $documentManager,
|
private DocumentManager $documentManager,
|
||||||
private SerializerInterface $serializer,
|
private SerializerInterface $serializer,
|
||||||
private Contact $contactTransformer,
|
private Contact $contactTransformer,
|
||||||
private RequestStack $requestStack,
|
private RequestStack $requestStack,
|
||||||
private Shop $shopService)
|
private Shop $shopService
|
||||||
{
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/savecontact/{uuid}', methods: ['PUT'])]
|
#[Route(path: '/savecontact/{uuid}', methods: ['PUT'])]
|
||||||
@ -40,7 +42,8 @@ class SaveContact extends AbstractController
|
|||||||
#[Tag('Plugin/Custom/PSC/CollectLayouter')]
|
#[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'))]
|
#[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]);
|
$product = $this->entityManager->getRepository(Product::class)->findOneBy(['uuid' => $uuid]);
|
||||||
|
|
||||||
@ -62,12 +65,40 @@ class SaveContact extends AbstractController
|
|||||||
return $this->json(['success' => true]);
|
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);
|
||||||
|
$this->saveContactHelper->saveData();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->json(['success' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
#[Route(path: '/savenewcontact/{uuid}', methods: ['PUT'])]
|
#[Route(path: '/savenewcontact/{uuid}', methods: ['PUT'])]
|
||||||
#[ParamConverter('data', class: Input::class, converter: 'psc_rest.request_body')]
|
#[ParamConverter('data', class: Input::class, converter: 'psc_rest.request_body')]
|
||||||
#[Tag('Plugin/Custom/PSC/CollectLayouter')]
|
#[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'))]
|
#[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]);
|
$product = $this->entityManager->getRepository(Product::class)->findOneBy(['uuid' => $uuid]);
|
||||||
|
|
||||||
@ -93,3 +124,4 @@ class SaveContact extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -88,7 +88,7 @@ class DesignerController extends AbstractController
|
|||||||
$token = null;
|
$token = null;
|
||||||
if ($contactUuid) {
|
if ($contactUuid) {
|
||||||
$user = $contactRepository->findOneBy(['uuid' => $contactUuid]);
|
$user = $contactRepository->findOneBy(['uuid' => $contactUuid]);
|
||||||
$token = $JWTTokenManager->create($user);
|
$token = $JWTTokenManager->create($this->getUser());
|
||||||
}
|
}
|
||||||
/** @var Setting $settings */
|
/** @var Setting $settings */
|
||||||
$settings = $this->serializer->deserialize($productDoc->getPluginSettingModule('collectlayouter', 'config') ?? '{}', Setting::class, 'json');
|
$settings = $this->serializer->deserialize($productDoc->getPluginSettingModule('collectlayouter', 'config') ?? '{}', Setting::class, 'json');
|
||||||
|
|||||||
@ -121,7 +121,7 @@
|
|||||||
$('.loadingScreen').removeClass('hidden');
|
$('.loadingScreen').removeClass('hidden');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'PUT',
|
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",
|
contentType: "application/json",
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
contactUuid: contactUuid,
|
contactUuid: contactUuid,
|
||||||
@ -213,7 +213,7 @@
|
|||||||
|
|
||||||
$('#customerForm').html('');
|
$('#customerForm').html('');
|
||||||
$.ajax({
|
$.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",
|
contentType: "application/json",
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": "Bearer {{ jwt }}"
|
"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