import { SC, ReactComponent, DynamicForm } from 'smartclient-pro/react'; let isc = window.isc; SC.defineClass("EvolutionForm", DynamicForm); class EvolutionForm extends DynamicForm { static ISC_CLASS_NAME = "EvolutionForm"; static IS_CLASS = true; static PROPERTY_TYPES = { "overrideFieldsWidths": "Boolean", "applyParentWidth": "Boolean" }; static width = "100%"; static minHintWidth = 2; static colWidths = [20, "*"]; static overrideFieldsWidths = true; static applyParentWidth = false; static init = function () { this.Super("init", arguments); if (this.overrideFieldsWidths) { const cols = this.numCols || 2; for (const field of this.getFields()) { if (field.adaptWidth) { field.colSpan = cols; } } } }; static drawn = function () { if (this.overrideFieldsWidths) { EvolutionForm.setFieldsWidths(this); } }; static resized = function () { if (this.overrideFieldsWidths) { EvolutionForm.setFieldsWidths(this); } }; static setFieldsWidths(form) { setTimeout(() => { const patternWidth = form.applyParentWidth ? form.parentElement.getInnerWidth() : form.getInnerContentWidth(); if (form.prevWidth !== patternWidth) { form.prevWidth = patternWidth; const fields = form.getFields(); for (const field of fields) { if (field.adaptWidth) { const width = patternWidth - field.getVisibleTitleWidth(false); if (field.getWidth() !== width) { field.setWidth(width); if (field.canvas) { field.canvas.setWidth(width); } } } } if(form.itemsResized) { form.itemsResized(); } } }, 50); }; } isc.EvolutionForm.addProperties(EvolutionForm); Object.defineProperty(EvolutionForm, "name", { value: "EvolutionForm" }); ReactComponent.registerClass("EvolutionForm", EvolutionForm); export default EvolutionForm;