diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/cobrands/fixmystreet/fixmystreet.js | 6 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/staff.js | 26 |
2 files changed, 32 insertions, 0 deletions
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index a4bab095e..9afb28294 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -128,6 +128,8 @@ function isR2L() { }); })(jQuery); +fixmystreet.hooks = fixmystreet.hooks || {}; + fixmystreet.mobile_reporting = { apply_ui: function() { // Creates the "app-like" mobile reporting UI with full screen map @@ -425,6 +427,10 @@ $.extend(fixmystreet.set_up, { $category_meta.empty(); } }); + + if (fixmystreet.hooks.update_problem_fields) { + fixmystreet.hooks.update_problem_fields($(this).data('role'), $(this).data('body'), args); + } }); }, diff --git a/web/cobrands/fixmystreet/staff.js b/web/cobrands/fixmystreet/staff.js index b92a70f9c..d808d4ad9 100644 --- a/web/cobrands/fixmystreet/staff.js +++ b/web/cobrands/fixmystreet/staff.js @@ -342,3 +342,29 @@ $.extend(fixmystreet.set_up, { }); } }); + +$.extend(fixmystreet.hooks, { + update_problem_fields: function(role, body, args) { + if (role == 'inspector') { + var title = args.category + ' problem has been scheduled for fixing'; + var description = args.category + ' problem found - scheduled for fixing by ' + body; + + var $title_field = $('#form_title'); + var $description_field = $('#form_detail'); + + if ($title_field.val().length === 0 || $title_field.data('autopopulated') === true) { + $title_field.val(title); + $title_field.data('autopopulated', true); + } + + if ($description_field.val().length === 0 || $description_field.data('autopopulated') === true) { + $description_field.val(description); + $description_field.data('autopopulated', true); + } + + $('#form_title, #form_detail').on('keyup', function() { + $(this).data('autopopulated', false); + }); + } + } +}); |