oskar-anderson / HedgehogDBD

ERD modeling tool for visualizing database diagrams
https://hedgehog-dbd.vercel.app/
MIT License
11 stars 1 forks source link

Add suggestions for foreign key tables #23

Closed v4ngelix closed 1 year ago

v4ngelix commented 1 year ago

I tried out the application and I really like it. One thing that started to bother me was that when I wanted to set FK I had to constantly look up what the table name was. So I decided to add a suggestions select to FK setting.

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hedgehog-dbd ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 24, 2023 0:08am
oskar-anderson commented 1 year ago

Overall seems like a good idea

oskar-anderson commented 1 year ago

This would only support one attribute per field.

The attributes are meant as a CSV free text field input that get converted to string[] on save. So far one value (FK or PK) is used, but in the future one field might have 2 attributes like "PK, AI", AI - auto increment. Also the idea was that users can write custom attributes that they can use in scripts like for example some programming framework ORM domain model annotations.

Is it possible to have a regular text input with a tiny button next to it that will open a select that has all the table names and clicking on the table name would insert the table name string into the attribute text field current caret? Insertion should happen using selectionStart and selectionEnd like demonstrated here https://stackoverflow.com/questions/11076975/how-to-insert-text-into-the-textarea-at-the-current-cursor-position

oskar-anderson commented 1 year ago

I created a hints field for attributes commands and tables #25

I tried using a searchable select component from select2, but it was too difficult to get the correct style'ing. I hope the native select is good enough and the search functionality is not that important.

Would this be suitable solution?

v4ngelix commented 1 year ago

This would only support one attribute per field.

The attributes are meant as a CSV free text field input that get converted to string[] on save. So far one value (FK or PK) is used, but in the future one field might have 2 attributes like "PK, AI", AI - auto increment. Also the idea was that users can write custom attributes that they can use in scripts like for example some programming framework ORM domain model annotations.

Is it possible to have a regular text input with a tiny button next to it that will open a select that has all the table names and clicking on the table name would insert the table name string into the attribute text field current caret? Insertion should happen using selectionStart and selectionEnd like demonstrated here https://stackoverflow.com/questions/11076975/how-to-insert-text-into-the-textarea-at-the-current-cursor-position

Yes, that is true. Maybe its better to have a "cog" icon on every row which would open up a modal for setting attributes? The modal would have a table, where you could add as many predefined or custom attributes you want.

Concerning the selectionStart and selectionEnd, It's possible to use these to manipulate the input string, but I think its better to have input fields for every bit of data, the user is going to set. I feel that doing string manipulation is a brittle solution.

v4ngelix commented 1 year ago

I created a hints field for attributes commands and tables #25

I tried using a searchable select component from select2, but it was too difficult to get the correct style'ing. I hope the native select is good enough and the search functionality is not that important.

Would this be suitable solution?

Sorry, no, I don't think hints field is the correct solution. Also, I don't think that you need a 3-rd party library for group titles. You can have searchability and subtitles with pure vanilla html. Have a look here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select#advanced_select_with_multiple_features.

oskar-anderson commented 1 year ago

This would only support one attribute per field. The attributes are meant as a CSV free text field input that get converted to string[] on save. So far one value (FK or PK) is used, but in the future one field might have 2 attributes like "PK, AI", AI - auto increment. Also the idea was that users can write custom attributes that they can use in scripts like for example some programming framework ORM domain model annotations. Is it possible to have a regular text input with a tiny button next to it that will open a select that has all the table names and clicking on the table name would insert the table name string into the attribute text field current caret? Insertion should happen using selectionStart and selectionEnd like demonstrated here https://stackoverflow.com/questions/11076975/how-to-insert-text-into-the-textarea-at-the-current-cursor-position

Yes, that is true. Maybe its better to have a "cog" icon on every row which would open up a modal for setting attributes? The modal would have a table, where you could add as many predefined or custom attributes you want.

Concerning the selectionStart and selectionEnd, It's possible to use these to manipulate the input string, but I think its better to have input fields for every bit of data, the user is going to set. I feel that doing string manipulation is a brittle solution.

Yes, that is definitely a better solution. This was just a fast fix.

I did not want to implement a separate modal with all functionalities to add, edit, delete, reorder attributes with different creation subviews for each type, as the FK attribute is the only one that takes arguments. At first I though this could be solved by using a tag component like this select. It supports deletion, but not reordering.

Also it is now possible to add relations from the main draw view as well (right click on row). So this should not be as big of a problem for now.

By cog modal do you mean appending one attribute to the text input or entire system for managing the input values like this? 2023-10-02 14_40_34-Window

v4ngelix commented 1 year ago

Sorry for the long silence. I just wanted to let you know that I no longer have the time to continue contributing. Feel free to merge or delete the current feature branch.