8000 Newsletter Segment Logic - choose between or & and by VaniW · Pull Request #91 · pimcore/customer-data-framework · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Newsletter Segment Logic - choose between or & and #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/Newsletter/AddressSource/SegmentAddressSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,20 @@ class SegmentAddressSource implements AddressSourceAdapterInterface
/* @var SendingParamContainer[] */
private $sendingParamContainers = [];

private $operator = SegmentManagerInterface::CONDITION_OR;


/**
* @param array $arguments ['segmentIds' => string[]]
* @param array $arguments ['segmentIds' => string[], 'operator' => string]
*/
public function __construct(array $arguments)
{
$operator = $arguments['operator'];
if ($operator == "and") {
$this->operator = SegmentManagerInterface::CONDITION_AND;
} else {
$this->operator = SegmentManagerInterface::CONDITION_OR;
}
$this->segmentManager = \Pimcore::getContainer()->get(SegmentManagerInterface::class);
$this->sendingParamContainers = $this->setUpSendingParamContainers(array_filter($arguments['segmentIds']));
}
Expand Down Expand Up @@ -92,7 +101,7 @@ function ($customer) {

return new SendingParamContainer($customer->getEmail(), ['emailAddress' => $customer->getEmail()]);
},
$this->segmentManager->getCustomersBySegmentIds($segmentIds)->getObjects() ?? []
$this->segmentManager->getCustomersBySegmentIds($segmentIds, $this->operator)->getObjects() ?? []
)
);
}
Expand Down
32 changes: 30 additions & 2 deletions src/Resources/public/js/SegmentAddressSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ pimcore.document.newsletters.addressSourceAdapters.SegmentAddressSource = Class.
getValues: function () {
console.log();
return {
segmentIds: this.segmentStore.getData().items.map(item => item.id)
segmentIds: this.segmentStore.getData().items.map(item => item.id),
operator: this.operatorsBox.getValue()
};
},

Expand All @@ -23,6 +24,14 @@ pimcore.document.newsletters.addressSourceAdapters.SegmentAddressSource = Class.
fields: ['id', 'name']
});

this.operatorsStore = new Ext.data.Store({
fields: ['name'],
data : [
{'name': t('cmf_newsletter_or'), 'val' : 'or'},
{'name': t('cmf_newsletter_and'), 'val' : 'and'}
]
});

var segmentGrid = Ext.create('Ext.grid.Panel', {
minHeight: 90,
border: true,
Expand Down Expand Up @@ -111,7 +120,26 @@ pimcore.document.newsletters.addressSourceAdapters.SegmentAddressSource = Class.
});
}.bind(this));

return segmentGrid;
this.operatorsBox = Ext.create('Ext.form.ComboBox', {
fieldLabel: t('cmf_newsletter_operators'),
store: this.operatorsStore,
queryMode: 'local',
displayField: 'name',
valueField: 'val',
width: 400,
style: "padding-top:30px",
value: this.operatorsStore.first(),
});

var form = Ext.create('Ext.form.Panel', {
height: 200,
items: [
segmentGrid,
this.operatorsBox
]
});

return form;
},

isFromTree: function (ddSource) {
Expand Down
5 changes: 4 additions & 1 deletion src/Resources/translations/admin.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,7 @@ cmf_segment_import_customers: "Kunden CSV-Liste importieren"
cmf_replace_segments: "Segmente ersetzen"
cmf_operator_customer_segments: "Operator Kundensegmente"
newsletter_SegmentAddressSource: "CMF: Kundensegmente"
cmf_newsletter_selectedSegments: "Gewählte Segmente"
cmf_newsletter_selectedSegments: "Gewählte Segmente"
cmf_newsletter_operators: "Operator"
cmf_newsletter_or: "Oder"
cmf_newsletter_and: "Und"
5 changes: 4 additions & 1 deletion src/Resources/translations/admin.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,7 @@ cmf_segment_import_customers: "Import customer CSV list"
cmf_replace_segments: "replace segments"
cmf_operator_customer_segments: "Operator Customer Segments"
newsletter_SegmentAddressSource: "CMF: Customer Segments"
cmf_newsletter_selectedSegments: "Selected Segments"
cmf_newsletter_selectedSegments: "Selected Segments"
cmf_newsletter_operators: "Operator"
cmf_newsletter_or: "Or"
cmf_newsletter_and: "And"
0