All files / src/app/models CategoryModel.ts

91.66% Statements 11/12
0% Branches 0/1
0% Functions 0/1
90% Lines 9/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 651x           1x               1x 1x       1x                   1x                 1x                   1x                   1x            
import {
  Model,
  model,
  ModelArg,
  required,
} from '@decaf-ts/decorator-validation';
import {
  uilistprop,
  uielement,
  uilistmodel,
  uimodel,
  hideOn,
  uilayoutprop,
} from '@decaf-ts/ui-decorators';
import { OperationKeys, readonly, timestamp } from '@decaf-ts/db-decorators';
import { index, pk } from '@decaf-ts/core';
@uilistmodel('ngx-decaf-list-item', { icon: 'cafe-outline' })
@uimodel('ngx-decaf-crud-form')
@model()
export class CategoryModel extends Model {
 
  @pk({ type: Number })
  @hideOn(OperationKeys.CREATE)
  @uilistprop('uid')
  @readonly()
  @uielement('ngx-decaf-crud-field', {
    label: 'category.id.label',
    placeholder: 'category.id.placeholder',
  })
  id!: number;
 
  @uielement('ngx-decaf-crud-field', {
    label: 'category.name.label',
    placeholder: 'category.name.placeholder',
  })
  @uilistprop('title')
  @uilayoutprop(1, 2)
  @required()
  name!: string;
 
  @uielement('ngx-decaf-crud-field', {
    label: 'category.description.label',
    placeholder: 'category.description.placeholder',
    type: 'textarea',
  })
  @uilistprop('description')
  @index()
  @uilayoutprop(1, 2)
  description!: string;
 
  @uielement('ngx-decaf-crud-field', {
    label: 'category.created.label',
    placeholder: 'category.created.placeholder',
    type: 'textarea',
  })
  @uilistprop('info')
  @timestamp([OperationKeys.CREATE])
  @hideOn(OperationKeys.CREATE)
  createdAt!: Date;
 
  constructor(args: ModelArg<CategoryModel> = {}) {
    super(args);
  }
}