Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: d8b081ff by Tony Chemit at 2023-12-01T15:35:26+01:00 Review SubtractColum to a better null management - - - - - a88911d9 by Tony Chemit at 2023-12-01T15:54:38+01:00 Review first ColumnRendererConsumer (add null management + improve the code) - - - - - 44de672d by Tony Chemit at 2023-12-01T15:54:38+01:00 Rename html export configuration tab to metadata - - - - - 3f0ecbae by Tony Chemit at 2023-12-01T15:55:24+01:00 Improve report html export (now fill the hole cell :)) - - - - - bbeeac87 by Tony Chemit at 2023-12-01T16:06:32+01:00 Merge branch 'feature/issue-2811' into develop Définir les règles de mise en forme conditionnelle sur les tableaux de synthèse - Closes #2811 - - - - - 7e08d2ef by Tony Chemit at 2023-12-01T16:08:17+01:00 Add client configuration option skipConsolidateStepForReport - Closes #281x ? - - - - - 19 changed files: - client/configuration/src/main/config/Client.ini - client/configuration/src/main/i18n/getters/config.getter - client/core/src/main/java/fr/ird/observe/client/main/body/ClientConfigUI.java - client/datasource/actions/src/main/i18n/templates/reportHtmlExport_en_GB.ftl - client/datasource/actions/src/main/i18n/templates/reportHtmlExport_es_ES.ftl - client/datasource/actions/src/main/i18n/templates/reportHtmlExport_fr_FR.ftl - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/consolidate/ConsolidateModel.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/consolidate/actions/Start.java - client/runner/src/main/i18n/translations/client-runner_en_GB.properties - client/runner/src/main/i18n/translations/client-runner_es_ES.properties - client/runner/src/main/i18n/translations/client-runner_fr_FR.properties - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psLogbookWellPlanCheck.properties - toolkit/api-report/src/main/java/fr/ird/observe/report/ColumnRendererConsumer.java - toolkit/api-report/src/main/java/fr/ird/observe/report/operations/SubtractColum.java - toolkit/api-report/src/main/java/fr/ird/observe/report/renderers/HighlightIfAbsoluteDeltaIsPositive.java - toolkit/api-report/src/main/java/fr/ird/observe/report/renderers/HighlightIfNumericalValueIsPositive.java - toolkit/api-report/src/main/resources/fr/ird/observe/report/renderers/HighlightIfAbsoluteDeltaIsPositive.js - toolkit/api-report/src/main/resources/fr/ird/observe/report/renderers/HighlightIfNotI18nReferentialValue.js - toolkit/api-report/src/main/resources/fr/ird/observe/report/renderers/HighlightIfNumericalValueIsPositive.js Changes: ===================================== client/configuration/src/main/config/Client.ini ===================================== @@ -1047,6 +1047,12 @@ key = ui.tree.config.node.unsaved.color type = color defaultValue = java.awt.Color[r=255,g=0,b=0] +[option skipConsolidateStepForReport] +description = observe.config.ui.actions.report.skipConsolidateStep +key = ui.actions.report.skipConsolidateStep +type = Boolean +defaultValue = false + [action adminUi] description = observe.ui.action.commandline.launch.admin.ui action = fr.ird.observe.client.ObserveCLAction#launchAdminUI ===================================== client/configuration/src/main/i18n/getters/config.getter ===================================== @@ -121,6 +121,7 @@ observe.config.swingPreferencesFile.description observe.config.swingSessionFile.description observe.config.temperature.format observe.config.temporaryDirectory.description +observe.config.ui.actions.report.skipConsolidateStep observe.config.ui.autoPopupNumberEditor observe.config.ui.autoSelectText observe.config.ui.blockStateColor ===================================== client/core/src/main/java/fr/ird/observe/client/main/body/ClientConfigUI.java ===================================== @@ -408,6 +408,7 @@ public class ClientConfigUI extends JXTitledPanel implements WithClientUIContext helper.addOption(ClientConfigOption.SHOW_SQL); helper.addOption(ClientConfigOption.USE_JVM_KEY_STORE); + helper.addOption(ClientConfigOption.SKIP_CONSOLIDATE_STEP_FOR_REPORT); } ===================================== client/datasource/actions/src/main/i18n/templates/reportHtmlExport_en_GB.ftl ===================================== @@ -40,6 +40,7 @@ margin-right: 10px; } + <#--noinspection CssUnusedSymbol--> td.gridjs-td { background-color: transparent; } @@ -61,28 +62,44 @@ color: #fff; } + tr:hover td[class~="cellNull"] { + background-color: rgb(160, 160, 160); + } + + tr:hover td[class~="cellWarning"] { + background-color: rgb(255, 175, 10); + } + + tr:hover td[class~="cellError"] { + background-color: rgb(255, 10, 10); + } + + <#--noinspection CssUnusedSymbol--> + td.cellNull { + background-color: rgb(128, 128, 128); + } <#--noinspection CssUnusedSymbol--> - .cellWarning { - background-color: orange; + td.cellWarning { + background-color: rgb(255, 165, 0); } - <#-- <#–noinspection CssUnusedSymbol–>--> - <#-- td:has(span.cellWarning):before {--> - <#-- padding-right: 8px;--> - <#-- content: "\26A0";--> - <#-- }--> +<#-- <#–noinspection CssUnusedSymbol–>--> +<#-- td:has(span.cellWarning):before {--> +<#-- padding-right: 8px;--> +<#-- content: "\26A0";--> +<#-- }--> <#--noinspection CssUnusedSymbol--> - .cellError { - background-color: red; + td.cellError { + background-color: rgb(255, 0, 0); } - <#-- <#–noinspection CssUnusedSymbol–>--> - <#-- td:has(span.cellError):before {--> - <#-- padding-right: 8px;--> - <#-- content: "\26D4";--> - <#-- }--> +<#-- <#–noinspection CssUnusedSymbol–>--> +<#-- td:has(span.cellError):before {--> +<#-- padding-right: 8px;--> +<#-- content: "\26D4";--> +<#-- }--> .widget { position: relative; @@ -257,7 +274,7 @@ } <#list .data_model.columnRendererFunctions as key> - ${key}</#list> +${key}</#list> function createColumns(json) { let result = !!json["columnNames"] ? json["columnNames"] : []; @@ -266,6 +283,7 @@ } let renderers = json["columnRendererDefinitions"]; let i = 0; + let data = json.data; <#list .data_model.columnRendererInitCode as value> ${value}</#list> return result; @@ -323,7 +341,7 @@ </div> </div> <ul class="widget-tabs"> - <li class="widget-tab"><a href="#tab-configuration" class="widget-tab-link">Configuration</a> + <li class="widget-tab"><a href="#tab-configuration" class="widget-tab-link">Metadata</a> <li class="widget-tab"><a href="#tab-result" class="widget-tab-link">Result</a> </ul> </div> ===================================== client/datasource/actions/src/main/i18n/templates/reportHtmlExport_es_ES.ftl ===================================== @@ -40,6 +40,7 @@ margin-right: 10px; } + <#--noinspection CssUnusedSymbol--> td.gridjs-td { background-color: transparent; } @@ -61,28 +62,44 @@ color: #fff; } + tr:hover td[class~="cellNull"] { + background-color: rgb(160, 160, 160); + } + + tr:hover td[class~="cellWarning"] { + background-color: rgb(255, 175, 10); + } + + tr:hover td[class~="cellError"] { + background-color: rgb(255, 10, 10); + } <#--noinspection CssUnusedSymbol--> - .cellWarning { - background-color: orange; + td.cellNull { + background-color: rgb(128, 128, 128); } - <#-- <#–noinspection CssUnusedSymbol–>--> - <#-- td:has(span.cellWarning):before {--> - <#-- padding-right: 8px;--> - <#-- content: "\26A0";--> - <#-- }--> + <#--noinspection CssUnusedSymbol--> + td.cellWarning { + background-color: rgb(255, 165, 0); + } + +<#-- <#–noinspection CssUnusedSymbol–>--> +<#-- td:has(span.cellWarning):before {--> +<#-- padding-right: 8px;--> +<#-- content: "\26A0";--> +<#-- }--> <#--noinspection CssUnusedSymbol--> - .cellError { - background-color: red; + td.cellError { + background-color: rgb(255, 0, 0); } - <#-- <#–noinspection CssUnusedSymbol–>--> - <#-- td:has(span.cellError):before {--> - <#-- padding-right: 8px;--> - <#-- content: "\26D4";--> - <#-- }--> +<#-- <#–noinspection CssUnusedSymbol–>--> +<#-- td:has(span.cellError):before {--> +<#-- padding-right: 8px;--> +<#-- content: "\26D4";--> +<#-- }--> .widget { position: relative; @@ -257,7 +274,7 @@ } <#list .data_model.columnRendererFunctions as key> - ${key}</#list> +${key}</#list> function createColumns(json) { let result = !!json["columnNames"] ? json["columnNames"] : []; @@ -266,6 +283,7 @@ } let renderers = json["columnRendererDefinitions"]; let i = 0; + let data = json.data; <#list .data_model.columnRendererInitCode as value> ${value}</#list> return result; @@ -310,7 +328,6 @@ </ul> </div> <div class="widget-list" id="tab-result"> - <div class="config-panel"> <label><input id="search" type="checkbox" checked/> Search</label>| <label><input id="resizable" type="checkbox" checked/> Resizable columns</label>| @@ -323,10 +340,11 @@ </div> </div> <ul class="widget-tabs"> - <li class="widget-tab"><a href="#tab-configuration" class="widget-tab-link">Configuration</a> + <li class="widget-tab"><a href="#tab-configuration" class="widget-tab-link">Metadata</a> <li class="widget-tab"><a href="#tab-result" class="widget-tab-link">Result</a> </ul> </div> + <script type="application/javascript"> const json = ${.data_model.json}; ===================================== client/datasource/actions/src/main/i18n/templates/reportHtmlExport_fr_FR.ftl ===================================== @@ -63,9 +63,26 @@ color: #fff; } + tr:hover td[class~="cellNull"] { + background-color: rgb(160, 160, 160); + } + + tr:hover td[class~="cellWarning"] { + background-color: rgb(255, 175, 10); + } + + tr:hover td[class~="cellError"] { + background-color: rgb(255, 10, 10); + } + + <#--noinspection CssUnusedSymbol--> + td.cellNull { + background-color: rgb(128, 128, 128); + } + <#--noinspection CssUnusedSymbol--> - .cellWarning { - background-color: orange; + td.cellWarning { + background-color: rgb(255, 165, 0); } <#-- <#–noinspection CssUnusedSymbol–>--> @@ -75,8 +92,8 @@ <#-- }--> <#--noinspection CssUnusedSymbol--> - .cellError { - background-color: red; + td.cellError { + background-color: rgb(255, 0, 0); } <#-- <#–noinspection CssUnusedSymbol–>--> @@ -267,6 +284,7 @@ ${key}</#list> } let renderers = json["columnRendererDefinitions"]; let i = 0; + let data = json.data; <#list .data_model.columnRendererInitCode as value> ${value}</#list> return result; @@ -323,7 +341,7 @@ ${key}</#list> </div> </div> <ul class="widget-tabs"> - <li class="widget-tab"><a href="#tab-configuration" class="widget-tab-link">Configuration</a> + <li class="widget-tab"><a href="#tab-configuration" class="widget-tab-link">Méta-données</a> <li class="widget-tab"><a href="#tab-result" class="widget-tab-link">Résultat</a> </ul> </div> ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/consolidate/ConsolidateModel.java ===================================== @@ -53,6 +53,7 @@ public class ConsolidateModel extends AdminActionModel { private boolean consolidationFailIfLengthWeightParameterNotFound; private boolean consolidationFailIfLengthLengthParameterNotFound; + private boolean skipForReport; public ConsolidateModel() { super(AdminStep.CONSOLIDATE); @@ -87,6 +88,7 @@ public class ConsolidateModel extends AdminActionModel { setConsolidationFailIfLengthWeightParameterNotFound(getClientConfig().isConsolidationFailIfLengthWeightParameterNotFound()); setConsolidationFailIfLengthLengthParameterNotFound(getClientConfig().isConsolidationFailIfLengthLengthParameterNotFound()); + uiModel.getConsolidateModel().setSkipForReport(getClientConfig().isSkipConsolidateStepForReport()); } @Override @@ -121,4 +123,12 @@ public class ConsolidateModel extends AdminActionModel { this.consolidationFailIfLengthLengthParameterNotFound = consolidationFailIfLengthLengthParameterNotFound; firePropertyChange("consolidationFailIfLengthLengthParameterNotFound", oldValue, consolidationFailIfLengthLengthParameterNotFound); } + + public boolean isSkipForReport() { + return skipForReport; + } + + public void setSkipForReport(boolean skipForReport) { + this.skipForReport = skipForReport; + } } ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/consolidate/actions/Start.java ===================================== @@ -87,7 +87,9 @@ public class Start extends AdminTabUIActionSupport<ConsolidateUI> { ConsolidateModel stepModel = ui.getStepModel(); AdminUIModel model = ui.getModel(); - + if (stepModel.isSkipForReport()) { + return WizardState.SUCCESSED; + } stepModel.setSource(model.getConfigModel().getLeftSourceModel().getSafeSource(false)); Set<String> tripIds = model.getSelectDataModel().getSelectionDataModel().getSelectedDataIds(); ===================================== client/runner/src/main/i18n/translations/client-runner_en_GB.properties ===================================== @@ -138,6 +138,7 @@ observe.config.swingPreferencesFile.description=Swing preferences file. observe.config.swingSessionFile.description=Swing session file. observe.config.temperature.format=Default temperature unit observe.config.temporaryDirectory.description=Default temporary directory used by application and clean at each launch. +observe.config.ui.actions.report.skipConsolidateStep=To skip consolidate step in action Report observe.config.ui.autoPopupNumberEditor=To auto popup on number editor when it acquires the focus observe.config.ui.autoSelectText=To auto select text in widgets when it acquires the focus observe.config.ui.blockStateColor=Color of block state ===================================== client/runner/src/main/i18n/translations/client-runner_es_ES.properties ===================================== @@ -138,6 +138,7 @@ observe.config.swingPreferencesFile.description=Swing preferences file. observe.config.swingSessionFile.description=Copia de seguridad del estado del UI. observe.config.temperature.format=Unidad de temperatura observe.config.temporaryDirectory.description=Directorio temporal por defecto +observe.config.ui.actions.report.skipConsolidateStep=To skip consolidate step in action Report \#TODO observe.config.ui.autoPopupNumberEditor=Para mostrar automáticamente el editor numérico durante la edición de un número observe.config.ui.autoSelectText=To auto select text in widgets when it acquires the focus \#TODO observe.config.ui.blockStateColor=Color of block state \#TODO ===================================== client/runner/src/main/i18n/translations/client-runner_fr_FR.properties ===================================== @@ -138,6 +138,7 @@ observe.config.swingPreferencesFile.description=Fichier de sauvegarde des préf observe.config.swingSessionFile.description=Fichier de sauvegarde des états des UI. observe.config.temperature.format=Unité de température observe.config.temporaryDirectory.description=Le répertoire temporaire par défaut +observe.config.ui.actions.report.skipConsolidateStep=Pour ne pas exécuter l'étape de consolidation dans l'assistant des rapports observe.config.ui.autoPopupNumberEditor=Pour afficher automatiquement l'éditeur numérique lors de l'édition d'un nombre observe.config.ui.autoSelectText=Pour sélectionner le texte sur les éditeurs lorsqu'il acquière le focus observe.config.ui.blockStateColor=Couleur lorsque l'on bloque une partie de l'application ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psLogbookWellPlanCheck.properties ===================================== @@ -29,6 +29,6 @@ syntax.nbRequests=5 result.columns=20 result.rows=4 result.0=483^CAP BOJADOR^30/03/2019^08/04/2019^30/03/2019^1^15:12^0.0^123.0^43.0^0.0^0.0^0.0^0.0^12.0^0.0^0.0^166.0^12.0^154.0 -result.1=483^CAP BOJADOR^30/03/2019^08/04/2019^01/04/2019^1^15:12^null^null^null^null^null^null^null^null^null^null^null^null^- -result.2=483^CAP BOJADOR^30/03/2019^08/04/2019^01/04/2019^1^15:12^null^null^null^null^null^null^null^null^null^null^null^null^- -result.3=Total^null^null^null^null^null^-^0.0^123.0^43.0^0.0^0.0^0.0^0.0^12.0^0.0^0.0^166.0^12.0^- \ No newline at end of file +result.1=483^CAP BOJADOR^30/03/2019^08/04/2019^01/04/2019^1^15:12^null^null^null^null^null^null^null^null^null^null^null^null^null +result.2=483^CAP BOJADOR^30/03/2019^08/04/2019^01/04/2019^1^15:12^null^null^null^null^null^null^null^null^null^null^null^null^null +result.3=Total^null^null^null^null^null^-^0.0^123.0^43.0^0.0^0.0^0.0^0.0^12.0^0.0^0.0^166.0^12.0^154.0 \ No newline at end of file ===================================== toolkit/api-report/src/main/java/fr/ird/observe/report/ColumnRendererConsumer.java ===================================== @@ -44,9 +44,12 @@ import java.util.Objects; */ public interface ColumnRendererConsumer<P extends ColumnRendererParameters> { - static void addHighLighters(JXTable table, HighlightPredicate warningDPredicate, HighlightPredicate errorPredicate) { + static void addHighLighters(JXTable table, HighlightPredicate nullPredicate, HighlightPredicate warningPredicate, HighlightPredicate errorPredicate) { + if (nullPredicate != null) { + table.addHighlighter(new ColorHighlighter(nullPredicate, Color.GRAY, Color.BLACK)); + } table.addHighlighter(new ColorHighlighter(errorPredicate, Color.RED, Color.BLACK)); - table.addHighlighter(new ColorHighlighter(warningDPredicate, Color.ORANGE, Color.BLACK)); + table.addHighlighter(new ColorHighlighter(warningPredicate, Color.ORANGE, Color.BLACK)); } static SingletonSupplier<String> htmlFunctions(Class<?> type) { @@ -94,6 +97,6 @@ public interface ColumnRendererConsumer<P extends ColumnRendererParameters> { String htmlFunctions(); default String htmlInitCode() { - return String.format("init%s(renderers[i++], result);\n", getClass().getSimpleName()); + return String.format("init%s(renderers[i++], result, data);\n", getClass().getSimpleName()); } } ===================================== toolkit/api-report/src/main/java/fr/ird/observe/report/operations/SubtractColum.java ===================================== @@ -73,22 +73,27 @@ public class SubtractColum implements ReportOperationConsumer { Double v1 = getValue(row, column1, incoming); Double v2 = getValue(row, column2, incoming); - if (v1 == null || v2 == null) { - return "-"; + if (v1 == null && v2 == null) { + return null; + } + if (v1 == null) { + v1 = 0d; + } + if (v2 == null) { + v2 = 0d; } float result = (float) (v1 - v2); return Numbers.roundFourDigits(result); } - protected Double getValue(int x, int y, DataMatrix incoming) { - Serializable o = incoming.getValue(y, x); + protected Double getValue(int row, int column, DataMatrix incoming) { + Serializable o = incoming.getValue(column, row); if (o == null || "null".equals(o)) { return null; } try { return Double.parseDouble(o.toString()); } catch (NumberFormatException e) { - // une des données de la colonne n'est pas un count on sort directement log.debug(String.format("Could not convert %s to number", o), e); return null; } ===================================== toolkit/api-report/src/main/java/fr/ird/observe/report/renderers/HighlightIfAbsoluteDeltaIsPositive.java ===================================== @@ -78,6 +78,7 @@ public class HighlightIfAbsoluteDeltaIsPositive implements ColumnRendererConsume @Override public void consumeSwing(Parameters parameters, JXTable table) { ColumnRendererConsumer.addHighLighters(table, + new ParametersHighlightPredicate(parameters, null), new ParametersHighlightPredicate(parameters, true), new ParametersHighlightPredicate(parameters, false)); } @@ -124,9 +125,9 @@ public class HighlightIfAbsoluteDeltaIsPositive implements ColumnRendererConsume static class ParametersHighlightPredicate implements HighlightPredicate { private final Parameters parameters; - private final boolean warning; + private final Boolean warning; - ParametersHighlightPredicate(Parameters parameters, boolean warning) { + ParametersHighlightPredicate(Parameters parameters, Boolean warning) { this.parameters = parameters; this.warning = warning; } @@ -137,13 +138,16 @@ public class HighlightIfAbsoluteDeltaIsPositive implements ColumnRendererConsume if (column != parameters.getColumn1() && column != parameters.getColumn2()) { return false; } - Object value1 = adapter.getValue(parameters.getColumn1()); + Object value1 = adapter.getValue(); if (value1 == null || value1.toString().equals("-")) { + return warning == null; + } + if (warning == null) { return false; } - Object value2 = adapter.getValue(parameters.getColumn2()); + Object value2 = adapter.getValue(column == parameters.getColumn1() ? parameters.getColumn2() : parameters.getColumn1()); if (value2 == null || value2.toString().equals("-")) { - return false; + return !warning; } Double d1 = Double.valueOf(value1.toString()); Double d2 = Double.valueOf(value2.toString()); ===================================== toolkit/api-report/src/main/java/fr/ird/observe/report/renderers/HighlightIfNumericalValueIsPositive.java ===================================== @@ -76,6 +76,7 @@ public class HighlightIfNumericalValueIsPositive implements ColumnRendererConsum @Override public void consumeSwing(Parameters parameters, JXTable table) { ColumnRendererConsumer.addHighLighters(table, + new ParametersHighlightPredicate(parameters, null), new ParametersHighlightPredicate(parameters, true), new ParametersHighlightPredicate(parameters, false)); } @@ -117,9 +118,9 @@ public class HighlightIfNumericalValueIsPositive implements ColumnRendererConsum static class ParametersHighlightPredicate implements HighlightPredicate { private final Parameters parameters; - private final boolean warning; + private final Boolean warning; - ParametersHighlightPredicate(Parameters parameters, boolean warning) { + ParametersHighlightPredicate(Parameters parameters, Boolean warning) { this.parameters = parameters; this.warning = warning; } @@ -130,8 +131,11 @@ public class HighlightIfNumericalValueIsPositive implements ColumnRendererConsum if (column != parameters.getColumn()) { return false; } - Object value1 = adapter.getValue(parameters.getColumn()); + Object value1 = adapter.getValue(); if (value1 == null || value1.toString().equals("-")) { + return warning == null; + } + if (warning == null) { return false; } double d1 = Double.parseDouble(value1.toString()); ===================================== toolkit/api-report/src/main/resources/fr/ird/observe/report/renderers/HighlightIfAbsoluteDeltaIsPositive.js ===================================== @@ -19,38 +19,67 @@ * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ -function HighlightIfAbsoluteDeltaIsPositive(row, column1, column2, warningThreshHold, errorThreshHold) { - let value1 = row.cells[column1].data; - let value2 = row.cells[column2].data; - if (!!!value1 || value2 === "-") { - return value1; +function HighlightIfAbsoluteDeltaIsPositive(cell, row, column2, warningThreshHold, errorThreshHold) { + if (!cell) { + return; + } + if (!!!cell || cell === "-") { + return { + 'data-cell-content': "", + 'class': 'gridjs-td cellNull', + }; } - if (!!!value2 || value2 === "-") { - return value1; + let value2 = row.cells[column2].data; + if (!!!value2 || value2 === " ") { + return; } - if (value1 === value2) { - return value1; + if (cell === value2) { + return; } - let delta = Math.abs(value1 - value2); + let delta = Math.abs(cell - value2); if (delta < warningThreshHold) { - return value1; + return; } - let className = delta < errorThreshHold ? "cellWarning" : "cellError"; - // noinspection JSUnresolvedReference - return gridjs.html(`<span class="${className}"\>${value1}</span>`); + return { + 'data-cell-content': cell, + 'class': 'gridjs-td ' + (delta < errorThreshHold ? "cellWarning" : "cellError"), + }; } -function initHighlightIfAbsoluteDeltaIsPositive(renderer, result) { +function initHighlightIfAbsoluteDeltaIsPositive(renderer, result, json) { let column1 = renderer["column1"]; let column2 = renderer["column2"]; + let height = json.height; + let data = json.data; + for (let row = 0; row < height; row++) { + for (let column = column1; column <= column2; column++) { + if (!!!data[row][column]) { + data[row][column] = "-"; + } + } + } let warningThreshHold = renderer["warningThreshHold"]; let errorThreshHold = renderer["errorThreshHold"]; result[column1] = { name: result [column1], - formatter: (_, row) => HighlightIfAbsoluteDeltaIsPositive(row, column1, column2, warningThreshHold, errorThreshHold) + formatter: cell => { + if (!!!cell || cell === "-") { + // noinspection JSUnresolvedReference + return gridjs.html(" "); + } + return cell; + }, + attributes: (cell, row) => HighlightIfAbsoluteDeltaIsPositive(cell, row, column2, warningThreshHold, errorThreshHold) }; result[column2] = { name: result [column2], - formatter: (_, row) => HighlightIfAbsoluteDeltaIsPositive(row, column2, column1, warningThreshHold, errorThreshHold) + formatter: cell => { + if (!!!cell || cell === "-") { + // noinspection JSUnresolvedReference + return gridjs.html(" "); + } + return cell; + }, + attributes: (cell, row) => HighlightIfAbsoluteDeltaIsPositive(cell, row, column1, warningThreshHold, errorThreshHold) }; -} +} \ No newline at end of file ===================================== toolkit/api-report/src/main/resources/fr/ird/observe/report/renderers/HighlightIfNotI18nReferentialValue.js ===================================== @@ -19,26 +19,27 @@ * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ -function HighlightIfNotI18nReferentialValue(row, column, label) { - let value = row.cells[column].data; - if (!!!value) { - return value; +function HighlightIfNotI18nReferentialValue(cell, label) { + if (!!!cell) { + return; } - if (value === label) { - return value; + if (cell === label) { + return; } - // noinspection JSUnresolvedReference - return gridjs.html(`<span class="cellError">${value}</span>`); + return { + 'data-cell-content': cell, + 'class': 'gridjs-td cellError', + }; } -function initHighlightIfNotI18nReferentialValue(renderer, result) { +function initHighlightIfNotI18nReferentialValue(renderer, result, json) { let columns = renderer["columns"]; let label = renderer["label"]; for (let j = 0; j < columns.length; j++) { let column = columns[j]; result [column] = { name: result [column], - formatter: (_, row) => HighlightIfNotI18nReferentialValue(row, column, label) + attributes: cell => HighlightIfNotI18nReferentialValue(cell, label) }; } } ===================================== toolkit/api-report/src/main/resources/fr/ird/observe/report/renderers/HighlightIfNumericalValueIsPositive.js ===================================== @@ -19,26 +19,46 @@ * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ -function HighlightIfNumericalValueIsPositive(row, column, warningThreshHold, errorThreshHold) { - let value = row.cells[column].data; - if (!!!value || value === "-") { - return value; +function HighlightIfNumericalValueIsPositive(cell, warningThreshHold, errorThreshHold) { + if (!cell) { + return; } - let delta = Math.abs(value); + if (!!!cell || cell === "-") { + return { + 'data-cell-content': "", + 'class': 'gridjs-td cellNull', + }; + } + let delta = Math.abs(cell); if (delta < warningThreshHold) { - return value; + return; } - let className = delta < errorThreshHold ? "cellWarning" : "cellError"; - // noinspection JSUnresolvedReference - return gridjs.html(`<span class="${className}"\>${value}</span>`); + return { + 'data-cell-content': cell, + 'class': 'gridjs-td ' + (delta < errorThreshHold ? "cellWarning" : "cellError"), + }; } -function initHighlightIfNumericalValueIsPositive(renderer, result) { +function initHighlightIfNumericalValueIsPositive(renderer, result, json) { let column = renderer["column"]; + let height = json.height; + let data = json.data; + for (let row = 0; row < height; row++) { + if (!!!data[row][column]) { + data[row][column] = "-"; + } + } let warningThreshHold = renderer["warningThreshHold"]; let errorThreshHold = renderer["errorThreshHold"]; result[column] = { name: result [column], - formatter: (_, row) => HighlightIfNumericalValueIsPositive(row, column, warningThreshHold, errorThreshHold) + formatter: cell => { + if (!!!cell || cell === "-") { + // noinspection JSUnresolvedReference + return gridjs.html(" "); + } + return cell; + }, + attributes: cell => HighlightIfNumericalValueIsPositive(cell, warningThreshHold, errorThreshHold) }; -} +} \ No newline at end of file View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/c2557d282a8e149254598bf03... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/c2557d282a8e149254598bf03... You're receiving this email because of your account on gitlab.com.