From 4737b103c07bb98e079e80e08b58341a2c9f9db9 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Mon, 2 Dec 2024 19:50:32 +0200 Subject: [PATCH 01/15] fix i18n --- app/javascript/submission_form/i18n.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/submission_form/i18n.js b/app/javascript/submission_form/i18n.js index bbe65ad52..3db90855d 100644 --- a/app/javascript/submission_form/i18n.js +++ b/app/javascript/submission_form/i18n.js @@ -780,7 +780,7 @@ const pt = { verify_id: 'Verificar ID', identity_verification: 'Verificação de identidade', complete: 'Completar', - preencher_todos_os_campos_obrigatórios_para_concluir: 'Preencher todos os campos obrigatórios para concluir', + fill_all_required_fields_to_complete: 'Preencher todos os campos obrigatórios para concluir', sign_and_complete: 'Assinar e Completar', invite: 'Convidar', email: 'E-mail', @@ -975,7 +975,7 @@ const nl = { verify_id: 'Verifiëren ID', identity_verification: 'Identiteitsverificatie', complete: 'Voltooien', - vul_alle_verplichte_velden_in_om_te_voltooien: 'Vul alle verplichte velden in om te voltooien', + fill_all_required_fields_to_complete: 'Vul alle verplichte velden in om te voltooien', sign_and_complete: 'Ondertekenen en voltooien', invite: 'Uitnodigen', email: 'E-mail', From e3bed5ae678adb573a509b00fece1580c2f7d05f Mon Sep 17 00:00:00 2001 From: Alex Turchyn Date: Tue, 3 Dec 2024 20:49:28 +0200 Subject: [PATCH 02/15] add iso codes to phone data --- app/javascript/submission_form/phone_data.js | 224 +++++++++++++++++- app/javascript/submission_form/phone_step.vue | 4 +- .../submission_form/verification_step.vue | 2 +- 3 files changed, 224 insertions(+), 6 deletions(-) diff --git a/app/javascript/submission_form/phone_data.js b/app/javascript/submission_form/phone_data.js index de8ea83b3..36d5c054e 100644 --- a/app/javascript/submission_form/phone_data.js +++ b/app/javascript/submission_form/phone_data.js @@ -1,5 +1,6 @@ export default [ [ + 'US', 'United States', '1', '🇺🇸', @@ -14,60 +15,70 @@ export default [ ] ], [ + 'AF', 'Afghanistan', '93', '🇦🇫', ['Kabul'] ], [ + 'AX', 'Aland Islands', '358', '🇦🇽', ['Mariehamn'] ], [ + 'AL', 'Albania', '355', '🇦🇱', ['Tirane'] ], [ + 'DZ', 'Algeria', '213', '🇩🇿', ['Algiers'] ], [ + 'AS', 'American Samoa', '1684', '🇦🇸', ['Pago_Pago'] ], [ + 'AD', 'Andorra', '376', '🇦🇩', ['Andorra'] ], [ + 'AO', 'Angola', '244', '🇦🇴', ['Luanda'] ], [ + 'AI', 'Anguilla', '1264', '🇦🇮', ['Anguilla'] ], [ + 'AG', 'Antigua and Barbuda', '1268', '🇦🇬', ['Antigua'] ], [ + 'AR', 'Argentina', '54', '🇦🇷', @@ -87,18 +98,21 @@ export default [ ] ], [ + 'AM', 'Armenia', '374', '🇦🇲', ['Yerevan'] ], [ + 'AW', 'Aruba', '297', '🇦🇼', ['Aruba'] ], [ + 'AU', 'Australia', '61', '🇦🇺', @@ -118,90 +132,105 @@ export default [ ] ], [ + 'AT', 'Austria', '43', '🇦🇹', ['Vienna'] ], [ + 'AZ', 'Azerbaijan', '994', '🇦🇿', ['Baku'] ], [ + 'BS', 'Bahamas', '1242', '🇧🇸', ['Nassau'] ], [ + 'BH', 'Bahrain', '973', '🇧🇭', ['Bahrain'] ], [ + 'BD', 'Bangladesh', '880', '🇧🇩', ['Dhaka'] ], [ + 'BB', 'Barbados', '1246', '🇧🇧', ['Barbados'] ], [ + 'BE', 'Belgium', '32', '🇧🇪', ['Brussels'] ], [ + 'BZ', 'Belize', '501', '🇧🇿', ['Belize'] ], [ + 'BJ', 'Benin', '229', '🇧🇯', ['Porto-Novo'] ], [ + 'BM', 'Bermuda', '1441', '🇧🇲', ['Bermuda'] ], [ + 'BT', 'Bhutan', '975', '🇧🇹', ['Thimphu'] ], [ + 'BO', 'Bolivia', '591', '🇧🇴', ['La_Paz'] ], [ + 'BA', 'Bosnia and Herzegovina', '387', '🇧🇦', ['Sarajevo'] ], [ + 'BW', 'Botswana', '267', '🇧🇼', ['Gaborone'] ], [ + 'BR', 'Brazil', '55', '🇧🇷', @@ -225,48 +254,56 @@ export default [ ] ], [ + 'IO', 'British Indian Ocean Territory', '246', '🇮🇴', ['Chagos'] ], [ + 'BN', 'Brunei Darussalam', '673', '🇧🇳', ['Brunei'] ], [ + 'BG', 'Bulgaria', '359', '🇧🇬', ['Sofia'] ], [ + 'BF', 'Burkina Faso', '226', '🇧🇫', ['Ouagadougou'] ], [ + 'BI', 'Burundi', '257', '🇧🇮', ['Bujumbura'] ], [ + 'KH', 'Cambodia', '855', '🇰🇭', ['Phnom_Penh'] ], [ + 'CM', 'Cameroon', '237', '🇨🇲', ['Douala'] ], [ + 'CA', 'Canada', '1', '🇨🇦', @@ -302,252 +339,294 @@ export default [ ] ], [ + 'CV', 'Cape Verde', '238', '🇨🇻', ['Cape_Verde'] ], [ + 'KY', 'Cayman Islands', '1345', '🇰🇾', ['Cayman'] ], [ + 'TD', 'Chad', '235', '🇹🇩', ['Ndjamena'] ], [ + 'CL', 'Chile', '56', '🇨🇱', ['Punta_Arenas', 'Santiago', 'Easter'] ], [ + 'CN', 'China', '86', '🇨🇳', ['Shanghai', 'Urumqi'] ], [ + 'CX', 'Christmas Island', '61', '🇨🇽', ['Christmas'] ], [ + 'CC', 'Cocos (Keeling) Islands', '61', '🇨🇨', ['Cocos'] ], [ + 'CO', 'Colombia', '57', '🇨🇴', ['Bogota'] ], [ + 'KM', 'Comoros', '269', '🇰🇲', ['Comoro'] ], [ + 'CD', 'Congo, The Democratic Republic of the', '243', '🇨🇩', ['Kinshasa', 'Lubumbashi'] ], [ + 'CK', 'Cook Islands', '682', '🇨🇰', ['Rarotonga'] ], [ + 'CR', 'Costa Rica', '506', '🇨🇷', ['Costa_Rica'] ], [ + 'CI', "Côte d'Ivoire", '225', '🇨🇮', ['Abidjan'] ], [ + 'HR', 'Croatia', '385', '🇭🇷', ['Zagreb'] ], [ + 'CY', 'Cyprus', '357', '🇨🇾', ['Nicosia', 'Famagusta'] ], [ + 'CZ', 'Czech Republic', '420', '🇨🇿', ['Prague'] ], [ + 'DK', 'Denmark', '45', '🇩🇰', ['Copenhagen'] ], [ + 'DJ', 'Djibouti', '253', '🇩🇯', ['Djibouti'] ], [ + 'DM', 'Dominica', '1767', '🇩🇲', ['Dominica'] ], [ + 'DO', 'Dominican Republic', '1849', '🇩🇴', ['Santo_Domingo'] ], [ + 'EC', 'Ecuador', '593', '🇪🇨', ['Guayaquil', 'Galapagos'] ], [ + 'EG', 'Egypt', '20', '🇪🇬', ['Cairo'] ], [ + 'SV', 'El Salvador', '503', '🇸🇻', ['El_Salvador'] ], [ + 'GQ', 'Equatorial Guinea', '240', '🇬🇶', ['Malabo'] ], [ + 'ER', 'Eritrea', '291', '🇪🇷', ['Asmara'] ], [ + 'EE', 'Estonia', '372', '🇪🇪', ['Tallinn'] ], [ + 'ET', 'Ethiopia', '251', '🇪🇹', ['Addis_Ababa'] ], [ + 'FK', 'Falkland Islands (Malvinas)', '500', '🇫🇰', ['Stanley'] ], [ + 'FO', 'Faroe Islands', '298', '🇫🇴', ['Faroe'] ], [ + 'FJ', 'Fiji', '679', '🇫🇯', ['Fiji'] ], [ + 'FI', 'Finland', '358', '🇫🇮', ['Helsinki'] ], [ + 'FR', 'France', '33', '🇫🇷', ['Paris'] ], [ + 'GF', 'French Guiana', '594', '🇬🇫', ['Cayenne'] ], [ + 'PF', 'French Polynesia', '689', '🇵🇫', ['Tahiti', 'Marquesas', 'Gambier'] ], [ + 'GA', 'Gabon', '241', '🇬🇦', ['Libreville'] ], [ + 'GM', 'Gambia', '220', '🇬🇲', ['Banjul'] ], [ + 'GE', 'Georgia', '995', '🇬🇪', ['Tbilisi'] ], [ + 'DE', 'Germany', '49', '🇩🇪', ['Berlin', 'Busingen'] ], [ + 'GH', 'Ghana', '233', '🇬🇭', ['Accra'] ], [ + 'GI', 'Gibraltar', '350', '🇬🇮', ['Gibraltar'] ], [ + 'GR', 'Greece', '30', '🇬🇷', ['Athens'] ], [ + 'GL', 'Greenland', '299', '🇬🇱', @@ -559,85 +638,98 @@ export default [ ] ], [ + 'GD', 'Grenada', '1473', '🇬🇩', ['Grenada'] ], [ + 'GP', 'Guadeloupe', '590', '🇬🇵', ['Guadeloupe'] ], [ + 'GU', 'Guam', '1671', '🇬🇺', ['Guam'] ], [ + 'GT', 'Guatemala', '502', '🇬🇹', ['Guatemala'] ], [ + 'GN', 'Guinea', '224', '🇬🇳', ['Conakry'] ], [ + 'GW', 'Guinea-Bissau', '245', '🇬🇼', ['Bissau'] ], [ + 'GY', 'Guyana', '592', '🇬🇾', ['Guyana'] ], [ + 'HT', 'Haiti', '509', '🇭🇹', ['Port-au-Prince'] ], [ + 'HN', 'Honduras', '504', '🇭🇳', ['Tegucigalpa'] ], [ + 'HK', 'Hong Kong', '852', '🇭🇰', ['Hong_Kong'] ], [ + 'HU', 'Hungary', '36', '🇭🇺', ['Budapest'] ], - [ + 'IS', 'Iceland', '354', '🇮🇸', ['Reykjavik'] ], [ + 'IN', 'India', '91', '🇮🇳', ['Kolkata'] ], [ + 'ID', 'Indonesia', '62', '🇮🇩', @@ -649,60 +741,70 @@ export default [ ] ], [ + 'IQ', 'Iraq', '964', '🇮🇶', ['Baghdad'] ], [ + 'IE', 'Ireland', '353', '🇮🇪', ['Dublin'] ], [ + 'IM', 'Isle of Man', '44', '🇮🇲', ['Isle_of_Man'] ], [ + 'IL', 'Israel', '972', '🇮🇱', ['Jerusalem'] ], [ + 'IT', 'Italy', '39', '🇮🇹', ['Rome'] ], [ + 'JM', 'Jamaica', '1876', '🇯🇲', ['Jamaica'] ], [ + 'JP', 'Japan', '81', '🇯🇵', ['Tokyo'] ], [ + 'JE', 'Jersey', '44', '🇯🇪', ['Jersey'] ], [ + 'JO', 'Jordan', '962', '🇯🇴', ['Amman'] ], [ + 'KZ', 'Kazakhstan', '7', '🇰🇿', @@ -715,162 +817,190 @@ export default [ ] ], [ + 'KE', 'Kenya', '254', '🇰🇪', ['Nairobi'] ], [ + 'KI', 'Kiribati', '686', '🇰🇮', ['Tarawa', 'Enderbury', 'Kiritimati'] ], [ + 'KR', 'South Korea', '82', '🇰🇷', ['Seoul'] ], [ + 'KW', 'Kuwait', '965', '🇰🇼', ['Kuwait'] ], [ + 'KG', 'Kyrgyzstan', '996', '🇰🇬', ['Bishkek'] ], [ + 'LA', 'Laos', '856', '🇱🇦', ['Vientiane'] ], [ + 'LV', 'Latvia', '371', '🇱🇻', ['Riga'] ], [ + 'LB', 'Lebanon', '961', '🇱🇧', ['Beirut'] ], [ + 'LS', 'Lesotho', '266', '🇱🇸', ['Maseru'] ], [ + 'LR', 'Liberia', '231', '🇱🇷', ['Monrovia'] ], [ + 'LI', 'Liechtenstein', '423', '🇱🇮', ['Vaduz'] ], [ + 'LT', 'Lithuania', '370', '🇱🇹', ['Vilnius'] ], [ + 'LU', 'Luxembourg', '352', '🇱🇺', ['Luxembourg'] ], [ + 'MO', 'Macao', '853', '🇲🇴', ['Macau'] ], [ + 'MK', 'North Macedonia', '389', '🇲🇰', ['Skopje'] ], [ + 'MG', 'Madagascar', '261', '🇲🇬', ['Antananarivo'] ], [ + 'MW', 'Malawi', '265', '🇲🇼', ['Blantyre'] ], [ + 'MY', 'Malaysia', '60', '🇲🇾', ['Kuala_Lumpur', 'Kuching'] ], [ + 'MV', 'Maldives', '960', '🇲🇻', ['Maldives'] ], + [ + 'ML', 'Mali', '223', '🇲🇱', ['Bamako'] ], [ + 'MT', 'Malta', '356', '🇲🇹', ['Malta'] ], [ + 'MH', 'Marshall Islands', '692', '🇲🇭', ['Majuro', 'Kwajalein'] ], [ + 'MQ', 'Martinique', '596', '🇲🇶', ['Martinique'] ], [ + 'MR', 'Mauritania', '222', '🇲🇷', ['Nouakchott'] ], [ + 'MU', 'Mauritius', '230', '🇲🇺', ['Mauritius'] ], [ + 'YT', 'Mayotte', '262', '🇾🇹', ['Mayotte'] ], [ + 'MX', 'Mexico', '52', '🇲🇽', @@ -889,476 +1019,553 @@ export default [ ] ], [ + 'FM', 'Micronesia, Federated States of', '691', '🇫🇲', ['Chuuk', 'Pohnpei', 'Kosrae'] ], - [ + 'MD', 'Moldova', '373', '🇲🇩', ['Chisinau'] ], [ + 'MC', 'Monaco', '377', '🇲🇨', ['Monaco'] ], [ + 'MN', 'Mongolia', '976', '🇲🇳', ['Ulaanbaatar', 'Hovd', 'Choibalsan'] ], [ + 'ME', 'Montenegro', '382', '🇲🇪', ['Podgorica'] ], [ + 'MS', 'Montserrat', '1664', '🇲🇸', ['Montserrat'] ], [ + 'MA', 'Morocco', '212', '🇲🇦', ['Casablanca'] ], [ + 'MZ', 'Mozambique', '258', '🇲🇿', ['Maputo'] ], [ + 'NA', 'Namibia', '264', '🇳🇦', ['Windhoek'] ], [ + 'NR', 'Nauru', '674', '🇳🇷', ['Nauru'] ], [ + 'NP', 'Nepal', '977', '🇳🇵', ['Kathmandu'] ], [ + 'NL', 'Netherlands', '31', '🇳🇱', ['Amsterdam'] ], [ + 'NC', 'New Caledonia', '687', '🇳🇨', ['Noumea'] ], [ + 'NZ', 'New Zealand', '64', '🇳🇿', ['Auckland', 'Chatham'] ], [ + 'NE', 'Niger', '227', '🇳🇪', ['Niamey'] ], [ + 'NG', 'Nigeria', '234', '🇳🇬', ['Lagos'] ], [ + 'NU', 'Niue', '683', '🇳🇺', ['Niue'] ], [ + 'NF', 'Norfolk Island', '672', '🇳🇫', ['Norfolk'] ], [ + 'MP', 'Northern Mariana Islands', '1670', '🇲🇵', ['Saipan'] ], [ + 'NO', 'Norway', '47', '🇳🇴', ['Oslo'] ], [ + 'OM', 'Oman', '968', '🇴🇲', ['Muscat'] ], [ + 'PK', 'Pakistan', '92', '🇵🇰', ['Karachi'] ], [ + 'PW', 'Palau', '680', '🇵🇼', ['Palau'] ], [ + 'PA', 'Panama', '507', '🇵🇦', ['Panama'] ], [ + 'PG', 'Papua New Guinea', '675', '🇵🇬', ['Port_Moresby', 'Bougainville'] ], [ + 'PY', 'Paraguay', '595', '🇵🇾', ['Asuncion'] ], [ + 'PE', 'Peru', '51', '🇵🇪', ['Lima'] ], [ + 'PH', 'Philippines', '63', '🇵🇭', ['Manila'] ], [ + 'PN', 'Pitcairn', '872', '🇵🇳', ['Pitcairn'] ], [ + 'PL', 'Poland', '48', '🇵🇱', ['Warsaw'] ], [ + 'PT', 'Portugal', '351', '🇵🇹', ['Lisbon', 'Madeira', 'Azores'] ], [ + 'PR', 'Puerto Rico', '1939', '🇵🇷', ['Puerto_Rico'] ], [ + 'QA', 'Qatar', '974', '🇶🇦', ['Qatar'] ], [ + 'RO', 'Romania', '40', '🇷🇴', ['Bucharest'] ], [ + 'RW', 'Rwanda', '250', '🇷🇼', ['Kigali'] ], [ + 'RE', 'Reunion', '262', '🇷🇪', ['Reunion'] ], [ + 'BL', 'Saint Barthelemy', '590', '🇧🇱', ['St_Barthelemy'] ], [ + 'SH', 'Saint Helena, Ascension and Tristan Da Cunha', '290', '🇸🇭', ['St_Helena'] ], [ + 'KN', 'Saint Kitts and Nevis', '1869', '🇰🇳', ['St_Kitts'] ], [ + 'LC', 'Saint Lucia', '1758', '🇱🇨', ['St_Lucia'] ], [ + 'MF', 'Saint Martin', '590', '🇲🇫', ['Marigot'] ], [ + 'PM', 'Saint Pierre and Miquelon', '508', '🇵🇲', ['Miquelon'] ], [ + 'VC', 'Saint Vincent and the Grenadines', '1784', '🇻🇨', ['St_Vincent'] ], [ + 'WS', 'Samoa', '685', '🇼🇸', ['Apia'] ], [ + 'SM', 'San Marino', '378', '🇸🇲', ['San_Marino'] ], [ + 'ST', 'Sao Tome and Principe', '239', '🇸🇹', ['Sao_Tome'] ], [ + 'SA', 'Saudi Arabia', '966', '🇸🇦', ['Riyadh'] ], [ + 'SN', 'Senegal', '221', '🇸🇳', ['Dakar'] ], [ + 'RS', 'Serbia', '381', '🇷🇸', ['Belgrade'] ], [ + 'SC', 'Seychelles', '248', '🇸🇨', ['Mahe'] ], - [ + 'SL', 'Sierra Leone', '232', '🇸🇱', ['Freetown'] ], [ + 'SG', 'Singapore', '65', '🇸🇬', ['Singapore'] ], [ + 'SK', 'Slovakia', '421', '🇸🇰', ['Bratislava'] ], [ + 'SI', 'Slovenia', '386', '🇸🇮', ['Ljubljana'] ], [ + 'SB', 'Solomon Islands', '677', '🇸🇧', ['Guadalcanal'] ], [ + 'ZA', 'South Africa', '27', '🇿🇦', ['Johannesburg'] ], [ + 'ES', 'Spain', '34', '🇪🇸', ['Madrid', 'Ceuta', 'Canary'] ], [ + 'LK', 'Sri Lanka', '94', '🇱🇰', ['Colombo'] ], [ + 'SR', 'Suriname', '597', '🇸🇷', ['Paramaribo'] ], [ + 'SJ', 'Svalbard and Jan Mayen', '47', '🇸🇯', ['Longyearbyen'] ], [ + 'SZ', 'Eswatini', '268', '🇸🇿', ['Mbabane'] ], [ + 'SE', 'Sweden', '46', '🇸🇪', ['Stockholm'] ], [ + 'CH', 'Switzerland', '41', '🇨🇭', ['Zurich'] ], [ + 'TW', 'Taiwan', '886', '🇹🇼', ['Taipei'] ], [ + 'TJ', 'Tajikistan', '992', '🇹🇯', ['Dushanbe'] ], [ + 'TZ', 'Tanzania, United Republic of', '255', '🇹🇿', ['Dar_es_Salaam'] ], [ + 'TH', 'Thailand', '66', '🇹🇭', ['Bangkok'] ], [ + 'TL', 'Timor-Leste', '670', '🇹🇱', ['Dili'] ], [ + 'TG', 'Togo', '228', '🇹🇬', ['Lome'] ], [ + 'TK', 'Tokelau', '690', '🇹🇰', ['Fakaofo'] ], [ + 'TO', 'Tonga', '676', '🇹🇴', ['Tongatapu'] ], [ + 'TT', 'Trinidad and Tobago', '1868', '🇹🇹', ['Port_of_Spain'] ], [ + 'TN', 'Tunisia', '216', '🇹🇳', ['Tunis'] ], [ + 'TR', 'Turkey', '90', '🇹🇷', ['Istanbul'] ], [ + 'TM', 'Turkmenistan', '993', '🇹🇲', ['Ashgabat'] ], [ + 'TC', 'Turks and Caicos Islands', '1649', '🇹🇨', ['Grand_Turk'] ], [ + 'TV', 'Tuvalu', '688', '🇹🇻', ['Funafuti'] ], [ + 'UG', 'Uganda', '256', '🇺🇬', ['Kampala'] ], [ + 'UA', 'Ukraine', '380', '🇺🇦', @@ -1370,66 +1577,77 @@ export default [ ] ], [ + 'AE', 'United Arab Emirates', '971', '🇦🇪', ['Dubai'] ], [ + 'GB', 'United Kingdom', '44', '🇬🇧', ['London'] ], [ + 'UY', 'Uruguay', '598', '🇺🇾', ['Montevideo'] ], [ + 'UZ', 'Uzbekistan', '998', '🇺🇿', ['Samarkand', 'Tashkent'] ], [ + 'VU', 'Vanuatu', '678', '🇻🇺', ['Efate'] ], [ + 'VN', 'Vietnam', '84', '🇻🇳', ['Ho_Chi_Minh'] ], [ + 'VG', 'Virgin Islands, British', '1284', '🇻🇬', ['Tortola'] ], [ + 'VI', 'Virgin Islands, U.S.', '1340', '🇻🇮', ['St_Thomas'] ], [ + 'WF', 'Wallis and Futuna', '681', '🇼🇫', ['Wallis'] ], [ + 'YE', 'Yemen', '967', '🇾🇪', ['Aden'] ], [ + 'ZM', 'Zambia', '260', '🇿🇲', diff --git a/app/javascript/submission_form/phone_step.vue b/app/javascript/submission_form/phone_step.vue index 9c4678947..844eca009 100644 --- a/app/javascript/submission_form/phone_step.vue +++ b/app/javascript/submission_form/phone_step.vue @@ -180,8 +180,8 @@ export default { }, computed: { countries () { - return phoneData.map(([name, dial, flag, tz]) => { - return { name, dial, flag, tz } + return phoneData.map(([iso, name, dial, flag, tz]) => { + return { iso, name, dial, flag, tz } }) }, countriesDialIndex () { diff --git a/app/javascript/submission_form/verification_step.vue b/app/javascript/submission_form/verification_step.vue index d0b0a5583..555cc6483 100644 --- a/app/javascript/submission_form/verification_step.vue +++ b/app/javascript/submission_form/verification_step.vue @@ -95,7 +95,7 @@ export default { countryCode () { const browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone const browserTz = browserTimeZone.split('/')[1] - const country = phoneData.find(([a, b, c, tz]) => tz.includes(browserTz)) + const country = phoneData.find(([a, b, c, e, tz]) => tz.includes(browserTz)) return country[0] }, From 975f3a95fed435d1f75161faf8a1bf4ae5281a6e Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Tue, 3 Dec 2024 15:04:44 +0200 Subject: [PATCH 03/15] add db search path --- config/database.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/database.yml b/config/database.yml index f26c54efc..20921d2d1 100644 --- a/config/database.yml +++ b/config/database.yml @@ -19,6 +19,9 @@ production: username: <%= ENV['DATABASE_USER'] %> password: <%= ENV['DATABASE_PASSWORD'] %> database: <%= ENV['DATABASE_NAME'] %> + <% if !ENV['DATABASE_SEARCH_PATH'].to_s.empty? %> + search_path: <%= ENV['DATABASE_SEARCH_PATH'] %> + <% end %> <% elsif ENV['DATABASE_URL'].to_s.empty? %> adapter: sqlite3 database: <%= ENV['WORKDIR'] || '.' %>/db.sqlite3 From b1c31672eef1a84c89ca63bebe833b9a32c02940 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Wed, 4 Dec 2024 17:40:46 +0200 Subject: [PATCH 04/15] use tz country code --- app/javascript/submission_form/verification_step.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/submission_form/verification_step.vue b/app/javascript/submission_form/verification_step.vue index 555cc6483..dff8ac478 100644 --- a/app/javascript/submission_form/verification_step.vue +++ b/app/javascript/submission_form/verification_step.vue @@ -107,7 +107,7 @@ export default { clientId: this.eidEasyData.client_id, docId: this.eidEasyData.doc_id, language: this.locale, - countryCode: this.browserCountry, + countryCode: this.countryCode, enabledMethods: { signature: this.eidEasyData.available_methods }, From d8126c4a4721e30be3e406fb973e1866d5ee9dae Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Thu, 5 Dec 2024 19:20:17 +0200 Subject: [PATCH 05/15] uniq submission.submitters --- app/views/submitter_mailer/completed_email.html.erb | 2 +- lib/replace_email_variables.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/submitter_mailer/completed_email.html.erb b/app/views/submitter_mailer/completed_email.html.erb index 70792c86a..7269fb390 100644 --- a/app/views/submitter_mailer/completed_email.html.erb +++ b/app/views/submitter_mailer/completed_email.html.erb @@ -2,6 +2,6 @@ <%= render 'custom_content', content: @body, submitter: @submitter %> <% else %>

<%= t('hi_there') %>,

-

<%= I18n.t(:name_has_been_completed_by_submitters, name: @submitter.submission.template.name, submitters: @submitter.submission.submitters.order(:completed_at).map { |e| e.name || e.email || e.phone }.join(', ')) %>

+

<%= I18n.t(:name_has_been_completed_by_submitters, name: @submitter.submission.template.name, submitters: @submitter.submission.submitters.order(:completed_at).map { |e| e.name || e.email || e.phone }.uniq.join(', ')) %>

<%= link_to submission_url(@submitter.submission), submission_url(@submitter.submission) %>

<% end %> diff --git a/lib/replace_email_variables.rb b/lib/replace_email_variables.rb index 572fd0a46..430b57572 100644 --- a/lib/replace_email_variables.rb +++ b/lib/replace_email_variables.rb @@ -92,6 +92,6 @@ def build_submission_link(submission) end def build_submission_submitters(submission) - submission.submitters.order(:completed_at).map { |e| e.name || e.email || e.phone }.join(', ') + submission.submitters.order(:completed_at).map { |e| e.name || e.email || e.phone }.uniq.join(', ') end end From 38b5eccb65237fdea8086a1ae61a33ef5b35fd7d Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Fri, 6 Dec 2024 00:47:40 +0200 Subject: [PATCH 06/15] adjust readonly fields --- app/javascript/submission_form/form.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/javascript/submission_form/form.vue b/app/javascript/submission_form/form.vue index f3d363abb..53b666d55 100644 --- a/app/javascript/submission_form/form.vue +++ b/app/javascript/submission_form/form.vue @@ -15,8 +15,9 @@ /> Date: Sat, 7 Dec 2024 01:35:59 +0200 Subject: [PATCH 07/15] document conditions --- app/controllers/templates_controller.rb | 2 +- app/javascript/form.js | 1 + app/javascript/submission_form/form.vue | 50 ++++++++++++++++- app/javascript/template_builder/area.vue | 2 +- app/javascript/template_builder/builder.vue | 17 ++++++ .../template_builder/conditions_modal.vue | 32 ++++++----- app/javascript/template_builder/field.vue | 4 +- app/javascript/template_builder/fields.vue | 12 +++++ app/javascript/template_builder/preview.vue | 48 ++++++++++++++++- app/views/submissions/show.html.erb | 7 +-- .../submit_form/_submission_form.html.erb | 2 +- app/views/submit_form/show.html.erb | 53 ++++++++++--------- lib/submissions.rb | 38 +++++++++++++ .../generate_combined_attachment.rb | 2 + .../generate_preview_attachments.rb | 4 +- .../generate_result_attachments.rb | 36 ++++++++----- lib/submitters/submit_values.rb | 7 +++ 17 files changed, 252 insertions(+), 65 deletions(-) diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index 306476b29..0d4147550 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -109,7 +109,7 @@ def destroy def template_params params.require(:template).permit( :name, - { schema: [%i[attachment_uuid name]], + { schema: [[:attachment_uuid, :name, { conditions: [%i[field_uuid value action operation]] }]], submitters: [%i[name uuid is_requester linked_to_uuid invite_by_uuid email]], fields: [[:uuid, :submitter_uuid, :name, :type, :required, :readonly, :default_value, diff --git a/app/javascript/form.js b/app/javascript/form.js index 604d06a43..f9583da62 100644 --- a/app/javascript/form.js +++ b/app/javascript/form.js @@ -15,6 +15,7 @@ safeRegisterElement('submission-form', class extends HTMLElement { this.app = createApp(Form, { submitter: JSON.parse(this.dataset.submitter), inviteSubmitters: JSON.parse(this.dataset.inviteSubmitters), + schema: JSON.parse(this.dataset.schema), canSendEmail: this.dataset.canSendEmail === 'true', previousSignatureValue: this.dataset.previousSignatureValue, goToLast: this.dataset.goToLast === 'true', diff --git a/app/javascript/submission_form/form.vue b/app/javascript/submission_form/form.vue index 53b666d55..f8c4031db 100644 --- a/app/javascript/submission_form/form.vue +++ b/app/javascript/submission_form/form.vue @@ -652,6 +652,11 @@ export default { required: false, default: null }, + schema: { + type: Array, + required: false, + default: () => [] + }, attachments: { type: Array, required: false, @@ -841,6 +846,21 @@ export default { isMobile () { return /android|iphone|ipad/i.test(navigator.userAgent) }, + attachmentConditionsIndex () { + return this.schema.reduce((acc, item) => { + if (item.conditions?.length) { + if (item.conditions.every((c) => this.fieldsUuidIndex[c.field_uuid])) { + acc[item.attachment_uuid] = this.checkFieldConditions(item) + } else { + acc[item.attachment_uuid] = true + } + } else { + acc[item.attachment_uuid] = true + } + + return acc + }, {}) + }, emptyValueRequiredStep () { return this.stepFields.find((fields, index) => { return fields.some((f) => { @@ -921,7 +941,7 @@ export default { return this.currentStepFields[0] }, readonlyConditionalFields () { - return this.fields.filter((f) => f.readonly && f.conditions?.length && this.checkFieldConditions(f)) + return this.fields.filter((f) => f.readonly && f.conditions?.length && this.checkFieldConditions(f) && this.checkFieldDocumentsConditions(f)) }, stepFields () { const verificationFields = [] @@ -943,7 +963,7 @@ export default { return sortedFields.reduce((acc, f) => { const prevStep = acc[acc.length - 1] - if (this.checkFieldConditions(f)) { + if (this.checkFieldConditions(f) && this.checkFieldDocumentsConditions(f)) { if (f.type === 'checkbox' && Array.isArray(prevStep) && prevStep[0].type === 'checkbox' && !f.description) { prevStep.push(f) } else { @@ -976,6 +996,23 @@ export default { if (isEmpty(value) && this.currentStep > 0) { this.currentStep -= 1 } + }, + attachmentConditionsIndex: { + deep: true, + immediate: true, + handler (value) { + this.$nextTick(() => { + const root = this.$root.$el.parentNode.getRootNode() + + for (const key in value) { + const doc = root.querySelector(`[id="document-${key}"`) + + if (doc) { + doc.classList.toggle('hidden', !value[key]) + } + } + }) + } } }, beforeUnmount () { @@ -1057,6 +1094,15 @@ export default { onOrientationChange (event) { this.orientation = event.target.type }, + checkFieldDocumentsConditions (field) { + if (field.areas?.length) { + return field.areas.some((area) => { + return this.attachmentConditionsIndex[area.attachment_uuid] + }) + } else { + return true + } + }, checkFieldConditions (field) { if (field.conditions?.length) { const result = field.conditions.reduce((acc, cond) => { diff --git a/app/javascript/template_builder/area.vue b/app/javascript/template_builder/area.vue index 61439a78f..6211bf516 100644 --- a/app/javascript/template_builder/area.vue +++ b/app/javascript/template_builder/area.vue @@ -257,7 +257,7 @@ :to="modalContainerEl" > diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index d8a9c3dc2..99550031a 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -362,6 +362,7 @@ :default-submitters="defaultSubmitters" :draw-field-type="drawFieldType" :default-fields="[...defaultRequiredFields, ...defaultFields]" + :template="template" :default-required-fields="defaultRequiredFields" :field-types="fieldTypes" :with-sticky-submitters="withStickySubmitters" @@ -1023,6 +1024,22 @@ export default { if (!field.areas.length) { this.template.fields.splice(this.template.fields.indexOf(field), 1) + + this.template.fields.forEach((f) => { + (f.conditions || []).forEach((c) => { + if (c.field_uuid === field.uuid) { + f.conditions.splice(f.conditions.indexOf(c), 1) + } + }) + }) + + this.template.schema.forEach((item) => { + (item.conditions || []).forEach((c) => { + if (c.field_uuid === field.uuid) { + item.conditions.splice(item.conditions.indexOf(c), 1) + } + }) + }) } this.save() diff --git a/app/javascript/template_builder/conditions_modal.vue b/app/javascript/template_builder/conditions_modal.vue index 3fbe13133..5bcc01293 100644 --- a/app/javascript/template_builder/conditions_modal.vue +++ b/app/javascript/template_builder/conditions_modal.vue @@ -9,7 +9,7 @@