Skip to content

Commit

Permalink
Fix version sort for TBA mod, fix bad selected version when adding
Browse files Browse the repository at this point in the history
Address #5
  • Loading branch information
circlesabound committed Apr 9, 2024
1 parent 51e3497 commit 02900da
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions web/src/app/mods/mod-list/mod-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ <h1 class="title is-1">Mod list</h1>
<th>Version</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let modInfo of modInfoList; let i = index" app-mod-object [(modInfo)]="modInfoList[i]" (removeModInfo)="removeMod($event)"></tr>
</tbody>
<tfoot>
<tr>
<td>
Expand All @@ -40,9 +43,6 @@ <h1 class="title is-1">Mod list</h1>
</td>
</tr>
</tfoot>
<tbody>
<tr *ngFor="let modInfo of modInfoList; let i = index" app-mod-object [(modInfo)]="modInfoList[i]" (removeModInfo)="removeMod($event)"></tr>
</tbody>
</table>

<button id="save-button" class="button is-success" (click)="pushModList()" [ngClass]="{'is-loading': saveButtonLoading}">
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/mods/mod-list/mod-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class ModListComponent implements OnInit {
return of(ret);
}),
map(infoShort => {
const versions = infoShort.releases.map(r => r.version).sort().reverse();
const versions = infoShort.releases?.map(r => r.version).sort(compareVersions).reverse();
const selectedVersion = versions.length === 0 ? '' : versions[0];
const ret: ModInfo = {
name: infoShort.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</td>
<td>
<div class="select is-small" style="min-width: 50%;">
<select style="min-width: 100%;">
<option class="dropdown-item" *ngFor="let version of modInfo.versions" (click)="setSelectedVersion(version)">
<select style="min-width: 100%;" [(ngModel)]="modInfo.selectedVersion">
<option class="dropdown-item" *ngFor="let version of modInfo.versions" [ngValue]="version" (click)="setSelectedVersion(version)">
{{version}}
</option>
</select>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class ModObjectComponent implements OnInit {
this.removeModInfo.emit(this.modInfo);
}

// TODO possibly not needed anymore with ngModel bind, need to test
setSelectedVersion(version: string): void {
this.modInfo.selectedVersion = version;
this.modInfoChange.emit(this.modInfo);
Expand Down

0 comments on commit 02900da

Please sign in to comment.