gov_uk_date_fields 3.2.0.rc3 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gov_uk_date_fields/form_fields.rb +136 -171
- data/lib/gov_uk_date_fields/version.rb +2 -2
- data/test/dummy/app/assets/config/manifest.js +1 -1
- data/test/dummy/app/views/employees/_form.html.erb +1 -1
- data/test/dummy/config/database.yml +3 -0
- data/test/dummy/config/locales/en.yml +20 -1
- data/test/dummy/log/test.log +3681 -0
- data/test/dummy/test/controllers/employees_controller_test.rb +3 -7
- data/test/dummy/test/fixtures/files/date_fields_error.html +37 -0
- data/test/dummy/test/fixtures/files/date_fields_no_error.html +36 -0
- data/test/dummy/test/fixtures/files/date_fields_no_heading.html +34 -0
- data/test/dummy/test/models/default_error_clash_employee_test.rb +2 -2
- data/test/dummy/test/models/form_date_test.rb +1 -4
- data/test/dummy/test/models/form_fields_test.rb +28 -307
- data/test/dummy/test/models/omit_error_clash_employee_test.rb +2 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/0C/0C2zg6Fz4ZDKb2SJoMeKCyuiEkK3VLTLoXTk6XtsYnk.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/1q/1qTKTELCNcaTGecih6WmU5XbelY0-n9ECxNFb7B3NDY.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/23/23OcjleyoUnN5T0v_oEwEEVK7l5HEyIO_KGRr2Makg0.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/2v/2vYH0-57Ot7PCLWkuyRiVWFoDqDAisPuU54eB1XCuZs.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/87/87lBrKaac9bxHnrcDd3_kuqKV7Cn2kb3-9Yh1xDySjo.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/AX/AX3L2fGpRF9VevxsOcMT3K8MFiRGjRX81JBxvrH7IIc.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Dm/DmmfrCpXtt74Hr6NO54lxyOCDv6klnDyBqeDFR7oDU8.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Dw/DWiSprTdmJSiF4eYqRLDfLfWLyF-m0Mk3TOoLQXKKW0.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/HZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/bE/bEgoYkpGjiyAWAaXBvA_-Aya6FVRKq3XugvZkD08uXQ.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/kB/kBO5u1GYzp_3At4KdTa7gu6M-8iJYzXwK7awXVhfdqQ.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/lm/lmLdQ9YYUNBpTGdPEpu9Jg8U72UBOztolRY2JGn69PQ.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/nP/nPNMfuYlHJYq2PChYn-dJcrv2a_jlRXt70OIDOC2f3A.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/oR/oREyRPrhTN2nImWV9UIIivSk5CeZ7vpcmwFg6CMNoGQ.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/qK/qKwRM7szJUtdx-IcB_777nsCap0rkqBzoVO9zNTaLsY.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/xo/xo0vwho1GEXuJPGLrvAxM5Ag7xiZme4jPtTrZL2wSGY.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/yG/yGhSuZRuCtgZCBYZtGTzP3HHN73lpDEh0ZSY9fXMr74.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/zF/zFkhrrravmeW44GBd3ZlMtqo96To6Zso0hWQ_7NIgU4.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/0F/0FBvTP5GR23sqfKQqc3ndsfMXyIceqNSEMDGdeKx-iw.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/0I/0I0SJYh6xyz2kJ-P0dZ1c8kq_lc0wkRDY1ZEeAombQo.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/0a/0a16TXIS237lMaBIne5Nr5Zz_LkXQroGtjhqyUhCOYQ.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/11/11ovRdbo434VRd2K0Sat3eZTuQn6hLBSz69i01_fDZ8.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/2U/2UTPo9bZtE2VMmv3ozQT5LpfnndJo1TaQ6VAOY0dAFQ.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/2d/2dhiBTjBCH6rUfCJGoAp3fXgrDHxLIrybhE4TAS2su8.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/4e/4eJoHAAJ4SF9Yw_4r61OtLTF9pK28G2ESTXYTkgT0qQ.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/4g/4gt5Zf3XYLpssAYW6ANTaUFYel_6yWgzo9gI0M-lR6E.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/52/5248EdGUC74D1uVXiRxivkYvXF6xizQCiiKneqnfik4.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/5y/5Y9YnqLJJcIPyOyVcyWfDDb-U8nRpHueM2YGPtYmZm4.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/5y/5y-aQ4cIum-_A2jTKUwbHTzo6AL99_jhiXTAcxlc5Ss.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/6H/6H4HGvZ3o4Pj8QMLBN3igwFMMODcAyz8U2Ap0ACQqok.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/7H/7Hh93d3G281lD_G4MM-K7YL0RtvfF3osZ3tK86p8Psk.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/7Z/7Z60_jhGYjjOBTk3r8Aa2ZV4DwTHuXc4JsqT13bCljc.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/8W/8W7Id0h5U77_eVkkCY4ROJBUKABLRHsr5yo_vzBNoA4.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/92/92DncEpOSowpziX2RSXmGIKXaJo7h2rr9Hh6wyVOsRM.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/AO/AOY_58Ai8y4zMJ13jdYBdoBNJHwlX4gtzflhfP2nl6k.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/AX/AX3L2fGpRF9VevxsOcMT3K8MFiRGjRX81JBxvrH7IIc.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/C-/C-dw0M8QOQN8DjROlM-aUteggu3d6KaQD-rBmHAQ4dU.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/CM/CMeCT2T7Nd7PUPEtbK1YCarmzltllbcbsHI892df9Uo.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Da/DahTrnxxMFavj3bHuCvhl03IXIb5XRXdj6PLUtMwVoI.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Dm/DmmfrCpXtt74Hr6NO54lxyOCDv6klnDyBqeDFR7oDU8.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Do/Do83AoOat5W-c1g7piDGy2GMmffsY6JY0Qfuh5PY3GM.cache +2 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Dw/DWiSprTdmJSiF4eYqRLDfLfWLyF-m0Mk3TOoLQXKKW0.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/EA/EAMGb3LcvsJYsKCvU0FH3cFXQBqTmDHdm68CRcGGkxs.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/HZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Hu/HuxqAoY_FoJq94YbRhmLRcXiA6K7xPXT3ViyV8vtr38.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/LI/LIOeD2c3MYj4K4LebnGYcpb1F-G7eHCqyVcF3fLmivk.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Lw/Lw7tUkUABT5dQ0eElpmhiEbK8h6ChHhEEb3iIP_q6As.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/My/Myq6rgVMKFWObJUsyisfudlI1fWDVaFHdJtx_YNWgkE.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/O6/O6PjkGTcXaO89C6AbuadQ3tNJM7JAUPl22JkjSlGYT0.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/OC/OCgWDw6AmW2ndZhYQJCovAT3MrQ1FUcjKcIVnicQFWs.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/OI/OIcpSS_toFEgHpKqLUFT_EO_KEIHJ2ti8VepxMz0ROk.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Ok/OkjwT_Bg1Ete5QvfmAGVm-YuMHrlbTH5VOI8aDtyDbg.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/P2/P2eaoG_3TI887exxv_G88ZYFhwOs5UOqKB7If9FLtHE.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/PF/PFD-K2z1IpxItwCxGEIxoq56ay6rKDrBA1wUNEYxOOc.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Pb/Pb2Wc_FYaxn6JgXTJbW_unn8UhGBuRirp7PEBynJFyA.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Pw/PwV1n0VInOtXSi2kWiNdBHG44NAKqGfQx4OijtmIk5I.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Q1/Q1XF7k1XjotY1C9SUWw3RaOuqBTZ3AygKU0FsKSGe8U.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/T6/T6J4CcKu5C6mgeOQxg5nNc-lRwowH_UgZWmD_GWtKTE.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/US/USEnPg2AGtX0pVqQNI_iGrLtB9t-r253_6DzFzhoY9Q.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/V2/V20OShSf4KQuR_tjMKpClFMr_EWUbxFeXbOhvvz9QM4.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/V8/V8ZewWLrocSiIOMQMOeIrIXDgvktN939nWcA_wnBszs.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/VQ/VQD_HVLaDTBoPGbAKzzV-_A-w_pjFujFXcYW1T5yVJ4.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Vk/Vk0wJE8hvbtGSNnzIW3-Evd7_M-Bc7emek0GFZQPapI.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/WG/WG5dYP-ckKzAMi5OcUWS50k31lbRPXJ-ipfPbVB_xlY.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/YS/YSAUVr5d_wbRSzz2BleSmYfkMZPYTbL3ftCUchYei3I.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Ye/Ye_ONiDRDCf5YZOULWxLUfsr-IjJryfMOA6FoDugNJA.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/aS/aSw2fAfFJBikdJOTGE7_86zOLdFTCWV_lkKX3TwOkb8.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/bD/bDtRIDP0s9tKUSyIAH31D5jroSMXZV0K7TynjIx3-8o.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/bn/bnXRQyRSltQCM8FUXL8lpo4y5YaBLea1PIvciJFDf9Y.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/br/bruJcqITayQQfuI_0x5dUW7M9DzJdRPNh8Igf0jpniY.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/cj/cjnpc-ByYZiJFv2-sjRS1AxvpxtM3S6sE2VB7NxZe80.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/cu/cuFUNLq4kuBeMs4w5fUvIkk-MFPMl2OnmsssjJMyPK8.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/e7/e7BUqMzL_1E7BBnoV_nbJLoQu_SGqKtKJWOsQsZQUjU.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/fa/faTijp_rKjBEvLHMOJ2DtpixNdcS8LpJgk_kSFfXa7I.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/hi/HIwfqm8aLEFNNe1kRosjv97hgxdWZtZR4SUmIwPD_L4.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/hr/hr3vgmohlHUPBxg_1SkwssAeKMG4IeMmyHmsdaGxJXo.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/hx/hxaDKsXJi-m5nKlmbR1hk4a4Xg2YfFwmrW_TtmS7jlE.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/i6/i6MnwGOTb-6wI1QoaMbUG6_si7ex6qJIq-6BD8a0atQ.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/jf/jfyB4_hKx91oYrg3Uz8kejw-1HKvL3WNzfXHySfnrjg.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/jr/jrhg63vKri996YfYxadgGPKa0s0Z0QeRBvv78nSjZd8.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/k2/k230zg3KWZuQ9up5IruYh082tu4CAmgAheZJN-w5_pE.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/k9/k9czmo4FEiAIwA9VBgJzkuaEIzFHi4ncQa6QcilA4Hs.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/l2/l2kRUfGOavyI9m_fh5Po6aCsWqcXA-N1alZsislQsyQ.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/lo/lop19Wm1uQZfGd6HfEAEdB1zDu5eWXraq_C7CfdepFI.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/m7/M74bdzSYi7Dt522cDdBL3cfCik79h5YPNJfBk5Y_KMs.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/m7/m7zZtDfOpfg4A2T8djXPwZ9bzt8QYGlaD7_1BmZ_XYI.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/oU/oUcXXxKagL4rpV2nZ9mguSwRZuRJ4amZlMbYJjZ0MNA.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/pr/prQPg8mGVONBTk9Fg0dBPPW0jFaWR2sduO876XIDzwI.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/ps/psBBNOAKRh8YioHXsWx2sTo_Nhf1SB1nRF73bYh6szg.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/pv/pv6tV3CDkIAmLXdU8EPLlNEkXAKJPufVD4VP30o4fWo.cache +2 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/py/pyGAJrY1mgvF3JKeIGd7oSFKe34ZIyP04fOnInQI9Pc.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/qh/qhcFpLxR_Q-MR3fQHOsfLnsd999iPY3-MULVjw5IyTo.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/r9/r9EqVDhnX2xtdKYUJJ9TnrUnvcnVpFqzDp0_X9mRZAs.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/rV/rVIqk5blVIvnPB5_UOcU5Kb2jaOoDLVJJP-3cTJ-O58.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/rf/rfLkA5p4BXXJJ74YR8FbQbDV4Bb0WHxNwzsgAp1OLTs.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/sD/sDAsuJtgLiV-QkQe-cSdXfiUOjOOa0Y26yKETGY4I5Q.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/uf/ufhKc2bX_OCnWPA1CIAmeHU8VxWbdA5qUlSdEScnkeY.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/uh/uhyjgIntx0ROlUReN-lOokLm-C_h3Qc0Tb55Ng5SNuM.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/wN/WnG-tLWvfYaiK9GlHONheAINtcktwQW3RGqbY7XjaJk.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/wX/wXqpuaP5B32TnHsCqCG8T8yFYTeC12ot6B3CZXVwZs4.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/xY/xYwuUZks6Apchm69F0RMY1VhCiOkTc0vnd0gdEdujIA.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/xz/xzt9-xebMB-HhzrGOZ-ybRzxoje_BYreHI6qS4ZdqXk.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/yX/yX4FWx00r4Ktdk56ieu0rpZC0oTTAJM5a8D7o9m4Gb4.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/z9/z9sop_5Fsj3dppixvAQ6tts4MmhlyxvWiGi_YXnOvxc.cache +0 -0
- metadata +197 -14
- data/test/sample.html +0 -25
- data/vendor/assets/javascripts/govuk_date_fields.js +0 -57
- data/vendor/assets/stylesheets/_govuk_date_fields.scss +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79f6690a87a5fe34ef7473660d47aad6f58019daca5cec9efec97b5038817c54
|
4
|
+
data.tar.gz: 81e1ee5473edf78be16e334a88ffb68cdda223b45b20693cb5b44f9381cc55cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d2f1925d6a6e630bdbd4ce005dfb6cea0511e6ba63f6e1efee83047f417a52ee1c9aaef42cef6a447a1025370d0fbdc14a65b9c8ac602ef7d08a64ad8065fa4
|
7
|
+
data.tar.gz: c6e04f555e451fa43a7e9c65e323879e6f0f2f88e1152023a4e5d69c250ac8838032c6bf4353314378baba510885ab623accb17b589c2106aac82da9f3efd87a
|
@@ -1,19 +1,15 @@
|
|
1
1
|
module GovUkDateFields
|
2
|
-
|
3
2
|
class FormFields
|
4
|
-
|
3
|
+
include ActionView::Context
|
4
|
+
include ActionView::Helpers::TagHelper
|
5
|
+
|
6
|
+
delegate :concat, to: :@output_buffer
|
5
7
|
|
6
8
|
DATE_SEGMENTS = {
|
7
9
|
day: '_dd',
|
8
10
|
month: '_mm',
|
9
11
|
year: '_yyyy',
|
10
|
-
}
|
11
|
-
|
12
|
-
DEFAULT_PLACEHOLDERS = {
|
13
|
-
day: 'DD',
|
14
|
-
month: 'MM',
|
15
|
-
year: 'YYYY'
|
16
|
-
}
|
12
|
+
}.freeze
|
17
13
|
|
18
14
|
def initialize(form, object_name, attribute, options={})
|
19
15
|
@form = form
|
@@ -24,28 +20,42 @@ module GovUkDateFields
|
|
24
20
|
@day_value = @object.send("#{@attribute}_dd")&.gsub(/\D/, '')
|
25
21
|
@month_value = @object.send("#{@attribute}_mm")&.gsub(/\D/, '')
|
26
22
|
@year_value = @object.send("#{@attribute}_yyyy")&.gsub(/\D/, '')
|
27
|
-
@form_hint_text = @options[:form_hint_text] || "For example, 31 3 1980"
|
28
|
-
@fieldset_required = false
|
29
|
-
@fieldset_id = @options[:id]
|
30
|
-
@error_messages = @options[:error_messages]
|
31
|
-
@hint_id = form_group_hint_id
|
32
|
-
@today_button = @options[:today_button] || false
|
33
|
-
parse_options
|
34
23
|
end
|
35
24
|
|
36
25
|
def raw_output
|
37
|
-
|
38
|
-
generate_input_fields
|
39
|
-
else
|
40
|
-
generate_old_style_input_fields
|
41
|
-
end
|
26
|
+
generate_input_fields
|
42
27
|
end
|
43
28
|
|
44
29
|
def output
|
45
30
|
raw_output.html_safe
|
46
31
|
end
|
47
32
|
|
48
|
-
|
33
|
+
private
|
34
|
+
|
35
|
+
def generate_input_fields
|
36
|
+
content_tag(:div, class: form_group_classes) do
|
37
|
+
content_tag(:fieldset, fieldset_options(@attribute, @options)) do
|
38
|
+
concat fieldset_legend(@attribute, @options)
|
39
|
+
concat hint(@attribute)
|
40
|
+
concat error(@attribute)
|
41
|
+
concat input_fields_div
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def generate_input_for(name, value, width: 2)
|
47
|
+
css_class = "govuk-input govuk-date-input__input govuk-input--width-#{width}"
|
48
|
+
css_class += " govuk-input--error" if error_for_attr?
|
49
|
+
|
50
|
+
content_tag(:div, class: 'govuk-date-input__item') do
|
51
|
+
content_tag(:div, class: 'govuk-form-group') do
|
52
|
+
%Q|
|
53
|
+
<label class="govuk-label govuk-date-input__label" for="#{html_id(name)}">#{localized_label(name)}</label>
|
54
|
+
<input class="#{css_class}" id="#{html_id(name)}" name="#{html_name(name)}" value="#{value}" type="text" inputmode="numeric" pattern="[0-9]*">
|
55
|
+
|.html_safe
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
49
59
|
|
50
60
|
def error_for_attr?
|
51
61
|
error_attribute_names.include?(@attribute) && @object.errors[@attribute].any?
|
@@ -59,202 +69,157 @@ module GovUkDateFields
|
|
59
69
|
end
|
60
70
|
end
|
61
71
|
|
62
|
-
def
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
def generate_old_style_input_fields
|
67
|
-
%Q[
|
68
|
-
#{@form.text_field(@attribute, field_options(@day_value, html_id(:day), html_name(:day), placeholder(:day), 2))}
|
69
|
-
#{@form.text_field(@attribute, field_options(@month_value, html_id(:month), html_name(:month), placeholder(:month), 3))}
|
70
|
-
#{@form.text_field(@attribute, field_options(@year_value, html_id(:year), html_name(:year), placeholder(:year), 4))}
|
71
|
-
]
|
72
|
-
end
|
73
|
-
|
74
|
-
def generate_start_fieldset
|
75
|
-
%Q|
|
76
|
-
#{generate_fieldset_tag}
|
77
|
-
#{generate_legend_tag}
|
78
|
-
<span class="form-label-bold">#{@options[:legend_text]}</span>
|
79
|
-
<span class="form-hint" id="#{@hint_id}">#{@form_hint_text}</span>
|
80
|
-
#{generate_error_message}
|
81
|
-
</legend>
|
82
|
-
<div class="form-date">
|
83
|
-
|
|
84
|
-
end
|
85
|
-
|
86
|
-
def generate_fieldset_tag
|
87
|
-
css_class = "form-group gov_uk_date"
|
88
|
-
css_class += " form-group-error" if error_for_attr?
|
89
|
-
|
90
|
-
result = %Q|
|
91
|
-
<div class="#{css_class}"|
|
92
|
-
result += %Q| id="#{form_group_id}"|
|
93
|
-
result += ">"
|
94
|
-
result += %Q| <fieldset|
|
95
|
-
result += ">"
|
96
|
-
result
|
72
|
+
def html_id(date_segment)
|
73
|
+
brackets2underscore(html_name(date_segment))
|
97
74
|
end
|
98
75
|
|
99
|
-
def
|
100
|
-
"
|
76
|
+
def html_name(date_segment)
|
77
|
+
"#{@object_name}[#{@attribute}#{DATE_SEGMENTS[date_segment]}]"
|
101
78
|
end
|
102
79
|
|
103
|
-
def
|
104
|
-
|
105
|
-
%Q|<legend class="#{@options[:legend_class]}">|
|
106
|
-
else
|
107
|
-
"<legend>"
|
108
|
-
end
|
80
|
+
def brackets2underscore(string)
|
81
|
+
string.tr('[','_').tr(']', '_').gsub('__', '_').gsub(/_$/, '')
|
109
82
|
end
|
110
83
|
|
111
|
-
def
|
112
|
-
|
113
|
-
if error_for_attr?
|
114
|
-
result = "<ul>"
|
115
|
-
if @error_messages.nil?
|
116
|
-
@error_messages = @object.errors[@attribute]
|
117
|
-
end
|
118
|
-
@error_messages.each do |message|
|
119
|
-
result += %Q|<li><span class="error-message">#{message}</span></li>|
|
120
|
-
end
|
121
|
-
result += "</ul>"
|
122
|
-
end
|
123
|
-
result
|
84
|
+
def attribute_prefix
|
85
|
+
brackets2underscore(@object_name.to_s)
|
124
86
|
end
|
125
87
|
|
126
|
-
def
|
127
|
-
|
128
|
-
result += generate_today_button if @today_button
|
129
|
-
result += generate_day_input_field(@day_value) + generate_month_input_field(@month_value) + generate_year_input_field(@year_value)
|
130
|
-
result += generate_end_fieldset
|
131
|
-
result
|
88
|
+
def form_group_id
|
89
|
+
[attribute_prefix, @attribute].join('_')
|
132
90
|
end
|
133
91
|
|
134
|
-
def
|
135
|
-
|
136
|
-
@today_button[:class]
|
137
|
-
else
|
138
|
-
'button'
|
139
|
-
end
|
92
|
+
def form_group_hint_id
|
93
|
+
[form_group_id, 'hint'].join('_')
|
140
94
|
end
|
141
95
|
|
142
|
-
def
|
143
|
-
|
96
|
+
def form_group_classes
|
97
|
+
classes = ['govuk-form-group']
|
98
|
+
classes << 'govuk-form-group--error' if error_for_attr?
|
99
|
+
classes
|
144
100
|
end
|
145
101
|
|
146
|
-
def
|
147
|
-
|
148
|
-
end
|
102
|
+
def fieldset_options(attribute, options)
|
103
|
+
defaults = { class: 'govuk-fieldset', role: 'group' }
|
149
104
|
|
150
|
-
|
151
|
-
|
152
|
-
|
105
|
+
aria_ids = []
|
106
|
+
aria_ids << id_for(attribute, 'hint') if hint(attribute)
|
107
|
+
aria_ids << id_for(attribute, 'error') if error_for_attr?
|
153
108
|
|
154
|
-
|
155
|
-
|
156
|
-
css_class += " form-control-error" if error_for_attr?
|
109
|
+
# If the array is empty, `#presence` will return nil
|
110
|
+
defaults['aria-describedby'] = aria_ids.presence
|
157
111
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
</div>
|
163
|
-
|
|
112
|
+
merge_attributes(
|
113
|
+
options[:fieldset_options],
|
114
|
+
default: defaults
|
115
|
+
)
|
164
116
|
end
|
165
117
|
|
166
|
-
def
|
167
|
-
|
168
|
-
|
118
|
+
def fieldset_legend(attribute, options)
|
119
|
+
default_attrs = { class: 'govuk-fieldset__legend' }.freeze
|
120
|
+
default_opts = { visually_hidden: false, page_heading: true, size: 'xl' }.freeze
|
169
121
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
end
|
122
|
+
legend_options = merge_attributes(
|
123
|
+
options[:legend_options],
|
124
|
+
default: default_attrs
|
125
|
+
).reverse_merge(
|
126
|
+
default_opts
|
127
|
+
)
|
177
128
|
|
178
|
-
|
179
|
-
css_class = "form-control"
|
180
|
-
css_class += " form-control-error" if error_for_attr?
|
129
|
+
opts = legend_options.extract!(*default_opts.keys)
|
181
130
|
|
182
|
-
|
183
|
-
|
184
|
-
<label for="#{html_id(:year)}">Year</label>
|
185
|
-
<input class="#{css_class}" id="#{html_id(:year)}" name="#{html_name(:year)}" type="number" min="0" max="2100" value="#{year_value}">
|
186
|
-
</div>
|
187
|
-
|
|
188
|
-
end
|
131
|
+
legend_options[:class] << " govuk-fieldset__legend--#{opts[:size]}"
|
132
|
+
legend_options[:class] << " govuk-visually-hidden" if opts[:visually_hidden]
|
189
133
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
raise ArgumentError.new("Invalid combination of options: You must specifigy :legend_text if :legend_class or :form_hint_text are specified")
|
134
|
+
# The `page_heading` option can be false to disable "Legends as page headings"
|
135
|
+
# https://design-system.service.gov.uk/get-started/labels-legends-headings/
|
136
|
+
#
|
137
|
+
if opts[:page_heading]
|
138
|
+
content_tag(:legend, legend_options) do
|
139
|
+
content_tag(:h1, fieldset_text(attribute), class: 'govuk-fieldset__heading')
|
197
140
|
end
|
141
|
+
else
|
142
|
+
content_tag(:legend, fieldset_text(attribute), legend_options)
|
198
143
|
end
|
199
144
|
end
|
200
145
|
|
201
|
-
def
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
146
|
+
def input_fields_div
|
147
|
+
content_tag(:div, class: 'govuk-date-input', id: form_group_id) do
|
148
|
+
concat generate_input_for(:day, @day_value)
|
149
|
+
concat generate_input_for(:month, @month_value)
|
150
|
+
concat generate_input_for(:year, @year_value, width: 4)
|
206
151
|
end
|
207
152
|
end
|
208
153
|
|
154
|
+
def hint(attribute)
|
155
|
+
return unless hint_text(attribute)
|
156
|
+
content_tag(:span, hint_text(attribute), class: 'govuk-hint', id: id_for(attribute, 'hint'))
|
157
|
+
end
|
209
158
|
|
210
|
-
def
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
end
|
159
|
+
def error(attribute)
|
160
|
+
return unless error_for_attr?
|
161
|
+
|
162
|
+
text = error_full_message_for(attribute)
|
163
|
+
content_tag(:span, text, class: 'govuk-error-message', id: id_for(attribute, 'error'))
|
216
164
|
end
|
217
165
|
|
218
|
-
def
|
219
|
-
|
166
|
+
def id_for(attribute, suffix)
|
167
|
+
[attribute_prefix, attribute, suffix].join('_')
|
220
168
|
end
|
221
169
|
|
222
|
-
def
|
223
|
-
|
170
|
+
def default_label attribute
|
171
|
+
attribute.to_s.split('.').last.humanize.capitalize
|
224
172
|
end
|
225
173
|
|
226
|
-
def
|
227
|
-
|
174
|
+
def fieldset_text attribute
|
175
|
+
localized 'helpers.fieldset', attribute, default_label(attribute)
|
228
176
|
end
|
229
177
|
|
230
|
-
def
|
231
|
-
|
178
|
+
def hint_text attribute
|
179
|
+
localized 'helpers.hint', attribute, ''
|
232
180
|
end
|
233
181
|
|
234
|
-
def
|
235
|
-
|
236
|
-
|
182
|
+
def localized_label attribute
|
183
|
+
localized 'helpers.label', attribute, default_label(attribute)
|
184
|
+
end
|
237
185
|
|
238
|
-
|
239
|
-
|
240
|
-
|
186
|
+
def error_full_message_for attribute
|
187
|
+
message = @object.errors.full_messages_for(attribute).first
|
188
|
+
message&.sub default_label(attribute), localized_label(attribute)
|
241
189
|
end
|
242
190
|
|
243
|
-
|
244
|
-
|
245
|
-
|
191
|
+
# If a form view is reused but the attribute doesn't change (for example in
|
192
|
+
# partials) an `i18n_attribute` can be used to lookup the legend or hint locales
|
193
|
+
# based on this, instead of the original attribute.
|
194
|
+
#
|
195
|
+
# We prioritise the `i18n_attribute` if provided, and if no locale is found,
|
196
|
+
# we try the 'real' attribute as a fallback and finally the default value.
|
197
|
+
#
|
198
|
+
def localized scope, attribute, default
|
199
|
+
found = if @options[:i18n_attribute]
|
200
|
+
key = "#{@object_name}.#{@options[:i18n_attribute]}"
|
201
|
+
|
202
|
+
I18n.translate(key, default: '', scope: scope).presence ||
|
203
|
+
I18n.translate("#{key}_html", default: '', scope: scope).html_safe.presence
|
204
|
+
end
|
205
|
+
|
206
|
+
return found if found
|
207
|
+
|
208
|
+
key = "#{@object_name}.#{attribute}"
|
246
209
|
|
247
|
-
|
210
|
+
# Passes blank String as default because nil is interpreted as no default
|
211
|
+
I18n.translate(key, default: '', scope: scope).presence ||
|
212
|
+
I18n.translate("#{key}_html", default: default, scope: scope).html_safe.presence
|
248
213
|
end
|
249
214
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
}
|
215
|
+
# Given an attributes hash that could include any number of arbitrary keys, this method
|
216
|
+
# ensure we merge one or more 'default' attributes into the hash, creating the keys if
|
217
|
+
# don't exist, or merging the defaults if the keys already exists.
|
218
|
+
# It supports strings or arrays as values.
|
219
|
+
#
|
220
|
+
def merge_attributes attributes, default:
|
221
|
+
hash = attributes || {}
|
222
|
+
hash.merge(default) { |_key, oldval, newval| Array(newval) + Array(oldval) }
|
258
223
|
end
|
259
224
|
end
|
260
225
|
end
|
@@ -17,6 +17,9 @@
|
|
17
17
|
default: &default
|
18
18
|
adapter: postgresql
|
19
19
|
encoding: unicode
|
20
|
+
host: localhost
|
21
|
+
username: <%= ENV["POSTGRES_USER"] %>
|
22
|
+
password: <%= ENV["POSTGRES_PASSWORD"] %>
|
20
23
|
# For details on connection pooling, see rails configuration guide
|
21
24
|
# http://guides.rubyonrails.org/configuring.html#database-pooling
|
22
25
|
pool: 5
|
@@ -20,4 +20,23 @@
|
|
20
20
|
# available at http://guides.rubyonrails.org/i18n.html.
|
21
21
|
|
22
22
|
en:
|
23
|
-
|
23
|
+
errors:
|
24
|
+
format: "%{message}"
|
25
|
+
attributes:
|
26
|
+
dob:
|
27
|
+
blank: Enter the date of birth
|
28
|
+
|
29
|
+
helpers:
|
30
|
+
fieldset:
|
31
|
+
employee:
|
32
|
+
dob: Date of birth
|
33
|
+
custom_i18n_attribute: A custom legend
|
34
|
+
label:
|
35
|
+
dob:
|
36
|
+
day: Day
|
37
|
+
month: Month
|
38
|
+
year: Year
|
39
|
+
hint:
|
40
|
+
employee:
|
41
|
+
dob: For example, 12 11 2007
|
42
|
+
custom_i18n_attribute: A custom hint
|