Skip to content

Commit

Permalink
Adapt to moved basket domain
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Dec 22, 2024
1 parent d43b965 commit 1785060
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 44 deletions.
2 changes: 1 addition & 1 deletion js/basket.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Aimeos.Basket = {
mixins: {
methods: {
can(action) {
return Aimeos.can(action, this.item['order.basket.siteid'] || null, this.siteid)
return Aimeos.can(action, this.item['basket.siteid'] || null, this.siteid)
},
}
},
Expand Down
20 changes: 10 additions & 10 deletions src/Admin/JQAdm/Basket/Standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function copy() : ?string
throw new \Aimeos\Admin\JQAdm\Exception( sprintf( $msg, 'id' ) );
}

$manager = \Aimeos\MShop::create( $context, 'order/basket' );
$manager = \Aimeos\MShop::create( $context, 'basket' );

$view->item = $manager->get( $id );
$view->itemData = $this->toArray( $view->item, true );
Expand All @@ -124,7 +124,7 @@ public function delete() : ?string
{
$view = $this->view();

$manager = \Aimeos\MShop::create( $this->context(), 'order/basket' );
$manager = \Aimeos\MShop::create( $this->context(), 'basket' );
$manager->begin();

try
Expand All @@ -136,7 +136,7 @@ public function delete() : ?string
}

$search = $manager->filter()->slice( 0, count( (array) $ids ) );
$search->setConditions( $search->compare( '==', 'order.basket.id', $ids ) );
$search->setConditions( $search->compare( '==', 'basket.id', $ids ) );
$items = $manager->search( $search );

foreach( $items as $item )
Expand Down Expand Up @@ -178,7 +178,7 @@ public function get() : ?string
throw new \Aimeos\Admin\JQAdm\Exception( sprintf( $msg, 'id' ) );
}

$manager = \Aimeos\MShop::create( $context, 'order/basket' );
$manager = \Aimeos\MShop::create( $context, 'basket' );

