Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Base } from '../_base';
- export interface ICarOptionBackend {
- id: number;
- carId: number;
- }
- export class CarOption extends Base {
- public id: number = null;
- public name: number = null;
- public parentId: number = null;
- public checked = false;
- protected mapping: Array<Object> = [
- { key: 'id', value: 'id' },
- { key: 'name', value: 'name' },
- { key: 'parentId', value: 'parent_id' },
- ];
- static setChecked(opts: CarOption[],
- options: CarOption[]): CarOption[] {
- let optsIds: number[] = options.map(item => item.id);
- return opts.map((item: CarOption) => {
- item.checked = optsIds.indexOf(item.id) > -1;
- return item;
- });
- }
- constructor(carOption?: ICarOptionBackend) {
- super();
- if (carOption) {
- this.deserialize(carOption);
- }
- }
- public clone(): CarOption {
- let carOption: CarOption = new CarOption();
- Object.assign(carOption, this);
- return carOption;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement