Resource fixes!
[browser-rts.git] / src / render / unit-training.ts
index bfed36e2cd33cca3d346141b203327a92370b239..0214bfe301402ff31de4ad328a4a1c5cd9b5ac54 100644 (file)
@@ -2,7 +2,6 @@ import _ from "lodash";
 import { CityWithLocation } from "../repository/city";
 import { UnitTrainingQueue } from "../repository/training-queue";
 import { Unit } from "../repository/unit";
-import { topbar } from "./topbar";
 
 function progressBar(current, max): string {
     const percent = Math.ceil((current/max) * 100);
@@ -24,18 +23,19 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini
         <th>Unit</th>
         <th>Avail.</td>
         <th></th>
+        <th width="200">Cost</th>
     </tr>
     <tr>
         <th>Soldiers</th>
         <td>${city.population}</td>
         <td>
             <form hx-post="/units">
-                <input type="number" name="amount" size="6" max="${city.population}" hx-trigger="change" hx-post="/cost/training" hx-target="#${unit.soldiers.slug}-cost">
+                <input type="number" name="amount" size="6" max="${city.population}" hx-trigger="keyup" hx-post="/cost/training" hx-target="#${unit.soldiers.slug}-cost">
                 <input type="hidden" name="type" value="${unit.soldiers.slug}">
                 <button type="submit" ${city.population ? '' : 'disabled'}>Train</button>
             </form>
-            <span id="${unit.soldiers.slug}-cost"></span>
         </td>
+        <td id="${unit.soldiers.slug}-cost"></span>
     </tr>
     <tr>
         <th>Attackers</th>
@@ -46,8 +46,8 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini
                 <input type="hidden" name="type" value="${unit.attackers.slug}">
                 <button type="submit" ${city.soldiers ? '' : 'disabled'}>Train</button>
             </form>
-            <span id="${unit.attackers.slug}-cost"></span>
         </td>
+        <td id="${unit.attackers.slug}-cost"></span>
     </tr>
     <tr>
         <th>Defenders</th>
@@ -58,8 +58,8 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini
                 <input type="hidden" name="type" value="${unit.defenders.slug}">
                 <button type="submit" ${city.soldiers ? '' : 'disabled'}>Train</button>
             </form>
-            <span id="${unit.defenders.slug}-cost"></span>
         </td>
+        <td id="${unit.defenders.slug}-cost"></td>
     </tr>
     <tr>
         <th>Special Attackers</th>
@@ -72,6 +72,7 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini
             </form>
             <span id="${unit.sp_attackers.slug}-cost"></span>
         </td>
+        <td id="${unit.sp_attackers.slug}-cost"></td>
     </tr>
     <tr>
         <th>Special Defenders</th>
@@ -82,8 +83,8 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini
                 <input type="hidden" name="type" value="${unit.sp_defenders.slug}">
                 <button type="submit" ${city.defenders ? '': 'disabled'}>Train</button>
             </form>
-            <span id="${unit.sp_defenders.slug}-cost"></span>
         </td>
+        <td id="${unit.sp_defenders.slug}-cost"></td>
         </tr>
     </table>
     `;
@@ -115,5 +116,5 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini
     </div>
     `;
 
-    return html + queues + topbar(city);
-}
\ No newline at end of file
+    return html + queues;
+}