MCPcopy Index your code
hub / github.com/bugy/script-server / findField

Function findField

web-src/tests/unit/admin/ParameterConfigForm_test.js:29–48  ·  view source on GitHub ↗
(form, expectedName, failOnMissing = true)

Source from the content-addressed store, hash-verified

27}
28
29export const findField = (form, expectedName, failOnMissing = true) => {
30 for (const child of form.$children) {
31 let fieldName;
32 if (child.$options._componentTag === ChipsList.name) {
33 fieldName = child.title;
34 } else if (child.$options._componentTag === ScriptField.name) {
35 fieldName = child.scriptPathField.name;
36 } else {
37 fieldName = child.$props.config?.name;
38 }
39
40 if (!isNull(fieldName) && (fieldName.toLowerCase() === expectedName.toLowerCase())) {
41 return child;
42 }
43 }
44
45 if (failOnMissing) {
46 throw Error('Failed to find field: ' + expectedName)
47 }
48};
49
50export const findUiMappingFields = (form, failOnMissing = true) => {
51 const mappingComponent = form.findComponent(ParameterValuesUiMapping)

Callers 4

_findFieldFunction · 0.90
setValueByUserFunction · 0.85
findFieldInputElementFunction · 0.85
_findFieldFunction · 0.85

Calls 1

isNullFunction · 0.90

Tested by

no test coverage detected