I'm working with an Angular2 grid that showcases an array of Fabrics, each with its own color or fabric type properties. Right now, all Fabrics are displayed in the grid, but I need to implement a series of checkboxes for color and fabric type, along with the corresponding quantity next to each checkbox. The filtered Fabrics should only display after clicking on an "apply filter" button, and selecting one checkbox should dynamically update the counts of the other checkboxes.
For example:
https://i.sstatic.net/tcs25.png
I would appreciate any guidance on how to approach this. I already have all the necessary data. Should I create a pipe, a filtering service, or a form?
** MODELS **
A ProductConfigurationOption serves as the parent option for choice options, such as Fabric being a ConfigurationOption.
A configuration-option-choice represents a specific fabric like Tan Chenille. Each individual ConfigurationOptionChoice comes with various OptionChoiceProperties.
product-configuration-option.ts
import { ProductConfigurationOptionChoice } from './product-configuration-option-choice';
import { IProductConfiguratorOptionChoiceProperties } from '../Interfaces/iproduct-configurator-option-choice-properties';
import { IProductConfigurationOptionChoice } from '../ Interfaces/iproduct-configuration-option-choice';
import { IProductConfigurationOption } from '../Interfaces/iproduct-configuration-option';
export class ProductConfigurationOption implements IProductConfigurationOption {
constructor(
public ConfiguratorID: number,
public OptionID: number,
public OptionName: string,
public OptionDescription: string,
public OptionSortOrder: number,
public SKUPartOrdinal: number,
public ProductConfigurationOptionChoice: IProductConfigurationOptionChoice[],
public OptionChoicesProperties: IProductConfiguratorOptionChoiceProperties[]
) {
}
}
product-configuration-option-choice.ts
import { ProductConfiguratorOptionChoiceProperties } from '../Models/product-configurator-option-choice-properties';
import { IProductConfiguratorOptionChoiceProperties } from '../Interfaces/iproduct-configurator-option-choice-properties';
import { IProductConfigurationOptionChoice } from '../Interfaces/iproduct-configuration-option-choice';
export class ProductConfigurationOptionChoice implements IProductConfigurationOptionChoice {
public OptionChoiceID: number;
public OptionID: number;
public OptionValue: string;
public OptionChoiceName: string;
public OptionChoiceDescription: string;
public SKUPart: string;
public ImageURL: string;
public SortOrder: number;
public PriceOffset: number;
public OptionChoiceProperties: IProductConfiguratorOptionChoiceProperties[];
constructor( ){
}
setOptionChoiceProperties(optionProperties: ProductConfiguratorOptionChoiceProperties[]) {
this.OptionChoiceProperties = optionProperties;
}
}
product-configurator-option-choice-properties.ts
import { IProductConfiguratorOptionChoiceProperties } from '../Interfaces/iproduct-configurator-option-choice-properties';
export class ProductConfiguratorOptionChoiceProperties implements IProductConfiguratorOptionChoiceProperties {
constructor(
public OptionChoiceId: number,
public PropertyId: number,
public Name: string,
public Value: string
) {
}
}
Currently, my approach involves extracting OptionChoiceProperties, converting them into checkboxes representing their quantities, and exploring ways to dynamically adjust these quantities when filters are applied.