Notes
![]() ![]() Notes - notes.io |
addMCOptions = (options, requestJson = {}, isInitialize = false) => {
let filteredSource = [],
filteredDestination = [];
// requestJson = {};
this.sourceMCRules.map(source => {
if (find(options, source) !== undefined) {
filteredDestination.push(source);
} else {
filteredSource.push(source);
}
});
this.createSubscriptionForm.destinationMCRules.value.map(destination => {
filteredDestination.push(destination);
});
// this.hasChanges = true;
this.sourceMCRules = filteredSource;
let tempRequestJson = {};
// case 1: onchange - create: isInitialize: false
// case 2: onchange - edit : isInitialize: false
// caase 3 inilizize - edit : isInitialize: true,
// cas3 4: save subscription - read
if (!isInitialize) {
// onchange
if (this.subscriptionViewType === 'create')
tempRequestJson = {
category: 'MARKETING_CONTEXT',
enabled: true,
feedType: 'PD', // as we support only PD feedType
condition: `group.key IN (${filteredDestination
.map(item => `'${item.geoId}|${item.languageId}|${item.segmentId}||${item.channelId}|${item.formatId}'`)
.join(',')})`,
sortOrder: 0,
// version: this.partnerInformation.version,
partner: {
id: this.partnerId
}
};
else if (this.subscriptionViewType === 'edit') {
tempRequestJson = {
...this.createSubscriptionForm.destinationMCRules.requestJson,
condition: `group.key IN (${filteredDestination
.map(item => `'${item.geoId}|${item.languageId}|${item.segmentId}||${item.channelId}|${item.formatId}'`)
.join(',')})`
};
// to handle existing paartners with targetAttributeMapping as null/empty and Include all parts is true
// in Edit, pulling all the available attributes in CSC UI
// if there is edit in Marketing context, passing this to backend for backend compatibility
const attributesForInclusion = this.createSubscriptionForm.attributesForInclusion?.value;
const targetAttributesMapping = this.partnerInformation?.targetAttributesMapping?.PD || {};
const isEquivalent = this.compareAttributeAndTargetAttribute(attributesForInclusion, targetAttributesMapping);
if (this.createSubscriptionForm?.allParts?.value === true && !isEquivalent) {
// updating there is a edit in Attributes for inclusion
this.editSubscriptionForm = {
...this.editSubscriptionForm,
attributesForInclusion: ''
};
}
this.editSubscriptionForm = {
...this.editSubscriptionForm,
destinationMCRules: ''
};
}
} else {
tempRequestJson = requestJson;
}
this.createSubscriptionForm.destinationMCRules = {
value: filteredDestination,
requestJson: tempRequestJson
};
if (!isInitialize) this.subscriptionHasEdits = true;
};
removeMCOptions = options => {
let filteredSource = [],
filteredDestination = [],
requestJson = {};
this.createSubscriptionForm.destinationMCRules.value.forEach(source => {
if (find(options, source) !== undefined) {
filteredSource.push(source);
} else {
filteredDestination.push(source);
}
});
this.sourceMCRules.forEach(source => {
filteredSource.push(source);
});
// this.hasChanges = true;
this.sourceMCRules = filteredSource;
// case 1: onchange - create: isInitialize: false
// case 2: onchange - edit : isInitialize: false
// caase 3 inilizize - edit : isInitialize: true not possible
if (this.subscriptionViewType === 'create')
requestJson = {
category: 'MARKETING_CONTEXT',
enabled: true,
feedType: 'PD', // as we support only PD feedType
condition: `group.key IN (${filteredDestination
.map(item => `'${item.geoId}|${item.languageId}|${item.segmentId}||${item.channelId}|${item.formatId}'`)
.join(',')})`,
sortOrder: 0,
partner: {
id: this.partnerId
}
};
else if (this.subscriptionViewType === 'edit') {
requestJson = {
...this.createSubscriptionForm.destinationMCRules.requestJson,
condition: `group.key IN (${filteredDestination
.map(item => `'${item.geoId}|${item.languageId}|${item.segmentId}||${item.channelId}|${item.formatId}'`)
.join(',')})`
};
// to handle existing paartners with targetAttributeMapping as null/empty and Include all parts is true
// in Edit, pulling all the available attributes in CSC UI
// if there is edit in Marketing context, passing this to backend for backend compatibility
const attributesForInclusion = this.createSubscriptionForm.attributesForInclusion?.value;
const targetAttributesMapping = this.partnerInformation?.targetAttributesMapping?.PD || [];
const isEquivalent = this.compareAttributeAndTargetAttribute(attributesForInclusion, targetAttributesMapping);
if (this.createSubscriptionForm?.allParts?.value === true && !isEquivalent) {
// updating there is a edit in Attributes for inclusion
this.editSubscriptionForm = {
...this.editSubscriptionForm,
attributesForInclusion: ''
};
}
this.editSubscriptionForm = {
...this.editSubscriptionForm,
destinationMCRules: ''
};
}
this.createSubscriptionForm.destinationMCRules = {
value: filteredDestination,
requestJson
};
this.subscriptionHasEdits = true;
};
condition: `group.key IN (${filteredDestination
.map(item => `'${item.geoId}|${item.languageId}|${item.segmentId}||${item.channelId}|${item.formatId}'`)
.join(',')})`
looks like we have the same condition statement in 4 places in this file. Can you create a common function it?
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team