backoffice: lock prefilled user fill after user selection (#73784) #59
|
@ -1687,7 +1687,13 @@ def test_backoffice_submission_user_selection_then_live_prefill(pub):
|
|||
assert resp.pyquery('.submit-user-selection')
|
||||
resp.form['user_id'] = str(random_user.id) # happens via javascript
|
||||
live_resp = app.post(live_url + '?modified_field_id=user', params=resp.form.submit_fields())
|
||||
assert live_resp.json == {'result': {'3': {'visible': True, 'content': 'test9@invalid'}}}
|
||||
assert live_resp.json == {'result': {'3': {'visible': True, 'content': 'test9@invalid', 'locked': False}}}
|
||||
|
||||
# check with locked field
|
||||
formdef.fields[1].prefill['locked'] = True
|
||||
formdef.store()
|
||||
live_resp = app.post(live_url + '?modified_field_id=user', params=resp.form.submit_fields())
|
||||
assert live_resp.json == {'result': {'3': {'visible': True, 'content': 'test9@invalid', 'locked': True}}}
|
||||
|
||||
|
||||
def test_backoffice_submission_user_selection_then_card_data_source(pub):
|
||||
|
|
|
@ -948,8 +948,9 @@ class FormStatusPage(Directory, FormTemplateMixin):
|
|||
elif field.get_prefill_configuration().get('type') == 'user':
|
||||
update_prefill = bool(get_request().form.get('modified_field_id') == 'user')
|
||||
if update_prefill:
|
||||
value = field.get_prefill_value(user=formdata.user)[0]
|
||||
value, locked = field.get_prefill_value(user=formdata.user)
|
||||
entry['content'] = value
|
||||
entry['locked'] = locked
|
||||
|
||||
return json.dumps({'result': result})
|
||||
|
||||
|
|
|
@ -611,6 +611,10 @@ $(function() {
|
|||
$(widget).find('input[type=radio]').prop('checked', false);
|
||||
$(widget).find('input[type=radio][value="'+value.content+'"]').prop('checked', true);
|
||||
}
|
||||
if (data.modified_field == 'user' && value.locked) {
|
||||
$(widget).addClass('widget-readonly');
|
||||
$(widget).find('input').attr('readonly', 'readonly');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue