View Customize Script Not Working
Closed this issue · 4 comments
Hello,
I am trying to get my view customize script to work. I have two custom fields in redmine. They are Product Family and Product. Product Family has 3 possible values. They are Lattice Public Site, NetVisit, and Nexus.
When Lattice Public Site is selected I only want to see PubSite, View&Agree and PREA displayed in the Product custom field... this works. When NetVisit is selected I only want to see Pin Acct, SchedulePage, and Scheduler displayed in the Product custom field.... this does not work. When Nexus is selected, I only want to see SPCHSRVR, NexMblSvc, and NEX displayed in the Product custom field.... this does not work. Can someone please help me with this? Here is my script:
$(function() {
var parentFieldId = 'issue_custom_field_values_24';
var childFieldId = 'issue_custom_field_values_2';
var isTarget = function(child, parent) {
var childText = child.text();
var NexusChild = (childText == 'SPCHSRVR' || childText == 'NexMblSvc' || childText == 'NEX');
var NetVisitChild = (childText == 'Pin Acct' || childText == 'SchedulePage' || childText == 'Scheduler');
var LPSChild = (childText == 'PubSite' || childText == 'View&Agree' || childText == 'PREA');
if (parent.text() == 'NEXUS') {
return NexusChild;
} else {
return !NexusChild;
}
if (parent.text() == 'NetVisit') {
return NetVisitChild;
} else {
return !NetVisitChild;
}
if (parent.text() == 'Lattice Public Site') {
return LPSChild;
} else {
return !LPSChild;
}
}
var narrowChildField = function() {
var parentSelected = $('#' + parentFieldId + ' > option:selected');
$('#' + childFieldId + ' > option').each(function() {
var child = $(this);
if (isTarget(child, parentSelected)) {
child.show();
child.prop('disabled', false);
} else {
child.hide();
child.prop('disabled', true);
}
});
}
narrowChildField();
$('#all_attributes').change(function(e) {
if (e.target.id == parentFieldId) {
narrowChildField();
}
});
var _replaceIssueFormWith = replaceIssueFormWith;
replaceIssueFormWith = function(html){
_replaceIssueFormWith(html);
narrowChildField();
};
});
Can anyone help me? Does anyone have any suggestions?
Hi @destiny931
The code seems to be wrong.
I think the following will be the correct code.
if (parent.text() == 'NEXUS') {
return NexusChild;
} else if (parent.text() == 'NetVisit') {
return NetVisitChild;
} else if (parent.text() == 'Lattice Public Site') {
return LPSChild;
} else {
return false;
}
This issue is stale because it has been open for 60 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.