Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NMRL-285 ReferenceException while creating Analysis Request: Invalid target UID #104

Merged
merged 4 commits into from
May 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions bika/lims/skins/bika/bika_widgets/referencewidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
});
save_UID_check();
check_UID_check();
check_missing_UID();

load_addbutton_overlays();
load_editbutton_overlays();
});
Expand Down Expand Up @@ -61,23 +63,6 @@ function referencewidget_lookups(elements) {
continue;
}

// Prevent from saving previous record when input value is empty
// By default, a recordwidget input element gets an empty value
// when receives the focus, so the underneath values must be
// cleared too.
// var elName = $(element).attr("name");
// $("input[name='"+elName+"']").live("focusin", function(){
// var fieldName = $(this).attr("name");
// if($(this).val() || $(this).val().length===0){
// var val = $(this).val();
// var uid = $(this).attr("uid");
// $(this).val("");
// $(this).attr("uid", "");
// $("input[name='"+fieldName+"_uid']").val("");
// $(this).trigger("unselected", [val,uid]);
// }
// });

options.select = function (event, ui) {
event.preventDefault();
var fieldName = $(this).attr("name");
Expand Down Expand Up @@ -206,6 +191,30 @@ function check_UID_check() {
});
}


function check_missing_UID(){
/* This will remove the display value (the text-input value) if the
uid attribute OR the *_uid hidden field, have no value.

If the display value is removed, then also verify that both the uid attr
and the _uid hidden field are both blanked!
*/
$.each($(".ArchetypesReferenceWidget").children("input.referencewidget"),
function (index, field) {
var uid = $(this).attr("uid");
var fieldName = $(this).attr("fieldName");
var _uidinput = $("input[name^='" + fieldName + "_uid']");
var _uid = $(_uidinput).val();
if (!uid || uid == undefined || uid == ""
|| !_uid || _uid == undefined || _uid == ""){
$(field).val("");
$(field).attr("uid", "");
$(_uidinput).val("");
}
}
)
}

function apply_button_overlay(button) {
/**
* Given an element (button), this function sets its overlay options.
Expand Down