MCPcopy Create free account
hub / github.com/pywebio/PyWebIO / gen_columns_def

Function gen_columns_def

webiojs/src/models/datatable.ts:89–123  ·  view source on GitHub ↗
(
        current_columns: { [field: string]: any },  // all leaf node is {}
        path: string[],
        field_args: { [field: string]: any },
        path_field_args: { [field: string]: any },
        args_from_parent: { [field: string]: any }
    )

Source from the content-addressed store, hash-verified

87
88
89 function gen_columns_def(
90 current_columns: { [field: string]: any }, // all leaf node is {}
91 path: string[],
92 field_args: { [field: string]: any },
93 path_field_args: { [field: string]: any },
94 args_from_parent: { [field: string]: any }
95 ) {
96 let column_def: any[] = [];
97 Object.keys(current_columns).forEach((key) => {
98 let val = current_columns[key];
99 path.push(key);
100 let path_field = path2field(path);
101 if (Object.keys(val).length > 0) {
102 let extra_args = {
103 ...args_from_parent,
104 ...(path_field_args[path_field] || {}),
105 };
106 column_def.push({
107 headerName: capitalizeFirstLetter(key.replace(/_/g, " ")),
108 children: gen_columns_def(val, path, field_args, path_field_args, extra_args)
109 });
110 } else {
111 let column = {
112 headerName: capitalizeFirstLetter(key.replace(/_/g, " ")),
113 field: path_field,
114 ...args_from_parent,
115 ...(field_args[key] || {}),
116 ...(path_field_args[path_field] || {}),
117 };
118 column_def.push(column);
119 }
120 path.pop();
121 })
122 return column_def;
123 }
124
125 let columns = {};
126 let rows = [];

Callers 1

row_data_and_column_defFunction · 0.85

Calls 3

path2fieldFunction · 0.85
capitalizeFirstLetterFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…