forked from shopware/shopware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next-18082/create-action-to-set-afiliate-and-campaign-c…
…ode-of-customer-and-order' into 'trunk' NEXT-18082 - Create action to set an affiliate and campaign code to customer and order See merge request shopware/6/product/platform!6927
- Loading branch information
Showing
20 changed files
with
1,071 additions
and
9 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
changelog/_unreleased/2021-11-23-add-affiliate-and-campaign-code-action.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: Add an affiliate and campaign code action | ||
issue: NEXT-18082 | ||
flag: FEATURE_NEXT_17973 | ||
--- | ||
# Core | ||
* Added `Shopware/Core/Content/Flow/Dispatching/Action/AddCustomerAffiliateAndCampaignCodeAction` class to handle add affiliate and campaign code to Customer action. | ||
* Added `Shopware/Core/Content/Flow/Dispatching/Action/AddOrderAffiliateAndCampaignCodeAction` class to handle add affiliate and campaign code to Order action. | ||
___ | ||
# Administration | ||
* Added component `sw-flow-affiliate-and-campaign-code-modal` to show a modal that allows adding affiliate and campaign code for customer/order. | ||
* Added `getAffiliateAndCampaignCodeDescription` function at `src/module/sw-flow/component/sw-flow-sequence-action/index.js` to get affiliate and campaign code description. | ||
* Added `ADD_CUSTOMER_AFFILIATE_AND_CAMPAIGN_CODE` and `ADD_ORDER_AFFILIATE_AND_CAMPAIGN_CODE` into action list at `src/module/sw-flow/constant/flow.constant.js`. | ||
* Added adding affiliate and campaign code action icon and title at `src/module/sw-flow/service/flow-builder.service.js`. | ||
* Added `convertEntityName` function at `src/module/sw-flow/service/flow-builder.service.js`. | ||
* Deprecated `convertEntityName` function at `src/module/sw-flow/component/modals/sw-flow-tag-modal/index.js` and `src/module/sw-flow/component/modals/sw-flow-set-entity-custom-field-modal/index.js`. | ||
* Added watcher `entity` at `src/module/sw-flow/component/modals/sw-flow-set-entity-custom-field-modal/index.js`. |
123 changes: 123 additions & 0 deletions
123
...on/src/module/sw-flow/component/modals/sw-flow-affiliate-and-campaign-code-modal/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import template from './sw-flow-affiliate-and-campaign-code-modal.html.twig'; | ||
|
||
const { Component, Mixin, Service } = Shopware; | ||
const { ShopwareError } = Shopware.Classes; | ||
const { mapState } = Component.getComponentHelper(); | ||
|
||
Component.register('sw-flow-affiliate-and-campaign-code-modal', { | ||
template, | ||
|
||
mixins: [ | ||
Mixin.getByName('placeholder'), | ||
Mixin.getByName('notification'), | ||
], | ||
|
||
props: { | ||
sequence: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}, | ||
|
||
data() { | ||
return { | ||
entityError: null, | ||
entity: null, | ||
affiliateCode: { | ||
value: null, | ||
upsert: false, | ||
}, | ||
campaignCode: { | ||
value: null, | ||
upsert: false, | ||
}, | ||
}; | ||
}, | ||
|
||
computed: { | ||
entityOptions() { | ||
const options = []; | ||
if (!this.triggerEvent) { | ||
return []; | ||
} | ||
|
||
Object.entries(this.triggerEvent.data).forEach(([key, value]) => { | ||
if (value.type !== 'entity') { | ||
return; | ||
} | ||
|
||
options.push({ | ||
label: Service('flowBuilderService').convertEntityName(key), | ||
value: key, | ||
}); | ||
}); | ||
|
||
return options; | ||
}, | ||
|
||
...mapState('swFlowState', ['triggerEvent']), | ||
}, | ||
|
||
watch: { | ||
entity(value) { | ||
if (value && this.entityError) { | ||
this.entityError = null; | ||
} | ||
}, | ||
}, | ||
|
||
created() { | ||
this.createdComponent(); | ||
}, | ||
|
||
methods: { | ||
createdComponent() { | ||
if (this.entityOptions.length) { | ||
this.entity = this.entityOptions[0].value; | ||
} | ||
|
||
if (!this.sequence.config) { | ||
return; | ||
} | ||
|
||
this.entity = this.sequence.config.entity; | ||
this.affiliateCode = { ...this.sequence.config.affiliateCode }; | ||
this.campaignCode = { ...this.sequence.config.campaignCode }; | ||
}, | ||
|
||
fieldError(field) { | ||
if (!field || !field.length) { | ||
return new ShopwareError({ | ||
code: 'c1051bb4-d103-4f74-8988-acbcafc7fdc3', | ||
}); | ||
} | ||
|
||
return null; | ||
}, | ||
|
||
onSave() { | ||
this.entityError = this.fieldError(this.entity); | ||
if (this.entityError) { | ||
return; | ||
} | ||
|
||
const config = { | ||
entity: this.entity, | ||
affiliateCode: this.affiliateCode, | ||
campaignCode: this.campaignCode, | ||
}; | ||
|
||
const sequence = { | ||
...this.sequence, | ||
config, | ||
}; | ||
|
||
this.$emit('process-finish', sequence); | ||
this.onClose(); | ||
}, | ||
|
||
onClose() { | ||
this.$emit('modal-close'); | ||
}, | ||
}, | ||
}); |
91 changes: 91 additions & 0 deletions
91
...low-affiliate-and-campaign-code-modal/sw-flow-affiliate-and-campaign-code-modal.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{% block sw_flow_affiliate_and_campaign_code_modal %} | ||
<sw-modal | ||
class="sw-flow-affiliate-and-campaign-code-modal" | ||
:title="$tc('sw-flow.modals.affiliateAndCampaignCode.title')" | ||
@modal-close="onClose" | ||
> | ||
{% block sw_flow_affiliate_and_campaign_code_modal_content %} | ||
<div class="sw-flow-affiliate-and-campaign-code-modal__content"> | ||
{% block sw_flow_affiliate_and_campaign_code_modal_entity %} | ||
<sw-single-select | ||
v-model="entity" | ||
class="sw-flow-affiliate-and-campaign-code-modal__entity" | ||
required | ||
show-clearable-button | ||
:label="$tc('sw-flow.modals.affiliateAndCampaignCode.labelEntity')" | ||
:placeholder="$tc('sw-flow.modals.affiliateAndCampaignCode.placeholderEntity')" | ||
:error="entityError" | ||
:options="entityOptions" | ||
/> | ||
{% endblock %} | ||
|
||
<sw-container | ||
columns="4fr 1fr" | ||
gap="30px" | ||
> | ||
{% block sw_flow_affiliate_and_campaign_code_modal_affiliate_code %} | ||
<sw-text-field | ||
v-model="affiliateCode.value" | ||
class="sw-flow-affiliate-and-campaign-code-modal__affiliate-code" | ||
:label="$tc('sw-flow.modals.affiliateAndCampaignCode.labelAffiliateCode')" | ||
:placeholder="$tc('sw-flow.modals.affiliateAndCampaignCode.placeholderAffiliateCode')" | ||
/> | ||
{% endblock %} | ||
|
||
{% block sw_flow_affiliate_and_campaign_code_modal_affiliate_code_overwrite %} | ||
<sw-switch-field | ||
v-model="affiliateCode.upsert" | ||
class="sw-flow-affiliate-and-campaign-code-modal__affiliate-code-overwrite" | ||
:label="$tc('sw-flow.modals.affiliateAndCampaignCode.overwrite')" | ||
/> | ||
{% endblock %} | ||
</sw-container> | ||
|
||
<sw-container | ||
columns="4fr 1fr" | ||
gap="30px" | ||
> | ||
{% block sw_flow_affiliate_and_campaign_code_modal_campaign_code %} | ||
<sw-text-field | ||
v-model="campaignCode.value" | ||
class="sw-flow-affiliate-and-campaign-code-modal__campaign-code" | ||
:label="$tc('sw-flow.modals.affiliateAndCampaignCode.labelCampaignCode')" | ||
:placeholder="$tc('sw-flow.modals.affiliateAndCampaignCode.placeholderCampaignCode')" | ||
/> | ||
{% endblock %} | ||
|
||
{% block sw_flow_affiliate_and_campaign_code_modal_campaign_code_overwrite %} | ||
<sw-switch-field | ||
v-model="campaignCode.upsert" | ||
class="sw-flow-affiliate-and-campaign-code-modal__campaign-code-overwrite" | ||
:label="$tc('sw-flow.modals.affiliateAndCampaignCode.overwrite')" | ||
/> | ||
{% endblock %} | ||
</sw-container> | ||
</div> | ||
{% endblock %} | ||
|
||
<template #modal-footer> | ||
{% block sw_flow_affiliate_and_campaign_code_modal_footer_cancel_button %} | ||
<sw-button | ||
class="sw-flow-affiliate-and-campaign-code-modal__cancel-button" | ||
size="small" | ||
@click="onClose" | ||
> | ||
{{ $tc('global.default.cancel') }} | ||
</sw-button> | ||
{% endblock %} | ||
|
||
{% block sw_flow_affiliate_and_campaign_code_modal_footer_save_button %} | ||
<sw-button | ||
class="sw-flow-affiliate-and-campaign-code-modal__save-button" | ||
variant="primary" | ||
size="small" | ||
@click="onSave" | ||
> | ||
{{ sequence.id ? $tc('sw-flow.modals.buttonSaveAction') : $tc('sw-flow.modals.buttonAddAction') }} | ||
</sw-button> | ||
{% endblock %} | ||
</template> | ||
</sw-modal> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.