mirror of
https://github.com/arcan1s/ffxivbis.git
synced 2025-04-24 17:27:17 +00:00
add action button to suggest table
Also replace functions with lambdas
This commit is contained in:
parent
6023e86570
commit
b1ac894ccf
@ -207,8 +207,8 @@
|
|||||||
}),
|
}),
|
||||||
type: "POST",
|
type: "POST",
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
success: function (_) { reload(); },
|
success: _ => { reload(); },
|
||||||
error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); },
|
error: (jqXHR, _, errorThrown) => { requestAlert(jqXHR, errorThrown); },
|
||||||
});
|
});
|
||||||
updateBisDialog.modal("hide");
|
updateBisDialog.modal("hide");
|
||||||
return true; // action expects boolean result
|
return true; // action expects boolean result
|
||||||
@ -247,9 +247,9 @@
|
|||||||
url: `/api/v1/party/${partyId}`,
|
url: `/api/v1/party/${partyId}`,
|
||||||
type: "GET",
|
type: "GET",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (data) {
|
success: response => {
|
||||||
const items = data.map(function (player) {
|
const items = response.map(player => {
|
||||||
return player.bis.map(function (loot) {
|
return player.bis.map(loot => {
|
||||||
return {
|
return {
|
||||||
nick: player.nick,
|
nick: player.nick,
|
||||||
job: player.job,
|
job: player.job,
|
||||||
@ -258,12 +258,12 @@
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
const payload = items.reduce(function (left, right) { return left.concat(right); }, []);
|
const payload = items.reduce((left, right) => { return left.concat(right); }, []);
|
||||||
table.bootstrapTable("load", payload);
|
table.bootstrapTable("load", payload);
|
||||||
table.bootstrapTable("uncheckAll");
|
table.bootstrapTable("uncheckAll");
|
||||||
table.bootstrapTable("hideLoading");
|
table.bootstrapTable("hideLoading");
|
||||||
|
|
||||||
const options = data.map(function (player) {
|
const options = response.map(player => {
|
||||||
const option = document.createElement("option");
|
const option = document.createElement("option");
|
||||||
option.innerText = formatPlayerId(player);
|
option.innerText = formatPlayerId(player);
|
||||||
option.dataset.nick = player.nick;
|
option.dataset.nick = player.nick;
|
||||||
@ -272,13 +272,13 @@
|
|||||||
});
|
});
|
||||||
playerInput.empty().append(options);
|
playerInput.empty().append(options);
|
||||||
},
|
},
|
||||||
error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); },
|
error: (jqXHR, _, errorThrown) => { requestAlert(jqXHR, errorThrown); },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function removePiece() {
|
function removePiece() {
|
||||||
const pieces = table.bootstrapTable("getSelections");
|
const pieces = table.bootstrapTable("getSelections");
|
||||||
pieces.map(function (loot) {
|
pieces.map(loot => {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `/api/v1/party/${partyId}/bis`,
|
url: `/api/v1/party/${partyId}/bis`,
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
@ -296,8 +296,8 @@
|
|||||||
}),
|
}),
|
||||||
type: "POST",
|
type: "POST",
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
success: function (_) { reload(); },
|
success: _ => { reload(); },
|
||||||
error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); },
|
error: (jqXHR, _, errorThrown) => { requestAlert(jqXHR, errorThrown); },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -325,8 +325,8 @@
|
|||||||
}),
|
}),
|
||||||
type: "PUT",
|
type: "PUT",
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
success: function (_) { reload(); },
|
success: _ => { reload(); },
|
||||||
error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); },
|
error: (jqXHR, _, errorThrown) => { requestAlert(jqXHR, errorThrown); },
|
||||||
});
|
});
|
||||||
updateBisDialog.modal("hide");
|
updateBisDialog.modal("hide");
|
||||||
return true; // action expects boolean result
|
return true; // action expects boolean result
|
||||||
@ -342,7 +342,7 @@
|
|||||||
return false; // should not happen
|
return false; // should not happen
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function () {
|
$(() => {
|
||||||
setupFormClear(updateBisDialog, reset);
|
setupFormClear(updateBisDialog, reset);
|
||||||
setupRemoveButton(table, removeButton);
|
setupRemoveButton(table, removeButton);
|
||||||
|
|
||||||
@ -353,8 +353,8 @@
|
|||||||
|
|
||||||
hideControls();
|
hideControls();
|
||||||
|
|
||||||
updateBisButton.click(function () { reset(); });
|
updateBisButton.click(() => { reset(); });
|
||||||
addPieceButton.click(function () { reset(); });
|
addPieceButton.click(() => { reset(); });
|
||||||
|
|
||||||
table.bootstrapTable({});
|
table.bootstrapTable({});
|
||||||
reload();
|
reload();
|
||||||
|
@ -88,7 +88,7 @@
|
|||||||
|
|
||||||
<div id="add-loot-dialog" tabindex="-1" role="dialog" class="modal fade">
|
<div id="add-loot-dialog" tabindex="-1" role="dialog" class="modal fade">
|
||||||
<div class="modal-dialog modal-lg" role="document">
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
<form class="modal-content" action="javascript:" onsubmit="addLoot()">
|
<form class="modal-content" action="javascript:" onsubmit="addLootModal()">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h4 class="modal-title">add looted piece</h4>
|
<h4 class="modal-title">add looted piece</h4>
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="close"></button>
|
||||||
@ -132,6 +132,7 @@
|
|||||||
<table id="stats" class="table table-striped table-hover">
|
<table id="stats" class="table table-striped table-hover">
|
||||||
<thead class="table-primary">
|
<thead class="table-primary">
|
||||||
<tr>
|
<tr>
|
||||||
|
<th data-formatter="addLootFormatter"></th>
|
||||||
<th data-field="nick">nick</th>
|
<th data-field="nick">nick</th>
|
||||||
<th data-field="job">job</th>
|
<th data-field="job">job</th>
|
||||||
<th data-field="isRequired">required</th>
|
<th data-field="isRequired">required</th>
|
||||||
@ -198,30 +199,40 @@
|
|||||||
const pieceTypeInput = $("#piece-type");
|
const pieceTypeInput = $("#piece-type");
|
||||||
const playerInput = $("#player");
|
const playerInput = $("#player");
|
||||||
|
|
||||||
function addLoot() {
|
function addLoot(nick, job) {
|
||||||
const player = getCurrentOption(playerInput);
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `/api/v1/party/${partyId}/loot`,
|
url: `/api/v1/party/${partyId}/loot`,
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
action: "add",
|
action: "add",
|
||||||
piece: {
|
piece: {
|
||||||
pieceType: pieceTypeInput.val(),
|
pieceType: pieceTypeInput.val(),
|
||||||
job: player.dataset.job,
|
job: job,
|
||||||
piece: pieceInput.val(),
|
piece: pieceInput.val(),
|
||||||
},
|
},
|
||||||
playerId: {
|
playerId: {
|
||||||
partyId: partyId,
|
partyId: partyId,
|
||||||
nick: player.dataset.nick,
|
nick: nick,
|
||||||
job: player.dataset.job,
|
job: job,
|
||||||
},
|
},
|
||||||
isFreeLoot: freeLootInput.is(":checked"),
|
isFreeLoot: freeLootInput.is(":checked"),
|
||||||
}),
|
}),
|
||||||
type: "POST",
|
type: "POST",
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
success: function (_) { reload(); },
|
success: _ => {
|
||||||
error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); },
|
|
||||||
});
|
|
||||||
addLootDialog.modal("hide");
|
addLootDialog.modal("hide");
|
||||||
|
reload();
|
||||||
|
},
|
||||||
|
error: (jqXHR, _, errorThrown) => { requestAlert(jqXHR, errorThrown); },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function addLootFormatter(value, row, index) {
|
||||||
|
return `<button type="button" class="btn btn-primary" onclick="addLoot('${row.nick}', '${row.job}')"><i class="bi bi-plus"></i></button>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addLootModal() {
|
||||||
|
const player = getCurrentOption(playerInput);
|
||||||
|
addLoot(player.dataset.nick, player.dataset.job);
|
||||||
return true; // action expects boolean result
|
return true; // action expects boolean result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,9 +247,9 @@
|
|||||||
url: `/api/v1/party/${partyId}`,
|
url: `/api/v1/party/${partyId}`,
|
||||||
type: "GET",
|
type: "GET",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (data) {
|
success: response => {
|
||||||
const items = data.map(function (player) {
|
const items = response.map(player => {
|
||||||
return player.loot.map(function (loot) {
|
return player.loot.map(loot => {
|
||||||
return {
|
return {
|
||||||
nick: player.nick,
|
nick: player.nick,
|
||||||
job: player.job,
|
job: player.job,
|
||||||
@ -249,12 +260,12 @@
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
const payload = items.reduce(function (left, right) { return left.concat(right); }, []);
|
const payload = items.reduce((left, right) => { return left.concat(right); }, []);
|
||||||
table.bootstrapTable("load", payload);
|
table.bootstrapTable("load", payload);
|
||||||
table.bootstrapTable("uncheckAll");
|
table.bootstrapTable("uncheckAll");
|
||||||
table.bootstrapTable("hideLoading");
|
table.bootstrapTable("hideLoading");
|
||||||
|
|
||||||
const options = data.map(function (player) {
|
const options = response.map(player => {
|
||||||
const option = document.createElement("option");
|
const option = document.createElement("option");
|
||||||
option.innerText = formatPlayerId(player);
|
option.innerText = formatPlayerId(player);
|
||||||
option.dataset.nick = player.nick;
|
option.dataset.nick = player.nick;
|
||||||
@ -263,13 +274,13 @@
|
|||||||
});
|
});
|
||||||
playerInput.empty().append(options);
|
playerInput.empty().append(options);
|
||||||
},
|
},
|
||||||
error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); },
|
error: (jqXHR, _, errorThrown) => { requestAlert(jqXHR, errorThrown); },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeLoot() {
|
function removeLoot() {
|
||||||
const pieces = table.bootstrapTable("getSelections");
|
const pieces = table.bootstrapTable("getSelections");
|
||||||
pieces.map(function (loot) {
|
pieces.map(loot => {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `/api/v1/party/${partyId}/loot`,
|
url: `/api/v1/party/${partyId}/loot`,
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
@ -288,8 +299,8 @@
|
|||||||
}),
|
}),
|
||||||
type: "POST",
|
type: "POST",
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
success: function (_) { reload(); },
|
success: _ => { reload(); },
|
||||||
error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); },
|
error: (jqXHR, _, errorThrown) => { requestAlert(jqXHR, errorThrown); },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -306,8 +317,8 @@
|
|||||||
type: "PUT",
|
type: "PUT",
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (data) {
|
success: response => {
|
||||||
const payload = data.map(function (stat) {
|
const payload = response.map(stat => {
|
||||||
return {
|
return {
|
||||||
nick: stat.nick,
|
nick: stat.nick,
|
||||||
job: stat.job,
|
job: stat.job,
|
||||||
@ -321,11 +332,11 @@
|
|||||||
stats.bootstrapTable("uncheckAll");
|
stats.bootstrapTable("uncheckAll");
|
||||||
stats.bootstrapTable("hideLoading");
|
stats.bootstrapTable("hideLoading");
|
||||||
},
|
},
|
||||||
error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); },
|
error: (jqXHR, _, errorThrown) => { requestAlert(jqXHR, errorThrown); },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function () {
|
$(() => {
|
||||||
setupFormClear(addLootDialog);
|
setupFormClear(addLootDialog);
|
||||||
setupRemoveButton(table, removeButton);
|
setupRemoveButton(table, removeButton);
|
||||||
|
|
||||||
|
@ -184,8 +184,8 @@
|
|||||||
}),
|
}),
|
||||||
type: "POST",
|
type: "POST",
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
success: function (_) { reload(); },
|
success: _ => { reload(); },
|
||||||
error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); },
|
error: (jqXHR, _, errorThrown) => { requestAlert(jqXHR, errorThrown); },
|
||||||
});
|
});
|
||||||
addPlayerDialog.modal("hide");
|
addPlayerDialog.modal("hide");
|
||||||
return true; // action expects boolean result
|
return true; // action expects boolean result
|
||||||
@ -210,18 +210,18 @@
|
|||||||
url: `/api/v1/party/${partyId}`,
|
url: `/api/v1/party/${partyId}`,
|
||||||
type: "GET",
|
type: "GET",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (data) {
|
success: response => {
|
||||||
table.bootstrapTable("load", data);
|
table.bootstrapTable("load", response);
|
||||||
table.bootstrapTable("uncheckAll");
|
table.bootstrapTable("uncheckAll");
|
||||||
table.bootstrapTable("hideLoading");
|
table.bootstrapTable("hideLoading");
|
||||||
},
|
},
|
||||||
error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); },
|
error: (jqXHR, _, errorThrown) => { requestAlert(jqXHR, errorThrown); },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function removePlayers() {
|
function removePlayers() {
|
||||||
const players = table.bootstrapTable("getSelections");
|
const players = table.bootstrapTable("getSelections");
|
||||||
players.map(function (player) {
|
players.map(player => {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `/api/v1/party/${partyId}`,
|
url: `/api/v1/party/${partyId}`,
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
@ -234,13 +234,13 @@
|
|||||||
}),
|
}),
|
||||||
type: "POST",
|
type: "POST",
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
success: function (_) { reload(); },
|
success: _ => { reload(); },
|
||||||
error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); },
|
error: (jqXHR, _, errorThrown) => { requestAlert(jqXHR, errorThrown); },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function () {
|
$(() => {
|
||||||
setupFormClear(addPlayerDialog);
|
setupFormClear(addPlayerDialog);
|
||||||
setupRemoveButton(table, removeButton);
|
setupRemoveButton(table, removeButton);
|
||||||
|
|
||||||
|
@ -173,8 +173,8 @@
|
|||||||
}),
|
}),
|
||||||
type: "POST",
|
type: "POST",
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
success: function (_) { reload(); },
|
success: _ => { reload(); },
|
||||||
error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); },
|
error: (jqXHR, _, errorThrown) => { requestAlert(jqXHR, errorThrown); },
|
||||||
});
|
});
|
||||||
addUserDialog.modal("hide");
|
addUserDialog.modal("hide");
|
||||||
return true; // action expects boolean result
|
return true; // action expects boolean result
|
||||||
@ -191,28 +191,28 @@
|
|||||||
url: `/api/v1/party/${partyId}/users`,
|
url: `/api/v1/party/${partyId}/users`,
|
||||||
type: "GET",
|
type: "GET",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (data) {
|
success: response => {
|
||||||
table.bootstrapTable("load", data);
|
table.bootstrapTable("load", response);
|
||||||
table.bootstrapTable("uncheckAll");
|
table.bootstrapTable("uncheckAll");
|
||||||
table.bootstrapTable("hideLoading");
|
table.bootstrapTable("hideLoading");
|
||||||
},
|
},
|
||||||
error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); },
|
error: (jqXHR, _, errorThrown) => { requestAlert(jqXHR, errorThrown); },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeUsers() {
|
function removeUsers() {
|
||||||
const users = table.bootstrapTable("getSelections");
|
const users = table.bootstrapTable("getSelections");
|
||||||
users.map(function (user) {
|
users.map(user => {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `/api/v1/party/${partyId}/users/${user.username}`,
|
url: `/api/v1/party/${partyId}/users/${user.username}`,
|
||||||
type: "DELETE",
|
type: "DELETE",
|
||||||
success: function (_) { reload(); },
|
success: _ => { reload(); },
|
||||||
error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); },
|
error: (jqXHR, _, errorThrown) => { requestAlert(jqXHR, errorThrown); },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function () {
|
$(() => {
|
||||||
setupFormClear(addUserDialog);
|
setupFormClear(addUserDialog);
|
||||||
setupRemoveButton(table, removeButton);
|
setupRemoveButton(table, removeButton);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user