Extract managed form elements from XML
This commit is contained in:
@@ -3338,15 +3338,33 @@ function buildIdeFormElements(form: ProjectWorkspaceData["forms"][number] | unde
|
||||
return explicitElements.map((element, index) => ({
|
||||
id: element.lineage_id || `element.${index}`,
|
||||
name: element.name,
|
||||
caption: element.name,
|
||||
controlKind: controlKindForFormNode(element.name, element.kind),
|
||||
binding: element.qualified_name || element.name,
|
||||
width: "stretch"
|
||||
caption: formElementString(element.attributes, ["caption", "title", "synonym"]) ?? element.name,
|
||||
controlKind: controlKindForFormNode(element.name, formElementString(element.attributes, ["control_kind", "control", "type", "kind"]) ?? element.kind),
|
||||
binding: formElementString(element.attributes, ["binding", "dataPath", "data_path", "path"]) ?? element.qualified_name ?? element.name,
|
||||
width: formElementWidth(element.attributes, index)
|
||||
}));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
function formElementString(attributes: Record<string, unknown>, keys: string[]): string | null {
|
||||
for (const key of keys) {
|
||||
const value = attributes[key];
|
||||
if (typeof value === "string" && value.trim()) {
|
||||
return value.trim();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function formElementWidth(attributes: Record<string, unknown>, index: number): IdeFormElementDraft["width"] {
|
||||
const raw = formElementString(attributes, ["width", "layout_width", "placement"]);
|
||||
if (raw === "half" || raw === "third" || raw === "stretch") {
|
||||
return raw;
|
||||
}
|
||||
return index < 2 ? "half" : "stretch";
|
||||
}
|
||||
|
||||
function controlKindForFormNode(name: string, kind: string): IdeFormElementDraft["controlKind"] {
|
||||
const normalized = `${name} ${kind}`.toLowerCase();
|
||||
if (normalized.includes("таб") || normalized.includes("table")) return "table";
|
||||
|
||||
@@ -772,7 +772,10 @@ export function ProjectSetupClient({ initialSetup }: Readonly<{ initialSetup: Pr
|
||||
return;
|
||||
} else if (mode === "reindex") {
|
||||
setLastSyncPreview(null);
|
||||
await postJson(`/api/sfera/projects/${setup.project_id}/reindex`, undefined);
|
||||
const job = await postJson<OperationJob>(`/api/sfera/projects/${setup.project_id}/reindex/jobs`, undefined);
|
||||
setServerImportJob(job);
|
||||
keepImportRun = true;
|
||||
return;
|
||||
} else {
|
||||
setLastImportResult(null);
|
||||
setServerImportJob(null);
|
||||
|
||||
@@ -139,6 +139,7 @@ export type NamedNode = {
|
||||
kind: string;
|
||||
name: string;
|
||||
qualified_name: string;
|
||||
attributes: Record<string, unknown>;
|
||||
};
|
||||
|
||||
export type SourceLocation = {
|
||||
|
||||
Reference in New Issue
Block a user