From 630e7c4b21f7416eeb75a6dacd5000defd08f31b Mon Sep 17 00:00:00 2001 From: James Dunkerley Date: Fri, 12 May 2023 15:24:33 +0100 Subject: [PATCH] PR comments. --- .../builtin/visualization/java_script/table.js | 16 ++++++++++------ .../Base/0.0.0-dev/src/Data/Text/Extensions.enso | 2 +- .../Standard/Base/0.0.0-dev/src/Metadata.enso | 2 +- .../0.0.0-dev/src/Table/Visualization.enso | 12 +++++------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app/gui/view/graph-editor/src/builtin/visualization/java_script/table.js b/app/gui/view/graph-editor/src/builtin/visualization/java_script/table.js index 4dccfb92c67ae..7291a53f16499 100644 --- a/app/gui/view/graph-editor/src/builtin/visualization/java_script/table.js +++ b/app/gui/view/graph-editor/src/builtin/visualization/java_script/table.js @@ -38,8 +38,7 @@ class TableVisualization extends Visualization { this.setPreprocessor( 'Standard.Visualization.Table.Visualization', 'prepare_visualization', - this.row_limit.toString(), - this.page.toString() + this.row_limit.toString() ) } } @@ -238,7 +237,7 @@ class TableVisualization extends Visualization { } // Update Status Bar - this.createRowDropdown( + this.updateStatusBarControls( parsedData.all_rows_count === undefined ? 1 : parsedData.all_rows_count, dataTruncated ) @@ -266,7 +265,10 @@ class TableVisualization extends Visualization { return buttonElem } - createRowDropdown(all_rows_count, dataTruncated) { + // Updates the status bar to reflect the current row limit and page, shown at top of the visualization. + // - Creates the row dropdown and page buttons. + // - Updated the row counts and filter available options. + updateStatusBarControls(all_rows_count, dataTruncated) { const pageLimit = Math.ceil(all_rows_count / this.row_limit) if (this.page > pageLimit) { this.page = pageLimit @@ -317,8 +319,10 @@ class TableVisualization extends Visualization { 25000, 50000, 100000, - all_rows_count, - ].filter(r => r <= all_rows_count && r <= 100000) + ].filter(r => r <= all_rows_count) + if (all_rows_count < rowCounts[rowCounts.length-1] && rowCounts.indexOf(all_rows_count) === -1) { + rowCounts.push(all_rows_count) + } rowLimitElem.innerHTML = '' rowCounts.forEach(r => { const option = this.makeOption(r, r.toString()) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso index 50b29c6285c19..e97d9bec3014b 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso @@ -347,7 +347,7 @@ Text.split self delimiter="," case_sensitivity=Case_Sensitivity.Sensitive use_re _ : Vector -> delimiter.length == 1 _ -> False # If it's a vector of one element, just call it on that one element. - if delimiter_is_singleton_vector then self.split delimiter=(delimiter.first) case_sensitivity=case_sensitivity use_regex=use_regex else` + if delimiter_is_singleton_vector then self.split delimiter=(delimiter.first) case_sensitivity=case_sensitivity use_regex=use_regex else case use_regex of False -> delimiters = split_find_delimiters self delimiter case_sensitivity diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Metadata.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Metadata.enso index 0ad6a032f1eca..c985a248e65ec 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Metadata.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Metadata.enso @@ -83,5 +83,5 @@ make_single_choice : Vector -> Display -> Widget make_single_choice values display=Display.Always = make_option value = case value of _ : Vector -> Choice.Option value.first value.second - _ -> Choice.Option value value.pretty + _ : Text -> Choice.Option value value.pretty Widget.Single_Choice (values.map make_option) Nothing display diff --git a/distribution/lib/Standard/Visualization/0.0.0-dev/src/Table/Visualization.enso b/distribution/lib/Standard/Visualization/0.0.0-dev/src/Table/Visualization.enso index 920abd4f9e263..8b4be931d5f0e 100644 --- a/distribution/lib/Standard/Visualization/0.0.0-dev/src/Table/Visualization.enso +++ b/distribution/lib/Standard/Visualization/0.0.0-dev/src/Table/Visualization.enso @@ -17,12 +17,10 @@ import project.Helpers Arguments: - x: The table to prepare for visualisation. - max_rows: The maximum number of rows to display. - - page: The page to display. In case of Database backed data, it materializes a fragment of the data. -prepare_visualization : Any -> Integer -> Integer -> Text -prepare_visualization y max_rows=1000 page=0 = - _ = page +prepare_visualization : Any -> Integer -> Text +prepare_visualization y max_rows=1000 = x = Warning.set y [] result = case x of @@ -42,7 +40,7 @@ prepare_visualization y max_rows=1000 page=0 = all_rows_count = x.row_count make_json_for_table dataframe [] all_rows_count _ : Function -> - pairs = [['_display_text_', '[Function]']] + pairs = [['_display_text_', '[Function '+x.to_text+']']] value = JS_Object.from_pairs pairs JS_Object.from_pairs [["json", value]] _ -> @@ -102,7 +100,7 @@ make_json_for_object_matrix current vector idx=0 = if idx == vector.length then _ -> js_object = row.to_js_object if js_object.is_a JS_Object . not then False else - if js_object.field_names.sort == ["type" , "constructor"] then False else + if js_object.field_names.sort == ["constructor", "type"] then False else pairs = js_object.field_names.map f-> [f, make_json_for_value (js_object.get f)] JS_Object.from_pairs pairs if to_append == False then Nothing else @@ -190,5 +188,5 @@ make_json_for_value val level=0 = case val of truncated = val.columns.take 5 . map _.name prepared = if val.column_count > 5 then truncated + ["… " + (val.column_count - 5).to_text+ " more"] else truncated "Table{" + val.row_count.to_text + " rows x [" + (prepared.join ", ") + "]}" - _ : Function -> "[Function]" + _ : Function -> "[Function "+val.to_text+"]" _ -> val.to_display_text