testset.1.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. import { Validators } from '@angular/forms';
  2. import { ValueTransformer } from './../interfaces';
  3. // ---------------------------------------------------------------------------------------------------------------------
  4. // Native
  5. const basicTextField = {
  6. type: 'Text',
  7. label: 'Field One',
  8. placeholder: 'Type a value here'
  9. };
  10. const styledTextField = {
  11. type: 'Text',
  12. placeholder: 'With a DOM id and CSS classes applied',
  13. class: ['red', 'bgPaleBlue'],
  14. id: 'yoyo'
  15. };
  16. const textareaField = {
  17. type: 'Textarea',
  18. placeholder: 'Type your long-winded comments here'
  19. };
  20. const passwordField = {
  21. type: 'Password',
  22. placeholder: 'It\'s a secret'
  23. };
  24. const selectField = {
  25. type: 'Select',
  26. options: ['', 'Apples', 'Oranges', 'Pears', 'Gorgonzola']
  27. };
  28. const radioField = {
  29. type: 'radio',
  30. options: ['Tea', 'Coffee', 'Cocoa', 'Yerba Maté'],
  31. validators: [ Validators.required ],
  32. };
  33. const disabledTextField = {
  34. type: 'Text',
  35. placeholder: 'You can\'t touch this',
  36. isDisabled: true
  37. };
  38. const radioFieldHorizontal = {
  39. type: 'radio',
  40. options: ['Fish', 'Fowl', 'Neither'],
  41. horizontal: true
  42. };
  43. // ---------------------------------------------------------------------------------------------------------------------
  44. // Custom
  45. const checkbutton = {
  46. type: 'checkbutton',
  47. value: '456',
  48. onChange: (val) => { alert(val); }
  49. };
  50. const checkbutton2 = {
  51. type: 'checkbutton',
  52. value: 'Yowsa'
  53. };
  54. const modifiers = ['Matches', 'Starts With', 'Contains'];
  55. const transformerFunctions: ValueTransformer = {
  56. inputFn: val => {
  57. let modifier = 'Starts With';
  58. if (/^%.*?%$/.test(val)) {
  59. modifier = 'Contains';
  60. } else if (/^[^%].*?[^%]$/.test(val)) {
  61. modifier = 'Matches';
  62. } else if (/^%.*/.test(val)) {
  63. modifier = 'Starts With';
  64. }
  65. const transformedVal = val.replace(/%/g, '').trim();
  66. return { modifier: modifier, value: transformedVal };
  67. },
  68. outputFn: (mod, val) => {
  69. let transformedValue;
  70. switch (mod) {
  71. case 'Starts With':
  72. transformedValue = `%${val}`;
  73. break;
  74. case 'Contains':
  75. transformedValue = `%${val}%`;
  76. break;
  77. case 'Matches':
  78. default:
  79. transformedValue = val;
  80. break;
  81. }
  82. return transformedValue;
  83. }
  84. };
  85. const dropdownModifiedInput = {
  86. type: 'dropdownModifiedInput',
  87. value: 'lovely',
  88. modifiers,
  89. transform: transformerFunctions
  90. };
  91. const checkbuttonGroup = {
  92. type: 'CheckbuttonGroup',
  93. firstEnablesRest: true,
  94. meta: { iMaskTheOthers: {}, groupMemberTwo: {}, groupMemberThree: {} }
  95. };
  96. const multiline = {
  97. type: 'multiline',
  98. class: 'centered',
  99. value: `This is
  100. a multiline message
  101. for all the testers
  102. in the house`
  103. }
  104. // ---------------------------------------------------------------------------------------------------------------------
  105. // Kendo
  106. const timepicker = {
  107. type: 'timepicker',
  108. // value: new Date(1999, 10, 11, 12, 30, 45)
  109. value: "12:45"
  110. };
  111. const datepicker = {
  112. type: 'datepicker'
  113. };
  114. // ---------------------------------------------------------------------------------------------------------------------
  115. // Container
  116. const basicTextField2 = {
  117. type: 'Text',
  118. label: 'Required Field',
  119. validators: [ Validators.required, Validators.minLength(4) ],
  120. };
  121. const checkbuttonGroupArray = {
  122. type: 'CheckbuttonGroup',
  123. firstEnablesRest: false,
  124. showAllOrNone: true,
  125. meta: [
  126. {name: 'One', value: 111}, {name: 'Two', value: 222}, {name: 'Three', value: 333}, {name: 'Four', value: 444},
  127. {name: 'Five', value: 555}, {name: 'Six', value: 666}, {name: 'Seven', value: 777}, {name: 'Eight', value: 888}
  128. ]
  129. };
  130. const container = {
  131. type: 'Container',
  132. meta: {
  133. basicTextField2,
  134. checkbuttonGroupArray
  135. }
  136. };
  137. // ---------------------------------------------------------------------------------------------------------------------
  138. const model = {};
  139. const meta = {
  140. basicTextField,
  141. styledTextField,
  142. textareaField,
  143. passwordField,
  144. selectField,
  145. radioField,
  146. disabledTextField,
  147. radioFieldHorizontal,
  148. checkbutton,
  149. dropdownModifiedInput,
  150. checkbuttonGroup,
  151. timepicker,
  152. datepicker,
  153. container,
  154. multiline
  155. };
  156. export { model, meta };