Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async init() {
if(this.independant) {
this.mount(this.props);
this.ready = true;
}
else {
if(this.entityKey) {
await this.get();
this.ready = true;
}
else logError('no entity key provided');
}
},
redirectToList() {
async init() {
if(this.independant) {
this.mount(this.props);
this.ready = true;
}
else {
if(this.entityKey) {
await this.get();
this.setupActionBar();
this.ready = true;
}
else logError('no entity key provided');
}
},
render(h, { props, injections, data }) {
let { fieldKey,
contextFields,
contextData,
errorIdentifier,
updateVisibility,
...sharedProps } = props;
let { $form } = injections;
let field = contextFields[fieldKey];
let value = contextData[fieldKey];
if(!(fieldKey in contextFields)) {
logError(`Field display ('layout') : Can't find a field with key '${fieldKey}' in 'fields'`,contextFields);
return h(UnknownField, { props: { name: fieldKey } });
}
let isVisible = acceptCondition(contextFields, contextData, field.conditionalDisplay);
updateVisibility && updateVisibility(fieldKey, isVisible);
return isVisible ? h(FieldContainer, {
...data,
attrs: {
fieldKey,
fieldProps: field,
fieldType: field.type,
value: getValue($form, field, value, props.locale),
originalValue: value,
label: field.label,
updateError(errors) {
let error = errors[this.mergedErrorIdentifier];
if(error == null) {
this.clear();
}
else if(Array.isArray(error)) {
this.setError(error[0]);
}
else {
logError(`FieldContainer : Not processable error "${this.mergedErrorIdentifier}" : `, error);
}
},
setError(error) {
render(h) {
if(!this.component) {
let message = this.isCustom
? `unknown custom field type '${this.fieldType}', make sure you register it correctly`
: `unknown type '${this.fieldType}'`;
logError(`SharpField '${this.fieldKey}': ${message}`, this.fieldProps);
return null;
}
let { key, ...fieldProps } = this.fieldProps;
return h(this.component, {
props : {
fieldKey: this.fieldKey,
fieldLayout: this.fieldLayout,
value: this.value,
locale: this.locale,
uniqueIdentifier: this.uniqueIdentifier,
fieldConfigIdentifier: this.fieldConfigIdentifier,
...fieldProps
},