use of org.sablo.specification.WebLayoutSpecification in project servoy-client by Servoy.
the class FormLayoutGenerator method generateFormStartTag.
public static void generateFormStartTag(PrintWriter writer, Form form, String realFormName, boolean responsiveMode, boolean design) {
if (design) {
writer.print("<div ng-controller='DesignFormController' id='svyDesignForm' ");
if (form.isResponsiveLayout()) {
List<String> allowedChildren = new ArrayList<String>();
Collection<PackageSpecification<WebLayoutSpecification>> values = WebComponentSpecProvider.getSpecProviderState().getLayoutSpecifications().values();
for (PackageSpecification<WebLayoutSpecification> specifications : values) {
for (WebLayoutSpecification specification : specifications.getSpecifications().values()) {
if (specification.isTopContainer()) {
allowedChildren.add(specification.getPackageName() + "." + specification.getName());
}
}
}
if (allowedChildren.size() > 0) {
String allowedChildrenJoin = String.join(",", allowedChildren);
writer.print(" svy-allowed-children=\"");
writer.print(allowedChildrenJoin);
writer.print("\"");
JSONObject ngClass = new JSONObject();
String dropHighlightCondition = "<canContainDraggedElement(";
if (allowedChildren.size() > 1) {
for (int i = 0; i < allowedChildren.size() - 1; i++) {
dropHighlightCondition += "'" + allowedChildren.get(i) + "', ";
}
}
dropHighlightCondition += "'" + allowedChildren.get(allowedChildren.size() - 1) + "'";
dropHighlightCondition += ")<";
// added <> tokens so that we can remove quotes around the values so that angular will evaluate at runtime
ngClass.put("drop_highlight", dropHighlightCondition);
writer.print(" ng-class='" + ngClass.toString().replaceAll("\"<", "").replaceAll("<\"", "").replaceAll("'", "\"") + "'");
}
}
} else
writer.print(String.format("<svy-formload formname=\"%1$s\"><div ng-controller=\"%1$s\" ", realFormName));
if (Utils.getAsBoolean(Settings.getInstance().getProperty("servoy.ngclient.testingMode", "false"))) {
writer.print(String.format("data-svy-name=\"%1$s\" ", realFormName));
}
if (!form.isResponsiveLayout() && !responsiveMode) {
writer.print("svy-formstyle=\"formStyle\" ");
} else if (design) {
// design form should grow with content and dictate the height to parent
writer.print(" style=\"min-height:100%\"");
}
writer.print("svy-layout-update svy-form-class-update svy-autosave ");
// skip the scrollbars for forms in tableview then the portal component does this
if (design || (form.getView() != IFormConstants.VIEW_TYPE_TABLE && form.getView() != IFormConstants.VIEW_TYPE_TABLE_LOCKED)) {
writer.print(" svy-scrollbars='formProperties.scrollbars'");
}
String formClass = "svy-form";
if (form.isResponsiveLayout()) {
formClass += " svy-respform";
}
if (form.getStyleClass() != null) {
formClass += " " + form.getStyleClass();
}
writer.print(" class=\"");
writer.print(formClass);
writer.print("\"");
writer.print(">");
}
Aggregations