Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store icon, labels, and input options for types on the backend #661

Closed
pavish opened this issue Sep 14, 2021 · 11 comments
Closed

Store icon, labels, and input options for types on the backend #661

pavish opened this issue Sep 14, 2021 · 11 comments
Labels
needs: backend approval The backend team might not agree on whether this makes sense for the codebase needs: frontend approval The frontend team might not agree on whether this makes sense for the codebase needs: implementation specs We need clarity on HOW we'll implement it from a technical perspective type: enhancement New feature or request work: backend Related to Python, Django, and simple SQL
Milestone

Comments

@pavish
Copy link
Member

pavish commented Sep 14, 2021

Requirements

The frontend should be able to dynamically construct the view for displaying type options. The information related to this should be stored and obtained from the backend.

The backend should provide a JSON representation of the display properties essential to construct the dom and make requests on the frontend. It should cover:

  • Icon information (Links or base64 encoded icons. Links to an svg file would be best)
  • Universal Input options (Input used within table, filters, groups etc.,)
    • Type of input (depends on the db/mathesar type. Boolean has be a checkbox, while text has to be text input).
    • Label for input
    • Id for input (to use as key while making requests)
    • Validation options for custom types (eg., regexes need to be specified for email type. The input would be a text box, and additional validation needs to happen over it)
  • Feature specific input options (If there is a different UX for specific purposes eg., for filtering/grouping, the representation for that should also be covered)
  • Type options (what database options a type accepts)
  • Whether we support default values for the type

Related

@pavish pavish added type: enhancement New feature or request work: backend Related to Python, Django, and simple SQL ready Ready for implementation labels Sep 14, 2021
@pavish pavish added this to the 08. Initial Data Types milestone Sep 14, 2021
@kgodey kgodey added status: draft and removed ready Ready for implementation labels Sep 14, 2021
@kgodey
Copy link
Contributor

kgodey commented Sep 14, 2021

Marking as draft until the spec for how to represent things is fleshed out.

@kgodey kgodey self-assigned this Sep 27, 2021
@kgodey
Copy link
Contributor

kgodey commented Sep 27, 2021

Assigning to myself to flesh out backend implementation.

@seancolsen
Copy link
Contributor

seancolsen commented Nov 4, 2021

@kgodey @pavish

What's the rationale for delegating icon choice responsibility to the back end?

I would think we'd want to leave that choice up to the front end. Maybe we want to refactor all the icons to improve visual consistency. Maybe we want to apply CSS to change the icon color in certain contexts. Maybe we want to serve the icons as inline SVG. While these would all be possible with icon choices in the backend, any icon refactoring would inherently involve the back end which seems weird to me.

Are we planning to provide some kind of user-defined type system at some point? Perhaps that's the rationale? -- Because icons might be defined at runtime? Even in that case, I'd like to think through this choice a bit more before handing such a presentational responsibility to the back end.

@kgodey
Copy link
Contributor

kgodey commented Nov 4, 2021

@seancolsen Yes, the idea is to provide a user-defined type system at some point. People might have all sorts of custom Postgres types installed on their database and they might want to implement custom functionality for those types. The idea behind this issue is to allow the frontend to be type-agnostic and load whatever types the backend offers with all the information it needs for each type. It would also be useful in case someone was building, for example, a mobile client for Mathesar and wanted to use the same types and UX as the web frontend.

I too am iffy about delegating presentational responsibilities to the backend. I'd like to put this issue off until after the alpha release and think through it more.

@pavish
Copy link
Member Author

pavish commented Nov 4, 2021

Having dynamic types would help us build and publish types separate to the product itself. Considering that the idea is to allow plugins in the future, this would be an essential step towards that goal. Users can install a plugin which offers customized type support.

I understand the hesitation towards not wanting to place presentation elements on the backend, however the entire types endpoint is built specifically for the client to make use of.

My opinion is that everything related to types (allowed filters, allowed grouping options, sorting options, cell validation, label, icon etc.,) has to be stored on the database, inorder for us to move towards a plugin backed architecture.

We can think through this more.

@seancolsen
Copy link
Contributor

@pavish and I chatted about the icons issue on a call today, and he helped me understand more.

As I understand it now, it's not users who define the icons for new types, but plugin authors. That sounds great to me. Pavish and I chatted about various approaches that would allow the API communicate information about icons to the front end. The approach that I like the best is one where the types API returns an response like this:

[
  {
    "identifier": "email",
    "name": "Email",
    "icon": {
      "set": "fontAwesome",
      "name": "envelope",
    },
    // ...
  },
  // ...
]

We would then provide documentation to plugin authors on which icon sets we support and how to access the respective docs for each icon set to choose an icon. We'd begin by supporting only Font Awesome, but we could choose to add more at some point later on.

To me, this approach strikes the perfect balance between giving the front end control over the presentation of the icon and giving the plugin author the ability to choose their own icon.

If a time comes when plugin authors feel that their choice of icon is too limited, then could address that need at that point, for example by allowing them to add their own icon set from within the plugin.

@kgodey kgodey modified the milestones: [08] Initial Data Types, [16] General Improvements #6, [Beta] API v1 Nov 5, 2021
@kgodey
Copy link
Contributor

kgodey commented Nov 5, 2021

@seancolsen that makes sense, thanks!

I've moved this to the API v1 milestone (which is scheduled for post-alpha). I don't think it should block our implementation of data types.

@kgodey kgodey removed their assignment Nov 5, 2021
@kgodey kgodey modified the milestones: [Beta] API v1, Unprioritized Jun 1, 2022
@github-actions
Copy link

github-actions bot commented Feb 6, 2023

This issue has not been updated in 90 days and is being marked as stale.

@github-actions github-actions bot added the stale label Feb 6, 2023
@dmos62
Copy link
Contributor

dmos62 commented Aug 16, 2023

Can we close this? There's not been any activity here for 2 years. I'm also under the impression that we've walked back on the goal of putting the maximum of information on the backend (which we wanted so that implementing a new frontend would be easy).

@github-actions github-actions bot removed the stale label Aug 16, 2023
@kgodey
Copy link
Contributor

kgodey commented Aug 16, 2023

I'll defer to @pavish but I'm in support of closing. I assume we can reopen or open a new issue if/when we prioritize this work.

@seancolsen seancolsen added needs: backend approval The backend team might not agree on whether this makes sense for the codebase needs: frontend approval The frontend team might not agree on whether this makes sense for the codebase needs: implementation specs We need clarity on HOW we'll implement it from a technical perspective and removed status: draft labels Dec 5, 2023
@kgodey
Copy link
Contributor

kgodey commented Feb 2, 2024

Closing this, too old, requirements are out of date. We can create a new issue if we need this functionality in the future.

@kgodey kgodey closed this as not planned Won't fix, can't repro, duplicate, stale Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: backend approval The backend team might not agree on whether this makes sense for the codebase needs: frontend approval The frontend team might not agree on whether this makes sense for the codebase needs: implementation specs We need clarity on HOW we'll implement it from a technical perspective type: enhancement New feature or request work: backend Related to Python, Django, and simple SQL
Projects
No open projects
Development

No branches or pull requests

4 participants