Fixed litebans table breaking the server page #636

This commit is contained in:
Rsl1122 2018-07-19 09:51:19 +03:00
parent 403503e61f
commit 0661c0b1bd
5 changed files with 21 additions and 15 deletions

View File

@ -24,7 +24,7 @@ public class TableContainer {
protected final Formatter[] formatters; protected final Formatter[] formatters;
private List<Serializable[]> values; private List<Serializable[]> values;
private boolean jqueryDatatable; private String jqueryDatatable;
private String color; private String color;
@ -56,7 +56,7 @@ public class TableContainer {
return getTableHeader() + return getTableHeader() +
parseHeader() + parseHeader() +
parseBody() + parseBody() +
"</table>" + (jqueryDatatable ? "</div>" : ""); "</table>" + (jqueryDatatable != null ? "</div>" : "");
} }
public final String parseBody() { public final String parseBody() {
@ -112,17 +112,28 @@ public class TableContainer {
} }
/** /**
* Make use of JQuery Datatables plugin. * Make use of jQuery Data-tables plugin.
* <p>
* Use this with custom tables.
* <p> * <p>
* If this is called, result of {@code parseHtml()} should be wrapped with {@code Html.PANEL.parse(Html.PANEL_BODY.parse(result))} * If this is called, result of {@code parseHtml()} should be wrapped with {@code Html.PANEL.parse(Html.PANEL_BODY.parse(result))}
*/ */
public void useJqueryDataTables() { public void useJqueryDataTables() {
this.jqueryDatatable = true; this.jqueryDatatable = "player-plugin-table";
}
/**
* Make use of jQuery Data-tables plugin.
*
* @param sortType "player-table" or "player-plugin-table"
*/
public void useJqueryDataTables(String sortType) {
jqueryDatatable = sortType;
} }
private String getTableHeader() { private String getTableHeader() {
if (jqueryDatatable) { if (jqueryDatatable != null) {
return "<div class=\"table-responsive\">" + Html.TABLE_JQUERY.parse(); return "<div class=\"table-responsive\">" + Html.TABLE_JQUERY.parse(jqueryDatatable);
} else { } else {
return Html.TABLE_SCROLL.parse(); return Html.TABLE_SCROLL.parse();
} }

View File

@ -65,7 +65,7 @@ public enum Html {
TABLE_END("</tbody></table>"), TABLE_END("</tbody></table>"),
TABLE("<table class=\"table table-striped\">"), TABLE("<table class=\"table table-striped\">"),
TABLE_SCROLL("<table class=\"table table-striped scrollbar\">"), TABLE_SCROLL("<table class=\"table table-striped scrollbar\">"),
TABLE_JQUERY("<table class=\"table table-bordered table-striped table-hover player-table dataTable\">"), TABLE_JQUERY("<table class=\"table table-bordered table-striped table-hover ${0} dataTable\">"),
TABLE_COLORED("<table class=\"bg-${0} table table-striped\">"), TABLE_COLORED("<table class=\"bg-${0} table table-striped\">"),
TABLE_HEAD("<thead>${0}</thead>"), TABLE_HEAD("<thead>${0}</thead>"),
TABLE_BODY("<tbody>${0}</tbody>"), TABLE_BODY("<tbody>${0}</tbody>"),

View File

@ -39,7 +39,7 @@ public class PlayersTable extends TableContainer {
); );
this.players = players; this.players = players;
this.maxPlayers = maxPlayers; this.maxPlayers = maxPlayers;
useJqueryDataTables(); useJqueryDataTables("player-table");
setFormatter(2, Formatters.timeAmount()); setFormatter(2, Formatters.timeAmount());
setFormatter(4, Formatters.yearLongValue()); setFormatter(4, Formatters.yearLongValue());

View File

@ -32,7 +32,7 @@ public class PluginPlayersTable extends TableContainer {
this.players = players; this.players = players;
useJqueryDataTables(); useJqueryDataTables("player-plugin-table");
if (players.isEmpty()) { if (players.isEmpty()) {
addRow("No Players"); addRow("No Players");
@ -42,11 +42,6 @@ public class PluginPlayersTable extends TableContainer {
} }
} }
@Override
public String parseHtml() {
return super.parseHtml().replace("player-table", "player-plugin-table");
}
private static String[] getHeaders(Set<String> columnNames) { private static String[] getHeaders(Set<String> columnNames) {
List<String> header = new ArrayList<>(columnNames); List<String> header = new ArrayList<>(columnNames);
Collections.sort(header); Collections.sort(header);

View File

@ -864,7 +864,7 @@
<!-- Plan laod script --> <!-- Plan laod script -->
<script> <script>
$(function () { $(function () {
$('.player-table').DataTable({ $('.player-plugin-table').DataTable({
responsive: true responsive: true
}); });