UKHomeOffice-attic / hof

Home Office Forms
GNU General Public License v2.0
14 stars 6 forks source link

Dates bundles into mixin- Has this been done? #38

Open sulthan-ahmed opened 8 years ago

sulthan-ahmed commented 8 years ago

Not sure if this is done but it would be helpful

JoeChapman commented 8 years ago

There is a date mixin, however, the real issue is that there is no way to write a date field config definition is such a way that neatly describes the association between the elements of a date component.

E.g. A date component requires four elements (fields) that are associated by the initial part of the key ('foo').

{
'foo': {
    '....': '...'
},
'foo-day': {
    '....': '...'
},
'foo-month': {
    '....': '...'
},
'foo-year': {
    '....': '...'
}

I would like to see dates described as single field, with nested fields.

{
'foo': {
   'day': {
        '....': '...'
    },
    'month': {
        '....': '...'
    },
    'year': {
        '....': '...'
    }
}
daniel-ac-martin commented 8 years ago

I think this feature has been discussed in https://github.com/UKHomeOffice/passports-form-wizard/issues/35

We have the basis for a solution somewhere in brp_app (on the arrange.js controller). Allowing us to take advantage of the date validators in passports-form-controller. But I haven't turned it into a generic controller yet.

JoeChapman commented 8 years ago

@daniel-ac-martin is there a commit associated with it that you can reference here? If it's good, but you just don't have the time to finish, perhaps someone else can pick it up to get it past the finish line.

daniel-ac-martin commented 8 years ago

@JoeChapman I'm not certain, but I believe it is this: https://github.com/UKHomeOffice/brp_app/commit/8801c700a9c6708e728e60b700c93e4224d44518

i.e. It is some stuff added on top of the base controller rather than using the date controller.

daniel-ac-martin commented 8 years ago

Quick update: Finally wrote a controller that does this on Saturday. Haven't written any tests yet so haven't published it. Hope to write those tests by the start of next week. Nag me if I forget about it.

Once that is done I think we should make HOF's base-controller inherit from it and deprecate the current date-controller. (The plan is to invite hmpo to make use of it and if they approve it can be merged into either the main form-controller of the wizard's controller.)

Annoyingly, we need to patch a couple of the validators in HOF as we are more permissive over the date inputs we will accept. (I'd like to get these changes into the form-controller as I believe our approach is superior.)

JoeChapman commented 8 years ago

@daniel-ac-martin what concerns me is that it will only work on a Saturday!

daniel-ac-martin commented 8 years ago

@JoeChapman There's just no pleasing some people!

sulthan-ahmed commented 8 years ago

hahaaa @daniel-ac-martin and @JoeChapman

daniel-ac-martin commented 8 years ago

https://github.com/UKHomeOffice/hof-controllers/pull/39