Skip to content

Commit

Permalink
Merge pull request #4895 in SW/shopware from SW-18668/5.2/add-documen…
Browse files Browse the repository at this point in the history
…t-type-base-store to 5.2

* commit '05695815fd4b3f7629d8f1460eb32eff20dacf82':
  SW-18668 - Modify Base::getDocTypesAction to use DIC
  SW-18668 - Add document type base store
  • Loading branch information
htkassner committed May 12, 2017
2 parents ecf9ac2 + 0569581 commit a64f83e
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 0 deletions.
2 changes: 2 additions & 0 deletions UPGRADE-5.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This changelog references changes done in Shopware 5.2 patch versions.
* Added conditional statement in `themes/Frontend/Responsive/frontend/_public/src/js/jquery.product-slider.js` to prevent the jquery plugin from sending ajax requests indefinitely
* Added `limit` parameter to `createQuery` and `createOptionQuery` in `engine/Shopware/Bundle/ESIndexingBundle/Property/PropertyQueryFactory`
* Added default `limit` of 100 in `engine/Shopware/Bundle/ESIndexingBundle/Property/PropertyIndexer::populate`
* Added a base store for `Shopware.apps.Base.model.DocType`

## 5.2.22
* Fixed the picture implementation of the `box-emotion.tpl` to load the correct image sizes
* Added new event `plugin/swAutoSubmit/onChangeSelection` in `themes/Frontend/Responsive/frontend/_public/src/js/jquery.auto-submit.js`
Expand Down
39 changes: 39 additions & 0 deletions engine/Shopware/Controllers/Backend/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

use Doctrine\DBAL\Connection;
use Shopware\Components\CSRFWhitelistAware;
use Shopware\Models\Document\Document;
use Shopware\Models\Shop\Locale;

/**
Expand Down Expand Up @@ -939,6 +940,44 @@ public function getSalutationsAction()
$this->View()->assign('data', $salutations);
}

/**
* Returns a list of document types. Supports store paging, sorting and filtering over the standard ExtJs store
* parameters. Each document type has the following fields:
* <code>
* [int] id
* [string] name
* [string] template
* [string] numbers
* [int] left
* [int] right
* [int] top
* [int] bottom
* [int] pageBreak
* </code>
*
* @throws \Exception
*/
public function getDocTypesAction()
{
$modelManager = $this->container->get('models');
$repository = $modelManager
->getRepository(Document::class);

$builder = $repository->createQueryBuilder('d');

$builder->select('d')
->addFilter((array) $this->Request()->getParam('filter', []))
->addOrderBy((array) $this->Request()->getParam('sort', []))
->setFirstResult($this->Request()->getParam('start', 0))
->setMaxResults($this->Request()->getParam('limit', 250));

$query = $builder->getQuery();
$total = $modelManager->getQueryCount($query);
$data = $query->getArrayResult();

$this->View()->assign(['success' => true, 'data' => $data, 'total' => $total]);
}

/**
* Add the table alias to the passed filter and sort parameters.
*
Expand Down
1 change: 1 addition & 0 deletions themes/Backend/ExtJs/backend/base/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
{include file='backend/base/store/category_tree.js'}
{include file='backend/base/store/customer_group.js'}
{include file='backend/base/store/dispatch.js'}
{include file='backend/base/store/doc_type.js'}
{include file='backend/base/store/payment.js'}
{include file='backend/base/store/shop.js'}
{include file='backend/base/store/shop_language.js'}
Expand Down
52 changes: 52 additions & 0 deletions themes/Backend/ExtJs/backend/base/store/doc_type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Shopware 5
* Copyright (c) shopware AG
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* "Shopware" is a registered trademark of shopware AG.
* The licensing of the program under the AGPLv3 does not imply a
* trademark license. Therefore any rights, title and interest in
* our trademarks remain entirely with us.
*
* @category Shopware
* @package Base
* @subpackage Store
* @version $Id$
* @author shopware AG
*/

/**
* The base store for document types.
*/
Ext.define('Shopware.apps.Base.store.DocType', {
extend: 'Ext.data.Store',

alternateClassName: 'Shopware.store.DocType',
storeId: 'base.Payment',
model : 'Shopware.apps.Base.model.DocType',
pageSize: 1000,
remoteFilter: true,

proxy:{
type:'ajax',
url:'{url action="getDocTypes"}',
reader:{
type: 'json',
root: 'data',
totalProperty: 'total'
}
}
}).create();

0 comments on commit a64f83e

Please sign in to comment.