Merge branch 'master' of github.com:Mailtrain-org/mailtrain into access

Conflicts:
	package.json
This commit is contained in:
Tomas Bures 2017-06-17 10:11:07 +02:00
commit f776170854
16 changed files with 395 additions and 172 deletions

View file

@ -311,7 +311,7 @@ function addCustomField(listId, name, defaultValue, type, group, groupTemplate,
}
if (module.exports.grouped.indexOf(type) < 0) {
column = ('custom_' + slugify(name, '_') + '_' + shortid.generate()).toLowerCase().replace(/[^a-z0-9\_]/g, '');
column = ('custom_' + slugify(name, '_') + '_' + shortid.generate()).toLowerCase().replace(/[^a-z0-9_]/g, '');
}
let query = 'INSERT INTO custom_fields (`list`, `name`, `key`,`default_value`, `type`, `group`, `group_template`, `column`, `visible`) VALUES(?,?,?,?,?,?,?,?,?)';
@ -398,6 +398,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
// ignore missing values
return;
}
/* eslint-disable indent */
switch (field.type) {
case 'text':
case 'website':
@ -413,7 +414,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
visible: !!field.visible,
mergeTag: field.key,
mergeValue: (valueList[field.column] || '').toString().trim() || field.defaultValue,
['type' + (field.type || '').toString().trim().replace(/(?:^|\-)([a-z])/g, (m, c) => c.toUpperCase())]: true
['type' + (field.type || '').toString().trim().replace(/(?:^|-)([a-z])/g, (m, c) => c.toUpperCase())]: true
};
row.push(item);
break;
@ -443,7 +444,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
visible: !!field.visible,
mergeTag: field.key,
mergeValue: value || field.defaultValue,
['type' + (field.type || '').toString().trim().replace(/(?:^|\-)([a-z])/g, (m, c) => c.toUpperCase())]: true
['type' + (field.type || '').toString().trim().replace(/(?:^|-)([a-z])/g, (m, c) => c.toUpperCase())]: true
};
row.push(item);
break;
@ -459,7 +460,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
visible: !!field.visible,
mergeTag: field.key,
mergeValue: (Number(valueList[field.column]) || Number(field.defaultValue) || 0).toString(),
['type' + (field.type || '').toString().trim().replace(/(?:^|\-)([a-z])/g, (m, c) => c.toUpperCase())]: true
['type' + (field.type || '').toString().trim().replace(/(?:^|-)([a-z])/g, (m, c) => c.toUpperCase())]: true
};
row.push(item);
break;
@ -476,7 +477,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
key: 'group-g' + field.id,
mergeTag: field.key,
mergeValue: field.defaultValue,
['type' + (field.type || '').toString().trim().replace(/(?:^|\-)([a-z])/g, (m, c) => c.toUpperCase())]: true,
['type' + (field.type || '').toString().trim().replace(/(?:^|-)([a-z])/g, (m, c) => c.toUpperCase())]: true,
groupTemplate: field.groupTemplate,
options: (field.options || []).map(subField => {
if (onlyExisting && subField.column && !valueList.hasOwnProperty(subField.column)) {
@ -507,7 +508,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
case 'date-us':
case 'birthday-us':
{
let isUs = /\-us$/.test(field.type);
let isUs = /-us$/.test(field.type);
let isYear = field.type.indexOf('date-') === 0;
let value = valueList[field.column];
let day, month, year;
@ -568,12 +569,13 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
visible: !!field.visible,
mergeTag: field.key,
mergeValue: (useDate ? value : formatted) || field.defaultValue,
['type' + (field.type || '').toString().trim().replace(/(?:^|\-)([a-z])/g, (m, c) => c.toUpperCase())]: true
['type' + (field.type || '').toString().trim().replace(/(?:^|-)([a-z])/g, (m, c) => c.toUpperCase())]: true
};
row.push(item);
break;
}
}
/* eslint-enable indent */
});
return row;

View file

@ -414,7 +414,7 @@ module.exports.update = (listId, cid, updates, allowEmail, callback) => {
}
});
fields.getValues(fields.getRow(fieldList, updates, true, true), true).forEach(field => {
fields.getValues(fields.getRow(fieldList, updates, true, true, true), true).forEach(field => {
keys.push(field.key);
values.push(field.value);
});
@ -495,7 +495,7 @@ module.exports.changeStatus = (listId, id, campaignId, status, callback) => {
}
// status change is not related to a campaign or it marks message as bounced etc.
if (!campaignId || status !== Status.SUBSCRIBED) {
if (!campaignId || status !== Status.SUBSCRIBED && status !== Status.UNSUBSCRIBED) {
return connection.commit(err => {
if (err) {
return helpers.rollbackAndReleaseConnection(connection, () => callback(err));