diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt index d05fbc6..adc7800 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Tournament.kt @@ -203,7 +203,7 @@ fun Tournament.Companion.fromJson(json: Json.Object, default: Tournament<*>? = n shortName = json.getString("shortName") ?: default?.shortName ?: badRequest("missing shortName"), startDate = json.getString("startDate")?.let { LocalDate.parse(it) } ?: default?.startDate ?: badRequest("missing startDate"), endDate = json.getString("endDate")?.let { LocalDate.parse(it) } ?: default?.endDate ?: badRequest("missing endDate"), - country = json.getString("country") ?: default?.country ?: badRequest("missing country"), + country = (json.getString("country") ?: default?.country ?: "fr").let { if (it.isEmpty()) "fr" else it }, location = json.getString("location") ?: default?.location ?: badRequest("missing location"), online = json.getBoolean("online") ?: default?.online ?: false, komi = json.getDouble("komi") ?: default?.komi ?: 7.5, diff --git a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/ratings/RatingsManager.kt b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/ratings/RatingsManager.kt index e79d268..d85e7c3 100644 --- a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/ratings/RatingsManager.kt +++ b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/ratings/RatingsManager.kt @@ -103,12 +103,32 @@ object RatingsManager: Runnable { if (aga && ratingsHandlers[Ratings.AGA]!!.active) mask = mask or Ratings.AGA.flag if (egf && ratingsHandlers[Ratings.EGF]!!.active) mask = mask or Ratings.EGF.flag if (ffg && ratingsHandlers[Ratings.FFG]!!.active) mask = mask or Ratings.FFG.flag - val matches = index.match(needle, mask, country) - return matches.map { it -> players[it] }.toCollection(Json.MutableArray()) + return if (needle == "*") { + sortedPlayers(mask, country) + } else { + val matches = index.match(needle, mask, country) + matches.map { it -> players[it] }.toCollection(Json.MutableArray()) + } } finally { updateLock.readLock().unlock() } } + + private fun sortedPlayers(mask: Int, country: String?): Json.Array { + val cntry = country?.let { it.uppercase(Locale.ROOT) } + val orig = Ratings.values().filter { (it.flag and mask) != 0 }.map { it.name }.toSet() + return players.filter { + val player = it as Json.Object + (cntry == null || cntry == player.getString("country")) && orig.contains(player.getString("origin")) + }.sortedWith { a,b -> + val left = a as Json.Object + val right = b as Json.Object + val cmp = left.getString("name")!!.compareTo(right.getString("name")!!) + if (cmp == 0) left.getString("firstname")!!.compareTo(right.getString("firstname")!!) + else cmp + }.toCollection(Json.MutableArray()) + } + val index = PlayerIndex() } diff --git a/view-webapp/src/main/webapp/js/tour-registration.inc.js b/view-webapp/src/main/webapp/js/tour-registration.inc.js index 5685510..968862b 100644 --- a/view-webapp/src/main/webapp/js/tour-registration.inc.js +++ b/view-webapp/src/main/webapp/js/tour-registration.inc.js @@ -21,19 +21,19 @@ function searchResultShown() { function search(needle) { needle = needle.trim(); - if (needle && needle.length > 2) { + if (needle && (needle === '*' || needle.length > 2)) { let form = $('#player-form')[0]; let search = { needle: needle, - aga: form.val('aga'), + // aga: form.val('aga'), egf: form.val('egf'), ffg: form.val('ffg'), } let country = form.val('countryFilter'); if (country) search.countryFilter = country; let searchFormState = { - countryFilter: country ? true : false, - aga: search.aga, + countryFilter: !!country, + // aga: search.aga, egf: search.egf, ffg: search.ffg }; @@ -92,7 +92,7 @@ function addPlayers() { let status = form.val('final') || false; form.reset(); // initial search checkboxes position - ['countryFilter', 'aga', 'egf', 'ffg'].forEach(id => { + ['countryFilter', /* 'aga', */ 'egf', 'ffg'].forEach(id => { let value = store(id); let ctl = $(`#${id}`); if (value !== null && typeof(value) !== 'undefined' && ctl.length) { @@ -253,7 +253,7 @@ onLoad(() => { }); let searchFormState = store('searchFormState') if (searchFormState) { - for (let id of ["countryFilter", "aga", "egf", "ffg"]) { + for (let id of ["countryFilter", /* "aga", */ "egf", "ffg"]) { let ctl = $(`#${id}`); if (ctl.length) { ctl[0].checked = searchFormState[id]; @@ -410,4 +410,7 @@ onLoad(() => { })); bulkUpdate(players); }); + $('#browse-players').on('click', e => { + search('*'); + }); }); diff --git a/view-webapp/src/main/webapp/tour-registration.inc.html b/view-webapp/src/main/webapp/tour-registration.inc.html index d51a42c..1bad515 100644 --- a/view-webapp/src/main/webapp/tour-registration.inc.html +++ b/view-webapp/src/main/webapp/tour-registration.inc.html @@ -84,12 +84,13 @@ #end -
+
+#* Disabled
@@ -99,6 +100,7 @@
+*#
@@ -117,6 +119,11 @@
+
+ +