Loading TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/TapSchemaEditingBean.java +43 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,8 @@ import it.inaf.ia2.tsm.UpdateOperations; import java.io.Serializable; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Objects; import javax.faces.context.FacesContext; Loading Loading @@ -517,4 +519,45 @@ public class TapSchemaEditingBean implements Serializable { } }).getString(); } /** * Returns the columns list sorting them using {@code column_index} if * available. */ public List<Column> getColumns() { Table table = getSelectedTable(); if (table == null) { return null; } List<Column> columns = new ArrayList<>(table.getAddedOrRemovedChildren()); if (hasColumnsSorter) { Collections.sort(columns, new Comparator<Column>() { @Override public int compare(Column column1, Column column2) { Integer columnIndex1 = column1.getValue(Column.COLUMN_INDEX, Integer.class); Integer columnIndex2 = column2.getValue(Column.COLUMN_INDEX, Integer.class); if (columnIndex1 == null && columnIndex2 == null) { // When column index is not specified use the column name for sorting return column1.getName().compareToIgnoreCase(column2.getName()); } // Columns with the column index must be shown before the ones which don't have it. if (columnIndex1 != null && columnIndex2 == null) { return -1; } if (columnIndex1 == null && columnIndex2 != null) { return 1; } // Compare the column indexes if they are not null. return columnIndex1.compareTo(columnIndex2); } }); } return columns; } } TASMAN-webapp/src/main/webapp/resources/js/columns-sorter.js +1 −1 Original line number Diff line number Diff line Loading @@ -96,7 +96,7 @@ jsf.ajax.request('main', null, { 'javax.faces.behavior.event': 'action', execute: '@none', render: 'main:column_wrapper', render: 'main:tables_wrapper', onevent: function (event) { if (event.status === 'success') { $('#columns-sorter').modal('hide'); Loading TASMAN-webapp/src/main/webapp/tapSchemaEditing.xhtml +1 −1 Original line number Diff line number Diff line Loading @@ -243,7 +243,7 @@ <div class="columns-wrapper"> <div class="columns-selector"> <ul class="nav nav-pills"> <ui:repeat value="#{tapSchemaEditing.selectedTable.addedOrRemovedChildren}" var="column" id="columns-list"> <ui:repeat value="#{tapSchemaEditing.columns}" var="column" id="columns-list"> <li role="presentation" class="#{tapSchemaEditing.selectedColumn.name eq column.name ? 'active': ''}"> <h:commandLink role="tab" action="#{tapSchemaEditing.setSelectedColumn(column)}" id="column-selector"> <h:commandButton class="btn btn-link remove-btn" disabled="#{!tapSchemaEditing.isColumnRemovable(column)}" value="×" onclick="TSM.stopPropagation(event)" id="column-remover"> Loading Loading
TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/TapSchemaEditingBean.java +43 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,8 @@ import it.inaf.ia2.tsm.UpdateOperations; import java.io.Serializable; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Objects; import javax.faces.context.FacesContext; Loading Loading @@ -517,4 +519,45 @@ public class TapSchemaEditingBean implements Serializable { } }).getString(); } /** * Returns the columns list sorting them using {@code column_index} if * available. */ public List<Column> getColumns() { Table table = getSelectedTable(); if (table == null) { return null; } List<Column> columns = new ArrayList<>(table.getAddedOrRemovedChildren()); if (hasColumnsSorter) { Collections.sort(columns, new Comparator<Column>() { @Override public int compare(Column column1, Column column2) { Integer columnIndex1 = column1.getValue(Column.COLUMN_INDEX, Integer.class); Integer columnIndex2 = column2.getValue(Column.COLUMN_INDEX, Integer.class); if (columnIndex1 == null && columnIndex2 == null) { // When column index is not specified use the column name for sorting return column1.getName().compareToIgnoreCase(column2.getName()); } // Columns with the column index must be shown before the ones which don't have it. if (columnIndex1 != null && columnIndex2 == null) { return -1; } if (columnIndex1 == null && columnIndex2 != null) { return 1; } // Compare the column indexes if they are not null. return columnIndex1.compareTo(columnIndex2); } }); } return columns; } }
TASMAN-webapp/src/main/webapp/resources/js/columns-sorter.js +1 −1 Original line number Diff line number Diff line Loading @@ -96,7 +96,7 @@ jsf.ajax.request('main', null, { 'javax.faces.behavior.event': 'action', execute: '@none', render: 'main:column_wrapper', render: 'main:tables_wrapper', onevent: function (event) { if (event.status === 'success') { $('#columns-sorter').modal('hide'); Loading
TASMAN-webapp/src/main/webapp/tapSchemaEditing.xhtml +1 −1 Original line number Diff line number Diff line Loading @@ -243,7 +243,7 @@ <div class="columns-wrapper"> <div class="columns-selector"> <ul class="nav nav-pills"> <ui:repeat value="#{tapSchemaEditing.selectedTable.addedOrRemovedChildren}" var="column" id="columns-list"> <ui:repeat value="#{tapSchemaEditing.columns}" var="column" id="columns-list"> <li role="presentation" class="#{tapSchemaEditing.selectedColumn.name eq column.name ? 'active': ''}"> <h:commandLink role="tab" action="#{tapSchemaEditing.setSelectedColumn(column)}" id="column-selector"> <h:commandButton class="btn btn-link remove-btn" disabled="#{!tapSchemaEditing.isColumnRemovable(column)}" value="×" onclick="TSM.stopPropagation(event)" id="column-remover"> Loading