diff options
author | Dave Arter <davea@mysociety.org> | 2018-04-26 21:14:22 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2018-04-30 13:18:58 +0100 |
commit | 7ac5bbd69f6157175e82fc286355881d73f561ea (patch) | |
tree | 07dad0f0187497d50a726975408fc7ffefc2cc6c /www/js | |
parent | 90a0e3b2a9721e8f913da72a65d193dc54f5b74f (diff) |
Skip extra details screen if empty
Some categories have extra fields but they’re all hidden;
in this case there’s no point showing the user an empty
screen so it’s skipped.
Diffstat (limited to 'www/js')
-rw-r--r-- | www/js/views/details.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/www/js/views/details.js b/www/js/views/details.js index 9f03d58..f2de9d8 100644 --- a/www/js/views/details.js +++ b/www/js/views/details.js @@ -87,8 +87,18 @@ timeout: 30000, success: function( data, status ) { if ( data && data.category_extra && data.category_extra.length > 0 ) { - that.model.set('category_extras', data.category_extra); - that.navigate('details_extra'); + // Some categories have only hidden fields - in that case we + // don't want to navigate to the details_extra view. + var all_hidden = data.category_extra_json.reduce(function(accumulator, field) { + return accumulator && (field.automated === "hidden_field"); + }, true); + + if (all_hidden) { + that.navigate( that.next ); + } else { + that.model.set('category_extras', data.category_extra); + that.navigate('details_extra'); + } } else { that.navigate( that.next ); } |