Skip to content

Global variable support #130

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

Closed
Pieter3033 opened this issue Nov 14, 2023 · 8 comments
Closed

Global variable support #130

Pieter3033 opened this issue Nov 14, 2023 · 8 comments
Labels
enhancement New feature or request

Comments

@Pieter3033
Copy link
Contributor

Hi,

Is it possible to add global variable support, across all of my SQLPage webpages.
I could be wrong, but I believe this is not a feature in SQLPage.

Currently I am working with 3 different form submissions, which updates a single row in my database.
This row has to be updated later on a separate page.

The reason I am using 3 form submissions is:
1st Form, The user Selects a Client. (Using a select box) (Creates a row)
2nd Form, The user Selects a Fleet based on the Client selected in the previous form. (Using a select box) (Updates the created row)
(The use of pre-defined select boxes allows me to prevent human error)
3rd Form, The user Submits information that has to update the row created in the first form.

Currently I am setting the type = hidden, essentially populating the input with a reference number that has been auto generated in the previous form and carrying it over the forms. I get the same results when setting the input to readonly.
Without this I have no way of referencing which row to update in the database.

The problem with this solution it is not as neat, because it either results in a blank space or a input box with no purpose.

Possible solution:

I am not sure if it is possible, but keeping the already supported local variables syntax mentioned in #49 and enabling it to act as global variables as well?

@Pieter3033 Pieter3033 added the enhancement New feature or request label Nov 14, 2023
@lovasoa
Copy link
Collaborator

lovasoa commented Nov 14, 2023

Hello and thanks for the feedback.

I don't think what you need is a global variable. Everything that is global should probably be stored in the database itself. But in your case, if I understand well, the state you want to save is not global but client-specific. If two people are connected to the form at the same time, they don't want to see the same pre-filled values in the second form.

I would have implemented what you are describing in one of three ways:

  1. with hidden form inputs, the way you are doing it. Can you post a screenshot of the "blank space" you are referencing ? I thing the problem to fix is here. Other than that, I don't see a problem with that solution.
  2. with cookies set on the client side, using the cookie component to store the values filled in the previous forms
  3. if we want to persist partially-filled forms in the long term and across devices and user reconnections: with a table in the database that contains the user id and the partially filled form values.

@lovasoa
Copy link
Collaborator

lovasoa commented Nov 15, 2023

I'm closing this for the moment, but I'm open to reopening it if there is something I missed. The discussion is still open.

@lovasoa lovasoa closed this as completed Nov 15, 2023
@Pieter3033
Copy link
Contributor Author

Thanks for the advice, I've implemented cookies across the first 2 forms and a unique user_id that automatically increases on the last form submisson and then gets saved in the database accordingly.

When the user want to edit the form I just reference back to the user_id created.

I appreciate your advice, have a good one.

Regards

@lovasoa
Copy link
Collaborator

lovasoa commented Nov 15, 2023

Can you still give a screenshot of your form, with the problematic "blank space" and the corresponding code ? Maybe there is still something to fix in SQLPage on that front ?

@lovasoa
Copy link
Collaborator

lovasoa commented Nov 15, 2023

And by the way, I am giving a talk about SQLPage at pgconf.eu this december, and I'd like to include feedback from users. If you have 15 minutes to chat about what you are using SQLPage for sometimes this week, I'd love to !

@Pieter3033
Copy link
Contributor Author

Can you still give a screenshot of your form, with the problematic "blank space" and the corresponding code ? Maybe there is still something to fix in SQLPage on that front ?

Currently I have scraped the idea to use type = hidden, but here is the example.
Note this is how I have done it previously.

Using the form component.

Code:

SELECT 
        'srf_notes' AS name
       ,'hidden' AS type

Screenshot: ( Marked in green is the "blank" space )
image

I discovered though, when entering nothing inside of the label parameter(not removing it, just leaving it blank), the problem of the "blank" space is resolved.

Code:

SELECT '' AS label
       ,'srf_notes' AS name
       ,'hidden' AS type 

Screenshot:
image

Conclusion:
I believe the cookie component Idea is my preference here.

@Pieter3033
Copy link
Contributor Author

And by the way, I am giving a talk about SQLPage at pgconf.eu this december, and I'd like to include feedback from users. If you have 15 minutes to chat about what you are using SQLPage for sometimes this week, I'd love to !

Congratulations,
I'd love to discuss my project with you!
How does tomorrow 14:00 (GMT+2) fit you?

@lovasoa
Copy link
Collaborator

lovasoa commented Nov 15, 2023

image

Ok, I see what you mean !

when entering nothing inside of the label parameter, the problem of the "blank" space is resolved

Just tried it, and there is actually still a small vertical margin that is added at the place of the hidden input.

I will release a new version of SQLPage where hidden inputs are really completely hidden. I think there should be no visual difference between a form that has a hidden field and the same form without that field. Thank you for bringing this to my attention !

I'd love to discuss my project with you! How does tomorrow 14:00 (GMT+2) fit you?

😊 I'll be in a meeting at that time, unfortunately. Can you do the evening (after 7pm GMT+2), or friday morning ? You can contact me on [email protected].

lovasoa added a commit that referenced this issue Nov 16, 2023
lovasoa added a commit that referenced this issue Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants