From 7884a8f51fccc2fcaca88c9e8229b2b3af5fc1df Mon Sep 17 00:00:00 2001 From: Shubham Goyal Date: Wed, 15 May 2024 13:44:17 +0530 Subject: [PATCH 01/76] abstract to displayErrors --- .../js/formplayer/menus/views/query.js | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js index 79521cf09174..83a3ddf5462d 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js @@ -796,34 +796,16 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", [ validateAllFields: function () { var self = this; var promise = $.Deferred(); - var invalidFields = []; var updatingModels = self.updateModelsForValidation || self._updateModelsForValidation(); $.when(updatingModels).done(function (response) { - // Gather error messages - self._getChildren().forEach(function (childView) { - if (!childView.isValid()) { - invalidFields.push(childView.model.get('text')); - } - }); - - // Display error messages - FormplayerFrontend.trigger('clearNotifications'); - if (invalidFields.length) { - var errorHTML = gettext("Please check the following fields:"); - errorHTML += ""; - FormplayerFrontend.trigger('showError', errorHTML, true, false); - } - + var invalidFields = self.displayErrors(); if (invalidFields.length) { promise.reject(response); } else { promise.resolve(response); } }); - return promise; }, @@ -868,6 +850,28 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", [ return promise; }, + displayErrors: function () { + var self = this; + // Gather error messages + var invalidFields = []; + self._getChildren().forEach(function (childView) { + if (!childView.isValid()) { + invalidFields.push(childView.model.get('text')); + } + }); + + // Display error messages + FormplayerFrontend.trigger('clearNotifications'); + if (invalidFields.length) { + var errorHTML = gettext("Please check the following fields:"); + errorHTML += ""; + FormplayerFrontend.trigger('showError', errorHTML, true, false); + } + return invalidFields; + }, + setStickyQueryInputs: function () { formplayerUtils.setStickyQueryInputs(this.getAnswers()); }, From bc6e2cf4324ae0511bb51b335a9c168f6f8dfa1f Mon Sep 17 00:00:00 2001 From: Shubham Goyal Date: Wed, 15 May 2024 14:16:40 +0530 Subject: [PATCH 02/76] abstract to updateModels --- .../js/formplayer/menus/views/query.js | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js index 83a3ddf5462d..0b086f64e6fb 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js @@ -824,25 +824,7 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", [ urlObject.setRequestInitiatedByTag(initiatedByTag); var fetchingPrompts = FormplayerFrontend.getChannel().request("app:select:menus", urlObject); $.when(fetchingPrompts).done(function (response) { - // Update models based on response - if (response.queryResponse) { - _.each(response.queryResponse.displays, function (responseModel, i) { - self._getChildModels()[i].set({ - error: responseModel.error, - required: responseModel.required, - required_msg: responseModel.required_msg, - }); - }); - } else { - _.each(response.models, function (responseModel, i) { - const childModels = self._getChildModels(); - childModels[i].set({ - error: responseModel.get('error'), - required: responseModel.get('required'), - required_msg: responseModel.get('required_msg'), - }); - }); - } + self.updateModels(response); promise.resolve(response); }); @@ -872,6 +854,29 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", [ return invalidFields; }, + updateModels: function (response) { + var self = this; + // Update models based on response + if (response.queryResponse) { + _.each(response.queryResponse.displays, function (responseModel, i) { + self._getChildModels()[i].set({ + error: responseModel.error, + required: responseModel.required, + required_msg: responseModel.required_msg, + }); + }); + } else { + _.each(response.models, function (responseModel, i) { + const childModels = self._getChildModels(); + childModels[i].set({ + error: responseModel.get('error'), + required: responseModel.get('required'), + required_msg: responseModel.get('required_msg'), + }); + }); + } + }, + setStickyQueryInputs: function () { formplayerUtils.setStickyQueryInputs(this.getAnswers()); }, From 7e8f6c68bca4245d64a1603b0507dae17f3b1e88 Mon Sep 17 00:00:00 2001 From: Shubham Goyal Date: Wed, 22 May 2024 16:21:17 +0530 Subject: [PATCH 03/76] convert menu:query to request and have it reply with a promise --- .../js/formplayer/menus/views/query.js | 29 ++++++++++++------- .../static/cloudcare/js/formplayer/router.js | 6 ++-- .../js/formplayer/spec/utils_spec.js | 2 +- docs/web_apps.rst | 2 +- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js index 0b086f64e6fb..c2b3b454c84b 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js @@ -746,20 +746,27 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", [ performSubmit: function (initiatedBy) { var self = this; - self.validateAllFields().done(function () { - FormplayerFrontend.trigger( - "menu:query", - self.getAnswers(), - self.options.sidebarEnabled, - initiatedBy - ); - if (self.smallScreenEnabled && self.options.sidebarEnabled) { - $('#sidebar-region').collapse('hide'); - } - sessionStorage.submitPerformed = true; + self.executeSearch(initiatedBy).done(function (response) { + self.updateModels(response); + self.displayErrors(); }); }, + executeSearch: function (initiatedBy) { + var request = FormplayerFrontend.getChannel().request( + "menu:query", + self.getAnswers(), + self.options.sidebarEnabled, + initiatedBy + ); + + if (self.smallScreenEnabled && self.options.sidebarEnabled) { + $('#sidebar-region').collapse('hide'); + } + sessionStorage.submitPerformed = true; + return request; + }, + updateSearchResults: function () { var self = this; var invalidRequiredFields = []; diff --git a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/router.js b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/router.js index 3ff424483fab..f052a9daee15 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/router.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/router.js @@ -76,7 +76,7 @@ hqDefine("cloudcare/js/formplayer/router", [ // We can't do any menu navigation without an appId FormplayerFrontend.trigger("apps:list"); } else { - menusController.selectMenu(urlObject); + return menusController.selectMenu(urlObject); } }, listUsers: function (page, query) { @@ -226,7 +226,7 @@ hqDefine("cloudcare/js/formplayer/router", [ API.listMenus(); }); - FormplayerFrontend.on("menu:query", function (queryDict, sidebarEnabled, initiatedByTag) { + FormplayerFrontend.getChannel().reply("menu:query", function (queryDict, sidebarEnabled, initiatedByTag) { var urlObject = utils.currentUrlToObject(); var queryObject = _.extend( { @@ -243,7 +243,7 @@ hqDefine("cloudcare/js/formplayer/router", [ urlObject.setRequestInitiatedByTag(initiatedByTag); let encodedUrl = utils.objectToEncodedUrl(urlObject.toJson()); sessionStorage.removeItem('selectedValues'); - API.listMenus(encodedUrl); + return API.listMenus(encodedUrl); }); FormplayerFrontend.on('restore_as:list', function () { diff --git a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/spec/utils_spec.js b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/spec/utils_spec.js index dca2054e97f4..471f8fcc5a55 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/spec/utils_spec.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/spec/utils_spec.js @@ -244,7 +244,7 @@ hqDefine("cloudcare/js/formplayer/spec/utils_spec", [ assert.equal(response.type, "query"); assert.deepEqual(_.pluck(response.displays, 'id'), ['dob']); - FormplayerFrontend.trigger("menu:query", {dob: "2010-01-19"}); + FormplayerFrontend.getChannel().request("menu:query", {dob: "2010-01-19"}); let url = Utils.currentUrlToObject(); assert.deepEqual(url.selections, ['1', 'action 0']); assert.deepEqual(_.keys(url.queryData), ["search_command.m1"]); diff --git a/docs/web_apps.rst b/docs/web_apps.rst index 1e446cb256bf..63795e897efa 100644 --- a/docs/web_apps.rst +++ b/docs/web_apps.rst @@ -323,7 +323,7 @@ Marionette `integrates with Backbone.Radio Date: Mon, 27 May 2024 10:36:01 +0530 Subject: [PATCH 04/76] correct self reference --- .../static/cloudcare/js/formplayer/menus/views/query.js | 1 + 1 file changed, 1 insertion(+) diff --git a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js index c2b3b454c84b..7b59c1977796 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js @@ -753,6 +753,7 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", [ }, executeSearch: function (initiatedBy) { + var self = this; var request = FormplayerFrontend.getChannel().request( "menu:query", self.getAnswers(), From 1a5d3abce99fb55aaca5b38b2457d2fb22e0a05a Mon Sep 17 00:00:00 2001 From: Shubham Goyal Date: Wed, 29 May 2024 14:14:18 +0530 Subject: [PATCH 05/76] return promise from selectMenu --- .../static/cloudcare/js/formplayer/menus/controller.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/controller.js b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/controller.js index b502e4ea982b..876678de08a1 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/controller.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/controller.js @@ -38,6 +38,7 @@ hqDefine("cloudcare/js/formplayer/menus/controller", [ options.preview = UsersModels.getCurrentUser().displayOptions.singleAppMode; var fetchingNextMenu = FormplayerFrontend.getChannel().request("app:select:menus", options); + var promise = $.Deferred(); /* Determine the next screen to display. Could be @@ -46,6 +47,7 @@ hqDefine("cloudcare/js/formplayer/menus/controller", [ */ $.when(fetchingNextMenu).done(function (menuResponse) { if (menuResponse.abort) { + promise.reject(); return; } @@ -62,6 +64,7 @@ hqDefine("cloudcare/js/formplayer/menus/controller", [ // If redirect was set, clear and go home. if (menuResponse.clearSession) { FormplayerFrontend.trigger("apps:currentApp"); + promise.reject(); return; } @@ -92,6 +95,7 @@ hqDefine("cloudcare/js/formplayer/menus/controller", [ FormplayerFrontend.trigger('showError', "Response did not contain appId even though it was" + "required. If this persists, please report an issue to CommCare HQ"); FormplayerFrontend.trigger("apps:list"); + promise.reject(); return; } urlObject.appId = menuResponse.appId; @@ -108,10 +112,13 @@ hqDefine("cloudcare/js/formplayer/menus/controller", [ menusUtils.handleLocationRequest(options); } menusUtils.startOrStopLocationWatching(menuResponse.shouldWatchLocation); + promise.resolve(menuResponse); }).fail(function () { // if it didn't go through, then it displayed an error message. // the right thing to do is then to just stay in the same place. + promise.reject(); }); + return promise; }; var selectDetail = function (caseId, detailIndex, isPersistent, isMultiSelect) { From 65d72b51ad5b52deba130f993dd6c38311315c0b Mon Sep 17 00:00:00 2001 From: robert-costello Date: Fri, 1 Nov 2024 16:41:13 -0400 Subject: [PATCH 06/76] add const to represent user clicking submit button --- .../apps/cloudcare/static/cloudcare/js/formplayer/constants.js | 1 + 1 file changed, 1 insertion(+) diff --git a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/constants.js b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/constants.js index bc0c79406460..0ef8102e1df0 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/constants.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/constants.js @@ -37,6 +37,7 @@ hqDefine("cloudcare/js/formplayer/constants", [], function () { FIELD_CHANGE: "field_change", PAGINATION: "pagination", CLICKABLE_ICON: "clickable_icon", + USER_CLICK_SUBMIT: "user_click_submit", }, //Custom Properties From d2cf66d79858c4586594f5a373760a7d5db22b4b Mon Sep 17 00:00:00 2001 From: robert-costello Date: Fri, 1 Nov 2024 16:41:59 -0400 Subject: [PATCH 07/76] display errors only if user clicks submit --- .../static/cloudcare/js/formplayer/menus/views/query.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js index 9a80ed64f92a..3edcd74fd30d 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js @@ -728,15 +728,17 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", [ submitAction: function (e) { var self = this; e.preventDefault(); - self.performSubmit(); + self.performSubmit(formplayerConstants.requestInitiatedByTagsMapping.USER_CLICK_SUBMIT); }, performSubmit: function (initiatedBy) { var self = this; self.executeSearch(initiatedBy).done(function (response) { self.updateModels(response); - self.displayErrors(); }); + if (initiatedBy === formplayerConstants.requestInitiatedByTagsMapping.USER_CLICK_SUBMIT) { + self.displayErrors(); + } }, executeSearch: function (initiatedBy) { From be0ac93655db2a8884adc20da4728259d6897f3f Mon Sep 17 00:00:00 2001 From: robert-costello Date: Thu, 7 Nov 2024 14:50:11 -0500 Subject: [PATCH 08/76] use separate const from datadog tags --- .../cloudcare/static/cloudcare/js/formplayer/constants.js | 3 ++- .../static/cloudcare/js/formplayer/menus/views/query.js | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/constants.js b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/constants.js index 0ef8102e1df0..7a5af7f77fa0 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/constants.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/constants.js @@ -37,9 +37,10 @@ hqDefine("cloudcare/js/formplayer/constants", [], function () { FIELD_CHANGE: "field_change", PAGINATION: "pagination", CLICKABLE_ICON: "clickable_icon", - USER_CLICK_SUBMIT: "user_click_submit", }, + USER_CLICK_SUBMIT: "userClickSubmit", + //Custom Properties POST_FORM_SYNC: "cc-sync-after-form", diff --git a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js index 3edcd74fd30d..bc285c4337d7 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js @@ -728,15 +728,15 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", [ submitAction: function (e) { var self = this; e.preventDefault(); - self.performSubmit(formplayerConstants.requestInitiatedByTagsMapping.USER_CLICK_SUBMIT); + self.performSubmit(null, formplayerConstants.USER_CLICK_SUBMIT); }, - performSubmit: function (initiatedBy) { + performSubmit: function (initiatedBy, userClickSubmit=null) { var self = this; self.executeSearch(initiatedBy).done(function (response) { self.updateModels(response); }); - if (initiatedBy === formplayerConstants.requestInitiatedByTagsMapping.USER_CLICK_SUBMIT) { + if (userClickSubmit === formplayerConstants.USER_CLICK_SUBMIT) { self.displayErrors(); } }, From 055e2b578a786b8a5e7e3d929f26996846604f41 Mon Sep 17 00:00:00 2001 From: robert-costello Date: Thu, 7 Nov 2024 15:18:40 -0500 Subject: [PATCH 09/76] lint --- .../static/cloudcare/js/formplayer/menus/views/query.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js index bc285c4337d7..abcb112ca637 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js @@ -731,7 +731,7 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", [ self.performSubmit(null, formplayerConstants.USER_CLICK_SUBMIT); }, - performSubmit: function (initiatedBy, userClickSubmit=null) { + performSubmit: function (initiatedBy, userClickSubmit = null) { var self = this; self.executeSearch(initiatedBy).done(function (response) { self.updateModels(response); From 4a73e0cc041a9c6fff24cd083f8382eebbecdc8a Mon Sep 17 00:00:00 2001 From: Minha Date: Wed, 4 Dec 2024 17:19:33 -0500 Subject: [PATCH 10/76] Add support for editing existing webuser invites --- corehq/apps/registration/forms.py | 30 ++++++-- .../static/users/js/custom_data_fields.js | 17 ++++- .../users/static/users/js/invite_web_user.js | 1 + .../apps/users/static/users/js/web_users.js | 4 + .../templates/users/invite_web_user.html | 1 + .../apps/users/templates/users/web_users.html | 9 ++- corehq/apps/users/urls.py | 1 + corehq/apps/users/views/__init__.py | 73 ++++++++++++++----- .../users/views/mobile/custom_data_fields.py | 8 +- corehq/tabs/tabclasses.py | 4 + 10 files changed, 118 insertions(+), 30 deletions(-) diff --git a/corehq/apps/registration/forms.py b/corehq/apps/registration/forms.py index 0caeffc1cd8c..6ea8422c3dad 100644 --- a/corehq/apps/registration/forms.py +++ b/corehq/apps/registration/forms.py @@ -494,7 +494,7 @@ class AdminInvitesUserForm(SelectUserLocationForm): def __init__(self, data=None, excluded_emails=None, is_add_user=None, role_choices=(), should_show_location=False, can_edit_tableau_config=False, - custom_data=None, *, domain, **kwargs): + custom_data=None, invitation=None, *, domain, **kwargs): self.custom_data = custom_data if data and self.custom_data: data = data.copy() @@ -519,11 +519,13 @@ def __init__(self, data=None, excluded_emails=None, is_add_user=None, programs = Program.by_domain(domain_obj.name) choices = [('', '')] + list((prog.get_id, prog.name) for prog in programs) self.fields['program'].choices = choices - + if invitation: + # not sure if this works - remove this comment after testing on staging + self.fields['program'].initial = invitation.program self.excluded_emails = [x.lower() for x in excluded_emails] if excluded_emails else [] if self.can_edit_tableau_config: - self._initialize_tableau_fields(data, domain) + self._initialize_tableau_fields(data, domain, invitation) self.helper = FormHelper() self.helper.form_method = 'POST' @@ -531,6 +533,12 @@ def __init__(self, data=None, excluded_emails=None, is_add_user=None, self.helper.label_class = 'col-sm-3 col-md-2' self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6' + + save_button_text = "Send Invite" + if invitation: + self.fields['email'].widget.attrs["readonly"] = True + save_button_text = "Update Invite" + fields = [ crispy.Fieldset( gettext("Information for new Web User"), @@ -574,8 +582,7 @@ def __init__(self, data=None, excluded_emails=None, is_add_user=None, ), hqcrispy.FormActions( twbscrispy.StrictButton( - (gettext("Add User") if is_add_user - else gettext("Send Invite")), + (gettext("Add User") if is_add_user else gettext(save_button_text)), type="submit", css_class="btn-primary", data_bind="enable: isSubmitEnabled", @@ -637,8 +644,17 @@ def clean(self): return cleaned_data - def _initialize_tableau_fields(self, data, domain): - self.tableau_form = BaseTableauUserForm(data, domain=domain) + def _initialize_tableau_fields(self, data, domain, invitation=None): + initial = {} + if invitation: + # For testing purposes only - not sure if this works + filterset = invitation.tableau_group_ids.filter() + indices = [index for index in filterset] + initial = { + 'tableau_role': invitation.tableau_role, + 'tableau_group_indices': indices, + } + self.tableau_form = BaseTableauUserForm(data, domain=domain, inital=initial) self.fields['tableau_group_indices'] = self.tableau_form.fields["groups"] self.fields['tableau_group_indices'].label = _('Tableau Groups') self.fields['tableau_role'] = self.tableau_form.fields['role'] diff --git a/corehq/apps/users/static/users/js/custom_data_fields.js b/corehq/apps/users/static/users/js/custom_data_fields.js index b06a9c9692de..4eb8877dfbcf 100644 --- a/corehq/apps/users/static/users/js/custom_data_fields.js +++ b/corehq/apps/users/static/users/js/custom_data_fields.js @@ -32,11 +32,12 @@ hqDefine("users/js/custom_data_fields", [ self.profile_slug = options.profile_slug; self.slugs = options.slugs; self.can_edit_original_profile = options.can_edit_original_profile; + self.initVals = options.initial_values; var originalProfileFields = {}, originalProfileId, originalProfile; - if (options.user_data) { + if (Object.keys(options.user_data).length) { originalProfileId = options.user_data[options.profile_slug]; if (originalProfileId) { originalProfile = self.profiles[originalProfileId]; @@ -44,11 +45,19 @@ hqDefine("users/js/custom_data_fields", [ originalProfileFields = originalProfile.fields; } } + } else if (Object.keys(self.initVals).length) { + originalProfileId = self.initVals['profile_id']; + originalProfile = self.profiles[originalProfileId]; + if (originalProfile) { + originalProfileFields = originalProfile.fields; + } } _.each(self.slugs, function (slug) { - self[slug] = fieldModel({ - value: options.user_data[slug] || originalProfileFields[slug], - }); + var value = options.user_data[slug] || originalProfileFields[slug]; + if (!value) { + value = self.initVals[slug]; + } + self[slug] = fieldModel({value: value}); }); self.serialize = function () { diff --git a/corehq/apps/users/static/users/js/invite_web_user.js b/corehq/apps/users/static/users/js/invite_web_user.js index 8aea316662ee..f35252fe6844 100644 --- a/corehq/apps/users/static/users/js/invite_web_user.js +++ b/corehq/apps/users/static/users/js/invite_web_user.js @@ -78,6 +78,7 @@ hqDefine('users/js/invite_web_user',[ profile_slug: initialPageData.get('custom_fields_profile_slug'), slugs: initialPageData.get('custom_fields_slugs'), can_edit_original_profile: true, + initial_values: initialPageData.get('initial_values'), }); } diff --git a/corehq/apps/users/static/users/js/web_users.js b/corehq/apps/users/static/users/js/web_users.js index adc46299d38f..cc94350a0e97 100644 --- a/corehq/apps/users/static/users/js/web_users.js +++ b/corehq/apps/users/static/users/js/web_users.js @@ -88,6 +88,10 @@ hqDefine("users/js/web_users",[ }); }; + self.inviteEditUrl = ko.computed(function () { + return initialPageData.reverse("edit_invitation", self.uuid); + }); + return self; }; diff --git a/corehq/apps/users/templates/users/invite_web_user.html b/corehq/apps/users/templates/users/invite_web_user.html index 70a88838ec43..f548f567eaa0 100644 --- a/corehq/apps/users/templates/users/invite_web_user.html +++ b/corehq/apps/users/templates/users/invite_web_user.html @@ -9,6 +9,7 @@ {% initial_page_data 'custom_fields_slugs' custom_fields_slugs %} {% initial_page_data 'custom_fields_profiles' custom_fields_profiles %} {% initial_page_data 'custom_fields_profile_slug' custom_fields_profile_slug %} + {% initial_page_data 'initial_values' initial_values %} {% registerurl "check_sso_trust" domain %}
{% blocktrans with hq_name=commcare_hq_names.COMMCARE_HQ_NAME cc_name=commcare_hq_names.COMMCARE_NAME %} @@ -270,10 +271,16 @@

{% trans 'Pending Invitations' {% if not request.is_view_only %}
+ + +