Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sortOptions() {
const { component } = this.props;
if (component && component.get('form')) {
const form = component.get('form');
const fieldsCanAccess = access.fieldsCanAccess('read', form);
const fields = [];
form.eachField(field => {
const name = field.get('name');
// Do we have access to the field? Allowed to sort? Not hidden? Not a button?
if (
fieldsCanAccess[name] !== undefined &&
!field.get('forbidSort') &&
!field.get('hidden') &&
!(field instanceof ButtonField)
) {
fields.push({
value: (form.isDefaultField(name) ? '' : 'fieldValues.') + name,
label: field.get('label')
});
}
calcFieldsCanAccess() {
const { component, mode } = this.props;
const canDowngrade = true;
const fieldsCanAccess = access.fieldsCanAccess(
// Default to update so that access control has a sensible default
mode ? mode : 'update',
component,
null,
canDowngrade
);
// We need to set the ignoreErrs state as there may be a field that is not accessible that is
// generating an error.
for (const field of component.getFields()) {
const ignoreErrs = fieldsCanAccess[field.get('name')] === undefined;
field.set({ ignoreErrs });
}
return fieldsCanAccess;
}