Commit 7eb73286 authored by Roman's avatar Roman

BRCD-1678 feat(Play) - add play name to subscriber fields

parent 0e611ace
......@@ -511,6 +511,18 @@ export const setFieldTitle = (field, entity, keyProperty = 'field_name') => {
return field.set('title', getFieldName(key, entityName, defaultLable));
};
export const addPlayToFieldTitle = (field, plays) => {
const fieldPlays = field.get('plays', Immutable.List());
if (!fieldPlays.isEmpty()) {
const fieldPlayLabels = fieldPlays.reduce(
(result, playName) => result.push(plays.get(playName, '')),
Immutable.List(),
).join(', ');
return field.set('title', `${field.get('title', '')} (${fieldPlayLabels})`);
}
return field;
};
export const toImmutableList = (value) => {
if ([undefined, null].includes(value)) {
return Immutable.List();
......
......@@ -54,8 +54,8 @@ import {
usageTypeSelector,
usageTypesDataSelector,
propertyTypeSelector,
subscriberFieldsSelector,
productFieldsSelector,
subscriberFieldsWithPlaySelector,
} from '../../selectors/settingsSelector';
class InputProcessor extends Component {
......@@ -589,7 +589,7 @@ const mapStateToProps = (state, props) => {
usageTypes: usageTypeSelector(state, props),
propertyTypes: propertyTypeSelector(state, props),
usageTypesData: usageTypesDataSelector(state, props),
subscriberFields: subscriberFieldsSelector(state, props),
subscriberFields: subscriberFieldsWithPlaySelector(state, props),
customRatingFields: productFieldsSelector(state, props),
fileType,
action,
......
......@@ -6,6 +6,7 @@ import {
getFieldNameType,
isLinkerField,
setFieldTitle,
addPlayToFieldTitle,
} from '../common/Util';
const getTaxation = (state, props) => // eslint-disable-line no-unused-vars
......@@ -371,6 +372,14 @@ export const accountImportFieldsSelector = createSelector(
selectAccountImportFields,
);
export const availablePlaysLabelsSelector = createSelector(
availablePlaysSettingsSelector,
(plays = Immutable.List()) => plays.reduce(
(labels, item) => labels.set(item.get('name'), item.get('label')),
Immutable.Map(),
),
);
export const subscriberFieldsSelector = createSelector(
getSubscriberFields,
(fields) => {
......@@ -385,6 +394,13 @@ export const subscriberFieldsSelector = createSelector(
},
);
export const subscriberFieldsWithPlaySelector = createSelector(
subscriberFieldsSelector,
availablePlaysLabelsSelector,
(fields = Immutable.List(), plays = Immutable.Map()) =>
fields.map(field => addPlayToFieldTitle(field, plays)),
);
export const linesFieldsSelector = createSelector(
getLinesFields,
(fields) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment