table_extended.js 98 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777
  1. // initial list
  2. QUnit.test('table new - initial list', assert => {
  3. App.i18n.set('de-de')
  4. $('#qunit').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. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  33. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  34. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  35. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  36. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  37. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  38. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  39. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  40. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  41. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  42. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  43. assert.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. assert.equal(result[0], 'noChanges')
  46. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  47. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  48. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  49. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  50. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  51. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  52. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  53. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  54. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  55. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  56. assert.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. assert.equal(result[0], 'fullRender.lenghtChanged')
  68. assert.equal(result[1], 2)
  69. assert.equal(result[2], 1)
  70. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  71. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  72. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  73. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  74. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  75. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), 'Priorität', 'check row 1')
  76. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  77. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  78. assert.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. assert.equal(result[0], 'emptyList')
  82. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  83. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Keine Einträge', 'check header')
  84. assert.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. assert.equal(result[0], 'fullRender')
  103. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  104. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  105. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  106. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  107. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  108. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  109. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  110. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  111. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  112. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  113. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  114. assert.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. assert.equal(result[0], 'fullRender.contentRemoved')
  140. assert.equal(result[1][0], undefined)
  141. assert.equal(result[2][0], 2)
  142. assert.equal(result[2][1], undefined)
  143. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  144. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  145. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  146. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  147. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  148. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  149. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  150. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  151. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  152. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  153. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  154. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  155. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '3 hoch', 'check row 3')
  156. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  157. assert.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. assert.equal(result[0], 'fullRender.contentChanged')
  160. assert.equal(result[1], 0)
  161. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  162. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  163. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  164. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  165. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  166. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '3 hoch', 'check row 1')
  167. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  168. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  169. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  170. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  171. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  172. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '1 niedrig', 'check row 3')
  173. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  174. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  175. assert.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. assert.equal(result[0], 'fullRender.contentChanged')
  178. assert.equal(result[1], 0)
  179. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  180. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  181. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  182. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  183. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  184. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  185. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  186. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  187. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  188. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  189. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  190. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  191. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '3 hoch', 'check row 3')
  192. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  193. assert.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. assert.equal(result[0], 'fullRender.contentRemoved')
  212. assert.equal(result[1][0], 1)
  213. assert.equal(result[1][1], undefined)
  214. assert.notOk(result[1][1])
  215. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  216. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  217. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  218. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  219. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  220. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  221. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  222. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  223. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  224. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '3 hoch', 'check row 3')
  225. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  226. assert.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. assert.equal(result[0], 'fullRender.overviewAttributesChanged')
  229. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  230. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  231. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  232. assert.equal(el.find('table > thead > tr > th').length, 2, 'check header')
  233. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 2, 'check row 1')
  234. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  235. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  236. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 2, 'check row 2')
  237. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '3 hoch', 'check row 3')
  238. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  239. assert.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. assert.equal(result[0], 'emptyList')
  243. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  244. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Keine Einträge', 'check header')
  245. assert.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. assert.equal(result[0], 'fullRender')
  264. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  265. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  266. assert.equal(el.find('table > thead > tr > th').length, 1, 'check header')
  267. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 1, 'check row 1')
  268. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  269. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 1, 'check row 2')
  270. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '3 hoch', 'check row 3')
  271. assert.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. assert.equal(result[0], 'fullRender.overviewAttributesChanged')
  274. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  275. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  276. assert.equal(el.find('table > thead > tr > th').length, 1, 'check header')
  277. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 1, 'check row 2')
  278. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '3 hoch', 'check row 3')
  279. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 1, 'check row 1')
  280. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 niedrig', 'check row 1')
  281. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 0, 'check row 3')
  282. $('#qunit').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. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  317. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  318. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  319. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  320. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 1, 'check row 1')
  321. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), 'some note', 'check row 1')
  322. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  323. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 niedrig', 'check row 2')
  324. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  325. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  326. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  327. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '2 normal', 'check row 3')
  328. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  329. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  330. assert.equal(el.find('tbody > tr:nth-child(4) > td').length, 1, 'check row 3')
  331. assert.equal(el.find('tbody > tr:nth-child(4) > td:first').text().trim(), 'some other note', 'check row 3')
  332. assert.equal(el.find('tbody > tr:nth-child(5) > td:first').text().trim(), '3 hoch', 'check row 5')
  333. assert.equal(el.find('tbody > tr:nth-child(5) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 5')
  334. assert.equal(el.find('tbody > tr:nth-child(5) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 5')
  335. assert.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. assert.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. assert.equal(result[0], 'fullRender.contentRemoved')
  356. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  357. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  358. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  359. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  360. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 1, 'check row 1')
  361. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), 'some note', 'check row 1')
  362. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  363. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 niedrig', 'check row 2')
  364. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  365. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  366. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  367. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '2 normal', 'check row 3')
  368. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  369. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  370. assert.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. assert.equal(result[0], 'fullRender.contentRemoved')
  396. assert.equal(result[1][0], undefined)
  397. assert.equal(result[2][0], 3)
  398. assert.equal(result[2][1], 4)
  399. assert.equal(result[2][2], undefined)
  400. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  401. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  402. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  403. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  404. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 1, 'check row 1')
  405. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), 'some note', 'check row 1')
  406. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  407. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 niedrig', 'check row 2')
  408. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  409. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  410. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  411. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '2 normal', 'check row 3')
  412. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  413. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  414. assert.equal(el.find('tbody > tr:nth-child(4) > td').length, 1, 'check row 3')
  415. assert.equal(el.find('tbody > tr:nth-child(4) > td:first').text().trim(), 'some other note', 'check row 3')
  416. assert.equal(el.find('tbody > tr:nth-child(5) > td:first').text().trim(), '3 hoch', 'check row 5')
  417. assert.equal(el.find('tbody > tr:nth-child(5) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 5')
  418. assert.equal(el.find('tbody > tr:nth-child(5) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 5')
  419. assert.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. assert.equal(result[0], 'fullRender.contentRemoved')
  459. assert.equal(result[1][0], undefined)
  460. assert.equal(result[2][0], 3)
  461. assert.equal(result[2][1], 6)
  462. assert.equal(result[2][2], undefined)
  463. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  464. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  465. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  466. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  467. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 1, 'check row 1')
  468. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), 'some note', 'check row 1')
  469. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  470. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 niedrig', 'check row 2')
  471. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  472. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  473. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  474. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '2 normal', 'check row 3')
  475. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  476. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  477. assert.equal(el.find('tbody > tr:nth-child(4) > td').length, 3, 'check row 4')
  478. assert.equal(el.find('tbody > tr:nth-child(4) > td:first').text().trim(), '5 high', 'check row 4')
  479. assert.equal(el.find('tbody > tr:nth-child(4) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 4')
  480. assert.equal(el.find('tbody > tr:nth-child(4) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 4')
  481. assert.equal(el.find('tbody > tr:nth-child(5) > td').length, 1, 'check row 5')
  482. assert.equal(el.find('tbody > tr:nth-child(5) > td:first').text().trim(), 'some other note', 'check row 5')
  483. assert.equal(el.find('tbody > tr:nth-child(6) > td:first').text().trim(), '3 hoch', 'check row 6')
  484. assert.equal(el.find('tbody > tr:nth-child(6) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 6')
  485. assert.equal(el.find('tbody > tr:nth-child(6) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 6')
  486. assert.equal(el.find('tbody > tr:nth-child(7) > td').length, 3, 'check row 7')
  487. assert.equal(el.find('tbody > tr:nth-child(7) > td:first').text().trim(), '4 high', 'check row 7')
  488. assert.equal(el.find('tbody > tr:nth-child(7) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 7')
  489. assert.equal(el.find('tbody > tr:nth-child(7) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 7')
  490. assert.equal(el.find('tbody > tr:nth-child(8) > td').length, 0, 'check row 8')
  491. $('#qunit').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. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  518. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  519. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  520. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  521. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  522. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '999 prio', 'check row 1')
  523. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '15.09.2011', 'check row 1')
  524. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  525. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  526. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '998 prio', 'check row 2')
  527. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '16.09.2011', 'check row 2')
  528. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  529. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  530. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '997 prio', 'check row 3')
  531. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '17.09.2011', 'check row 3')
  532. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  533. assert.equal(el.find('tbody > tr').length, 150)
  534. assert.equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  535. assert.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').trigger('click')
  537. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  538. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  539. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  540. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  541. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  542. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '0 prio', 'check row 1')
  543. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  544. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  545. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  546. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 prio', 'check row 2')
  547. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '09.06.2014', 'check row 2')
  548. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  549. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  550. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '10 prio', 'check row 3')
  551. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '31.05.2014', 'check row 3')
  552. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  553. assert.equal(el.find('tbody > tr').length, 150)
  554. assert.equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  555. assert.equal(el.find('.js-tableHead[data-column-key="name"] .js-sort .icon.icon-arrow-up').length, 1)
  556. assert.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').trigger('click')
  558. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  559. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  560. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  561. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  562. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  563. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '999 prio', 'check row 1')
  564. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '15.09.2011', 'check row 1')
  565. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  566. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  567. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '998 prio', 'check row 2')
  568. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '16.09.2011', 'check row 2')
  569. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  570. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  571. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '997 prio', 'check row 3')
  572. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '17.09.2011', 'check row 3')
  573. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  574. assert.equal(el.find('tbody > tr').length, 150)
  575. assert.equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  576. assert.equal(el.find('.js-tableHead[data-column-key="name"] .js-sort .icon.icon-arrow-down').length, 1)
  577. assert.equal(el.find('.js-tableHead[data-column-key="name"] .js-sort .icon.icon-arrow-up').length, 0)
  578. assert.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').trigger('click')
  580. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  581. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  582. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  583. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  584. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  585. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '999 prio', 'check row 1')
  586. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '15.09.2011', 'check row 1')
  587. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  588. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  589. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '998 prio', 'check row 2')
  590. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '16.09.2011', 'check row 2')
  591. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  592. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  593. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '997 prio', 'check row 3')
  594. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '17.09.2011', 'check row 3')
  595. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  596. assert.equal(el.find('tbody > tr').length, 150)
  597. assert.equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  598. assert.equal(el.find('.js-tableHead[data-column-key="name"] .js-sort .icon').length, 0)
  599. assert.equal(el.find('.js-tableHead[data-column-key="created_at"] .js-sort .icon.icon-arrow-down').length, 0)
  600. assert.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').trigger('click')
  602. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  603. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  604. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  605. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  606. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  607. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '0 prio', 'check row 1')
  608. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  609. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  610. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  611. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 prio', 'check row 2')
  612. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '09.06.2014', 'check row 2')
  613. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  614. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  615. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '2 prio', 'check row 3')
  616. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '08.06.2014', 'check row 3')
  617. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  618. assert.equal(el.find('tbody > tr').length, 150)
  619. assert.equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  620. assert.equal(el.find('.js-tableHead[data-column-key="name"] .js-sort .icon').length, 0)
  621. assert.equal(el.find('.js-tableHead[data-column-key="created_at"] .js-sort .icon.icon-arrow-down').length, 1)
  622. assert.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. assert.equal(result[0], 'fullRender.contentRemoved')
  628. assert.equal(result[1][0], 1)
  629. assert.equal(result[1][1], 0)
  630. assert.equal(result[2][0], 148)
  631. assert.equal(result[2][1], 149)
  632. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  633. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  634. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  635. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  636. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  637. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '2 prio', 'check row 1')
  638. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '08.06.2014', 'check row 1')
  639. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  640. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  641. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '3 prio', 'check row 2')
  642. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '07.06.2014', 'check row 2')
  643. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  644. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  645. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '4 prio', 'check row 3')
  646. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '06.06.2014', 'check row 3')
  647. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  648. assert.equal(el.find('tbody > tr:nth-child(149) > td:first').text().trim(), '150 prio', 'check row 3')
  649. assert.equal(el.find('tbody > tr:nth-child(149) > td:nth-child(2)').text().trim(), '11.01.2014', 'check row 3')
  650. assert.equal(el.find('tbody > tr:nth-child(149) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  651. assert.equal(el.find('tbody > tr:nth-child(150) > td:first').text().trim(), '151 prio', 'check row 3')
  652. assert.equal(el.find('tbody > tr:nth-child(150) > td:nth-child(2)').text().trim(), '10.01.2014', 'check row 3')
  653. assert.equal(el.find('tbody > tr:nth-child(150) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  654. assert.equal(el.find('tbody > tr').length, 150)
  655. assert.equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  656. assert.equal(el.find('.js-tableHead[data-column-key="name"] .js-sort .icon').length, 0)
  657. assert.equal(el.find('.js-tableHead[data-column-key="created_at"] .js-sort .icon.icon-arrow-down').length, 1)
  658. assert.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').trigger('click')
  660. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  661. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  662. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  663. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  664. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  665. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '999 prio', 'check row 1')
  666. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '15.09.2011', 'check row 1')
  667. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  668. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  669. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '998 prio', 'check row 2')
  670. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '16.09.2011', 'check row 2')
  671. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  672. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  673. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '997 prio', 'check row 3')
  674. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '17.09.2011', 'check row 3')
  675. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  676. assert.equal(el.find('tbody > tr').length, 150)
  677. assert.equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  678. assert.equal(el.find('.js-tableHead[data-column-key="name"] .js-sort .icon').length, 0)
  679. assert.equal(el.find('.js-tableHead[data-column-key="created_at"] .js-sort .icon.icon-arrow-down').length, 0)
  680. assert.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').trigger('click')
  682. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  683. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  684. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  685. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  686. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  687. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '2 prio', 'check row 1')
  688. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '08.06.2014', 'check row 1')
  689. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  690. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  691. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '3 prio', 'check row 2')
  692. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '07.06.2014', 'check row 2')
  693. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  694. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  695. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '4 prio', 'check row 3')
  696. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '06.06.2014', 'check row 3')
  697. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  698. assert.equal(el.find('tbody > tr:nth-child(149) > td:first').text().trim(), '150 prio', 'check row 3')
  699. assert.equal(el.find('tbody > tr:nth-child(149) > td:nth-child(2)').text().trim(), '11.01.2014', 'check row 3')
  700. assert.equal(el.find('tbody > tr:nth-child(149) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  701. assert.equal(el.find('tbody > tr:nth-child(150) > td:first').text().trim(), '151 prio', 'check row 3')
  702. assert.equal(el.find('tbody > tr:nth-child(150) > td:nth-child(2)').text().trim(), '10.01.2014', 'check row 3')
  703. assert.equal(el.find('tbody > tr:nth-child(150) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  704. assert.equal(el.find('tbody > tr').length, 150)
  705. assert.equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  706. $('#qunit').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. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  726. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  727. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  728. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  729. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3)
  730. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig')
  731. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014')
  732. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv')
  733. assert.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. assert.equal(result[0], 'fullRender.contentRemoved')
  752. assert.equal(result[1][0], undefined)
  753. assert.equal(result[2][0], 1)
  754. assert.equal(result[2][1], undefined)
  755. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  756. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  757. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  758. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  759. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3)
  760. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig')
  761. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014')
  762. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv')
  763. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3)
  764. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal')
  765. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014')
  766. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv')
  767. assert.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. assert.equal(result[0], 'fullRender.contentRemoved')
  793. assert.equal(result[1][0], undefined)
  794. assert.equal(result[2][0], 2)
  795. assert.equal(result[2][1], undefined)
  796. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  797. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  798. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  799. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  800. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3)
  801. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig')
  802. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014')
  803. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv')
  804. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3)
  805. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal')
  806. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014')
  807. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv')
  808. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3)
  809. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '3 hoch')
  810. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014')
  811. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv')
  812. assert.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. assert.equal(result[0], 'fullRender.contentRemoved')
  831. assert.equal(result[1][0], 0)
  832. assert.equal(result[1][1], undefined)
  833. assert.equal(result[2][0], undefined)
  834. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  835. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  836. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  837. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  838. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3)
  839. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '2 normal')
  840. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014')
  841. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv')
  842. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3)
  843. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '3 hoch')
  844. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014')
  845. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv')
  846. assert.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. assert.equal(result[0], 'fullRender.lenghtChanged')
  858. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  859. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  860. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  861. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  862. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3)
  863. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '2 normal')
  864. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014')
  865. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv')
  866. assert.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. assert.equal(result[0], 'emptyList')
  870. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  871. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Keine Einträge', 'check header')
  872. assert.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. assert.equal(result[0], 'fullRender')
  884. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  885. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  886. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  887. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  888. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3)
  889. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '2 normal')
  890. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014')
  891. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv')
  892. assert.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. assert.equal(result[0], 'fullRender.contentRemoved')
  911. assert.equal(result[1][0], undefined)
  912. assert.equal(result[2][0], 0)
  913. assert.equal(result[2][1], undefined)
  914. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  915. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  916. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  917. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  918. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3)
  919. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig')
  920. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014')
  921. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv')
  922. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3)
  923. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal')
  924. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014')
  925. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv')
  926. assert.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. assert.equal(result[0], 'fullRender.lenghtChanged')
  938. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  939. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  940. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  941. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  942. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3)
  943. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '2 normal')
  944. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014')
  945. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv')
  946. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 0)
  947. $('#qunit').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. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  974. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  975. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  976. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  977. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  978. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '0 prio', 'check row 1')
  979. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  980. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  981. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  982. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 prio', 'check row 2')
  983. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '09.06.2014', 'check row 2')
  984. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  985. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  986. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '2 prio', 'check row 3')
  987. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '08.06.2014', 'check row 3')
  988. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  989. assert.equal(el.find('tbody > tr').length, 150)
  990. assert.equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  991. assert.equal(el.find('.js-pager').first().find('.js-page').length, 2)
  992. assert.equal(el.find('.js-pager').first().find('.js-page.is-selected').length, 1)
  993. assert.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)').trigger('click')
  995. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  996. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  997. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  998. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  999. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1000. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '150 prio', 'check row 1')
  1001. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '11.01.2014', 'check row 1')
  1002. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1003. assert.equal(el.find('tbody > tr').length, 1)
  1004. assert.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. assert.equal(result[0], 'fullRender.contentRemoved')
  1017. assert.equal(result[1][0], undefined)
  1018. assert.equal(result[2][0], 1)
  1019. assert.equal(result[2][1], undefined)
  1020. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  1021. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1022. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1023. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1024. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1025. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '150 prio', 'check row 1')
  1026. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '11.01.2014', 'check row 1')
  1027. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1028. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 1')
  1029. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '500 prio', 'check row 1')
  1030. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  1031. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1032. assert.equal(el.find('tbody > tr').length, 2)
  1033. assert.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. assert.equal(result[0], 'fullRender.lenghtChanged')
  1038. //equal(result[1][0], 1)
  1039. //equal(result[1][1], undefined)
  1040. //equal(result[2][0], undefined)
  1041. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  1042. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1043. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1044. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1045. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1046. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '500 prio', 'check row 1')
  1047. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  1048. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1049. assert.equal(el.find('tbody > tr').length, 1)
  1050. assert.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. assert.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. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  1059. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1060. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1061. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1062. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1063. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '0 prio', 'check row 1')
  1064. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  1065. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1066. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1067. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 prio', 'check row 2')
  1068. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '09.06.2014', 'check row 2')
  1069. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  1070. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1071. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '4 prio', 'check row 3')
  1072. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '06.06.2014', 'check row 3')
  1073. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  1074. assert.equal(el.find('tbody > tr').length, 150)
  1075. assert.equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  1076. assert.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. assert.equal(result[0], 'fullRender.contentRemoved')
  1090. assert.equal(el.find('.js-pager').first().find('.js-page').length, 2)
  1091. assert.equal(el.find('.js-pager').first().find('.js-page.is-selected').length, 1)
  1092. assert.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)').trigger('click')
  1094. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  1095. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1096. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1097. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1098. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1099. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '150 prio', 'check row 1')
  1100. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '11.01.2014', 'check row 1')
  1101. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1102. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 1')
  1103. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '500 prio', 'check row 1')
  1104. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  1105. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1106. assert.equal(el.find('tbody > tr').length, 2)
  1107. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 0)
  1108. assert.equal(el.find('.js-pager').first().find('.js-page').length, 2)
  1109. assert.equal(el.find('.js-pager').first().find('.js-page.is-selected').length, 1)
  1110. assert.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)').trigger('click')
  1112. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  1113. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1114. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1115. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1116. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1117. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '0 prio', 'check row 1')
  1118. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  1119. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1120. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1121. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 prio', 'check row 2')
  1122. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '09.06.2014', 'check row 2')
  1123. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  1124. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1125. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '2 prio', 'check row 3')
  1126. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '08.06.2014', 'check row 3')
  1127. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  1128. assert.equal(el.find('tbody > tr').length, 150)
  1129. assert.equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  1130. assert.equal(el.find('.js-pager').first().find('.js-page').length, 2)
  1131. assert.equal(el.find('.js-pager').first().find('.js-page.is-selected').length, 1)
  1132. assert.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. assert.equal(result[0], 'fullRender.contentRemoved')
  1136. assert.equal(el.find('.js-pager').first().find('.js-page').length, 0)
  1137. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  1138. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1139. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1140. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1141. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1142. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '0 prio', 'check row 1')
  1143. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  1144. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1145. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1146. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 prio', 'check row 2')
  1147. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '09.06.2014', 'check row 2')
  1148. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  1149. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1150. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '4 prio', 'check row 3')
  1151. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '06.06.2014', 'check row 3')
  1152. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  1153. assert.equal(el.find('tbody > tr').length, 150)
  1154. assert.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. assert.equal(result[0], 'fullRender.contentRemoved')
  1168. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  1169. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1170. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1171. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1172. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1173. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '0 prio', 'check row 1')
  1174. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  1175. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1176. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1177. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 prio', 'check row 2')
  1178. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '09.06.2014', 'check row 2')
  1179. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 2')
  1180. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1181. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '2 prio', 'check row 3')
  1182. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '08.06.2014', 'check row 3')
  1183. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 3')
  1184. assert.equal(el.find('tbody > tr').length, 150)
  1185. assert.equal(el.find('tbody > tr:nth-child(151) > td').length, 0)
  1186. assert.equal(el.find('.js-pager').first().find('.js-page').length, 2)
  1187. assert.equal(el.find('.js-pager').first().find('.js-page.is-selected').length, 1)
  1188. assert.equal(el.find('.js-pager').first().find('.js-page.is-selected').text(), '1')
  1189. $('#qunit').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. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  1225. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1226. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1227. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1228. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1229. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1230. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
  1231. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1232. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1233. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1234. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  1235. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1236. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '3 hoch', 'check row 3')
  1237. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  1238. assert.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. assert.equal(result[0], 'fullRender.contentRemoved')
  1264. assert.equal(result[1][0], 0)
  1265. assert.equal(result[1][1], undefined)
  1266. assert.equal(result[2][0], 0)
  1267. assert.equal(result[2][1], undefined)
  1268. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  1269. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1270. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1271. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1272. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1273. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1274. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '12.06.2014', 'check row 1')
  1275. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1276. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1277. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1278. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  1279. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1280. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '3 hoch', 'check row 3')
  1281. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  1282. assert.equal(el.find('tbody > tr:nth-child(4) > td').length, 0, 'check row 3')
  1283. $('#qunit').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. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  1319. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1320. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1321. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1322. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1323. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1324. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '12.06.2014', 'check row 1')
  1325. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1326. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1327. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1328. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  1329. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1330. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '3 hoch', 'check row 3')
  1331. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  1332. assert.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. assert.equal(result[0], 'noChanges')
  1335. $('#qunit').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. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  1381. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1382. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1383. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1384. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1385. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1386. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '12.06.2014', 'check row 1')
  1387. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1388. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1389. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1390. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  1391. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1392. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '3 hoch', 'check row 3')
  1393. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  1394. assert.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. assert.equal(result[0], 'fullRender.contentChanged')
  1397. assert.equal(result[1], 0)
  1398. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  1399. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1400. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1401. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1402. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 3')
  1403. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '3 hoch', 'check row 3')
  1404. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  1405. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1406. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1407. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  1408. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 1')
  1409. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1410. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '12.06.2014', 'check row 1')
  1411. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1412. assert.equal(el.find('tbody > tr:nth-child(4) > td').length, 0, 'check row 3')
  1413. $('#qunit').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. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  1459. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1460. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1461. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1462. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1463. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1464. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '12.06.2014', 'check row 1')
  1465. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1466. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1467. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1468. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  1469. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 3')
  1470. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '3 hoch', 'check row 3')
  1471. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  1472. assert.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. assert.equal(result[0], 'fullRender.contentChanged')
  1475. assert.equal(result[1], 0)
  1476. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  1477. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1478. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1479. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1480. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 3')
  1481. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '3 hoch', 'check row 3')
  1482. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 3')
  1483. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1484. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1485. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
  1486. assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 3, 'check row 1')
  1487. assert.equal(el.find('tbody > tr:nth-child(3) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1488. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '12.06.2014', 'check row 1')
  1489. assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1490. assert.equal(el.find('tbody > tr:nth-child(4) > td').length, 0, 'check row 3')
  1491. $('#qunit').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. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  1521. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1522. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1523. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1524. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1525. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1526. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '', 'check row 1')
  1527. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1528. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1529. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1530. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '', 'check row 2')
  1531. assert.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. assert.equal(result[0], 'noChanges')
  1534. assert.equal(el.find('table > thead > tr').length, 1, 'row count')
  1535. assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
  1536. assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
  1537. assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
  1538. assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
  1539. assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
  1540. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '', 'check row 1')
  1541. assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'aktiv', 'check row 1')
  1542. assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
  1543. assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
  1544. assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '', 'check row 2')
  1545. $('#qunit').append('<hr><h1>table with large data and pager and 10 per page</h1><div id="table-new12"></div>')
  1546. var el = $('#table-new12')
  1547. var objects = [];
  1548. var created_at = Date.parse('2014-06-10T11:17:34.000Z')
  1549. for (i = 0; i < 35; i++) {
  1550. local_created_at = new Date(created_at - (1000 * 60 * 60 * 24 * i)).toISOString()
  1551. item = {
  1552. id: i,
  1553. name: i + ' prio',
  1554. note: 'some note',
  1555. active: true,
  1556. created_at: local_created_at,
  1557. }
  1558. objects.push(item)
  1559. }
  1560. App.TicketPriority.refresh(objects, {clear: true})
  1561. var table = new App.ControllerTable({
  1562. tableId: 'large_table_test_pager',
  1563. el: el,
  1564. overviewAttributes: ['name', 'created_at', 'active'],
  1565. model: App.TicketPriority,
  1566. objects: App.TicketPriority.all(),
  1567. checkbox: false,
  1568. radio: false,
  1569. pagerItemsPerPage: 10,
  1570. ttt: true
  1571. })
  1572. assert.equal(el.find('tbody > tr').length, 10)
  1573. assert.equal(el.find('.js-pager:first-child .js-page').length, 4)
  1574. $('#qunit').append('<hr><h1>table with large data and pager disabled</h1><div id="table-new13"></div>')
  1575. var el = $('#table-new13')
  1576. var objects = [];
  1577. var created_at = Date.parse('2014-06-10T11:17:34.000Z')
  1578. for (i = 0; i < 200; i++) {
  1579. local_created_at = new Date(created_at - (1000 * 60 * 60 * 24 * i)).toISOString()
  1580. item = {
  1581. id: i,
  1582. name: i + ' prio',
  1583. note: 'some note',
  1584. active: true,
  1585. created_at: local_created_at,
  1586. }
  1587. objects.push(item)
  1588. }
  1589. App.TicketPriority.refresh(objects, {clear: true})
  1590. var table = new App.ControllerTable({
  1591. tableId: 'large_table_test_pager',
  1592. el: el,
  1593. overviewAttributes: ['name', 'created_at', 'active'],
  1594. model: App.TicketPriority,
  1595. objects: App.TicketPriority.all(),
  1596. checkbox: false,
  1597. radio: false,
  1598. pagerEnabled: false,
  1599. ttt: true
  1600. })
  1601. assert.equal(el.find('tbody > tr').length, 200)
  1602. assert.equal(el.find('.js-pager:first-child .js-page').length, 0)
  1603. })