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

Admin Generator (Future): Add FinalFormRangeInput to form generator #2612

Merged
merged 4 commits into from
Oct 10, 2024

Conversation

andrearutrecht
Copy link
Contributor

@andrearutrecht andrearutrecht commented Oct 8, 2024

Description

FinalFormRangeInput fields can now be generated in forms. The new field type is numberRange. Data of the field is saved in this format: { min: number, max: number }

The names min and max are currently hardcoded, as they have to be named this way. FinalFormRangeInput passes the values named like this.

Example

The field with all possible options:

{ 
     type: "numberRange",
     name: "priceRange", 
     minValue: 25, // required
     maxValue: 500, // required
     disableSlider: true, //  optional, default is false
     startAdornment: "€" // optional
     endAdornment: "€" // optional, both adornments can be added for a field
 }

The field in product.entity:

@ObjectType()
@InputType("ProductPriceRangeInput")
export class ProductPriceRange {
    @Field()
    @IsNumber()
    min: number;

    @Field()
    @IsNumber()
    max: number;
}

{...}

export class Product extends BaseEntity<Product, "id"> {

{...}

    @Property({ type: "json", nullable: true })
    @Field(() => ProductPriceRange, { nullable: true })
    priceRange?: ProductPriceRange = undefined;

{...}

}
  • I have verified if my change requires an example

Example in demo: #2593

Screenshots/screencasts

Creating a Product with a price range:

Screen.Recording.2024-10-08.at.11.52.42.mp4

Example of editing a price range:

Screen.Recording.2024-10-08.at.11.54.01.mp4

Changeset

  • I have verified if my change requires a changeset

Related tasks and documents

Jira Task: https://vivid-planet.atlassian.net/browse/SVK-124

Open TODOs/questions

Further information

@andrearutrecht andrearutrecht self-assigned this Oct 8, 2024
@andrearutrecht andrearutrecht requested review from johnnyomair and nsams and removed request for johnnyomair October 8, 2024 10:22
@andrearutrecht andrearutrecht marked this pull request as ready for review October 8, 2024 10:22
@johnnyomair johnnyomair merged commit 6f82b6e into main Oct 10, 2024
11 checks passed
@johnnyomair johnnyomair deleted the admin-generator-number-range-field branch October 10, 2024 14:07
fichtnerma pushed a commit that referenced this pull request Nov 7, 2024
…#2612)

`FinalFormRangeInput` fields can now be generated in forms. The new
field type is `numberRange`. Data of the field is saved in this format:
`{ min: number, max: number }`

The names `min` and `max` are currently hardcoded, as they **have to**
be named this way. `FinalFormRangeInput` passes the values named like
this.
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.

3 participants