Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
beforeRender($event: BeforeRenderEventHandler): void {
const email = $event.instructions['email'];
if (email) {
// CHANGING RENDERING TYPE ON THE FLY
email.type = 'slideToggle';
}
const addressState = $event.instructions['address.state'];
if (addressState) {
// ASYNC CALLS THAT BLOCK THE WHOLE FORM FROM RENDERING, GOOD FOR GETTING DATA FROM REMOTE SERVER.
// E.G.: GETTING GROUPS LISTED UNDER A USER, ETC...
const p = new Promise( r => setTimeout(r, 1000 ))
.then( () => {
addressState.mergeData({
options: STATES
});
});
// mark this field as async, no render until promise completes.
$event.async(p);
}
}
/* @tdm-ignore:* */
validate: function (attrs) {
var errors = [];
Validation.checkGroupsNameField(errors, true, attrs.name, 'Subject');
Validation.checkGroupsNameField(errors, true, attrs.source, 'Source');
// Validation.checkGroupsNameField(errors, false, attrs.company.name, 'Company'); // commented in hotFix By Liliya
Validation.checkPhoneField(errors, false, attrs['phones.phone'] || attrs.phones.phone, 'Phone');
Validation.checkPhoneField(errors, false, attrs['phones.mobile'] || attrs.phones.mobile, 'Mobile');
Validation.checkCountryCityStateField(errors, false, attrs['address.country'] || attrs.address.country, 'Country');
Validation.checkCountryCityStateField(errors, false, attrs['address.state'] || attrs.address.state, 'State');
Validation.checkCountryCityStateField(errors, false, attrs['address.city'] || attrs.address.city, 'City');
Validation.checkZipField(errors, false, attrs['address.zip'] || attrs.address.zip, 'Zip');
Validation.checkStreetField(errors, false, attrs['address.street'] || attrs.address.street, 'Street');
Validation.checkEmailField(errors, false, attrs.email, 'Email');
Validation.checkNotesField(errors, false, attrs.internalNotes, 'Notes');
Validation.checkFacebookSocial(errors, false, attrs.social.FB, 'Facebook');
Validation.checkLinkedinSocial(errors, false, attrs.social.LI, 'LinkedIn');
/* if (!attrs.tempCompanyField) {
errors.push('Check company please. ');
}
if (!attrs.customer) {
errors.push('Check person please. ');
}*/
it('should return all values for all graphs', function (done) {
var mock = mockObject();
var leetMock = leet(mock);
var actual = leetMock.extract('firstName', 'address.state', 'phoneNumber.1.type');
assert.equal(Object.keys(actual).length, 3);
assert.property(actual, 'firstName');
assert.property(actual, 'address.state');
assert.property(actual, 'phoneNumber.1.type');
assert.equal(actual['firstName'], 'John');
assert.equal(actual['address.state'], 'NY');
assert.equal(actual['phoneNumber.1.type'], 'fax');
var args = ['firstName', 'address.state', 'phoneNumber.1.type'];
actual = leetMock.extract(args);
assert.equal(Object.keys(actual).length, 3);
assert.property(actual, 'firstName');
assert.property(actual, 'address.state');
assert.property(actual, 'phoneNumber.1.type');
assert.equal(actual['firstName'], 'John');
assert.equal(actual['address.state'], 'NY');
assert.equal(actual['phoneNumber.1.type'], 'fax');
done();
});
assert.equal(Object.keys(actual).length, 3);
assert.property(actual, 'firstName');
assert.property(actual, 'address.state');
assert.property(actual, 'phoneNumber.1.type');
assert.equal(actual['firstName'], 'John');
assert.equal(actual['address.state'], 'NY');
assert.equal(actual['phoneNumber.1.type'], 'fax');
var args = ['firstName', 'address.state', 'phoneNumber.1.type'];
actual = leetMock.extract(args);
assert.equal(Object.keys(actual).length, 3);
assert.property(actual, 'firstName');
assert.property(actual, 'address.state');
assert.property(actual, 'phoneNumber.1.type');
assert.equal(actual['firstName'], 'John');
assert.equal(actual['address.state'], 'NY');
assert.equal(actual['phoneNumber.1.type'], 'fax');
done();
});
validate: function (attrs) {
var errors = [];
Validation.checkGroupsNameField(errors, true, attrs['name.first'] || attrs.name.first, 'Company');
Validation.checkPhoneField(errors, false, attrs['phones.phone'] || attrs.phones.phone, 'Phone');
Validation.checkPhoneField(errors, false, attrs['phones.mobile'] || attrs.phones.mobile, 'Mobile');
Validation.checkCountryCityStateField(errors, false, attrs['address.country'] || attrs.address.country, 'Country');
Validation.checkCountryCityStateField(errors, false, attrs['address.state'] || attrs.address.state, 'State');
Validation.checkCountryCityStateField(errors, false, attrs['address.city'] || attrs.address.city, 'City');
Validation.checkZipField(errors, false, attrs['address.zip'] || attrs.address.zip, 'Zip');
Validation.checkEmailField(errors, false, attrs.email, 'Email');
if (errors.length > 0) {
return errors;
}
},
validate: function (attrs) {
var errors = [];
Validation.checkNameField(errors, true, attrs['name.first'] || attrs.name.first, 'First name');
Validation.checkNameField(errors, true, attrs['name.last'] || attrs.name.last, 'Last name');
Validation.checkPhoneField(errors, false, attrs['phones.phone'] || attrs.phones.phone, 'Phone');
Validation.checkPhoneField(errors, false, attrs['phones.mobile'] || attrs.phones.mobile, 'Mobile');
Validation.checkPhoneField(errors, false, attrs['phones.fax'] || attrs.phones.fax, 'Fax');
Validation.checkCountryCityStateField(errors, false, attrs['address.country'] || attrs.address.country, 'Country');
Validation.checkCountryCityStateField(errors, false, attrs['address.state'] || attrs.address.state, 'State');
Validation.checkCountryCityStateField(errors, false, attrs['address.city'] || attrs.address.city, 'City');
Validation.checkZipField(errors, false, attrs['address.zip'] || attrs.address.zip, 'Zip');
Validation.checkStreetField(errors, false, attrs['address.street'] || attrs.address.street, 'Street');
Validation.checkCountryCityStateField(errors, false, attrs['shippingAddress.country'] || attrs.address.country, 'Shipping Country');
Validation.checkCountryCityStateField(errors, false, attrs['shippingAddress.state'] || attrs.address.state, 'Shipping State');
Validation.checkCountryCityStateField(errors, false, attrs['shippingAddress.city'] || attrs.address.city, 'Shipping City');
Validation.checkZipField(errors, false, attrs['shippingAddress.zip'] || attrs.address.zip, 'Shipping Zip');
Validation.checkStreetField(errors, false, attrs['shippingAddress.street'] || attrs.address.street, 'Shipping Street');
Validation.checkNameField(errors, false, attrs.jobPosition, 'Job position');
Validation.checkSkypeField(errors, false, attrs.skype, 'Skype');
Validation.checkEmailField(errors, false, attrs.email, 'Email');
Validation.checkFacebookSocial(errors, false, attrs.social.FB, 'Facebook');
Validation.checkLinkedinSocial(errors, false, attrs.social.LI, 'LinkedIn');
}
if (address_city) {
query['address.city'] = stringQueryBuilder(address_city);
}
if (address_country) {
query['address.country'] = stringQueryBuilder(address_country);
}
if (address_postalcode) {
query['address.postalCode'] = stringQueryBuilder(address_postalcode);
}
if (address_state) {
query['address.state'] = stringQueryBuilder(address_state);
}
if (address_use) {
query['address.use'] = address_use;
}
if (endpoint) {
let queryBuilder = referenceQueryBuilder(endpoint, 'endpoint.reference');
for (let i in queryBuilder) {
query[i] = queryBuilder[i];
}
}
if (identifier) {
let queryBuilder = tokenQueryBuilder(identifier, 'value', 'identifier', '');
for (let i in queryBuilder) {
if (ors.length === 1) {
ors.push(ors[0]);
}
query.$and = ors;
}
if (addressCity) {
query['address.city'] = stringQueryBuilder(addressCity);
}
if (addressCountry) {
query['address.country'] = stringQueryBuilder(addressCountry);
}
if (addressPostalCode) {
query['address.postalCode'] = stringQueryBuilder(addressPostalCode);
}
if (addressState) {
query['address.state'] = stringQueryBuilder(addressState);
}
if (addressUse) {
query['address.use'] = stringQueryBuilder(addressUse);
}
if (communication) {
let queryBuilder = tokenQueryBuilder(communication, 'code', 'communication.coding', '');
for (let i in queryBuilder) {
query[i] = queryBuilder[i];
}
}
if (email) {
let queryBuilder = tokenQueryBuilder(email, 'value', 'telecom', 'email');
for (let i in queryBuilder) {
query[i] = queryBuilder[i];
}
}
}
if (address_city) {
query['address.city'] = stringQueryBuilder(address_city);
}
if (address_country) {
query['address.country'] = stringQueryBuilder(address_country);
}
if (address_postalcode) {
query['address.postalCode'] = stringQueryBuilder(address_postalcode);
}
if (address_state) {
query['address.state'] = stringQueryBuilder(address_state);
}
if (address_use) {
query['address.use'] = address_use;
}
if (animal_breed) {
let queryBuilder = tokenQueryBuilder(animal_breed, 'code', 'animal.breed.coding', '');
for (let i in queryBuilder) {
query[i] = queryBuilder[i];
}
}
if (animal_species) {
let queryBuilder = tokenQueryBuilder(animal_species, 'code', 'animal.species.coding', '');
for (let i in queryBuilder) {
}
if (addressCity) {
query['address.city'] = stringQueryBuilder(addressCity);
}
if (addressCountry) {
query['address.country'] = stringQueryBuilder(addressCountry);
}
if (addressPostalCode) {
query['address.postalCode'] = stringQueryBuilder(addressPostalCode);
}
if (addressState) {
query['address.state'] = stringQueryBuilder(addressState);
}
if (addressUse) {
query['address.use'] = addressUse;
}
if (endpoint) {
let queryBuilder = referenceQueryBuilder(endpoint, 'endpoint.reference');
for (let i in queryBuilder) {
query[i] = queryBuilder[i];
}
}
if (identifier) {
let queryBuilder = tokenQueryBuilder(identifier, 'value', 'identifier', '');
for (let i in queryBuilder) {