diff --git a/src/CoreShop/Bundle/AddressBundle/Resources/config/pimcore/admin.yml b/src/CoreShop/Bundle/AddressBundle/Resources/config/pimcore/admin.yml index caf4cc7d68..a069566053 100644 --- a/src/CoreShop/Bundle/AddressBundle/Resources/config/pimcore/admin.yml +++ b/src/CoreShop/Bundle/AddressBundle/Resources/config/pimcore/admin.yml @@ -5,6 +5,7 @@ core_shop_address: resource_country: '/bundles/coreshopaddress/pimcore/js/resource/country.js' resource_state: '/bundles/coreshopaddress/pimcore/js/resource/state.js' resource_zone: '/bundles/coreshopaddress/pimcore/js/resource/zone.js' + resource_country_salutation: '/bundles/coreshopaddress/pimcore/js/resource/country_salutation.js' country_item: '/bundles/coreshopaddress/pimcore/js/country/item.js' country_panel: '/bundles/coreshopaddress/pimcore/js/country/panel.js' state_item: '/bundles/coreshopaddress/pimcore/js/state/item.js' @@ -24,4 +25,4 @@ core_shop_address: editmode_js: core_extension_document_tag_country: '/bundles/coreshopaddress/pimcore/js/coreExtension/document/coreShopCountry.js' core_extension_document_tag_state: '/bundles/coreshopaddress/pimcore/js/coreExtension/document/coreShopState.js' - core_extension_document_tag_zone: '/bundles/coreshopaddress/pimcore/js/coreExtension/document/coreShopZone.js' \ No newline at end of file + core_extension_document_tag_zone: '/bundles/coreshopaddress/pimcore/js/coreExtension/document/coreShopZone.js' diff --git a/src/CoreShop/Bundle/AddressBundle/Resources/public/pimcore/js/resource/country.js b/src/CoreShop/Bundle/AddressBundle/Resources/public/pimcore/js/resource/country.js index b1111859be..298cbec3b6 100644 --- a/src/CoreShop/Bundle/AddressBundle/Resources/public/pimcore/js/resource/country.js +++ b/src/CoreShop/Bundle/AddressBundle/Resources/public/pimcore/js/resource/country.js @@ -1,4 +1,4 @@ -Ext.define('CoreShop.store.Country', { +Ext.define('CoreShop.address.Country', { extend: 'CoreShop.resource.ComboBox', alias: 'widget.coreshop.country', diff --git a/src/CoreShop/Bundle/AddressBundle/Resources/public/pimcore/js/resource/country_salutation.js b/src/CoreShop/Bundle/AddressBundle/Resources/public/pimcore/js/resource/country_salutation.js new file mode 100644 index 0000000000..12526b431b --- /dev/null +++ b/src/CoreShop/Bundle/AddressBundle/Resources/public/pimcore/js/resource/country_salutation.js @@ -0,0 +1,76 @@ +Ext.define('CoreShop.address.CountrySalutation', { + extend: 'Ext.container.Container', + alias: 'widget.coreshop.countrySalutation', + + config: { + country: { + name: 'country' + }, + salutation: { + name: 'salutation' + } + }, + + initComponent: function () { + this.items = [Ext.mergeIf(this.country, { + xtype: 'coreshop.country', + store: { + proxy: { + type: 'ajax', + url: '/admin/coreshop/countries/list-active', + reader: { + type: 'json', + } + }, + fields: [ + {name: 'id'}, + {name: 'name'} + ], + autoLoad: true, + remoteSort: false, + remoteFilter: false + }, + name: this.name_country, + allowBlank: false, + listeners: { + change: function(cmb) { + if (cmb.getValue() === null) { + cmb.up('panel').down('#salutation').setValue(null); + cmb.up('panel').down('#salutation').setDisabled(true); + } + else { + Ext.Ajax.request({ + url: '/admin/coreshop/countries/get', + method: 'get', + params: { + id: cmb.getValue() + }, + success: function (response) { + var res = Ext.decode(response.responseText); + + if (res.success) { + cmb.up('panel').down('#salutation').setStore(res.data.salutations.map(function(entry) { + return [entry, t('coreshop_salutation_' + entry)]; + })); + cmb.up('panel').down('#salutation').setDisabled(false); + } + }.bind(this) + }); + } + } + } + }), Ext.mergeIf(this.salutation, { + xtype: 'combo', + fieldLabel: t('coreshop_country_salutation'), + itemId: 'salutation', + name: this.name_salutation, + disabled: true, + allowBlank: false, + queryMode: 'local', + editable: false, + store: [] + })]; + + this.callParent(); + } +}); diff --git a/src/CoreShop/Bundle/AddressBundle/Resources/public/pimcore/js/resource/state.js b/src/CoreShop/Bundle/AddressBundle/Resources/public/pimcore/js/resource/state.js index 0776ea77f8..010f39a797 100644 --- a/src/CoreShop/Bundle/AddressBundle/Resources/public/pimcore/js/resource/state.js +++ b/src/CoreShop/Bundle/AddressBundle/Resources/public/pimcore/js/resource/state.js @@ -1,4 +1,4 @@ -Ext.define('CoreShop.store.State', { +Ext.define('CoreShop.address.State', { extend: 'CoreShop.resource.ComboBox', alias: 'widget.coreshop.state', diff --git a/src/CoreShop/Bundle/AddressBundle/Resources/public/pimcore/js/resource/zone.js b/src/CoreShop/Bundle/AddressBundle/Resources/public/pimcore/js/resource/zone.js index d9eaed81a3..3235946af9 100644 --- a/src/CoreShop/Bundle/AddressBundle/Resources/public/pimcore/js/resource/zone.js +++ b/src/CoreShop/Bundle/AddressBundle/Resources/public/pimcore/js/resource/zone.js @@ -1,4 +1,4 @@ -Ext.define('CoreShop.store.Zone', { +Ext.define('CoreShop.address.Zone', { extend: 'CoreShop.resource.ComboBox', alias: 'widget.coreshop.zone', diff --git a/src/CoreShop/Bundle/CurrencyBundle/Resources/public/pimcore/js/resource/currency.js b/src/CoreShop/Bundle/CurrencyBundle/Resources/public/pimcore/js/resource/currency.js index 32bfdbc21c..ae939e5306 100644 --- a/src/CoreShop/Bundle/CurrencyBundle/Resources/public/pimcore/js/resource/currency.js +++ b/src/CoreShop/Bundle/CurrencyBundle/Resources/public/pimcore/js/resource/currency.js @@ -1,4 +1,4 @@ -Ext.define('CoreShop.store.Currency', { +Ext.define('CoreShop.currency.Currency', { extend: 'CoreShop.resource.ComboBox', alias: 'widget.coreshop.currency', diff --git a/src/CoreShop/Bundle/CustomerBundle/Form/Type/CustomerType.php b/src/CoreShop/Bundle/CustomerBundle/Form/Type/CustomerType.php index 455ff7531f..91aef6f744 100644 --- a/src/CoreShop/Bundle/CustomerBundle/Form/Type/CustomerType.php +++ b/src/CoreShop/Bundle/CustomerBundle/Form/Type/CustomerType.php @@ -56,6 +56,18 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'coreshop.form.customer.lastname', ]); + if ($options['use_repeat_email']) { + $builder + ->add('email', RepeatedType::class, [ + 'type' => EmailType::class, + 'invalid_message' => 'coreshop.form.customer.email.must_match', + 'first_options' => ['label' => 'coreshop.form.customer.email'], + 'second_options' => ['label' => 'coreshop.form.customer.email_repeat'], + + ]); + } else { + $builder->add('email', EmailType::class); + } if ($options['allow_username']) { $builder->add('username', TextType::class, [ @@ -63,13 +75,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]); } - $builder->add('email', RepeatedType::class, [ - 'type' => EmailType::class, - 'invalid_message' => 'coreshop.form.customer.email.must_match', - 'first_options' => ['label' => 'coreshop.form.customer.email'], - 'second_options' => ['label' => 'coreshop.form.customer.email_repeat'], - ]); - if (!$options['guest'] && $options['allow_password_field']) { $builder ->add('password', RepeatedType::class, [ @@ -96,6 +101,7 @@ public function configureOptions(OptionsResolver $resolver): void { parent::configureOptions($resolver); + $resolver->setDefault('use_repeat_email', true); $resolver->setDefault('guest', false); $resolver->setDefault('allow_password_field', false); $resolver->setDefault('allow_username', false); diff --git a/src/CoreShop/Bundle/OrderBundle/Controller/AddressCreationController.php b/src/CoreShop/Bundle/OrderBundle/Controller/AddressCreationController.php new file mode 100644 index 0000000000..97c314ae71 --- /dev/null +++ b/src/CoreShop/Bundle/OrderBundle/Controller/AddressCreationController.php @@ -0,0 +1,86 @@ +get('form.factory')->createNamed('', AdminAddressCreationType::class); + + if ($request->getMethod() === 'POST') { + $form = $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $data = $form->getData(); + + /** + * @var CustomerInterface $customer + */ + $customer = $data['customer']; + + /** + * @var AddressInterface $address + */ + $address = $data['address']; + + $address->setPublished(true); + $address->setKey(uniqid()); + $address->setParent($objectService->createFolderByPath(sprintf( + '/%s/%s', + $customer->getFullPath(), + $this->getParameter('coreshop.folder.address') + ))); + $address->save(); + + if ($customer instanceof AddressesAwareInterface) { + $customer->addAddress($address); + } + + $this->get('event_dispatcher')->dispatch( + Events::ADMIN_ADDRESS_CREATION, + new AdminAddressCreationEvent($address, $customer, $data) + ); + + $customer->save(); + + return $this->viewHandler->handle(['success' => true, 'id' => $address->getId()]); + } + + return $this->viewHandler->handle( + [ + 'success' => false, + 'message' => $errorSerializer->serializeErrorFromHandledForm($form), + ] + ); + } + + return $this->viewHandler->handle(['success' => false, 'message' => 'Method not supported, use POST']); + } +} diff --git a/src/CoreShop/Bundle/OrderBundle/Controller/CustomerCreationController.php b/src/CoreShop/Bundle/OrderBundle/Controller/CustomerCreationController.php new file mode 100644 index 0000000000..1ea87f598c --- /dev/null +++ b/src/CoreShop/Bundle/OrderBundle/Controller/CustomerCreationController.php @@ -0,0 +1,103 @@ +get('form.factory')->createNamed('', AdminCustomerCreationType::class); + + if ($request->getMethod() === 'POST') { + $form = $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $data = $form->getData(); + + /** + * @var CustomerInterface $customer + */ + $customer = $data['customer']; + + /** + * @var AddressInterface $address + */ + $address = $data['address']; + + $customer->setPublished(true); + $customer->setParent($objectService->createFolderByPath(sprintf( + '/%s/%s', + $this->getParameter('coreshop.folder.customer'), + mb_strtoupper(mb_substr($customer->getLastname(), 0, 1)) + ))); + $customer->setKey(File::getValidFilename($customer->getEmail())); + $customer->setKey(Service::getUniqueKey($customer)); + $customer->save(); + + $address->setPublished(true); + $address->setKey(uniqid()); + $address->setParent($objectService->createFolderByPath(sprintf( + '/%s/%s', + $customer->getFullPath(), + $this->getParameter('coreshop.folder.address') + ))); + $address->save(); + + if ($customer instanceof DefaultAddressAwareInterface) { + $customer->setDefaultAddress($address); + } + + if ($customer instanceof AddressesAwareInterface) { + $customer->addAddress($address); + } + + $this->get('event_dispatcher')->dispatch( + Events::ADMIN_CUSTOMER_CREATION, + new AdminCustomerCreationEvent($customer, $data) + ); + + $customer->save(); + + return $this->viewHandler->handle(['success' => true, 'id' => $customer->getId()]); + } + + return $this->viewHandler->handle( + [ + 'success' => false, + 'message' => $errorSerializer->serializeErrorFromHandledForm($form), + ] + ); + } + + return $this->viewHandler->handle(['success' => false, 'message' => 'Method not supported, use POST']); + } +} diff --git a/src/CoreShop/Bundle/OrderBundle/Controller/OrderCreationController.php b/src/CoreShop/Bundle/OrderBundle/Controller/OrderCreationController.php index 395f17019d..838fce8453 100644 --- a/src/CoreShop/Bundle/OrderBundle/Controller/OrderCreationController.php +++ b/src/CoreShop/Bundle/OrderBundle/Controller/OrderCreationController.php @@ -263,7 +263,7 @@ protected function getCurrency(CurrencyInterface $currency): array return [ 'name' => $currency->getName(), 'symbol' => $currency->getSymbol(), - 'uso' => $currency->getIsoCode() + 'iso' => $currency->getIsoCode() ]; } diff --git a/src/CoreShop/Bundle/OrderBundle/DependencyInjection/Configuration.php b/src/CoreShop/Bundle/OrderBundle/DependencyInjection/Configuration.php index bf67929cef..69a0c845ce 100644 --- a/src/CoreShop/Bundle/OrderBundle/DependencyInjection/Configuration.php +++ b/src/CoreShop/Bundle/OrderBundle/DependencyInjection/Configuration.php @@ -14,7 +14,9 @@ namespace CoreShop\Bundle\OrderBundle\DependencyInjection; +use CoreShop\Bundle\OrderBundle\Controller\AddressCreationController; use CoreShop\Bundle\OrderBundle\Controller\CartPriceRuleController; +use CoreShop\Bundle\OrderBundle\Controller\CustomerCreationController; use CoreShop\Bundle\OrderBundle\Controller\OrderCommentController; use CoreShop\Bundle\OrderBundle\Controller\OrderController; use CoreShop\Bundle\OrderBundle\Controller\OrderCreationController; @@ -213,6 +215,8 @@ private function addModelsSection(ArrayNodeDefinition $node) ->scalarNode('edit')->defaultValue(OrderEditController::class)->end() ->scalarNode('payment')->defaultValue(OrderPaymentController::class)->end() ->scalarNode('comment')->defaultValue(OrderCommentController::class)->end() + ->scalarNode('customer_creation')->defaultValue(CustomerCreationController::class)->end() + ->scalarNode('address_creation')->defaultValue(AddressCreationController::class)->end() ->end() ->end() ->end() diff --git a/src/CoreShop/Bundle/OrderBundle/Event/AdminAddressCreationEvent.php b/src/CoreShop/Bundle/OrderBundle/Event/AdminAddressCreationEvent.php new file mode 100644 index 0000000000..d72c5389e5 --- /dev/null +++ b/src/CoreShop/Bundle/OrderBundle/Event/AdminAddressCreationEvent.php @@ -0,0 +1,66 @@ +address = $address; + $this->customer = $customer; + $this->data = $data; + } + + /** + * @return AddressInterface + */ + public function getAddress() + { + return $this->address; + } + + /** + * @return CustomerInterface + */ + public function getCustomer() + { + return $this->customer; + } + + /** + * @return array + */ + public function getData() + { + return $this->data; + } +} diff --git a/src/CoreShop/Bundle/OrderBundle/Event/AdminCustomerCreationEvent.php b/src/CoreShop/Bundle/OrderBundle/Event/AdminCustomerCreationEvent.php new file mode 100644 index 0000000000..812d2e5a65 --- /dev/null +++ b/src/CoreShop/Bundle/OrderBundle/Event/AdminCustomerCreationEvent.php @@ -0,0 +1,51 @@ +customer = $customer; + $this->data = $data; + } + + /** + * @return CustomerInterface + */ + public function getCustomer() + { + return $this->customer; + } + + /** + * @return array + */ + public function getData() + { + return $this->data; + } +} diff --git a/src/CoreShop/Bundle/OrderBundle/Events.php b/src/CoreShop/Bundle/OrderBundle/Events.php index 3773c22dba..4389dc94b8 100644 --- a/src/CoreShop/Bundle/OrderBundle/Events.php +++ b/src/CoreShop/Bundle/OrderBundle/Events.php @@ -20,4 +20,14 @@ final class Events * Fired before a Sale (Cart, Order, Quote) is passed to the client */ const SALE_DETAIL_PREPARE = 'coreshop.sale.detail.prepare'; + + /** + * Fired when an Admin creates a new Customer via a CoreShop UI + */ + const ADMIN_CUSTOMER_CREATION = 'coreshop.customer.admin_creation'; + + /** + * Fired when an Admin creates a new Address via a CoreShop UI + */ + const ADMIN_ADDRESS_CREATION = 'coreshop.address.admin_creation'; } diff --git a/src/CoreShop/Bundle/OrderBundle/Form/Type/AdminAddressCreationType.php b/src/CoreShop/Bundle/OrderBundle/Form/Type/AdminAddressCreationType.php new file mode 100644 index 0000000000..66fe0538df --- /dev/null +++ b/src/CoreShop/Bundle/OrderBundle/Form/Type/AdminAddressCreationType.php @@ -0,0 +1,49 @@ +add('customer', CustomerSelectionType::class, [ + 'constraints' => [ + new NotBlank(['groups' => ['coreshop']]), + ], + ]) + ->add('address', AddressType::class, [ + 'constraints' => [ + new Valid(['groups' => ['coreshop']]), + ], + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + parent::configureOptions($resolver); + + $resolver->setDefaults([ + 'csrf_protection' => false, + ]); + } +} diff --git a/src/CoreShop/Bundle/OrderBundle/Form/Type/AdminCustomerCreationType.php b/src/CoreShop/Bundle/OrderBundle/Form/Type/AdminCustomerCreationType.php new file mode 100644 index 0000000000..6373c54812 --- /dev/null +++ b/src/CoreShop/Bundle/OrderBundle/Form/Type/AdminCustomerCreationType.php @@ -0,0 +1,51 @@ +add('customer', CustomerType::class, [ + 'allow_password_field' => false, + 'use_repeat_email' => false, + 'guest' => true, + 'constraints' => [ + new Valid(['groups' => ['coreshop']]), + ], + ]) + ->add('address', AddressType::class, [ + 'constraints' => [ + new Valid(['groups' => ['coreshop']]), + ], + ]) + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + parent::configureOptions($resolver); + + $resolver->setDefaults([ + 'csrf_protection' => false + ]); + } +} diff --git a/src/CoreShop/Bundle/OrderBundle/Resources/config/pimcore/admin.yml b/src/CoreShop/Bundle/OrderBundle/Resources/config/pimcore/admin.yml index 52c22e06c5..338d334af5 100644 --- a/src/CoreShop/Bundle/OrderBundle/Resources/config/pimcore/admin.yml +++ b/src/CoreShop/Bundle/OrderBundle/Resources/config/pimcore/admin.yml @@ -23,6 +23,8 @@ core_shop_order: # sale_detail_abstract_block_detail: '/bundles/coreshoporder/pimcore/js/sale/detail/blocks/detail.js' # sale_list: '/bundles/coreshoporder/pimcore/js/sale/list.js' # sale_creation_panel: '/bundles/coreshoporder/pimcore/js/sale/create/panel.js' + order_creation_customer: '/bundles/coreshoporder/pimcore/js/order/create/customer.js' + order_creation_address: '/bundles/coreshoporder/pimcore/js/order/create/address.js' order_detail_abstract_block: '/bundles/coreshoporder/pimcore/js/order/detail/abstractBlock.js' order_creation_abstract_step: '/bundles/coreshoporder/pimcore/js/order/create/abstractStep.js' order_creation_step_base: '/bundles/coreshoporder/pimcore/js/order/create/step/base.js' diff --git a/src/CoreShop/Bundle/OrderBundle/Resources/config/pimcore/routing.yml b/src/CoreShop/Bundle/OrderBundle/Resources/config/pimcore/routing.yml index 18a88c4b0a..3385a698f8 100755 --- a/src/CoreShop/Bundle/OrderBundle/Resources/config/pimcore/routing.yml +++ b/src/CoreShop/Bundle/OrderBundle/Resources/config/pimcore/routing.yml @@ -141,3 +141,12 @@ coreshop_admin_order_add: coreshop_admin_order_remove: path: /%coreshop.admin.route.base%/order-edit/remove-item defaults: { _controller: 'coreshop.pimcore_controller.order_edit:removeItemAction'} + +##### CUSTOMER CREATION +coreshop_admin_order_customer_creation: + path: /%coreshop.admin.route.base%/order/customer/create + defaults: { _controller: 'coreshop.pimcore_controller.order_customer_creation:createCustomerAction'} + +coreshop_admin_order_address_creation: + path: /%coreshop.admin.route.base%/order/address/create + defaults: { _controller: 'coreshop.pimcore_controller.order_address_creation:createAddressAction'} diff --git a/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/order/create/address.js b/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/order/create/address.js new file mode 100644 index 0000000000..5f00cf9cda --- /dev/null +++ b/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/order/create/address.js @@ -0,0 +1,74 @@ +/* + * CoreShop. + * + * This source file is subject to the GNU General Public License version 3 (GPLv3) + * For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt + * files that are distributed with this source code. + * + * @copyright Copyright (c) 2015-2020 Dominik Pfaffenbauer (https://www.pfaffenbauer.at) + * @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3) + * + */ + +pimcore.registerNS('coreshop.order.order.create.address'); +coreshop.order.order.create.address = Class.create(coreshop.resource.creation, { + url: '/admin/coreshop/order/address/create', + type: 'address', + + getSettings: function() { + return [this.getAddressSettings()]; + }, + + getAddressSettings: function () { + this.addressForm = Ext.create('Ext.form.FieldSet', { + title: t('coreshop_address_create'), + items: [{ + xtype: 'coreshop.countrySalutation', + country: { + name: this.options.prefix + 'country', + fieldLabel: t('coreshop_address_create_country'), + }, + salutation: { + name: this.options.prefix + 'salutation', + fieldLabel: t('coreshop_address_create_salutation'), + }, + }, { + xtype: 'textfield', + name: this.options.prefix + 'firstname', + fieldLabel: t('coreshop_address_create_firstname'), + allowBlank: false + }, { + xtype: 'textfield', + name: this.options.prefix + 'lastname', + fieldLabel: t('coreshop_address_create_lastname'), + allowBlank: false + }, { + xtype: 'textfield', + name: this.options.prefix + 'street', + fieldLabel: t('coreshop_address_create_street'), + allowBlank: false + }, { + xtype: 'textfield', + name: this.options.prefix + 'number', + fieldLabel: t('coreshop_address_create_number'), + allowBlank: false + }, { + xtype: 'textfield', + name: this.options.prefix + 'postcode', + fieldLabel: t('coreshop_address_create_postcode'), + allowBlank: false + }, { + xtype: 'textfield', + name: this.options.prefix + 'city', + fieldLabel: t('coreshop_address_create_city'), + allowBlank: false + }, { + xtype: 'textfield', + name: this.options.prefix + 'phoneNumber', + fieldLabel: t('coreshop_address_create_phone_number') + }] + }); + + return this.addressForm; + }, +}); diff --git a/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/order/create/customer.js b/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/order/create/customer.js new file mode 100644 index 0000000000..13f0b67adc --- /dev/null +++ b/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/order/create/customer.js @@ -0,0 +1,59 @@ +/* + * CoreShop. + * + * This source file is subject to the GNU General Public License version 3 (GPLv3) + * For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt + * files that are distributed with this source code. + * + * @copyright Copyright (c) 2015-2020 Dominik Pfaffenbauer (https://www.pfaffenbauer.at) + * @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3) + * + */ + +pimcore.registerNS('coreshop.order.order.create.customer'); +coreshop.order.order.create.customer = Class.create(coreshop.resource.creation, { + url: '/admin/coreshop/order/customer/create', + type: 'customer', + + getSettings: function() { + return [ + this.getCustomerSettings(), + this.getAddressSettings() + ]; + }, + + getCustomerSettings: function () { + this.customerForm = Ext.create('Ext.form.FieldSet', { + title: t('coreshop_customer_create_customer'), + items: [{ + xtype: 'combobox', + store: [['male', t('coreshop_gender_male')], ['female', t('coreshop_gender_female')]], + name: this.options.prefix + 'gender', + fieldLabel: t('coreshop_customer_create_gender'), + allowBlank: false + }, { + xtype: 'textfield', + name: this.options.prefix + 'firstname', + fieldLabel: t('coreshop_customer_create_firstname'), + allowBlank: false + }, { + xtype: 'textfield', + name: this.options.prefix + 'lastname', + fieldLabel: t('coreshop_customer_create_lastname'), + allowBlank: false + }, { + xtype: 'textfield', + vtype: 'email', + name: this.options.prefix + 'email', + fieldLabel: t('coreshop_customer_create_email'), + allowBlank: false + }] + }); + + return this.customerForm; + }, + + getAddressSettings: function () { + return new coreshop.order.order.create.address({prefix: 'address.'}).getAddressSettings(); + }, +}); diff --git a/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/order/create/panel.js b/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/order/create/panel.js index 2823548c57..b921fbe860 100644 --- a/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/order/create/panel.js +++ b/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/order/create/panel.js @@ -66,25 +66,38 @@ coreshop.order.order.create.panel = Class.create({ }, loadSaleRelator: function() { - var me = this; + var me = this, + toolbarConfig = []; + + toolbarConfig.push(new Ext.Button({ + text: t("coreshop_order_create_customer"), + handler: this.createRelator.bind(this), + iconCls: "pimcore_icon_add", + enableToggle: true + })); - pimcore.helpers.itemselector( + this.selector = new coreshop.selector.selector( false, function (customer) { - this.loadCustomerDetail(customer.id); - }.bind(me), + me.loadCustomerDetail(customer.id); + }, { - type: ['object'], - subtype: { - object: ['object'] - }, - specific: { - classes: coreshop.stack.coreshop.customer - } + classes: coreshop.stack.coreshop.customer + }, + { + toolbar: toolbarConfig } ); }, + createRelator: function() { + var me = this; + new coreshop.order.order.create.customer({prefix: 'customer.'}, function(id) { + me.selector.window.close(); + me.loadCustomerDetail(id); + }).show(); + }, + loadCustomerDetail: function (customerId) { this.customerId = customerId; diff --git a/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/order/create/step/address.js b/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/order/create/step/address.js index 4d2d741972..3335b453c3 100644 --- a/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/order/create/step/address.js +++ b/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/order/create/step/address.js @@ -43,7 +43,7 @@ coreshop.order.order.create.step.address = Class.create(coreshop.order.order.cre }, setPreviewData: function(data) { - + this.addressStore.setData(data.customer.addresses); }, getValues: function (parent) { @@ -87,6 +87,7 @@ coreshop.order.order.create.step.address = Class.create(coreshop.order.order.cre xtype: 'combo', fieldLabel: t('coreshop_address_' + type), labelWidth: 150, + itemId: 'address', name: type + 'Address', store: this.addressStore, editable: false, @@ -115,6 +116,25 @@ coreshop.order.order.create.step.address = Class.create(coreshop.order.order.cre }.bind(this) } }, + { + xtype: 'button', + iconCls: 'pimcore_icon_add', + text: t('coreshop_address_create'), + handler: function () { + new coreshop.order.order.create.address( + { + prefix: 'address.', + params: { + customer: this.creationPanel.customerId + } + }, function(id) { + this[key].down('#address').setValue(id); + + this.eventManager.fireEvent('preview'); + }.bind(this) + ).show(); + }.bind(this) + }, this[addressDetailPanelKey] ] }); diff --git a/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/sale/detail/blocks/detail.js b/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/sale/detail/blocks/detail.js deleted file mode 100644 index abcc7846b3..0000000000 --- a/src/CoreShop/Bundle/OrderBundle/Resources/public/pimcore/js/sale/detail/blocks/detail.js +++ /dev/null @@ -1,295 +0,0 @@ -/* - * CoreShop. - * - * This source file is subject to the GNU General Public License version 3 (GPLv3) - * For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt - * files that are distributed with this source code. - * - * @copyright Copyright (c) 2015-2020 Dominik Pfaffenbauer (https://www.pfaffenbauer.at) - * @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3) - * - */ - -pimcore.registerNS('coreshop.order.sale.detail.blocks.detail'); -coreshop.order.sale.detail.blocks.detail = Class.create(coreshop.order.sale.detail.abstractBlock, { - - initBlock: function () { - - this.detailsStore = new Ext.data.JsonStore({ - data: [] - }); - - this.summaryStore = new Ext.data.JsonStore({ - data: [] - }); - - this.detailsInfo = Ext.create('Ext.panel.Panel', { - title: t('coreshop_products'), - border: true, - margin: '0 0 20 0', - iconCls: 'coreshop_icon_product', - }); - }, - - getPriority: function () { - return 10; - }, - - getPosition: function () { - return 'bottom'; - }, - - getPanel: function () { - return this.detailsInfo; - }, - - updateSale: function () { - - var detailItems; - - this.detailsStore.loadRawData(this.sale.details); - this.summaryStore.loadRawData(this.sale.summary); - - this.detailsInfo.removeAll(); - - detailItems = [this.generateItemGrid(), this.generateSummaryGrid()]; - - if (this.sale.priceRule) { - detailItems.splice(1, 0, this.generatePriceRuleItem(this.sale.priceRule)); - } - - this.detailsInfo.add(detailItems); - }, - - generateItemGrid: function () { - - var _ = this, - hasAdditionalData = false; - - if (Ext.isArray(this.sale.details)) { - Ext.Array.each(this.sale.details, function (row) { - if (row.hasOwnProperty('additional_details')) { - hasAdditionalData = true; - return false; - } - }) - } - - return { - xtype: 'grid', - margin: '0 0 15 0', - cls: 'coreshop-detail-grid', - store: this.detailsStore, - listeners: { - viewready: function (grid) { - if (hasAdditionalData === true) { - var view = grid.getView(), - rowExpander = grid.findPlugin('rowexpander'), - store = grid.getStore(), item; - for (var i = 0; i <= store.getCount(); i++) { - item = store.getAt(i); - if (item) { - rowExpander.toggleRow(i, item); - } - } - // remove toggle icon - view.getHeaderAtIndex(0).hide(); - } - } - }, - plugins: hasAdditionalData === true ? [{ - ptype: 'rowexpander', - expandOnDblClick: false, - rowBodyTpl: new Ext.XTemplate( - '', - '', - '', - '', - '', - '', - '', - '', - '
', - '{[ this.formatData(values) ]}', - '
', - { - formatData: function (row) { - var label = null, value = null; - if (row.type === 'string') { - value = row.value; - } else if (row.type === 'price') { - value = coreshop.util.format.currency(_.sale.currency.iso, row.value) - } else { - value = '--'; - } - - if (row.label !== null) { - label = row.translate_label ? t(row.label) : row.label; - } - - return label === null ? value : (label + ': ' + value); - } - } - ) - }] : [], - columns: [ - { - xtype: 'gridcolumn', - flex: 1, - dataIndex: 'product_name', - text: t('coreshop_product') - }, - { - xtype: 'gridcolumn', - dataIndex: 'wholesale_price', - text: t('coreshop_wholesale_price'), - width: 150, - align: 'right', - renderer: coreshop.util.format.currency.bind(this, this.sale.currency.iso) - }, - { - xtype: 'gridcolumn', - dataIndex: 'price_without_tax', - text: t('coreshop_price_without_tax'), - width: 150, - align: 'right', - renderer: coreshop.util.format.currency.bind(this, this.sale.currency.iso), - field: { - xtype: 'numberfield', - decimalPrecision: 4 - } - }, - { - xtype: 'gridcolumn', - dataIndex: 'price', - text: t('coreshop_price_with_tax'), - width: 150, - align: 'right', - renderer: coreshop.util.format.currency.bind(this, this.sale.currency.iso) - }, - { - xtype: 'gridcolumn', - dataIndex: 'quantity', - text: t('coreshop_quantity'), - width: 150, - align: 'right', - field: { - xtype: 'numberfield', - decimalPrecision: 0 - } - }, - { - xtype: 'gridcolumn', - dataIndex: 'total', - text: t('coreshop_total'), - width: 150, - align: 'right', - renderer: coreshop.util.format.currency.bind(this, this.sale.currency.iso) - }, - { - menuDisabled: true, - sortable: false, - xtype: 'actioncolumn', - width: 50, - items: this.generateActions() - } - ] - }; - }, - - generateSummaryGrid: function () { - - return { - xtype: 'grid', - margin: '0 0 15 0', - cls: 'coreshop-detail-grid', - store: this.summaryStore, - hideHeaders: true, - columns: [ - { - xtype: 'gridcolumn', - flex: 1, - align: 'right', - dataIndex: 'key', - renderer: function (value, metaData, record) { - if (record.get('text')) { - return '' + record.get('text') + ''; - } - - return '' + t('coreshop_' + value) + ''; - } - }, - { - xtype: 'gridcolumn', - dataIndex: 'value', - width: 150, - align: 'right', - renderer: function (value, md, record) { - var factor = record.get('factor') ?? pimcore.globalmanager.get('coreshop.currency.decimal_factor'); - var precision = record.get('precision') ?? pimcore.globalmanager.get('coreshop.currency.decimal_precision'); - - return '' + coreshop.util.format.currency_precision(this.sale.currency.iso, value, precision, factor) + ''; - }.bind(this) - } - ] - } - }, - - generatePriceRuleItem: function (priceRuleStoreData) { - - return { - xtype: 'grid', - margin: '0 0 15 0', - cls: 'coreshop-detail-grid', - store: new Ext.data.JsonStore({ - data: priceRuleStoreData - }), - hideHeaders: true, - title: t('coreshop_pricerules'), - columns: [ - { - xtype: 'gridcolumn', - flex: 1, - align: 'right', - dataIndex: 'name', - renderer: function (value, metaData, record) { - return record.get('code') !== null ? value + ' (' + (record.get('code')) + ')' : value; - }.bind(this) - }, - { - xtype: 'gridcolumn', - dataIndex: 'discountNet', - width: 150, - align: 'right', - renderer: function (value) { - return '' + coreshop.util.format.currency(this.sale.currency.iso, value) + ''; - }.bind(this) - }, - { - xtype: 'gridcolumn', - dataIndex: 'discount', - width: 150, - align: 'right', - renderer: function (value) { - return '' + coreshop.util.format.currency(this.sale.currency.iso, value) + ''; - }.bind(this) - } - ] - }; - }, - - generateActions: function () { - - return [ - { - iconCls: 'pimcore_icon_open', - tooltip: t('open'), - handler: function (grid, rowIndex) { - var record = grid.getStore().getAt(rowIndex); - - pimcore.helpers.openObject(record.get('o_id')); - } - } - ]; - } -}); diff --git a/src/CoreShop/Bundle/OrderBundle/Resources/translations/admin.de.yml b/src/CoreShop/Bundle/OrderBundle/Resources/translations/admin.de.yml index a27af40660..542196801f 100644 --- a/src/CoreShop/Bundle/OrderBundle/Resources/translations/admin.de.yml +++ b/src/CoreShop/Bundle/OrderBundle/Resources/translations/admin.de.yml @@ -273,4 +273,26 @@ coreshop_adjustment_identifier: 'Adjustment Typ' coreshop_creating_cart: 'Warenkorb wird erstellt' coreshop_creating_cart_finished: 'Warenkorb wurde erstellt' coreshop_creating_cart_finished_detail: 'Der Warenkorb wurde erfolgreich erstellt, wie wollen Sie fortfahren?' -coreshop_sale_action_open_cart: 'Warenkorb öffnen' +coreshop_customer_create: 'Kunde erstellen' +coreshop_customer_create_customer: 'Kunde' +coreshop_customer_create_gender: 'Geschlecht' +coreshop_customer_create_firstname: 'Vorname' +coreshop_customer_create_lastname: 'Nachname' +coreshop_customer_create_email: 'Email' +coreshop_address_create: 'Kunden Adresse' +coreshop_address_create_country: 'Land' +coreshop_address_create_salutation: 'Anrede' +coreshop_address_create_firstname: 'Vorname' +coreshop_address_create_lastname: 'Nachname' +coreshop_address_create_street: 'Straße' +coreshop_address_create_number: 'Nummer' +coreshop_address_create_postcode: 'Postleitzahl' +coreshop_address_create_city: 'Stadt' +coreshop_address_create_phone_number: 'Telefonnummer' +coreshop_sale_create_relator_order: 'Kunde erstellen' +coreshop_sale_create_relator_quote: 'Kunde erstellen' +coreshop_sale_create_relator_cart: 'Kunde erstellen' +coreshop_gender_male: 'Männlich' +coreshop_gender_female: 'Weiblich' +coreshop_salutation_mr: 'Herr' +coreshop_salutation_mrs: 'Frau' diff --git a/src/CoreShop/Bundle/OrderBundle/Resources/translations/admin.en.yml b/src/CoreShop/Bundle/OrderBundle/Resources/translations/admin.en.yml index 0a236bf4f4..3c3966b6e0 100644 --- a/src/CoreShop/Bundle/OrderBundle/Resources/translations/admin.en.yml +++ b/src/CoreShop/Bundle/OrderBundle/Resources/translations/admin.en.yml @@ -278,7 +278,27 @@ coreshop_adjustment_identifier: 'Adjustment Type' coreshop_creating_cart: 'Cart is getting created' coreshop_creating_cart_finished: 'Cart has been created' coreshop_creating_cart_finished_detail: 'The cart has been created successfully, how do you want to continue?' -coreshop_sale_action_open_cart: 'Open Cart' +coreshop_order_create_customer: 'Create Customer' +coreshop_customer_create: 'Create Customer' +coreshop_customer_create_customer: 'Customer' +coreshop_customer_create_gender: 'Gender' +coreshop_customer_create_firstname: 'Firstname' +coreshop_customer_create_lastname: 'Lastname' +coreshop_customer_create_email: 'Email' +coreshop_address_create: 'Customer Address' +coreshop_address_create_country: 'Country' +coreshop_address_create_salutation: 'Salutation' +coreshop_address_create_firstname: 'Firstname' +coreshop_address_create_lastname: 'Lastname' +coreshop_address_create_street: 'Street' +coreshop_address_create_number: 'Number' +coreshop_address_create_postcode: 'Post Code' +coreshop_address_create_city: 'City' +coreshop_address_create_phone_number: 'Phone Number' +coreshop_gender_male: 'Male' +coreshop_gender_female: 'Female' +coreshop_salutation_mr: 'Mr' +coreshop_salutation_mrs: 'Mrs' coreshop_customer_to_company_assign_to_new: 'Assign Customer to new Company' coreshop_customer_to_company_assign_to_existing: 'Assign Customer to existing Company' coreshop_payment_total: 'Payment Total' diff --git a/src/CoreShop/Bundle/ProductBundle/Resources/public/pimcore/js/product/units/builder.js b/src/CoreShop/Bundle/ProductBundle/Resources/public/pimcore/js/product/units/builder.js index 23e00f00d0..d2b61c5703 100644 --- a/src/CoreShop/Bundle/ProductBundle/Resources/public/pimcore/js/product/units/builder.js +++ b/src/CoreShop/Bundle/ProductBundle/Resources/public/pimcore/js/product/units/builder.js @@ -290,7 +290,7 @@ coreshop.product.unit.builder = Class.create({ dispatchUnitDefinitionChangeEvent: function () { - var values = this.convertDotNotationToObject(this.getValues()), + var values = coreshop.helpers.convertDotNotationToObject(this.getValues()), additionalUnitDefinitions = this.getAdditionalUnitDefinitions(); if (values.hasOwnProperty('additionalUnitDefinitions')) { @@ -490,25 +490,5 @@ coreshop.product.unit.builder = Class.create({ getValues: function () { return this.form.getForm().getFieldValues(); - }, - - convertDotNotationToObject: function (data) { - var obj = {}; - - Object.keys(data).forEach(function (key) { - var val = data[key], - step = obj; - - key.split('.').forEach(function (part, index, arr) { - if (index === arr.length - 1) { - step[part] = val; - } else if (step[part] === undefined) { - step[part] = {}; - } - step = step[part]; - }); - }); - - return obj; } }); diff --git a/src/CoreShop/Bundle/ResourceBundle/Resources/config/pimcore/admin.yml b/src/CoreShop/Bundle/ResourceBundle/Resources/config/pimcore/admin.yml index 6510751100..8803da9560 100644 --- a/src/CoreShop/Bundle/ResourceBundle/Resources/config/pimcore/admin.yml +++ b/src/CoreShop/Bundle/ResourceBundle/Resources/config/pimcore/admin.yml @@ -16,6 +16,9 @@ core_shop_resource: core_extension_data_select: '/bundles/coreshopresource/pimcore/js/coreExtension/data/select.js' core_extension_tag_select: '/bundles/coreshopresource/pimcore/js/coreExtension/tags/select.js' core_extension_tag_multiselect: '/bundles/coreshopresource/pimcore/js/coreExtension/tags/multiselect.js' + selector_object: '/bundles/coreshopresource/pimcore/js/selector/object.js' + selector_selector: '/bundles/coreshopresource/pimcore/js/selector/selector.js' + resource_creation: '/bundles/coreshopresource/pimcore/js/resource/creation.js' css: resource: '/bundles/coreshopresource/pimcore/css/resource.css' editmode_js: diff --git a/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/helpers.js b/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/helpers.js index d6df0ef18c..abc48f9ee4 100644 --- a/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/helpers.js +++ b/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/helpers.js @@ -35,3 +35,22 @@ coreshop.helpers.requestNicePathData = function (targets, responseHandler) { }.bind(this) }); }; + +coreshop.helpers.convertDotNotationToObject = function (data) { + var obj = {}; + + Object.keys(data).forEach(function (key) { //loop through the keys in the object + var val = data[key]; //grab the value of this key + var step = obj; //reference the object that holds the values + key.split(".").forEach(function (part, index, arr) { //split the parts and loop + if (index === arr.length - 1) { //If we are at the last index, than we set the value + step[part] = val; + } else if (step[part] === undefined) { //If we have not seen this key before, create an object + step[part] = {}; + } + step = step[part]; //Step up the object we are referencing + }); + }); + + return obj; +}; diff --git a/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/resource/creation.js b/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/resource/creation.js new file mode 100644 index 0000000000..f28fa91e51 --- /dev/null +++ b/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/resource/creation.js @@ -0,0 +1,100 @@ +/* + * CoreShop. + * + * This source file is subject to the GNU General Public License version 3 (GPLv3) + * For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt + * files that are distributed with this source code. + * + * @copyright Copyright (c) 2015-2020 Dominik Pfaffenbauer (https://www.pfaffenbauer.at) + * @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3) + * + */ + +pimcore.registerNS('coreshop.resource.creation'); +coreshop.resource.creation = Class.create({ + url: null, + type: null, + callback: Ext.emptyFn, + options: { + prefix: '', + params: {} + }, + + initialize: function (options, callback) { + this.options = Ext.isDefined(options) ? Ext.mergeIf(options, this.options) : this.options; + this.callback = Ext.isDefined(callback) ? callback : Ext.emptyFn; + + this.window = new Ext.Window({ + width: 670, + height: '80%', + modal: true, + resize: false, + title: t('coreshop_' + this.type + '_create'), + layout: 'fit', + items: this.getForm() + }); + }, + + show: function() { + this.window.show(); + }, + + close: function() { + this.window.close(); + }, + + getForm: function() { + this.form = Ext.create('Ext.form.Panel', { + bodyStyle: 'padding:10px;', + autoScroll: true, + border: false, + fieldDefaults: { + labelWidth: 300, + width: 600 + }, + items: this.getSettings(), + buttons: [{ + text: t('create'), + iconCls: 'pimcore_icon_apply', + handler: function (btn) { + if (btn.up('form').getForm().isValid()) { + var params = btn.up('form').getForm().getFieldValues(); + params = coreshop.helpers.convertDotNotationToObject(params); + + btn.setDisabled(true); + this.window.setLoading(); + + params = Ext.merge(params, this.options.params); + + Ext.Ajax.request({ + url: this.url, + method: 'post', + jsonData: params, + success: function (response) { + var res = Ext.decode(response.responseText); + if (res.success) { + this.callback(res.id); + this.window.close(); + } else { + this.window.setLoading(false); + btn.setDisabled(false); + pimcore.helpers.showNotification(t('error'), (res.message ? res.message : 'error'), 'error'); + } + }.bind(this), + failure: function (response) { + this.window.setLoading(false); + btn.setDisabled(false); + }.bind(this) + }); + } + }.bind(this) + }] + }); + + return this.form; + }, + + getSettings: function () { + return []; + }, +}); diff --git a/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/resource/item.js b/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/resource/item.js index dbce2f909d..f2673bbb53 100644 --- a/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/resource/item.js +++ b/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/resource/item.js @@ -85,7 +85,7 @@ coreshop.resource.item = Class.create({ var saveData = this.getSaveData(); saveData['id'] = this.data.id; - saveData = this.convertDotNotationToObject(saveData); + saveData = coreshop.helpers.convertDotNotationToObject(saveData); if (saveData.hasOwnProperty('stores')) { var stores = []; @@ -141,24 +141,5 @@ coreshop.resource.item = Class.create({ isValid: function () { return true; - }, - - convertDotNotationToObject: function (data) { - var obj = {}; - - Object.keys(data).forEach(function (key) { //loop through the keys in the object - var val = data[key]; //grab the value of this key - var step = obj; //reference the object that holds the values - key.split(".").forEach(function (part, index, arr) { //split the parts and loop - if (index === arr.length - 1) { //If we are at the last index, than we set the value - step[part] = val; - } else if (step[part] === undefined) { //If we have not seen this key before, create an object - step[part] = {}; - } - step = step[part]; //Step up the object we are referencing - }); - }); - - return obj; } }); diff --git a/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/selector/object.js b/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/selector/object.js new file mode 100644 index 0000000000..e143124f02 --- /dev/null +++ b/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/selector/object.js @@ -0,0 +1,151 @@ +/* + * CoreShop. + * + * This source file is subject to the GNU General Public License version 3 (GPLv3) + * For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt + * files that are distributed with this source code. + * + * @copyright Copyright (c) 2015-2020 Dominik Pfaffenbauer (https://www.pfaffenbauer.at) + * @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3) + * + */ + +pimcore.registerNS('coreshop.selector.object'); +coreshop.selector.object = Class.create(pimcore.element.selector.object, { + getForm: function () { + var i; + + //set "Home" object ID for search grid column configuration + this.object = new Object(); + this.object.id = 1; + + this.searchType = "search"; + + var compositeConfig = { + xtype: "toolbar", + items: [{ + xtype: "textfield", + name: "query", + width: 340, + hideLabel: true, + enableKeyEvents: true, + listeners: { + "keydown" : function (field, key) { + if (key.getKey() == key.ENTER) { + this.search(); + } + }.bind(this), + afterrender: function () { + this.focus(true,500); + } + } + }] + }; + + // classes + var possibleClassRestrictions = []; + var classStore = pimcore.globalmanager.get("object_types_store"); + classStore.each(function (rec) { + possibleClassRestrictions.push(rec.data.text); + }); + + var filterClassStore = []; + var selectedClassStore = []; + for (i=0; i 0); + this.saveConfig(asCopy) + }.bind(this) + }); + + this.columnConfigButton = new Ext.SplitButton({ + text: t('grid_options'), + hidden: true, + iconCls: "pimcore_icon_table_col pimcore_icon_overlay_edit", + handler: function () { + this.openColumnConfig(this.selectedClass, this.classId); + }.bind(this), + menu: [] + }); + + if (this.parent.config.hasOwnProperty('toolbar')) { + Ext.each(this.parent.config.toolbar, function(item) { + compositeConfig.items.push(item); + }); + } + + compositeConfig.items.push("->"); + + // add grid config main button + compositeConfig.items.push(this.columnConfigButton); + + // add grid config save button + compositeConfig.items.push(this.saveColumnConfigButton); + + if(!this.formPanel) { + this.formPanel = new Ext.form.FormPanel({ + region: "north", + bodyStyle: "padding: 2px;", + items: [compositeConfig] + }); + } + + return this.formPanel; + }, + + applyExtraParamsToStore: function () { + var formValues = this.formPanel.getForm().getFieldValues(); + + var proxy = this.store.getProxy(); + + proxy.setExtraParam("type", "object"); + proxy.setExtraParam("query", formValues.query); + proxy.setExtraParam("class", formValues.class); + + if (this.gridLanguage) { + proxy.setExtraParam("language", this.gridLanguage); + } + + if (this.parent.config && this.parent.config.context) { + proxy.setExtraParam("context", Ext.encode(this.parent.config.context)); + } + }, +}); + +pimcore.element.selector.object.addMethods(pimcore.element.helpers.gridColumnConfig); diff --git a/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/selector/selector.js b/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/selector/selector.js new file mode 100644 index 0000000000..8095081bd6 --- /dev/null +++ b/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/selector/selector.js @@ -0,0 +1,75 @@ +/* + * CoreShop. + * + * This source file is subject to the GNU General Public License version 3 (GPLv3) + * For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt + * files that are distributed with this source code. + * + * @copyright Copyright (c) 2015-2020 Dominik Pfaffenbauer (https://www.pfaffenbauer.at) + * @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3) + * + */ + +pimcore.registerNS('coreshop.selector.selector'); +coreshop.selector.selector = Class.create({ + + initialize: function (multiselect, callback, classes, config) { + this.classes = classes; + this.callback = callback; + this.multiselect = multiselect; + this.config = Ext.isDefined(config) ? config : {}; + + if (!this.multiselect) { + this.multiselect = false; + } + + if (!this.classes) { + this.classes = []; + pimcore.globalmanager.get("object_types_store").each(function (rec) { + this.classes.push(rec.data.text); + }.bind(this)); + } + + if (!this.callback) { + this.callback = Ext.emptyFn; + } + + this.panel = new Ext.Panel({ + border: false, + layout: "fit" + }); + + var windowWidth = 1000; + if (this.multiselect) { + windowWidth = 1250; + } + + var windowConfig = { + width: windowWidth, + height: 550, + title: t('search'), + modal: true, + layout: "fit", + items: [this.panel] + }; + + this.window = new Ext.Window(windowConfig); + + this.window.show(); + + this.current = new coreshop.selector.object(this); + }, + + setSearch: function (panel) { + delete this.current; + this.panel.removeAll(); + this.panel.add(panel); + + this.panel.updateLayout(); + }, + + commitData: function (data) { + this.callback(data); + this.window.close(); + } +}); diff --git a/src/CoreShop/Bundle/TaxationBundle/Resources/public/pimcore/js/resource/taxRate.js b/src/CoreShop/Bundle/TaxationBundle/Resources/public/pimcore/js/resource/taxRate.js index 53b5cd6966..6ab4b291e9 100644 --- a/src/CoreShop/Bundle/TaxationBundle/Resources/public/pimcore/js/resource/taxRate.js +++ b/src/CoreShop/Bundle/TaxationBundle/Resources/public/pimcore/js/resource/taxRate.js @@ -1,4 +1,4 @@ -Ext.define('CoreShop.store.TaxRate', { +Ext.define('CoreShop.taxation.TaxRate', { extend: 'CoreShop.resource.ComboBox', alias: 'widget.coreshop.taxRate', diff --git a/src/CoreShop/Bundle/TaxationBundle/Resources/public/pimcore/js/resource/taxRuleGroup.js b/src/CoreShop/Bundle/TaxationBundle/Resources/public/pimcore/js/resource/taxRuleGroup.js index 4d35bb4ba6..35774d3200 100644 --- a/src/CoreShop/Bundle/TaxationBundle/Resources/public/pimcore/js/resource/taxRuleGroup.js +++ b/src/CoreShop/Bundle/TaxationBundle/Resources/public/pimcore/js/resource/taxRuleGroup.js @@ -1,4 +1,4 @@ -Ext.define('CoreShop.store.TaxRuleGroup', { +Ext.define('CoreShop.taxation.TaxRuleGroup', { extend: 'CoreShop.resource.ComboBox', alias: 'widget.coreshop.taxRuleGroup', diff --git a/src/CoreShop/Component/Address/Model/DefaultAddressAwareInterface.php b/src/CoreShop/Component/Address/Model/DefaultAddressAwareInterface.php new file mode 100644 index 0000000000..150171dd67 --- /dev/null +++ b/src/CoreShop/Component/Address/Model/DefaultAddressAwareInterface.php @@ -0,0 +1,26 @@ +