File

projects/i-components/src/lib/components/tree-view/test/DataMock.ts

Index

Methods

Methods

Private Static CreateProduct
CreateProduct(prodcutId: number, name: string, description: string)
Parameters :
Name Type Optional
prodcutId number No
name string No
description string No
Returns : ProductDTO
Static GetProducts
GetProducts()
Returns : SimpleList<ProductDTO>
import { Component, Inject } from '@angular/core';
import {
  TreeViewModel,
  TEMPLATE_COMPONENT_CONTEXT,
  TEMPLATE_DECLARING_CONTEXT,
  SimpleList,
  propertyInfo,
  IList,
  ResourceDictionary,
  HierarchicalDataTemplate,
  Binding,
  UserControlModel,
  convertTypeTo,
} from '@mobilize/wms-framework';
import { BaseComponent } from '../../base/base.component';
/* eslint-disable */
@Component({
  selector: 'wm-component-wrapper3',
  template: ` <wm-tree-view [name]="name" [model]="tbmodel"> </wm-tree-view> `,
})
export class TestWrapperBindingsHierarchicalComponent extends UserControlModel {
  name = 'treeview3';
  tbmodel = new TreeViewModel();

  constructor() {
    super();
    this.initProperties();
  }

  protected initProperties() {
    const itemTemplate = Object.assign(
      new HierarchicalDataTemplate(
        MainPageProductGroupEntryDTComponent,
        this.tbmodel
      ),
      {
        ItemSource: new Binding('SubProducts'),
        ItemTemplate: new HierarchicalDataTemplate(
          MainPageProductGroupEntryDTComponent,
          this.tbmodel
        ),
      }
    );
    this.tbmodel = Object.assign(new TreeViewModel(), {
      ItemTemplate: itemTemplate,
      ItemsSource: DataMock.GetProducts(),
    });
  }
}

@Component({
  selector: 'MainPageProductGroupEntryDT',
  template: `<wm-text-block
    [text]="{ bindingPath: 'Name', ctxt: context }"
    class="textblock-wm-control0"
  >
  </wm-text-block>`,
})
export class MainPageProductGroupEntryDTComponent extends BaseComponent {
  constructor(
    @Inject(TEMPLATE_COMPONENT_CONTEXT) public context: any,
    @Inject(TEMPLATE_DECLARING_CONTEXT) public declaringContext: any
  ) {
    super();
  }
}

export class ProductDTO {
  private IsSelected = false;
  private productID0 = 0;
  @propertyInfo()
  get ProductID(): number {
    return this.productID0;
  }
  set ProductID(value: number) {
    this.productID0 = value;
  }
  private name1: string = null;
  @propertyInfo()
  get Name(): string {
    return this.name1;
  }
  set Name(value: string) {
    this.name1 = value;
  }
  private description3: string = null;
  @propertyInfo()
  get Description(): string {
    return this.description3;
  }
  set Description(value: string) {
    this.description3 = value;
  }
  private subProducts: IList<ProductDTO> = null;
  @propertyInfo('System.Collections.Generic.IList`1')
  get SubProducts(): IList<ProductDTO> {
    return this.subProducts;
  }
  set SubProducts(value: IList<ProductDTO>) {
    this.subProducts = value;
  }
  public constructor() {
    this.SubProducts = new SimpleList<ProductDTO>();
  }
}

export class DataMock {
  private static CreateProduct(
    prodcutId: number,
    name: string,
    description: string
  ): ProductDTO {
    return Object.assign(new ProductDTO(), {
      IsSelected: false,
      ProductID: prodcutId,
      Name: name,
      Description: description,
    });
  }
  public static GetProducts(): SimpleList<ProductDTO> {
    const products: SimpleList<ProductDTO> = new SimpleList<ProductDTO>();
    const p1: ProductDTO = DataMock.CreateProduct(1, 'product1', 'product 1');
    p1.SubProducts = new SimpleList<ProductDTO>();
    p1.SubProducts.add(
      DataMock.CreateProduct(2, 'subproduct1', 'subproduct 1')
    );
    p1.SubProducts.add(
      DataMock.CreateProduct(3, 'subproduct2', 'subproduct 2')
    );
    p1.SubProducts.add(
      DataMock.CreateProduct(4, 'subproduct3', 'subproduct 3')
    );
    products.add(p1);
    return products;
  }
}
/* eslint-enable */

result-matching ""

    No results matching ""