@@ -27,10 +27,10 @@ qx.Class.define("osparc.jobs.SubRunsTableModel", {
2727 const colIDs = Object . values ( subJobsCols ) . map ( col => col . id ) ;
2828 this . setColumns ( colLabels , colIDs ) ;
2929
30- this . setSortColumnIndexWithoutSortingData ( subJobsCols . START . column ) ; // It can only be sorted by started_at
30+ this . setSortColumnIndexWithoutSortingData ( subJobsCols . START . column ) ;
3131 this . setSortAscendingWithoutSortingData ( false ) ;
3232 Object . values ( subJobsCols ) . forEach ( col => {
33- this . setColumnSortable ( col . column , false ) ;
33+ this . setColumnSortable ( col . column , Boolean ( col . sortableMap ) ) ;
3434 } ) ;
3535
3636 this . setProjectUuid ( projectUuid ) ;
@@ -47,12 +47,31 @@ qx.Class.define("osparc.jobs.SubRunsTableModel", {
4747 init : false ,
4848 event : "changeFetching"
4949 } ,
50+
51+ orderBy : {
52+ check : "Object" ,
53+ init : {
54+ field : "started_at" , // started_at
55+ direction : "desc"
56+ }
57+ } ,
5058 } ,
5159
5260 members : {
61+ // overridden
62+ sortByColumn ( columnIndex , ascending ) {
63+ const subJobsCols = osparc . jobs . SubRunsTable . COLS ;
64+ const colInfo = Object . values ( subJobsCols ) . find ( col => col . column === columnIndex ) ;
65+ this . setOrderBy ( {
66+ field : colInfo . sortableMap ,
67+ direction : ascending ? "asc" : "desc"
68+ } )
69+ this . base ( arguments , columnIndex , ascending )
70+ } ,
71+
5372 // overridden
5473 _loadRowCount ( ) {
55- osparc . store . Jobs . getInstance ( ) . fetchSubJobs ( this . getProjectUuid ( ) )
74+ osparc . store . Jobs . getInstance ( ) . fetchSubJobs ( this . getProjectUuid ( ) , this . getOrderBy ( ) )
5675 . then ( subJobs => {
5776 this . _onRowCountLoaded ( subJobs . length )
5877 } )
@@ -68,7 +87,7 @@ qx.Class.define("osparc.jobs.SubRunsTableModel", {
6887 const lastRow = Math . min ( qxLastRow , this . _rowCount - 1 ) ;
6988 // Returns a request promise with given offset and limit
7089 const getFetchPromise = ( ) => {
71- return osparc . store . Jobs . getInstance ( ) . fetchSubJobs ( this . getProjectUuid ( ) )
90+ return osparc . store . Jobs . getInstance ( ) . fetchSubJobs ( this . getProjectUuid ( ) , this . getOrderBy ( ) )
7291 . then ( subJobs => {
7392 const data = [ ] ;
7493 const subJobsCols = osparc . jobs . SubRunsTable . COLS ;
0 commit comments