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

Experimental UI form separation #7777

Draft
wants to merge 51 commits into
base: devel
Choose a base branch
from

Conversation

VakarisZ
Copy link
Contributor

@VakarisZ VakarisZ commented Jul 24, 2023

Description

This branch is a concept to solving the problem of component explosion.
SEE LAST COMMIT ONLY

The problem

The data that the back-end API's use are not consistent.

Example data that the back-end gives and expects:

{ 
  "firewall": "enabled",
  "allow_password_login": true,
  "user_count": 1,
  "device_cound": "3"
}

This means that in the UI we need at least 4 components to display the data. ("enabled"/"disabled", true/false, int, int as string).

Instead, there should be only 2 components int the UI: bool and int.

The proposed solution is to create a UI version of the form:

{ 
  "firewall":  true,
  "allow_password_login": true,
  "user_count": 1,
  "device_cound": 3
}

The idea is to clone the form data and link the back-end form data with the front-end form data.
To be more specific:

  1. Each view should be able to include the optional translation layer
  2. In the translation layer, devs should be able to link the form values together via "computed" properties (see the last commit in this PR).

Benefits

The main benefits of this change is code design. After this change the codebase should have a lot less components and instead have a collection of "computed" properties that can be used for translating UI component state to what the various API's expect.

It would also allow us to v-bind form properties to the components, further simplifying the components and separating component logic from domain logic

Comment on lines +55 to +58
uiForm.value['record_dns_in_sql'] = (props.form['record_dns_in_sql'] === "enabled")
props.form['record_dns_in_sql'] = computed(() => {
return uiForm['record_dns_in_sql'] ? "enabled" : "disabled"
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This binding could be extracted into a composable, it doesn't need to be part of the form

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant