Skip to content

Commit d9fc4e8

Browse files
committed
RATESWSX-332: refactor admin order component to be compatible with sw6.7
1 parent 0f70499 commit d9fc4e8

File tree

6 files changed

+57
-44
lines changed

6 files changed

+57
-44
lines changed

src/Resources/app/administration/src/component/ratepay/ratepay-admin-create-order-form/index.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ Component.register('ratepay-admin-create-order-form', {
2525
data() {
2626
return {
2727
loading: false,
28-
salesChannels: null,
28+
salesChannels: [],
29+
salesChannelDomains: [],
2930

3031
selectedSalesChannelId: null,
3132
selectedSalesChannelDomainId: null,
@@ -39,26 +40,26 @@ Component.register('ratepay-admin-create-order-form', {
3940
this.salesChannelRepository = this.repositoryFactory.create('sales_channel');
4041
this.salesChannelDomainRepository = this.repositoryFactory.create('sales_channel_domain');
4142

42-
let criteria = new Criteria();
43+
const criteria = new Criteria();
4344
criteria.addFilter(Criteria.not('AND', [Criteria.equals('domains.url', null)]));
4445
criteria.addFilter(Criteria.equals('active', true));
45-
criteria.addAssociation('domains');
46+
criteria.addAssociation('domains'); // optional, can prefill domains
4647

4748
this.loading = true;
48-
this.salesChannelRepository
49-
.search(criteria, Shopware.Context.api)
50-
.then((result) => {
51-
this.salesChannels = result.filter((item) => {
52-
return item.domains.length > 0;
53-
});
54-
this.loading = false;
55-
});
49+
this.salesChannelRepository.search(criteria, Shopware.Context.api).then((result) => {
50+
this.salesChannels = result.filter(item => item.domains.length > 0);
51+
this.loading = false;
52+
});
5653
},
5754

5855
computed: {
59-
salesChannelDomains() {
60-
return this.selectedSalesChannelId ? this.salesChannels.get(this.selectedSalesChannelId)?.domains ?? [] : [];
61-
},
56+
domainCriteria() {
57+
const criteria = new Criteria();
58+
if (this.selectedSalesChannelId) {
59+
criteria.addFilter(Criteria.equals('salesChannelId', this.selectedSalesChannelId));
60+
}
61+
return criteria;
62+
}
6263
},
6364

6465
methods: {

src/Resources/app/administration/src/component/ratepay/ratepay-admin-create-order-form/ratepay-admin-create-order-form.twig

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
11
{#
2-
~ Copyright (c) Ratepay GmbH
3-
~
4-
~ For the full copyright and license information, please view the LICENSE
5-
~ file that was distributed with this source code.
2+
~ Copyright (c) 2020 Ratepay GmbH
3+
~
4+
~ For the full copyright and license information, please view the LICENSE
5+
~ file that was distributed with this source code.
66
#}
7-
<div>
8-
<sw-select-field v-model:value="selectedSalesChannelId"
9-
:label="$tc('ratepay.admin.create-order.modal.labels.salesChannel')"
10-
@update:value="selectedSalesChannelDomainId = null">
11-
<option>{{ $t('ratepay.admin.create-order.modal.please-select') }}</option>
12-
<option v-for="salesChannel in salesChannels"
13-
:value="salesChannel.id"
14-
:selected="salesChannel === selectedSalesChannelId">
15-
{{ salesChannel.translated.name }}
16-
</option>
17-
</sw-select-field>
187

8+
<div>
9+
<sw-entity-single-select
10+
v-model:value="selectedSalesChannelId"
11+
class="sw-cms-layout-assignment-modal__sales-channel-select"
12+
entity="sales_channel"
13+
:label="$tc('ratepay.admin.create-order.modal.labels.salesChannel')"
14+
@update:value="selectedSalesChannelDomainId = null"
15+
/>
1916

20-
<sw-select-field v-model:value="selectedSalesChannelDomainId"
21-
:label="$tc('ratepay.admin.create-order.modal.labels.salesChannelDomain')"
22-
v-if="salesChannelDomains.length">
23-
<option>{{ $t('ratepay.admin.create-order.modal.please-select') }}</option>
24-
<option v-for="salesChannelDomain in salesChannelDomains"
25-
:value="salesChannelDomain.id"
26-
:selected="salesChannelDomain.id === selectedSalesChannelDomainId">
27-
{{ salesChannelDomain.url }}
28-
</option>
29-
</sw-select-field>
17+
<sw-entity-single-select
18+
v-model:value="selectedSalesChannelDomainId"
19+
class="sw-cms-layout-assignment-modal__sales-channel-domain-select"
20+
entity="sales_channel_domain"
21+
:label="$tc('ratepay.admin.create-order.modal.labels.salesChannelDomain')"
22+
label-property="url"
23+
:criteria="domainCriteria"
24+
:disabled="!selectedSalesChannelId"
25+
/>
3026

3127
<sw-button @click="navigateToFrontend" class="sw-button--primary" v-if="selectedSalesChannelDomainId">
3228
{{ $t('ratepay.admin.create-order.modal.start-session') }}

src/Resources/app/administration/src/module/sw-order/page/sw-order-list/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ const {Component} = Shopware;
55
Component.override('sw-order-list', {
66
template,
77

8+
inject: ['repositoryFactory'],
9+
810
data() {
911
return {
1012
ratepayCreateOrderModal: false,
1113
salesChannels: null
1214
};
1315
},
1416

17+
1518
methods: {
1619
openRatepayCreateOrderModal() {
1720
this.ratepayCreateOrderModal = true

src/Resources/app/administration/src/module/sw-order/page/sw-order-list/sw-order-list.html.twig

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
~ For the full copyright and license information, please view the LICENSE
55
~ file that was distributed with this source code.
66
#}
7+
78
{% block sw_order_list_smart_bar_actions_add %}
89
{% parent %}
910

@@ -15,11 +16,14 @@
1516
{% endblock %}
1617

1718
{% block sw_order_list_content_slot %}
18-
{% parent %}
19+
{% parent %}
1920
<sw-modal :title="$tc('order.ratepay.create-order.newButtonText')"
2021
v-if="ratepayCreateOrderModal"
21-
@modal-close="ratepayCreateOrderModal = null">
22-
<ratepay-admin-create-order-form></ratepay-admin-create-order-form>
22+
@modal-close="ratepayCreateOrderModal = false"> <!-- ⚠️ geändert -->
23+
<ratepay-admin-create-order-form
24+
:sales-channels="salesChannels"
25+
@close="ratepayCreateOrderModal = false"> <!-- ⚠️ neu -->
26+
</ratepay-admin-create-order-form>
2327
</sw-modal>
2428
{% endblock %}
2529

@@ -33,8 +37,8 @@
3337
{% endblock %}
3438

3539
{% block sw_order_list_delete_modal_confirm %}
36-
<sw-button @click="onConfirmDelete(item.id)" :disabled="item.extensions.ratepayData !== undefined" variant="danger" size="small">
40+
<mt-button @click="onConfirmDelete(item.id)" :disabled="item.extensions.ratepayData !== undefined" variant="danger" size="small">
3741
{{ $tc('sw-order.list.buttonDelete') }}
38-
</sw-button>
42+
</mt-button>
3943
{% endblock %}
4044

src/Resources/public/administration/assets/rpay-payments-Bh0AbCMf.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Resources/public/administration/assets/rpay-payments-Bh0AbCMf.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)