|
41 | 41 | import io.vertigo.core.lang.WrappedException;
|
42 | 42 | import io.vertigo.core.locale.LocaleManager;
|
43 | 43 | import io.vertigo.core.node.Node;
|
44 |
| -import io.vertigo.core.util.StringUtil; |
45 | 44 | import io.vertigo.datamodel.data.definitions.DataDefinition;
|
46 | 45 | import io.vertigo.datamodel.data.definitions.DataField;
|
47 | 46 | import io.vertigo.datamodel.smarttype.SmartTypeManager;
|
@@ -95,7 +94,7 @@ public static String contextKey(final UiObject<?> uiObject) {
|
95 | 94 | * @return Name in context (use for input name)
|
96 | 95 | */
|
97 | 96 | public static String generateComponentUID(final String component, final String object, final String field, final String row) {
|
98 |
| - final String prefix = component + |
| 97 | + final var prefix = component + |
99 | 98 | Long.toHexString(UUID.randomUUID().getLeastSignificantBits()) +
|
100 | 99 | "_";
|
101 | 100 | return contextGet(prefix, object, field, row, true);
|
@@ -240,20 +239,7 @@ public static String smartTypeAlign(final String object, final String fieldName,
|
240 | 239 | final var smartTypeDefinition = getDataField(object + '.' + fieldName).smartTypeDefinition();
|
241 | 240 | if (smartTypeDefinition.getScope().isBasicType()) {
|
242 | 241 | final var dataType = smartTypeDefinition.getBasicType();
|
243 |
| - switch (dataType) { |
244 |
| - case Long: |
245 |
| - case Integer: |
246 |
| - case Double: |
247 |
| - case BigDecimal: |
248 |
| - return "right"; |
249 |
| - case Boolean: |
250 |
| - case Instant: |
251 |
| - case LocalDate: |
252 |
| - case String: |
253 |
| - case DataStream: |
254 |
| - default: |
255 |
| - return "left"; |
256 |
| - } |
| 242 | + return dataType.isNumber() ? "right" : "left"; |
257 | 243 | }
|
258 | 244 | }
|
259 | 245 | return "left";
|
@@ -391,9 +377,9 @@ public static String getCurrentLocaleForQuasar() {
|
391 | 377 | public static String compileVueJsTemplate(final String template) {
|
392 | 378 | final var requestParameter = new JsonObject();
|
393 | 379 | requestParameter.add("template", new JsonPrimitive(template));
|
394 |
| - final JsonObject compiledTemplate = callRestWS("http://localhost:8083/", GSON.toJson(requestParameter), JsonObject.class); |
| 380 | + final var compiledTemplate = (JsonObject) callRestWS("http://localhost:8083/", GSON.toJson(requestParameter), JsonObject.class); |
395 | 381 | final var render = compiledTemplate.get("render").getAsString();
|
396 |
| - final List<String> staticRenderFns = StreamSupport.stream(compiledTemplate.get("staticRenderFns").getAsJsonArray().spliterator(), false) |
| 382 | + final var staticRenderFns = StreamSupport.stream(compiledTemplate.get("staticRenderFns").getAsJsonArray().spliterator(), false) |
397 | 383 | .map(JsonElement::getAsString)
|
398 | 384 | .toList();
|
399 | 385 |
|
@@ -482,25 +468,18 @@ private static DataField getDataField(final String fieldPath) {
|
482 | 468 | * @return the resolved field name
|
483 | 469 | */
|
484 | 470 | public static String resolveDisplayField(final String object, final String field) {
|
485 |
| - if (StringUtil.isBlank(object) || StringUtil.isBlank(field)) { |
486 |
| - return null; |
487 |
| - } |
488 |
| - |
| 471 | + Assertion.check() |
| 472 | + .isNotBlank(object) |
| 473 | + .isNotBlank(field); |
| 474 | + // --- |
489 | 475 | if (field.contains("_")) {
|
490 | 476 | return field; // we don't modify the field if it already contains a modifier
|
491 | 477 | }
|
492 |
| - |
493 | 478 | final var dataField = getDataField(object + "." + field);
|
494 |
| - final var basicType = dataField.smartTypeDefinition().getBasicType(); |
495 |
| - |
496 |
| - switch (basicType) { |
497 |
| - case BigDecimal: |
498 |
| - case Double: |
499 |
| - case Integer: |
500 |
| - case Long: |
501 |
| - return field + "_fmt"; |
502 |
| - default: |
503 |
| - return field; |
| 479 | + final var smartTypeDefinition = dataField.smartTypeDefinition(); |
| 480 | + if (smartTypeDefinition.getScope().isBasicType()) { |
| 481 | + return smartTypeDefinition.getBasicType().isNumber() ? field + "_fmt" : field; |
504 | 482 | }
|
| 483 | + return field; |
505 | 484 | }
|
506 | 485 | }
|
0 commit comments