Каталог файловtilda-zero-forms-1.0.js
1601 if (elementObj.li_type === 'contact_method') {1602 const { typeName, valueName } = t_zeroForms__getContactMethodVarNames(elementObj);1603 return `${typeName};${valueName}`;1604 }1605 1606 return t396__decodeHtmlText(elementObj.li_nm);1607}1608 1609/**1610 * Возвращает имена переменных способа связи: тип (phone, telegram, ...) и значение (номер, имя пользователя, ...)1611 * @param {FormObjectEl} elementObj1612
История файла и сравнение версий
* @returns {{ typeName: string, valueName: string }}
1614function t_zeroForms__getContactMethodVarNames(elementObj) { 1616 typeName: t396__decodeHtmlText(elementObj.li_contact_method_type_nm || ''), 1617 valueName: t396__decodeHtmlText(elementObj.li_contact_method_id_nm || ''), 1622 * Возвращает список доступных способов связи без дублей и неизвестных значений 1623 * @param {FormObjectEl} elementObj 1624 * @returns {ContactMethod[]} 1626function t_zeroForms__getContactMethods(elementObj) { 1627 let contactMethods = elementObj.li_contact_methods; 1628 if (typeof contactMethods === 'string') { 1630 contactMethods = JSON.parse(contactMethods); 1632 contactMethods = []; 1635 if (!Array.isArray(contactMethods)) return []; 1637 const config = t_zeroForms__getContactMethodsConfig(); 1638 const types = contactMethods 1639 .map(contactMethod => contactMethod && contactMethod.value) 1640 .filter((type, index, list) => type && config[type] && list.indexOf(type) === index); 1642 return types.map(type => Object.assign({ type }, config[type])); 1646 * Создает поле "Способ связи" 1648 * @param {string} recid 1651 * elementObj: FormObjectEl, 1652 * contactMethods: ContactMethod[], 1654 * inputStyles: Object, 1655 * inputPreferences: Object, 1657 * @returns {HTMLDivElement | null} 1659function t_zeroForms__createContactMethod(recid, options) { 1660 const { formID, elementObj, contactMethods, formObj, inputStyles, inputPreferences } = options; 1661 if (!contactMethods.length) return null; 1663 const defaultMethod = 1664 contactMethods.find(method => method.type === elementObj.li_default_contact_method) || contactMethods[0]; 1665 const { typeName, valueName } = t_zeroForms__getContactMethodVarNames(elementObj); 1667 const container = t_zeroForms__createWrapper('t-contact-method__container'); 1668 const typesContainer = t_zeroForms__createWrapper('t-contact-method__types-container'); 1669 const valueContainer = t_zeroForms__createWrapper('t-contact-method__value-container'); 1671 // способ связи по умолчанию всегда располагается в начале списка 1672 const sortedMethods = [defaultMethod].concat(contactMethods.filter(method => method !== defaultMethod)); 1673 sortedMethods.forEach((contactMethod, index) => { 1674 const radio = t_zeroForms__createContactMethodRadio(contactMethod, { 1675 inputId: `contact-method-${elementObj.lid}-${index}`, 1676 inputName: typeName, 1677 isRequired: inputPreferences.require, 1678 isChecked: contactMethod === defaultMethod, 1680 typesContainer.appendChild(radio); 1683 contactMethods.forEach(contactMethod => { 1684 const valueGroup = t_zeroForms__createContactMethodValueGroup(recid, { 1687 inputName: valueName, 1690 isDefault: contactMethod === defaultMethod, 1692 valueContainer.appendChild(valueGroup); 1695 container.appendChild(typesContainer); 1696 container.appendChild(valueContainer); 1698 const styles = t_zeroForms__getContactMethodStyles(recid, formID, formObj); 1700 const stylesEl = document.createElement('style');