table_extended.js 90 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708
  1. // initial list
  2. test('table new - initial list', function() {
  3. App.i18n.set('de-de')
  4. $('#table').append('<hr><h1>table with data</h1><div id="table-new1"></div>')
  5. var el = $('#table-new1')
  6. App.TicketPriority.refresh([
  7. {
  8. id: 1,
  9. name: '1 low',
  10. note: 'some note 1',
  11. active: true,
  12. created_at: '2014-06-10T11:17:34.000Z',
  13. },
  14. {
  15. id: 2,
  16. name: '2 normal',
  17. note: 'some note 2',
  18. active: false,
  19. created_at: '2014-06-10T10:17:34.000Z',
  20. },
  21. ], {clear: true})
  22. var table = new App.ControllerTable({
  23. el: el,
  24. overviewAttributes: ['name', 'created_at', 'active'],
  25. model: App.TicketPriority,
  26. objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'}),
  27. checkbox: false,
  28. radio: false,
  29. })
  30. //equal(el.find('table').length, 0, 'row count')
  31. //table.render()
  32. equal(el.find('table > thead > tr').length, 1, 'row count')
  33. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  34. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  35. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  36. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  37. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  38. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  39. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  40. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  41. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  42. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  43. equal(el.find('tbody > tr:nth-child(3) > td').length, 0, 'check row 3')
  44. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  45. equal(result[0], 'noChanges')
  46. equal(el.find('table > thead > tr').length, 1, 'row count')
  47. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  48. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  49. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  50. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  51. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  52. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  53. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  54. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  55. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  56. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  57. App.TicketPriority.refresh([
  58. {
  59. id: 1,
  60. name: 'Priority',
  61. note: 'some note 1',
  62. active: true,
  63. created_at: '2014-06-10T11:17:34.000Z',
  64. },
  65. ], {clear: true})
  66. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  67. equal(result[0], 'fullRender.lenghtChanged')
  68. equal(result[1], 2)
  69. equal(result[2], 1)
  70. equal(el.find('table > thead > tr').length, 1, 'row count')
  71. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  72. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  73. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  74. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  75. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), 'Priorität', 'check row 1')
  76. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  77. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  78. equal(el.find('tbody > tr:nth-child(2) > td').length, 0, 'check row 2')
  79. App.TicketPriority.refresh([], {clear: true})
  80. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  81. equal(result[0], 'emptyList')
  82. equal(el.find('table > thead > tr').length, 1, 'row count')
  83. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Keine Einträge', 'check header')
  84. equal(el.find('tbody > tr:nth-child(1) > td').length, 0, 'check row 1')
  85. App.TicketPriority.refresh([
  86. {
  87. id: 1,
  88. name: '1 low',
  89. note: 'some note 1',
  90. active: true,
  91. created_at: '2014-06-10T11:17:34.000Z',
  92. },
  93. {
  94. id: 2,
  95. name: '2 normal',
  96. note: 'some note 2',
  97. active: false,
  98. created_at: '2014-06-10T10:17:34.000Z',
  99. },
  100. ], {clear: true})
  101. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  102. equal(result[0], 'fullRender')
  103. equal(el.find('table > thead > tr').length, 1, 'row count')
  104. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  105. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  106. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  107. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  108. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  109. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  110. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  111. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  112. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  113. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  114. equal(el.find('tbody > tr:nth-child(3) > td').length, 0, 'check row 3')
  115. App.TicketPriority.refresh([
  116. {
  117. id: 1,
  118. name: '1 low',
  119. note: 'some note 1',
  120. active: true,
  121. created_at: '2014-06-10T11:17:34.000Z',
  122. },
  123. {
  124. id: 2,
  125. name: '2 normal',
  126. note: 'some note 2',
  127. active: false,
  128. created_at: '2014-06-10T10:17:34.000Z',
  129. },
  130. {
  131. id: 3,
  132. name: '3 high',
  133. note: 'some note 3',
  134. active: false,
  135. created_at: '2014-06-10T10:17:38.000Z',
  136. },
  137. ], {clear: true})
  138. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  139. equal(result[0], 'fullRender.contentRemoved')
  140. equal(result[1][0], undefined)
  141. equal(result[2][0], 2)
  142. equal(result[2][1], undefined)
  143. equal(el.find('table > thead > tr').length, 1, 'row count')
  144. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  145. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  146. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  147. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  148. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  149. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  150. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  151. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  152. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  153. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  154. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  155. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '3 hoch', 'check row 3')
  156. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  157. equal(el.find('tbody > tr:nth-child(4) > td').length, 0, 'check row 4')
  158. result = table.update({sync: true, orderDirection: 'DESC', orderBy: 'name'})
  159. equal(result[0], 'fullRender.contentChanged')
  160. equal(result[1], 0)
  161. equal(el.find('table > thead > tr').length, 1, 'row count')
  162. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  163. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  164. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  165. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  166. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '3 hoch', 'check row 1')
  167. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  168. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  169. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  170. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  171. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  172. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '1 niedrig', 'check row 3')
  173. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  174. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  175. equal(el.find('tbody > tr:nth-child(4) > td').length, 0, 'check row 4')
  176. result = table.update({sync: true, orderDirection: 'ASC', orderBy: 'name'})
  177. equal(result[0], 'fullRender.contentChanged')
  178. equal(result[1], 0)
  179. equal(el.find('table > thead > tr').length, 1, 'row count')
  180. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  181. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  182. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  183. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  184. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  185. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  186. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  187. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  188. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  189. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  190. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  191. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '3 hoch', 'check row 3')
  192. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  193. equal(el.find('tbody > tr:nth-child(4) > td').length, 0, 'check row 4')
  194. App.TicketPriority.refresh([
  195. {
  196. id: 1,
  197. name: '1 low',
  198. note: 'some note 1',
  199. active: true,
  200. created_at: '2014-06-10T11:17:34.000Z',
  201. },
  202. {
  203. id: 3,
  204. name: '3 high',
  205. note: 'some note 3',
  206. active: false,
  207. created_at: '2014-06-10T10:17:38.000Z',
  208. },
  209. ], {clear: true})
  210. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  211. equal(result[0], 'fullRender.contentRemoved')
  212. equal(result[1][0], 1)
  213. equal(result[1][1], undefined)
  214. notOk(result[1][1])
  215. equal(el.find('table > thead > tr').length, 1, 'row count')
  216. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  217. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  218. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  219. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  220. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  221. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  222. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  223. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  224. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '3 hoch', 'check row 3')
  225. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  226. equal(el.find('tbody > tr:nth-child(3) > td').length, 0, 'check row 3')
  227. result = table.update({sync: true, overviewAttributes: ['name', 'created_at']})
  228. equal(result[0], 'fullRender.overviewAttributesChanged')
  229. equal(el.find('table > thead > tr').length, 1, 'row count')
  230. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  231. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  232. equal(el.find('table > thead > tr > th').length, 2, 'check header')
  233. equal(el.find('tbody > tr:nth-child(1) > td').length, 2, 'check row 1')
  234. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  235. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  236. equal(el.find('tbody > tr:nth-child(2) > td').length, 2, 'check row 2')
  237. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '3 hoch', 'check row 3')
  238. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  239. equal(el.find('tbody > tr:nth-child(3) > td').length, 0, 'check row 3')
  240. App.TicketPriority.refresh([], {clear: true})
  241. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  242. equal(result[0], 'emptyList')
  243. equal(el.find('table > thead > tr').length, 1, 'row count')
  244. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Keine Einträge', 'check header')
  245. equal(el.find('tbody > tr:nth-child(1) > td').length, 0, 'check row 1')
  246. App.TicketPriority.refresh([
  247. {
  248. id: 1,
  249. name: '1 low',
  250. note: 'some note 1',
  251. active: true,
  252. created_at: '2014-06-10T11:17:34.000Z',
  253. },
  254. {
  255. id: 3,
  256. name: '3 high',
  257. note: 'some note 3',
  258. active: false,
  259. created_at: '2014-06-10T10:17:38.000Z',
  260. },
  261. ], {clear: true})
  262. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'}), overviewAttributes: ['name'], orderBy: 'created_at', orderDirection: 'DESC'})
  263. equal(result[0], 'fullRender')
  264. equal(el.find('table > thead > tr').length, 1, 'row count')
  265. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  266. equal(el.find('table > thead > tr > th').length, 1, 'check header')
  267. equal(el.find('tbody > tr:nth-child(1) > td').length, 1, 'check row 1')
  268. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  269. equal(el.find('tbody > tr:nth-child(2) > td').length, 1, 'check row 2')
  270. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '3 hoch', 'check row 3')
  271. equal(el.find('tbody > tr:nth-child(3) > td').length, 0, 'check row 3')
  272. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'}), overviewAttributes: ['name'], orderBy: 'created_at', orderDirection: 'ASC'})
  273. equal(result[0], 'fullRender.overviewAttributesChanged')
  274. equal(el.find('table > thead > tr').length, 1, 'row count')
  275. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  276. equal(el.find('table > thead > tr > th').length, 1, 'check header')
  277. equal(el.find('tbody > tr:nth-child(1) > td').length, 1, 'check row 2')
  278. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '3 hoch', 'check row 3')
  279. equal(el.find('tbody > tr:nth-child(2) > td').length, 1, 'check row 1')
  280. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 niedrig', 'check row 1')
  281. equal(el.find('tbody > tr:nth-child(3) > td').length, 0, 'check row 3')
  282. $('#table').append('<hr><h1>table group by with data</h1><div id="table-new2"></div>')
  283. var el = $('#table-new2')
  284. App.TicketPriority.refresh([
  285. {
  286. id: 1,
  287. name: '1 low',
  288. note: 'some note',
  289. active: true,
  290. created_at: '2014-06-10T11:17:34.000Z',
  291. },
  292. {
  293. id: 2,
  294. name: '2 normal',
  295. note: 'some note',
  296. active: true,
  297. created_at: '2014-06-10T10:17:30.000Z',
  298. },
  299. {
  300. id: 3,
  301. name: '3 high',
  302. note: 'some other note',
  303. active: true,
  304. created_at: '2014-06-10T10:17:38.000Z',
  305. },
  306. ], {clear: true})
  307. var table = new App.ControllerTable({
  308. el: el,
  309. overviewAttributes: ['name', 'created_at', 'active'],
  310. model: App.TicketPriority,
  311. objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'}),
  312. checkbox: false,
  313. radio: false,
  314. groupBy: 'note',
  315. })
  316. equal(el.find('table > thead > tr').length, 1, 'row count')
  317. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  318. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  319. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  320. equal(el.find('tbody > tr:nth-child(1) > td').length, 1, 'check row 1')
  321. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), 'some note', 'check row 1')
  322. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  323. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 niedrig', 'check row 2')
  324. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  325. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  326. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  327. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '2 normal', 'check row 3')
  328. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  329. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  330. equal(el.find('tbody > tr:nth-child(4) > td').length, 1, 'check row 3')
  331. equal(el.find('tbody > tr:nth-child(4) > td:first').text().trim(), 'some other note', 'check row 3')
  332. equal(el.find('tbody > tr:nth-child(5) > td:first').text().trim(), '3 hoch', 'check row 5')
  333. equal(el.find('tbody > tr:nth-child(5) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 5')
  334. equal(el.find('tbody > tr:nth-child(5) > td:nth-child(3)').text().trim(), 'true', 'check row 5')
  335. equal(el.find('tbody > tr:nth-child(6) > td').length, 0, 'check row 6')
  336. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  337. equal(result[0], 'noChanges')
  338. App.TicketPriority.refresh([
  339. {
  340. id: 1,
  341. name: '1 low',
  342. note: 'some note',
  343. active: true,
  344. created_at: '2014-06-10T11:17:34.000Z',
  345. },
  346. {
  347. id: 2,
  348. name: '2 normal',
  349. note: 'some note',
  350. active: true,
  351. created_at: '2014-06-10T10:17:30.000Z',
  352. },
  353. ], {clear: true})
  354. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  355. equal(result[0], 'fullRender.contentRemoved')
  356. equal(el.find('table > thead > tr').length, 1, 'row count')
  357. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  358. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  359. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  360. equal(el.find('tbody > tr:nth-child(1) > td').length, 1, 'check row 1')
  361. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), 'some note', 'check row 1')
  362. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  363. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 niedrig', 'check row 2')
  364. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  365. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  366. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  367. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '2 normal', 'check row 3')
  368. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  369. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  370. equal(el.find('tbody > tr:nth-child(4) > td').length, 0, 'check row 6')
  371. App.TicketPriority.refresh([
  372. {
  373. id: 1,
  374. name: '1 low',
  375. note: 'some note',
  376. active: true,
  377. created_at: '2014-06-10T11:17:34.000Z',
  378. },
  379. {
  380. id: 2,
  381. name: '2 normal',
  382. note: 'some note',
  383. active: true,
  384. created_at: '2014-06-10T10:17:30.000Z',
  385. },
  386. {
  387. id: 3,
  388. name: '3 high',
  389. note: 'some other note',
  390. active: true,
  391. created_at: '2014-06-10T10:17:38.000Z',
  392. },
  393. ], {clear: true})
  394. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  395. equal(result[0], 'fullRender.contentRemoved')
  396. equal(result[1][0], undefined)
  397. equal(result[2][0], 3)
  398. equal(result[2][1], 4)
  399. equal(result[2][2], undefined)
  400. equal(el.find('table > thead > tr').length, 1, 'row count')
  401. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  402. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  403. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  404. equal(el.find('tbody > tr:nth-child(1) > td').length, 1, 'check row 1')
  405. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), 'some note', 'check row 1')
  406. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  407. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 niedrig', 'check row 2')
  408. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  409. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  410. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  411. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '2 normal', 'check row 3')
  412. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  413. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  414. equal(el.find('tbody > tr:nth-child(4) > td').length, 1, 'check row 3')
  415. equal(el.find('tbody > tr:nth-child(4) > td:first').text().trim(), 'some other note', 'check row 3')
  416. equal(el.find('tbody > tr:nth-child(5) > td:first').text().trim(), '3 hoch', 'check row 5')
  417. equal(el.find('tbody > tr:nth-child(5) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 5')
  418. equal(el.find('tbody > tr:nth-child(5) > td:nth-child(3)').text().trim(), 'true', 'check row 5')
  419. equal(el.find('tbody > tr:nth-child(6) > td').length, 0, 'check row 6')
  420. App.TicketPriority.refresh([
  421. {
  422. id: 1,
  423. name: '1 low',
  424. note: 'some note',
  425. active: true,
  426. created_at: '2014-06-10T11:17:34.000Z',
  427. },
  428. {
  429. id: 2,
  430. name: '2 normal',
  431. note: 'some note',
  432. active: true,
  433. created_at: '2014-06-10T10:17:30.000Z',
  434. },
  435. {
  436. id: 3,
  437. name: '3 high',
  438. note: 'some other note',
  439. active: true,
  440. created_at: '2014-06-10T10:17:38.000Z',
  441. },
  442. {
  443. id: 4,
  444. name: '4 high',
  445. note: 'some other note',
  446. active: true,
  447. created_at: '2014-06-10T10:17:39.000Z',
  448. },
  449. {
  450. id: 5,
  451. name: '5 high',
  452. note: 'some note',
  453. active: true,
  454. created_at: '2014-06-10T10:17:39.000Z',
  455. },
  456. ], {clear: true})
  457. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  458. equal(result[0], 'fullRender.contentRemoved')
  459. equal(result[1][0], undefined)
  460. equal(result[2][0], 3)
  461. equal(result[2][1], 6)
  462. equal(result[2][2], undefined)
  463. equal(el.find('table > thead > tr').length, 1, 'row count')
  464. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  465. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  466. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  467. equal(el.find('tbody > tr:nth-child(1) > td').length, 1, 'check row 1')
  468. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), 'some note', 'check row 1')
  469. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  470. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 niedrig', 'check row 2')
  471. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  472. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  473. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  474. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '2 normal', 'check row 3')
  475. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  476. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  477. equal(el.find('tbody > tr:nth-child(4) > td').length, 3, 'check row 4')
  478. equal(el.find('tbody > tr:nth-child(4) > td:first').text().trim(), '5 high', 'check row 4')
  479. equal(el.find('tbody > tr:nth-child(4) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 4')
  480. equal(el.find('tbody > tr:nth-child(4) > td:nth-child(3)').text().trim(), 'true', 'check row 4')
  481. equal(el.find('tbody > tr:nth-child(5) > td').length, 1, 'check row 5')
  482. equal(el.find('tbody > tr:nth-child(5) > td:first').text().trim(), 'some other note', 'check row 5')
  483. equal(el.find('tbody > tr:nth-child(6) > td:first').text().trim(), '3 hoch', 'check row 6')
  484. equal(el.find('tbody > tr:nth-child(6) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 6')
  485. equal(el.find('tbody > tr:nth-child(6) > td:nth-child(3)').text().trim(), 'true', 'check row 6')
  486. equal(el.find('tbody > tr:nth-child(7) > td').length, 3, 'check row 7')
  487. equal(el.find('tbody > tr:nth-child(7) > td:first').text().trim(), '4 high', 'check row 7')
  488. equal(el.find('tbody > tr:nth-child(7) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 7')
  489. equal(el.find('tbody > tr:nth-child(7) > td:nth-child(3)').text().trim(), 'true', 'check row 7')
  490. equal(el.find('tbody > tr:nth-child(8) > td').length, 0, 'check row 8')
  491. $('#table').append('<hr><h1>table with large data</h1><div id="table-new3"></div>')
  492. var el = $('#table-new3')
  493. var objects = [];
  494. var created_at = Date.parse('2014-06-10T11:17:34.000Z')
  495. for (i = 0; i < 1000; i++) {
  496. local_created_at = new Date(created_at - (1000 * 60 * 60 * 24 * i)).toISOString()
  497. item = {
  498. id: i,
  499. name: i + ' prio',
  500. note: 'some note',
  501. active: true,
  502. created_at: local_created_at,
  503. }
  504. objects.push(item)
  505. }
  506. App.TicketPriority.refresh(objects.reverse(), {clear: true})
  507. var table = new App.ControllerTable({
  508. tableId: 'large_table_test',
  509. el: el,
  510. overviewAttributes: ['name', 'created_at', 'active'],
  511. model: App.TicketPriority,
  512. objects: App.TicketPriority.all(),
  513. checkbox: false,
  514. radio: false,
  515. ttt: true
  516. })
  517. equal(el.find('table > thead > tr').length, 1, 'row count')
  518. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  519. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  520. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  521. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  522. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '999 prio', 'check row 1')
  523. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '15.09.2011', 'check row 1')
  524. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  525. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  526. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '998 prio', 'check row 2')
  527. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '16.09.2011', 'check row 2')
  528. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  529. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  530. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '997 prio', 'check row 3')
  531. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '17.09.2011', 'check row 3')
  532. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  533. equal(el.find('tbody > tr').length, 150)
  534. equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  535. equal(el.find('.js-tableHead[data-column-key="name"] .js-sort .icon').length, 0)
  536. el.find('.js-tableHead[data-column-key="name"] .js-sort').click()
  537. equal(el.find('table > thead > tr').length, 1, 'row count')
  538. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  539. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  540. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  541. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  542. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '0 prio', 'check row 1')
  543. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  544. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  545. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  546. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 prio', 'check row 2')
  547. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '09.06.2014', 'check row 2')
  548. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  549. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  550. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '10 prio', 'check row 3')
  551. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '31.05.2014', 'check row 3')
  552. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  553. equal(el.find('tbody > tr').length, 150)
  554. equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  555. equal(el.find('.js-tableHead[data-column-key="name"] .js-sort .icon.icon-arrow-up').length, 1)
  556. equal(el.find('.js-tableHead[data-column-key="name"] .js-sort .icon.icon-arrow-down').length, 0)
  557. el.find('.js-tableHead[data-column-key="name"] .js-sort').click()
  558. equal(el.find('table > thead > tr').length, 1, 'row count')
  559. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  560. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  561. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  562. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  563. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '999 prio', 'check row 1')
  564. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '15.09.2011', 'check row 1')
  565. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  566. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  567. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '998 prio', 'check row 2')
  568. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '16.09.2011', 'check row 2')
  569. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  570. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  571. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '997 prio', 'check row 3')
  572. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '17.09.2011', 'check row 3')
  573. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  574. equal(el.find('tbody > tr').length, 150)
  575. equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  576. equal(el.find('.js-tableHead[data-column-key="name"] .js-sort .icon.icon-arrow-down').length, 1)
  577. equal(el.find('.js-tableHead[data-column-key="name"] .js-sort .icon.icon-arrow-up').length, 0)
  578. equal(el.find('.js-tableHead[data-column-key="created_at"] .js-sort .icon').length, 0)
  579. el.find('.js-tableHead[data-column-key="created_at"] .js-sort').click()
  580. equal(el.find('table > thead > tr').length, 1, 'row count')
  581. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  582. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  583. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  584. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  585. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '999 prio', 'check row 1')
  586. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '15.09.2011', 'check row 1')
  587. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  588. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  589. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '998 prio', 'check row 2')
  590. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '16.09.2011', 'check row 2')
  591. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  592. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  593. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '997 prio', 'check row 3')
  594. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '17.09.2011', 'check row 3')
  595. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  596. equal(el.find('tbody > tr').length, 150)
  597. equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  598. equal(el.find('.js-tableHead[data-column-key="name"] .js-sort .icon').length, 0)
  599. equal(el.find('.js-tableHead[data-column-key="created_at"] .js-sort .icon.icon-arrow-down').length, 0)
  600. equal(el.find('.js-tableHead[data-column-key="created_at"] .js-sort .icon.icon-arrow-up').length, 1)
  601. el.find('.js-tableHead[data-column-key="created_at"] .js-sort').click()
  602. equal(el.find('table > thead > tr').length, 1, 'row count')
  603. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  604. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  605. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  606. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  607. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '0 prio', 'check row 1')
  608. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  609. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  610. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  611. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 prio', 'check row 2')
  612. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '09.06.2014', 'check row 2')
  613. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  614. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  615. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '2 prio', 'check row 3')
  616. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '08.06.2014', 'check row 3')
  617. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  618. equal(el.find('tbody > tr').length, 150)
  619. equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  620. equal(el.find('.js-tableHead[data-column-key="name"] .js-sort .icon').length, 0)
  621. equal(el.find('.js-tableHead[data-column-key="created_at"] .js-sort .icon.icon-arrow-down').length, 1)
  622. equal(el.find('.js-tableHead[data-column-key="created_at"] .js-sort .icon.icon-arrow-up').length, 0)
  623. objects = App.TicketPriority.all().reverse()
  624. objects.shift()
  625. objects.shift()
  626. result = table.update({sync: true, objects: objects})
  627. equal(result[0], 'fullRender.contentRemoved')
  628. equal(result[1][0], 1)
  629. equal(result[1][1], 0)
  630. equal(result[2][0], 148)
  631. equal(result[2][1], 149)
  632. equal(el.find('table > thead > tr').length, 1, 'row count')
  633. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  634. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  635. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  636. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  637. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '2 prio', 'check row 1')
  638. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '08.06.2014', 'check row 1')
  639. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  640. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  641. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '3 prio', 'check row 2')
  642. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '07.06.2014', 'check row 2')
  643. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  644. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  645. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '4 prio', 'check row 3')
  646. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '06.06.2014', 'check row 3')
  647. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  648. equal(el.find('tbody > tr:nth-child(149) > td:first').text().trim(), '150 prio', 'check row 3')
  649. equal(el.find('tbody > tr:nth-child(149) > td:nth-child(2)').text().trim(), '11.01.2014', 'check row 3')
  650. equal(el.find('tbody > tr:nth-child(149) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  651. equal(el.find('tbody > tr:nth-child(150) > td:first').text().trim(), '151 prio', 'check row 3')
  652. equal(el.find('tbody > tr:nth-child(150) > td:nth-child(2)').text().trim(), '10.01.2014', 'check row 3')
  653. equal(el.find('tbody > tr:nth-child(150) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  654. equal(el.find('tbody > tr').length, 150)
  655. equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  656. equal(el.find('.js-tableHead[data-column-key="name"] .js-sort .icon').length, 0)
  657. equal(el.find('.js-tableHead[data-column-key="created_at"] .js-sort .icon.icon-arrow-down').length, 1)
  658. equal(el.find('.js-tableHead[data-column-key="created_at"] .js-sort .icon.icon-arrow-up').length, 0)
  659. el.find('.js-tableHead[data-column-key="created_at"] .js-sort').click()
  660. equal(el.find('table > thead > tr').length, 1, 'row count')
  661. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  662. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  663. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  664. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  665. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '999 prio', 'check row 1')
  666. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '15.09.2011', 'check row 1')
  667. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  668. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  669. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '998 prio', 'check row 2')
  670. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '16.09.2011', 'check row 2')
  671. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  672. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  673. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '997 prio', 'check row 3')
  674. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '17.09.2011', 'check row 3')
  675. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  676. equal(el.find('tbody > tr').length, 150)
  677. equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  678. equal(el.find('.js-tableHead[data-column-key="name"] .js-sort .icon').length, 0)
  679. equal(el.find('.js-tableHead[data-column-key="created_at"] .js-sort .icon.icon-arrow-down').length, 0)
  680. equal(el.find('.js-tableHead[data-column-key="created_at"] .js-sort .icon.icon-arrow-up').length, 1)
  681. el.find('.js-tableHead[data-column-key="created_at"] .js-sort').click()
  682. equal(el.find('table > thead > tr').length, 1, 'row count')
  683. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  684. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  685. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  686. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  687. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '2 prio', 'check row 1')
  688. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '08.06.2014', 'check row 1')
  689. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  690. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  691. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '3 prio', 'check row 2')
  692. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '07.06.2014', 'check row 2')
  693. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  694. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  695. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '4 prio', 'check row 3')
  696. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '06.06.2014', 'check row 3')
  697. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  698. equal(el.find('tbody > tr:nth-child(149) > td:first').text().trim(), '150 prio', 'check row 3')
  699. equal(el.find('tbody > tr:nth-child(149) > td:nth-child(2)').text().trim(), '11.01.2014', 'check row 3')
  700. equal(el.find('tbody > tr:nth-child(149) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  701. equal(el.find('tbody > tr:nth-child(150) > td:first').text().trim(), '151 prio', 'check row 3')
  702. equal(el.find('tbody > tr:nth-child(150) > td:nth-child(2)').text().trim(), '10.01.2014', 'check row 3')
  703. equal(el.find('tbody > tr:nth-child(150) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  704. equal(el.find('tbody > tr').length, 150)
  705. equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  706. $('#table').append('<hr><h1>table with now data</h1><div id="table-new4"></div>')
  707. var el = $('#table-new4')
  708. App.TicketPriority.refresh([
  709. {
  710. id: 1,
  711. name: '1 low',
  712. note: 'some note',
  713. active: true,
  714. created_at: '2014-06-10T11:17:34.000Z',
  715. },
  716. ], {clear: true})
  717. var table = new App.ControllerTable({
  718. el: el,
  719. overviewAttributes: ['name', 'created_at', 'active'],
  720. model: App.TicketPriority,
  721. objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'}),
  722. checkbox: false,
  723. radio: false,
  724. })
  725. equal(el.find('table > thead > tr').length, 1, 'row count')
  726. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  727. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  728. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  729. equal(el.find('tbody > tr:nth-child(1) > td').length, 3)
  730. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig')
  731. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014')
  732. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true')
  733. equal(el.find('tbody > tr:nth-child(2) > td').length, 0)
  734. App.TicketPriority.refresh([
  735. {
  736. id: 1,
  737. name: '1 low',
  738. note: 'some note',
  739. active: true,
  740. created_at: '2014-06-10T11:17:34.000Z',
  741. },
  742. {
  743. id: 2,
  744. name: '2 normal',
  745. note: 'some note',
  746. active: true,
  747. created_at: '2014-06-10T10:17:30.000Z',
  748. },
  749. ], {clear: true})
  750. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  751. equal(result[0], 'fullRender.contentRemoved')
  752. equal(result[1][0], undefined)
  753. equal(result[2][0], 1)
  754. equal(result[2][1], undefined)
  755. equal(el.find('table > thead > tr').length, 1, 'row count')
  756. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  757. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  758. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  759. equal(el.find('tbody > tr:nth-child(1) > td').length, 3)
  760. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig')
  761. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014')
  762. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true')
  763. equal(el.find('tbody > tr:nth-child(2) > td').length, 3)
  764. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal')
  765. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014')
  766. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true')
  767. equal(el.find('tbody > tr:nth-child(3) > td').length, 0)
  768. App.TicketPriority.refresh([
  769. {
  770. id: 1,
  771. name: '1 low',
  772. note: 'some note',
  773. active: true,
  774. created_at: '2014-06-10T11:17:34.000Z',
  775. },
  776. {
  777. id: 2,
  778. name: '2 normal',
  779. note: 'some note',
  780. active: true,
  781. created_at: '2014-06-10T10:17:30.000Z',
  782. },
  783. {
  784. id: 3,
  785. name: '3 high',
  786. note: 'some note 3',
  787. active: true,
  788. created_at: '2014-06-10T10:17:38.000Z',
  789. },
  790. ], {clear: true})
  791. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  792. equal(result[0], 'fullRender.contentRemoved')
  793. equal(result[1][0], undefined)
  794. equal(result[2][0], 2)
  795. equal(result[2][1], undefined)
  796. equal(el.find('table > thead > tr').length, 1, 'row count')
  797. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  798. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  799. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  800. equal(el.find('tbody > tr:nth-child(1) > td').length, 3)
  801. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig')
  802. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014')
  803. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true')
  804. equal(el.find('tbody > tr:nth-child(2) > td').length, 3)
  805. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal')
  806. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014')
  807. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true')
  808. equal(el.find('tbody > tr:nth-child(3) > td').length, 3)
  809. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '3 hoch')
  810. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014')
  811. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true')
  812. equal(el.find('tbody > tr:nth-child(4) > td').length, 0)
  813. App.TicketPriority.refresh([
  814. {
  815. id: 3,
  816. name: '3 high',
  817. note: 'some note 3',
  818. active: true,
  819. created_at: '2014-06-10T10:17:38.000Z',
  820. },
  821. {
  822. id: 2,
  823. name: '2 normal',
  824. note: 'some note',
  825. active: true,
  826. created_at: '2014-06-10T10:17:30.000Z',
  827. },
  828. ], {clear: true})
  829. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  830. equal(result[0], 'fullRender.contentRemoved')
  831. equal(result[1][0], 0)
  832. equal(result[1][1], undefined)
  833. equal(result[2][0], undefined)
  834. equal(el.find('table > thead > tr').length, 1, 'row count')
  835. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  836. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  837. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  838. equal(el.find('tbody > tr:nth-child(1) > td').length, 3)
  839. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '2 normal')
  840. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014')
  841. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true')
  842. equal(el.find('tbody > tr:nth-child(2) > td').length, 3)
  843. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '3 hoch')
  844. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014')
  845. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true')
  846. equal(el.find('tbody > tr:nth-child(3) > td').length, 0)
  847. App.TicketPriority.refresh([
  848. {
  849. id: 2,
  850. name: '2 normal',
  851. note: 'some note',
  852. active: true,
  853. created_at: '2014-06-10T10:17:30.000Z',
  854. },
  855. ], {clear: true})
  856. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  857. equal(result[0], 'fullRender.lenghtChanged')
  858. equal(el.find('table > thead > tr').length, 1, 'row count')
  859. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  860. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  861. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  862. equal(el.find('tbody > tr:nth-child(1) > td').length, 3)
  863. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '2 normal')
  864. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014')
  865. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true')
  866. equal(el.find('tbody > tr:nth-child(2) > td').length, 0)
  867. App.TicketPriority.refresh([], {clear: true})
  868. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  869. equal(result[0], 'emptyList')
  870. equal(el.find('table > thead > tr').length, 1, 'row count')
  871. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Keine Einträge', 'check header')
  872. equal(el.find('tbody > tr:nth-child(1) > td').length, 0, 'check row 1')
  873. App.TicketPriority.refresh([
  874. {
  875. id: 2,
  876. name: '2 normal',
  877. note: 'some note',
  878. active: true,
  879. created_at: '2014-06-10T10:17:30.000Z',
  880. },
  881. ], {clear: true})
  882. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  883. equal(result[0], 'fullRender')
  884. equal(el.find('table > thead > tr').length, 1, 'row count')
  885. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  886. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  887. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  888. equal(el.find('tbody > tr:nth-child(1) > td').length, 3)
  889. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '2 normal')
  890. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014')
  891. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true')
  892. equal(el.find('tbody > tr:nth-child(2) > td').length, 0)
  893. App.TicketPriority.refresh([
  894. {
  895. id: 1,
  896. name: '1 low',
  897. note: 'some note',
  898. active: true,
  899. created_at: '2014-06-10T11:17:34.000Z',
  900. },
  901. {
  902. id: 2,
  903. name: '2 normal',
  904. note: 'some note',
  905. active: true,
  906. created_at: '2014-06-10T10:17:30.000Z',
  907. },
  908. ], {clear: true})
  909. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  910. equal(result[0], 'fullRender.contentRemoved')
  911. equal(result[1][0], undefined)
  912. equal(result[2][0], 0)
  913. equal(result[2][1], undefined)
  914. equal(el.find('table > thead > tr').length, 1, 'row count')
  915. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  916. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  917. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  918. equal(el.find('tbody > tr:nth-child(1) > td').length, 3)
  919. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig')
  920. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014')
  921. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true')
  922. equal(el.find('tbody > tr:nth-child(2) > td').length, 3)
  923. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal')
  924. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014')
  925. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true')
  926. equal(el.find('tbody > tr:nth-child(3) > td').length, 0)
  927. App.TicketPriority.refresh([
  928. {
  929. id: 2,
  930. name: '2 normal',
  931. note: 'some note',
  932. active: true,
  933. created_at: '2014-06-10T10:17:30.000Z',
  934. },
  935. ], {clear: true})
  936. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  937. equal(result[0], 'fullRender.lenghtChanged')
  938. equal(el.find('table > thead > tr').length, 1, 'row count')
  939. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  940. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  941. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  942. equal(el.find('tbody > tr:nth-child(1) > td').length, 3)
  943. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '2 normal')
  944. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014')
  945. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true')
  946. equal(el.find('tbody > tr:nth-child(2) > td').length, 0)
  947. $('#table').append('<hr><h1>table with large data and pager</h1><div id="table-new5"></div>')
  948. var el = $('#table-new5')
  949. var objects = [];
  950. var created_at = Date.parse('2014-06-10T11:17:34.000Z')
  951. for (i = 0; i < 151; i++) {
  952. local_created_at = new Date(created_at - (1000 * 60 * 60 * 24 * i)).toISOString()
  953. item = {
  954. id: i,
  955. name: i + ' prio',
  956. note: 'some note',
  957. active: true,
  958. created_at: local_created_at,
  959. }
  960. objects.push(item)
  961. }
  962. App.TicketPriority.refresh(objects, {clear: true})
  963. var table = new App.ControllerTable({
  964. tableId: 'large_table_test_pager',
  965. el: el,
  966. overviewAttributes: ['name', 'created_at', 'active'],
  967. model: App.TicketPriority,
  968. objects: App.TicketPriority.all(),
  969. checkbox: false,
  970. radio: false,
  971. ttt: true
  972. })
  973. equal(el.find('table > thead > tr').length, 1, 'row count')
  974. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  975. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  976. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  977. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  978. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '0 prio', 'check row 1')
  979. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  980. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  981. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  982. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 prio', 'check row 2')
  983. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '09.06.2014', 'check row 2')
  984. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  985. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  986. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '2 prio', 'check row 3')
  987. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '08.06.2014', 'check row 3')
  988. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  989. equal(el.find('tbody > tr').length, 150)
  990. equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  991. equal(el.find('.js-pager').first().find('.js-page').length, 2)
  992. equal(el.find('.js-pager').first().find('.js-page.is-selected').length, 1)
  993. equal(el.find('.js-pager').first().find('.js-page.is-selected').text(), '1')
  994. el.find('.js-pager').first().find('.js-page:nth-child(2)').click()
  995. equal(el.find('table > thead > tr').length, 1, 'row count')
  996. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  997. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  998. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  999. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1000. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '150 prio', 'check row 1')
  1001. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '11.01.2014', 'check row 1')
  1002. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1003. equal(el.find('tbody > tr').length, 1)
  1004. equal(el.find('tbody > tr:nth-child(2) > td').length, 0)
  1005. objects = [
  1006. {
  1007. id: 500,
  1008. name: '500 prio',
  1009. note: 'some note',
  1010. active: true,
  1011. created_at: '2014-06-10T10:17:30.000Z',
  1012. },
  1013. ]
  1014. App.TicketPriority.refresh(objects)
  1015. result = table.update({sync: true, objects: App.TicketPriority.all()})
  1016. equal(result[0], 'fullRender.contentRemoved')
  1017. equal(result[1][0], undefined)
  1018. equal(result[2][0], 1)
  1019. equal(result[2][1], undefined)
  1020. equal(el.find('table > thead > tr').length, 1, 'row count')
  1021. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1022. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1023. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1024. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1025. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '150 prio', 'check row 1')
  1026. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '11.01.2014', 'check row 1')
  1027. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1028. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 1')
  1029. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '500 prio', 'check row 1')
  1030. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  1031. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1032. equal(el.find('tbody > tr').length, 2)
  1033. equal(el.find('tbody > tr:nth-child(3) > td').length, 0)
  1034. objects = App.TicketPriority.all()
  1035. objects.splice(2,1)
  1036. result = table.update({sync: true, objects: objects})
  1037. equal(result[0], 'fullRender.lenghtChanged')
  1038. //equal(result[1][0], 1)
  1039. //equal(result[1][1], undefined)
  1040. //equal(result[2][0], undefined)
  1041. equal(el.find('table > thead > tr').length, 1, 'row count')
  1042. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1043. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1044. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1045. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1046. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '500 prio', 'check row 1')
  1047. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  1048. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1049. equal(el.find('tbody > tr').length, 1)
  1050. equal(el.find('tbody > tr:nth-child(2) > td').length, 0)
  1051. objects.splice(2,1)
  1052. result = table.update({sync: true, objects: objects})
  1053. equal(result[0], 'fullRender.lenghtChanged')
  1054. //equal(result[0], 'fullRender.contentRemoved')
  1055. //equal(result[1][0], 1)
  1056. //equal(result[1][1], undefined)
  1057. //equal(result[2][0], undefined)
  1058. equal(el.find('table > thead > tr').length, 1, 'row count')
  1059. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1060. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1061. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1062. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1063. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '0 prio', 'check row 1')
  1064. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  1065. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1066. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1067. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 prio', 'check row 2')
  1068. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '09.06.2014', 'check row 2')
  1069. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  1070. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1071. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '4 prio', 'check row 3')
  1072. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '06.06.2014', 'check row 3')
  1073. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  1074. equal(el.find('tbody > tr').length, 150)
  1075. equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  1076. equal(el.find('.js-pager').first().find('.js-page').length, 0)
  1077. objects = [
  1078. {
  1079. id: 500,
  1080. name: '500 prio',
  1081. note: 'some note',
  1082. active: true,
  1083. created_at: '2014-06-10T10:17:30.000Z',
  1084. },
  1085. ]
  1086. App.TicketPriority.refresh(objects)
  1087. objects = App.TicketPriority.all()
  1088. result = table.update({sync: true, objects: objects})
  1089. equal(result[0], 'fullRender.contentRemoved')
  1090. equal(el.find('.js-pager').first().find('.js-page').length, 2)
  1091. equal(el.find('.js-pager').first().find('.js-page.is-selected').length, 1)
  1092. equal(el.find('.js-pager').first().find('.js-page.is-selected').text(), '1')
  1093. el.find('.js-pager').first().find('.js-page:nth-child(2)').click()
  1094. equal(el.find('table > thead > tr').length, 1, 'row count')
  1095. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1096. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1097. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1098. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1099. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '150 prio', 'check row 1')
  1100. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '11.01.2014', 'check row 1')
  1101. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1102. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 1')
  1103. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '500 prio', 'check row 1')
  1104. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  1105. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1106. equal(el.find('tbody > tr').length, 2)
  1107. equal(el.find('tbody > tr:nth-child(3) > td').length, 0)
  1108. equal(el.find('.js-pager').first().find('.js-page').length, 2)
  1109. equal(el.find('.js-pager').first().find('.js-page.is-selected').length, 1)
  1110. equal(el.find('.js-pager').first().find('.js-page.is-selected').text(), '2')
  1111. el.find('.js-pager').first().find('.js-page:nth-child(1)').click()
  1112. equal(el.find('table > thead > tr').length, 1, 'row count')
  1113. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1114. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1115. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1116. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1117. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '0 prio', 'check row 1')
  1118. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  1119. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1120. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1121. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 prio', 'check row 2')
  1122. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '09.06.2014', 'check row 2')
  1123. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  1124. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1125. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '2 prio', 'check row 3')
  1126. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '08.06.2014', 'check row 3')
  1127. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  1128. equal(el.find('tbody > tr').length, 150)
  1129. equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  1130. equal(el.find('.js-pager').first().find('.js-page').length, 2)
  1131. equal(el.find('.js-pager').first().find('.js-page.is-selected').length, 1)
  1132. equal(el.find('.js-pager').first().find('.js-page.is-selected').text(), '1')
  1133. objects.splice(2,2)
  1134. result = table.update({sync: true, objects: objects})
  1135. equal(result[0], 'fullRender.contentRemoved')
  1136. equal(el.find('.js-pager').first().find('.js-page').length, 0)
  1137. equal(el.find('table > thead > tr').length, 1, 'row count')
  1138. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1139. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1140. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1141. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1142. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '0 prio', 'check row 1')
  1143. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  1144. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1145. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1146. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 prio', 'check row 2')
  1147. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '09.06.2014', 'check row 2')
  1148. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  1149. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1150. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '4 prio', 'check row 3')
  1151. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '06.06.2014', 'check row 3')
  1152. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  1153. equal(el.find('tbody > tr').length, 150)
  1154. equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  1155. objects = [
  1156. {
  1157. id: 501,
  1158. name: '501 prio',
  1159. note: 'some note',
  1160. active: true,
  1161. created_at: '2014-06-10T10:17:30.000Z',
  1162. },
  1163. ]
  1164. App.TicketPriority.refresh(objects)
  1165. objects = App.TicketPriority.all()
  1166. result = table.update({sync: true, objects: objects})
  1167. equal(result[0], 'fullRender.contentRemoved')
  1168. equal(el.find('table > thead > tr').length, 1, 'row count')
  1169. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1170. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1171. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1172. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1173. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '0 prio', 'check row 1')
  1174. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  1175. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1176. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1177. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 prio', 'check row 2')
  1178. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '09.06.2014', 'check row 2')
  1179. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
  1180. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1181. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '2 prio', 'check row 3')
  1182. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '08.06.2014', 'check row 3')
  1183. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 3')
  1184. equal(el.find('tbody > tr').length, 150)
  1185. equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  1186. equal(el.find('.js-pager').first().find('.js-page').length, 2)
  1187. equal(el.find('.js-pager').first().find('.js-page.is-selected').length, 1)
  1188. equal(el.find('.js-pager').first().find('.js-page.is-selected').text(), '1')
  1189. $('#table').append('<hr><h1>table with data 7</h1><div id="table-new7"></div>')
  1190. var el = $('#table-new7')
  1191. App.TicketPriority.refresh([
  1192. {
  1193. id: 1,
  1194. name: '1 low',
  1195. note: 'some note 1',
  1196. active: true,
  1197. created_at: '2014-06-10T11:17:34.000Z',
  1198. },
  1199. {
  1200. id: 2,
  1201. name: '2 normal',
  1202. note: 'some note 2',
  1203. active: false,
  1204. created_at: '2014-06-10T10:17:34.000Z',
  1205. },
  1206. {
  1207. id: 3,
  1208. name: '3 high',
  1209. note: 'some note 3',
  1210. active: false,
  1211. created_at: '2014-06-10T10:17:38.000Z',
  1212. },
  1213. ], {clear: true})
  1214. var table = new App.ControllerTable({
  1215. el: el,
  1216. overviewAttributes: ['name', 'created_at', 'active'],
  1217. model: App.TicketPriority,
  1218. objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'}),
  1219. checkbox: false,
  1220. radio: false,
  1221. })
  1222. //equal(el.find('table').length, 0, 'row count')
  1223. //table.render()
  1224. equal(el.find('table > thead > tr').length, 1, 'row count')
  1225. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1226. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1227. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1228. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1229. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1230. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  1231. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1232. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1233. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1234. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  1235. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1236. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '3 hoch', 'check row 3')
  1237. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  1238. equal(el.find('tbody > tr:nth-child(4) > td').length, 0, 'check row 3')
  1239. App.TicketPriority.refresh([
  1240. {
  1241. id: 1,
  1242. name: '1 low',
  1243. note: 'some note',
  1244. active: true,
  1245. created_at: '2014-06-12T11:17:34.000Z',
  1246. },
  1247. {
  1248. id: 2,
  1249. name: '2 normal',
  1250. note: 'some note 2',
  1251. active: false,
  1252. created_at: '2014-06-10T10:17:34.000Z',
  1253. },
  1254. {
  1255. id: 3,
  1256. name: '3 high',
  1257. note: 'some note 3',
  1258. active: false,
  1259. created_at: '2014-06-10T10:17:38.000Z',
  1260. },
  1261. ], {clear: true})
  1262. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  1263. equal(result[0], 'fullRender.contentRemoved')
  1264. equal(result[1][0], 0)
  1265. equal(result[1][1], undefined)
  1266. equal(result[2][0], 0)
  1267. equal(result[2][1], undefined)
  1268. equal(el.find('table > thead > tr').length, 1, 'row count')
  1269. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1270. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1271. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1272. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1273. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1274. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '12.06.2014', 'check row 1')
  1275. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1276. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1277. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1278. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  1279. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1280. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '3 hoch', 'check row 3')
  1281. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  1282. equal(el.find('tbody > tr:nth-child(4) > td').length, 0, 'check row 3')
  1283. $('#table').append('<hr><h1>table with data 8</h1><div id="table-new8"></div>')
  1284. var el = $('#table-new8')
  1285. App.TicketPriority.refresh([
  1286. {
  1287. id: 1,
  1288. name: '1 low',
  1289. note: 'some note',
  1290. active: true,
  1291. created_at: '2014-06-12T11:17:34.000Z',
  1292. },
  1293. {
  1294. id: 2,
  1295. name: '2 normal',
  1296. note: 'some note 2',
  1297. active: false,
  1298. created_at: '2014-06-10T10:17:34.000Z',
  1299. },
  1300. {
  1301. id: 3,
  1302. name: '3 high',
  1303. note: 'some note 3',
  1304. active: false,
  1305. created_at: '2014-06-10T10:17:38.000Z',
  1306. },
  1307. ], {clear: true})
  1308. var table = new App.ControllerTable({
  1309. el: el,
  1310. overviewAttributes: ['name', 'created_at', 'active'],
  1311. model: App.TicketPriority,
  1312. objects: App.TicketPriority.all(),
  1313. checkbox: false,
  1314. radio: false,
  1315. orderBy: 'not_existing',
  1316. orderDirection: 'DESC',
  1317. })
  1318. equal(el.find('table > thead > tr').length, 1, 'row count')
  1319. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1320. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1321. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1322. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1323. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1324. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '12.06.2014', 'check row 1')
  1325. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1326. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1327. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1328. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  1329. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1330. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '3 hoch', 'check row 3')
  1331. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  1332. equal(el.find('tbody > tr:nth-child(4) > td').length, 0, 'check row 3')
  1333. result = table.update({sync: true, objects: App.TicketPriority.all(), orderBy: 'not_existing', orderDirection: 'ASC'})
  1334. equal(result[0], 'noChanges')
  1335. $('#table').append('<hr><h1>table with data 9</h1><div id="table-new9"></div>')
  1336. var el = $('#table-new9')
  1337. App.TicketPriority.refresh([
  1338. {
  1339. id: 1,
  1340. name: '1 low',
  1341. external_id: 3,
  1342. note: 'some note',
  1343. active: true,
  1344. created_at: '2014-06-12T11:17:34.000Z',
  1345. },
  1346. {
  1347. id: 2,
  1348. name: '2 normal',
  1349. external_id: 2,
  1350. note: 'some note 2',
  1351. active: false,
  1352. created_at: '2014-06-10T10:17:34.000Z',
  1353. },
  1354. {
  1355. id: 3,
  1356. name: '3 high',
  1357. external_id: 1,
  1358. note: 'some note 3',
  1359. active: false,
  1360. created_at: '2014-06-10T10:17:38.000Z',
  1361. },
  1362. ], {clear: true})
  1363. App.TicketPriority.resetAttributes()
  1364. App.TicketPriority.updateAttributes([{
  1365. name: 'external_id',
  1366. display: 'External',
  1367. tag: 'input',
  1368. readonly: 1,
  1369. }])
  1370. var table = new App.ControllerTable({
  1371. el: el,
  1372. overviewAttributes: ['name', 'created_at', 'active'],
  1373. model: App.TicketPriority,
  1374. objects: App.TicketPriority.all(),
  1375. checkbox: false,
  1376. radio: false,
  1377. orderBy: 'external',
  1378. orderDirection: 'DESC',
  1379. })
  1380. equal(el.find('table > thead > tr').length, 1, 'row count')
  1381. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1382. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1383. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1384. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1385. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1386. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '12.06.2014', 'check row 1')
  1387. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1388. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1389. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1390. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  1391. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1392. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '3 hoch', 'check row 3')
  1393. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  1394. equal(el.find('tbody > tr:nth-child(4) > td').length, 0, 'check row 3')
  1395. result = table.update({sync: true, objects: App.TicketPriority.all(), orderBy: 'external', orderDirection: 'ASC'})
  1396. equal(result[0], 'fullRender.contentChanged')
  1397. equal(result[1], 0)
  1398. equal(el.find('table > thead > tr').length, 1, 'row count')
  1399. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1400. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1401. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1402. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 3')
  1403. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '3 hoch', 'check row 3')
  1404. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  1405. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1406. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1407. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  1408. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 1')
  1409. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1410. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '12.06.2014', 'check row 1')
  1411. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1412. equal(el.find('tbody > tr:nth-child(4) > td').length, 0, 'check row 3')
  1413. $('#table').append('<hr><h1>table with data 10</h1><div id="table-new10"></div>')
  1414. var el = $('#table-new10')
  1415. App.TicketPriority.refresh([
  1416. {
  1417. id: 1,
  1418. name: '1 low',
  1419. external_id: 3,
  1420. note: 'some note',
  1421. active: true,
  1422. created_at: '2014-06-12T11:17:34.000Z',
  1423. },
  1424. {
  1425. id: 2,
  1426. name: '2 normal',
  1427. external_id: 2,
  1428. note: 'some note 2',
  1429. active: false,
  1430. created_at: '2014-06-10T10:17:34.000Z',
  1431. },
  1432. {
  1433. id: 3,
  1434. name: '3 high',
  1435. external_id: 1,
  1436. note: 'some note 3',
  1437. active: false,
  1438. created_at: '2014-06-10T10:17:38.000Z',
  1439. },
  1440. ], {clear: true})
  1441. App.TicketPriority.resetAttributes()
  1442. App.TicketPriority.updateAttributes([{
  1443. name: 'external',
  1444. display: 'External',
  1445. tag: 'input',
  1446. readonly: 1,
  1447. }])
  1448. var table = new App.ControllerTable({
  1449. el: el,
  1450. overviewAttributes: ['name', 'created_at', 'active'],
  1451. model: App.TicketPriority,
  1452. objects: App.TicketPriority.all(),
  1453. checkbox: false,
  1454. radio: false,
  1455. orderBy: 'external',
  1456. orderDirection: 'ASC',
  1457. })
  1458. equal(el.find('table > thead > tr').length, 1, 'row count')
  1459. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1460. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1461. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1462. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1463. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1464. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '12.06.2014', 'check row 1')
  1465. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1466. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1467. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1468. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  1469. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1470. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '3 hoch', 'check row 3')
  1471. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  1472. equal(el.find('tbody > tr:nth-child(4) > td').length, 0, 'check row 3')
  1473. result = table.update({sync: true, objects: App.TicketPriority.all(), orderBy: 'external', orderDirection: 'DESC'})
  1474. equal(result[0], 'fullRender.contentChanged')
  1475. equal(result[1], 0)
  1476. equal(el.find('table > thead > tr').length, 1, 'row count')
  1477. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1478. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1479. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1480. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 3')
  1481. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '3 hoch', 'check row 3')
  1482. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  1483. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1484. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1485. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  1486. equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 1')
  1487. equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1488. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '12.06.2014', 'check row 1')
  1489. equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1490. equal(el.find('tbody > tr:nth-child(4) > td').length, 0, 'check row 3')
  1491. $('#table').append('<hr><h1>table with data 11</h1><div id="table-new11"></div>')
  1492. var el = $('#table-new11')
  1493. App.TicketPriority.refresh([
  1494. {
  1495. id: 1,
  1496. name: '1 low',
  1497. note: 'some note 1',
  1498. active: true,
  1499. created_at: '2014-06-10T11:17:34.000Z',
  1500. },
  1501. {
  1502. id: 2,
  1503. name: '2 normal',
  1504. note: 'some note 2',
  1505. active: false,
  1506. created_at: '2014-06-10T10:17:34.000Z',
  1507. },
  1508. ], {clear: true})
  1509. var table = new App.ControllerTable({
  1510. el: el,
  1511. overviewAttributes: ['name', 'created_at', 'active'],
  1512. model: App.TicketPriority,
  1513. objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'}),
  1514. checkbox: false,
  1515. radio: false,
  1516. frontendTimeUpdateExecute: false,
  1517. })
  1518. //equal(el.find('table').length, 0, 'row count')
  1519. //table.render()
  1520. equal(el.find('table > thead > tr').length, 1, 'row count')
  1521. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1522. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1523. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1524. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1525. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1526. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '', 'check row 1')
  1527. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1528. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1529. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1530. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '', 'check row 2')
  1531. equal(el.find('tbody > tr:nth-child(3) > td').length, 0, 'check row 3')
  1532. result = table.update({sync: true, objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'})})
  1533. equal(result[0], 'noChanges')
  1534. equal(el.find('table > thead > tr').length, 1, 'row count')
  1535. equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1536. equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1537. equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1538. equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1539. equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1540. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '', 'check row 1')
  1541. equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
  1542. equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1543. equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1544. equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '', 'check row 2')
  1545. })