Skip to content

Commit 66fb795

Browse files
committed
made popup for mods to be installed
1 parent 51f8bf2 commit 66fb795

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

ui/App/components/Mods/ModLoadSave.jsx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import React from 'react';
2+
import ReactDOMServer from 'react-dom/server';
23

34
class ModLoadSave extends React.Component {
45
constructor(props) {
56
super(props);
67

78
this.loadMods = this.loadMods.bind(this);
9+
this.loadModsSwalHandler = this.loadModsSwalHandler.bind(this);
810
}
911

1012
componentDidMount() {
@@ -23,6 +25,57 @@ class ModLoadSave extends React.Component {
2325
data: $(e.target).serialize(),
2426
dataType: "JSON",
2527
success: (data) => {
28+
let checkboxes = [];
29+
30+
data.data.mods.forEach((mod) => {
31+
let singleCheckbox = <tr key={mod.name}>
32+
<td>
33+
{mod.name}
34+
<input type="hidden" name="mod_name[]" value={mod.name}/>
35+
</td>
36+
<td>
37+
{mod.version.major + "." + mod.version.minor + "." + mod.version.build}
38+
<input type="hidden" name="mod_version[]"/>
39+
</td>
40+
</tr>
41+
42+
checkboxes.push(singleCheckbox);
43+
});
44+
45+
let table = <div>
46+
All Mods will be installed
47+
<div style={{display: "flex", width: "100%", justifyContent: "center"}}>
48+
<form id="swalForm">
49+
<table>
50+
<thead>
51+
<tr>
52+
<th>
53+
ModName
54+
</th>
55+
<th>
56+
ModVersion
57+
</th>
58+
</tr>
59+
</thead>
60+
<tbody>
61+
{checkboxes}
62+
</tbody>
63+
</table>
64+
</form>
65+
</div>
66+
</div>
67+
68+
swal({
69+
title: "Mods to install",
70+
text: ReactDOMServer.renderToStaticMarkup(table),
71+
html: true,
72+
type: 'info',
73+
showCancelButton: true,
74+
closeOnConfirm: false,
75+
confirmButtonText: "Download Mods!",
76+
cancelButtonText: "Cancel",
77+
showLoaderOnConfirm: true
78+
}, this.loadModsSwalHandler);
2679
},
2780
error: (jqXHR) => {
2881
let json_data = JSON.parse(jqXHR.responseJSON.data);
@@ -35,6 +88,13 @@ class ModLoadSave extends React.Component {
3588
});
3689
}
3790

91+
loadModsSwalHandler() {
92+
$.ajax({
93+
url: "/api/mods/install/multiple"
94+
})
95+
console.log($("#swalForm").serialize());
96+
}
97+
3898
render() {
3999
console.log(this.props.saves);
40100

0 commit comments

Comments
 (0)