}
},
lastName: DataTypes.STRING,
- tags: DataTypes.STRING,
+ tags: {
+ type: DataTypes.STRING,
+ get: function() {
+ var tags;
+ if (this.getDataValue('tags')) {
+ tags = this.getDataValue('tags').split(';');
+ if (tags.length > 1) {
+ tags.pop();
+ } else {
+ tags = []; //if the length is 1 the value is still in the format of the old tags, with comma separator. So I return an empty array since the old format is obsolete and invalid
+ }
+ } else {
+ tags = [];
+ }
+ return tags;
+ },
+ set: function(val) {
+ this.setDataValue('tags', val && val.length ? val.join(';') + ';' : null);
+ }
+ },
street: DataTypes.STRING,
postalCode: DataTypes.STRING,
city: DataTypes.STRING,
country: DataTypes.STRING,
dateOfBirth: DataTypes.STRING,
- description: DataTypes.STRING,
+ description: DataTypes.TEXT,
phone: DataTypes.STRING,
mobile: DataTypes.STRING,
fax: DataTypes.STRING,
email: DataTypes.STRING,
+ url: DataTypes.STRING,
+ planningtime: DataTypes.DATE
}, {
tableName: 'cm_contacts',
associate: function(models) {
Contact.addScope('list', {
include: [models.List]
});
+ Contact.addScope('company', {
+ include: [models.Company]
+ });
Contact.addScope('user', {
include: [models.User]
});
+ Contact.addScope('company_list_filter', function(query) {
+ var scope = {
+ where: {}
+ };
+ if (query.CompanyId) {
+ scope.where.CompanyId = query.CompanyId;
+ }
+ if (query.ListId) {
+ scope.where.ListId = query.ListId;
+ }
+ return scope;
+ });
}
});