$view->item = $manager->get( $id );
$view->itemData = $this->toArray( $view->item );
Expand Down Expand Up @@ -206,9 +206,9 @@ public function search() : ?string
{
$total = 0;
$params = $this->storeFilter( $view->param(), 'basket' );
$manager = \Aimeos\MShop::create( $this->context(), 'order/basket' );
$manager = \Aimeos\MShop::create( $this->context(), 'basket' );

$search = $manager->filter( false, true )->order( 'order.basket.ctime' );
$search = $manager->filter( false, true )->order( 'basket.ctime' );
$search = $this->initCriteria( $search, $params );

$view->items = $manager->search( $search, [], $total );
Expand Down Expand Up @@ -376,18 +376,18 @@ protected function getSubClientNames() : array
/**
* Constructs the data array for the view from the given item
*
* @param \Aimeos\MShop\Order\Item\Basket\Iface $item Basket item object
* @param \Aimeos\MShop\Basket\Item\Iface $item Basket item object
* @return string[] Multi-dimensional associative list of item data
*/
protected function toArray( \Aimeos\MShop\Order\Item\Basket\Iface $item, bool $copy = false ) : array
protected function toArray( \Aimeos\MShop\Basket\Item\Iface $item, bool $copy = false ) : array
{
$siteId = $this->context()->locale()->getSiteId();
$data = $item->toArray( true );

if( $copy === true )
{
$data['order.basket.siteid'] = $siteId;
$data['order.basket.id'] = '';
$data['basket.siteid'] = $siteId;
$data['basket.id'] = '';
}

return $data;
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/jqadm/basket/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<?php $currency = $this->translate( 'currency', $this->item->getItem()->getPrice()->getCurrencyId() ) ?>

<form class="item item-basket item-order form-horizontal container-fluid" method="POST" enctype="multipart/form-data" action="<?= $enc->attr( $this->link( 'admin/jqadm/url/save', $params ) ) ?>">
<input id="item-id" type="hidden" name="<?= $enc->attr( $this->formparam( array( 'item', 'order.basket.id' ) ) ) ?>" value="<?= $enc->attr( $this->item->getId() ) ?>">
<input id="item-id" type="hidden" name="<?= $enc->attr( $this->formparam( array( 'item', 'basket.id' ) ) ) ?>" value="<?= $enc->attr( $this->item->getId() ) ?>">
<input id="item-next" type="hidden" name="<?= $enc->attr( $this->formparam( array( 'next' ) ) ) ?>" value="get">
<?= $this->csrf()->formfield() ?>

Expand Down
54 changes: 27 additions & 27 deletions templates/admin/jqadm/basket/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
* interface.
*
* The names of the colums are in fact the search keys defined by the managers,
* e.g. "order.basket.id" for the order basket ID.
* e.g. "basket.id" for the order basket ID.
*
* @param array List of field names, i.e. search keys
* @since 2023.10
*/
$default = $this->config( 'admin/jqadm/basket/fields', ['order.basket.id', 'order.basket.customerid', 'order.basket.name', 'order.basket.ctime'] );
$default = $this->config( 'admin/jqadm/basket/fields', ['basket.id', 'basket.customerid', 'basket.name', 'basket.ctime'] );
$fields = $this->session( 'aimeos/admin/jqadm/basket/fields', $default );

$searchParams = $params = $this->get( 'pageParams', [] );
Expand All @@ -39,12 +39,12 @@


$columnList = [
'order.basket.id' => $this->translate( 'admin', 'ID' ),
'order.basket.customerid' => $this->translate( 'admin', 'Customer ID' ),
'order.basket.name' => $this->translate( 'admin', 'Name' ),
'order.basket.ctime' => $this->translate( 'admin', 'Created' ),
'order.basket.mtime' => $this->translate( 'admin', 'Modified' ),
'order.basket.editor' => $this->translate( 'admin', 'Editor' ),
'basket.id' => $this->translate( 'admin', 'ID' ),
'basket.customerid' => $this->translate( 'admin', 'Customer ID' ),
'basket.name' => $this->translate( 'admin', 'Name' ),
'basket.ctime' => $this->translate( 'admin', 'Created' ),
'basket.mtime' => $this->translate( 'admin', 'Modified' ),
'basket.editor' => $this->translate( 'admin', 'Editor' ),

];

Expand All @@ -57,7 +57,7 @@


<div class="list-view"
data-domain="order/basket"
data-domain="basket"
data-siteid="<?= $enc->attr( $this->site()->siteid() ) ?>"
data-filter="<?= $enc->attr( $this->session( 'aimeos/admin/jqadm/basket/filter', new \stdClass ) ) ?>"
data-items="<?= $enc->attr( $this->get( 'items', map() )->call( 'toArray', [true] )->all() ) ?>">
Expand Down Expand Up @@ -141,12 +141,12 @@
$this->config( 'admin/jqadm/partial/listsearch', 'listsearch' ), [
'fields' => array_merge( $fields, ['select'] ), 'filter' => $this->session( 'aimeos/admin/jqadm/basket/filter', [] ),
'data' => [
'order.basket.id' => ['op' => '=='],
'order.basket.customerid' => ['op' => '=='],
'order.basket.name' => [],
'order.basket.ctime' => ['op' => '-', 'type' => 'date'],
'order.basket.mtime' => ['op' => '-', 'type' => 'date'],
'order.basket.editor' => [],
'basket.id' => ['op' => '=='],
'basket.customerid' => ['op' => '=='],
'basket.name' => [],
'basket.ctime' => ['op' => '-', 'type' => 'date'],
'basket.mtime' => ['op' => '-', 'type' => 'date'],
'basket.editor' => [],

]
] );
Expand All @@ -164,23 +164,23 @@
v-bind:checked="checked(`<?= $enc->js( $id ) ?>`)"
v-bind:disabled="readonly(`<?= $enc->js( $id ) ?>`)">
</td>
<?php if( in_array( 'order.basket.id', $fields ) ) : ?>
<td class="order-basket-id"><a class="items-field" href="<?= $url ?>" tabindex="1"><?= $enc->html( $item->getId() ) ?></a></td>
<?php if( in_array( 'basket.id', $fields ) ) : ?>
<td class="basket-id"><a class="items-field" href="<?= $url ?>" tabindex="1"><?= $enc->html( $item->getId() ) ?></a></td>
<?php endif ?>
<?php if( in_array( 'order.basket.customerid', $fields ) ) : ?>
<td class="order-basket-customerid"><a class="items-field" href="<?= $url ?>"><?= $enc->html( $item->getCustomerId() ) ?></a></td>
<?php if( in_array( 'basket.customerid', $fields ) ) : ?>
<td class="basket-customerid"><a class="items-field" href="<?= $url ?>"><?= $enc->html( $item->getCustomerId() ) ?></a></td>
<?php endif ?>
<?php if( in_array( 'order.basket.name', $fields ) ) : ?>
<td class="order-basket-name"><a class="items-field" href="<?= $url ?>"><?= $enc->html( $item->getName() ) ?></a></td>
<?php if( in_array( 'basket.name', $fields ) ) : ?>
<td class="basket-name"><a class="items-field" href="<?= $url ?>"><?= $enc->html( $item->getName() ) ?></a></td>
<?php endif ?>
<?php if( in_array( 'order.basket.ctime', $fields ) ) : ?>
<td class="order-basket-ctime"><a class="items-field" href="<?= $url ?>"><?= $enc->html( $item->getTimeCreated() ) ?></a></td>
<?php if( in_array( 'basket.ctime', $fields ) ) : ?>
<td class="basket-ctime"><a class="items-field" href="<?= $url ?>"><?= $enc->html( $item->getTimeCreated() ) ?></a></td>
<?php endif ?>
<?php if( in_array( 'order.basket.mtime', $fields ) ) : ?>
<td class="order-basket-mtime"><a class="items-field" href="<?= $url ?>"><?= $enc->html( $item->getTimeModified() ) ?></a></td>
<?php if( in_array( 'basket.mtime', $fields ) ) : ?>
<td class="basket-mtime"><a class="items-field" href="<?= $url ?>"><?= $enc->html( $item->getTimeModified() ) ?></a></td>
<?php endif ?>
<?php if( in_array( 'order.basket.editor', $fields ) ) : ?>
<td class="order-basket-editor"><a class="items-field" href="<?= $url ?>"><?= $enc->html( $item->editor() ) ?></a></td>
<?php if( in_array( 'basket.editor', $fields ) ) : ?>
<td class="basket-editor"><a class="items-field" href="<?= $url ?>"><?= $enc->html( $item->editor() ) ?></a></td>
<?php endif ?>

<td class="actions">
Expand Down
9 changes: 4 additions & 5 deletions tests/Admin/JQAdm/Basket/StandardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ public function testSearch()
$param = array(
'site' => 'unittest', 'locale' => 'de',
'filter' => array(
'key' => array( 0 => 'order.basket.name' ),
'key' => array( 0 => 'basket.name' ),
'op' => array( 0 => '=~' ),
'val' => array( 0 => 'unittest' ),
),
'sort' => array( 'order.basket.ctime' ),
'sort' => array( 'basket.ctime' ),
);
$helper = new \Aimeos\Base\View\Helper\Param\Standard( $this->view, $param );
$this->view->addHelper( 'param', $helper );
Expand Down Expand Up @@ -180,9 +180,8 @@ protected function getViewNoRender( $real = true )

protected function getBasketId( $name = 'unittest name' )
{
$manager = \Aimeos\MShop::create( $this->context, 'order/basket' );
$search = $manager->filter()->slice( 0, 1 );
$search->setConditions( $search->compare( '==', 'order.basket.name', $name ) );
$manager = \Aimeos\MShop::create( $this->context, 'basket' );
$search = $manager->filter()->add( 'basket.name', '==', $name )->slice( 0, 1 );

return $manager->search( $search )
->first( new \Exception( sprintf( 'No basket item found for name "%1$s"', $name ) ) )
Expand Down

0 comments on commit 1785060

Please sign in to comment.