testset.1.ts.orig 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. };
  49. const checkbutton2 = {
  50. type: 'checkbutton',
  51. value: 'Yowsa'
  52. };
  53. const modifiers = ['Matches', 'Starts With', 'Contains'];
  54. const transformerFunctions: ValueTransformer = {
  55. inputFn: val => {
  56. let modifier = 'Starts With';
  57. if (/^%.*?%$/.test(val)) {
  58. modifier = 'Contains';
  59. } else if (/^[^%].*?[^%]$/.test(val)) {
  60. modifier = 'Matches';
  61. } else if (/^%.*/.test(val)) {
  62. modifier = 'Starts With';
  63. }
  64. const transformedVal = val.replace(/%/g, '').trim();
  65. return { modifier: modifier, value: transformedVal };
  66. },
  67. outputFn: (mod, val) => {
  68. let transformedValue;
  69. switch (mod) {
  70. case 'Starts With':
  71. transformedValue = `%${val}`;
  72. break;
  73. case 'Contains':
  74. transformedValue = `%${val}%`;
  75. break;
  76. case 'Matches':
  77. default:
  78. transformedValue = val;
  79. break;
  80. }
  81. return transformedValue;
  82. }
  83. };
  84. const dropdownModifiedInput = {
  85. type: 'dropdownModifiedInput',
  86. value: 'lovely',
  87. modifiers,
  88. transform: transformerFunctions
  89. };
  90. const checkbuttonGroup = {
  91. type: 'CheckbuttonGroup',
  92. firstEnablesRest: true,
  93. <<<<<<< HEAD
  94. meta: { iMaskTheOthers: {}, groupMemberTwo: {}, groupMemberThree: {} }
  95. };
  96. =======
  97. meta: [{name: 'iMaskTheOthers'}, {name: 'groupMemberTwo'}, {name: 'groupMemberThree'}]
  98. };
  99. >>>>>>> a3dfe85e06beb3d977f49241b2360bb3e2f4a09d
  100. // ---------------------------------------------------------------------------------------------------------------------
  101. // Kendo
  102. const timepicker = {
  103. type: 'timepicker'
  104. };
  105. const datepicker = {
  106. type: 'datepicker'
  107. };
  108. // ---------------------------------------------------------------------------------------------------------------------
  109. // Container
  110. const basicTextField2 = {
  111. type: 'Text',
  112. label: 'Required Field',
  113. validators: [ Validators.required, Validators.minLength(4) ],
  114. };
  115. <<<<<<< HEAD
  116. const checkbuttonGroupArray = {
  117. type: 'CheckbuttonGroup',
  118. firstEnablesRest: false,
  119. showAllOrNone: true,
  120. meta: [
  121. {name: 'One', value: 111}, {name: 'Two', value: 222}, {name: 'Three', value: 333}, {name: 'Four', value: 444},
  122. {name: 'Five', value: 555}, {name: 'Six', value: 666}, {name: 'Seven', value: 777}, {name: 'Eight', value: 888}
  123. ]
  124. =======
  125. const checkbuttonGroup2 = {
  126. type: 'CheckbuttonGroup',
  127. firstEnablesRest: true,
  128. meta: [{name: 'One'}, {name: 'Two'}, {name: 'Three'}]
  129. >>>>>>> a3dfe85e06beb3d977f49241b2360bb3e2f4a09d
  130. };
  131. const container = {
  132. type: 'Container',
  133. meta: {
  134. basicTextField2,
  135. <<<<<<< HEAD
  136. checkbuttonGroupArray
  137. =======
  138. checkbuttonGroup2,
  139. >>>>>>> a3dfe85e06beb3d977f49241b2360bb3e2f4a09d
  140. }
  141. };
  142. // ---------------------------------------------------------------------------------------------------------------------
  143. const model = {};
  144. const meta = {
  145. basicTextField,
  146. styledTextField,
  147. textareaField,
  148. passwordField,
  149. selectField,
  150. radioField,
  151. disabledTextField,
  152. radioFieldHorizontal,
  153. checkbutton,
  154. dropdownModifiedInput,
  155. checkbuttonGroup,
  156. timepicker,
  157. datepicker,
  158. container
  159. };
  160. export { model, meta };