table_extended.js 99 KB

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