Skip to content

Commit

Permalink
Revert "Move to_js_object to visualizations"
Browse files Browse the repository at this point in the history
This reverts commit 2dbb33c.
  • Loading branch information
radeusgd committed Mar 29, 2023
1 parent 9741430 commit ee5a1e7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,29 @@ type Value_Type
_ : Text -> "Unsupported_Data_Type (" + type_name + ")"
Value_Type.Mixed -> "Mixed"

## PRIVATE
Provides a JS object representation for use in visualizations.
to_js_object : JS_Object
to_js_object self =
constructor_name = Meta.meta self . constructor . name
display_text = self.to_display_text
additional_fields = case self of
Value_Type.Integer size ->
[["bits", size.to_bits]]
Value_Type.Float size ->
[["bits", size.to_bits]]
Value_Type.Decimal precision scale ->
[["precision", precision], ["scale", scale]]
Value_Type.Char size variable_length ->
[["size", size], ["variable_length", variable_length]]
Value_Type.Binary size variable_length ->
[["size", size], ["variable_length", variable_length]]
Value_Type.Unsupported_Data_Type type_name _ ->
[["type_name", type_name]]
_ -> []
JS_Object.from_pairs <|
[["type", "Value_Type"], ["constructor", constructor_name], ["_display_text_", display_text]] + additional_fields

# TODO move these functions below to a separate file

## The type representing inferring the column type automatically based on values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from Standard.Base import all
import Standard.Base.Data.Array_Proxy.Array_Proxy
from Standard.Base.Data.Json import render

from Standard.Table import Table, Column, Value_Type
from Standard.Table import Table, Column
import Standard.Table.Data.Row.Row

import project.Id.Id
Expand Down Expand Up @@ -180,29 +180,6 @@ Array.to_default_visualization_data : Text
Array.to_default_visualization_data self =
Vector.from_polyglot_array self . to_default_visualization_data

## PRIVATE
Provides a JS object representation for use in visualizations.
Value_Type.to_js_object : JS_Object
Value_Type.to_js_object self =
constructor_name = Meta.meta self . constructor . name
display_text = self.to_display_text
additional_fields = case self of
Value_Type.Integer size ->
[["bits", size.to_bits]]
Value_Type.Float size ->
[["bits", size.to_bits]]
Value_Type.Decimal precision scale ->
[["precision", precision], ["scale", scale]]
Value_Type.Char size variable_length ->
[["size", size], ["variable_length", variable_length]]
Value_Type.Binary size variable_length ->
[["size", size], ["variable_length", variable_length]]
Value_Type.Unsupported_Data_Type type_name _ ->
[["type_name", type_name]]
_ -> []
JS_Object.from_pairs <|
[["type", "Value_Type"], ["constructor", constructor_name], ["_display_text_", display_text]] + additional_fields

## PRIVATE

Looks for a column by a given name.
Expand Down

0 comments on commit ee5a1e7

Please sign in to comment.