Dynamic Type selection & customization on the frontend #1035
Replies: 4 comments 9 replies
-
1. Declarative format to construct the type selection paneThis is the current format, which is implemented in #926. The configuration for Text Mathesar type: {
identifier: 'Text',
defaultDbType: 'VARCHAR',
typeSwitchOptions: {
database: {
allowDefault: true,
configuration: {
form: {
variables: {
restrictFieldSize: {
type: 'boolean',
default: false,
},
fieldSizeLimit: {
type: 'integer',
default: 255,
},
},
layout: {
orientation: 'vertical',
elements: [
{
type: 'input',
variable: 'restrictFieldSize',
label: 'Restrict Field Size',
},
{
type: 'if',
variable: 'restrictFieldSize',
condition: 'eq',
value: true,
elements: [
{
type: 'input',
variable: 'fieldSizeLimit',
label: 'Field Size Limit',
},
],
},
],
},
},
determinationRules: [
{
resolve: 'CHAR',
rule: {
combination: 'and',
terms: [
{
id: 'restrictFieldSize',
op: 'eq',
value: true,
},
{
id: 'fieldSizeLimit',
op: 'lte',
value: 255,
},
{
id: 'fieldSizeLimit',
op: 'neq',
value: null,
},
],
},
},
{
resolve: 'VARCHAR',
rule: {
combination: 'and',
terms: [
{
id: 'restrictFieldSize',
op: 'eq',
value: true,
},
{
combination: 'or',
terms: [
{
id: 'fieldSizeLimit',
op: 'gt',
value: 255,
},
{
id: 'fieldSizeLimit',
op: 'eq',
value: null,
},
],
},
],
},
},
{
resolve: 'TEXT',
rule: {
id: 'restrictFieldSize',
op: 'eq',
value: false,
},
},
],
ruleReversalValues: {
CHAR: {
restrictFieldSize: true,
fieldSizeLimit: 255,
},
VARCHAR: {
restrictFieldSize: true,
fieldSizeLimit: null,
},
TEXT: {
restrictFieldSize: false,
fieldSizeLimit: null,
},
},
},
},
},
}; Please also refer the configuration for number, which is a bit more sophisticated: https://github.com/centerofci/mathesar/pull/926/files#diff-1a8cf2364d3f861e74c2e0cf0df43feb6be483ff9830ef16cba6e7c5887120d6 Description:
Apart from these, this will extend to support What I expect out of this thread:
|
Beta Was this translation helpful? Give feedback.
-
[RESOLVED] 2. Problems we need to handle based on (1)Problem 1:
Problem 2:
Solutions that resolve both problems 1 and 2: Solution A:
Solution B:
What I expect out of this thread:
|
Beta Was this translation helpful? Give feedback.
-
3. Dealing with type aliases
Solution A:
Solution B:
What I expect out of this thread:
|
Beta Was this translation helpful? Give feedback.
-
4. Display options
What I expect out of this thread:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The PR #926 implements the type configuration view for some basic Mathesar types. As discussed in #849 and several other discussions, we intend to make our frontend (and any general-purpose client) type-agnostic eventually.
Inorder to achieve that goal, we need to be able to construct a dynamic UI based on information stored on the db, by using a declarative format.
i. Type selection and customization
ii. Formatting and displaying values in table cell
iii. Inputting values in table cell
iv. Filtering options
v. Grouping options
vi. Default value selection
vii. Data source and formula selection
These are just on top of my head and we may have several other places where this would be required. Essentially any area of the UI that is rendered based on column type would need to be constructed dynamically.
The PR #926 lays the groundwork for all of these usecases while implementing a portion of i.
This discussion is only focused on database options in
(i). Type selection and customization
i.e this UI:Reference: Figma prototype
It is split into several sections to facilitate focused conversations.
Beta Was this translation helpful? Give feedback.
All reactions