mirror of
				https://github.com/arcan1s/ffxivbis.git
				synced 2025-10-31 05:33:41 +00:00 
			
		
		
		
	move modals to form validation
This commit is contained in:
		| @ -86,7 +86,7 @@ | ||||
|  | ||||
|     <div id="update-bis-dialog" tabindex="-1" role="dialog" class="modal fade"> | ||||
|         <div class="modal-dialog" role="document"> | ||||
|             <form class="modal-content"> | ||||
|             <form class="modal-content" action="javascript:" onsubmit="updateBis()"> | ||||
|                 <div class="modal-header"> | ||||
|                     <div class="btn-group" role="group" aria-label="Update bis"> | ||||
|                         <input id="add-piece-btn" name="update-bis" type="radio" class="btn-check" autocomplete="off" checked> | ||||
| @ -102,7 +102,7 @@ | ||||
|                     <div class="form-group row"> | ||||
|                         <label class="col-sm-4 col-form-label" for="player">player</label> | ||||
|                         <div class="col-sm-8"> | ||||
|                             <select id="player" name="player" class="form-control" title="player"></select> | ||||
|                             <select id="player" name="player" class="form-control" title="player" required></select> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                     <div id="piece-row" class="form-group row"> | ||||
| @ -120,14 +120,14 @@ | ||||
|                     <div id="bis-link-row" class="form-group row" style="display: none"> | ||||
|                         <label class="col-sm-4 col-form-label" for="bis-link">link</label> | ||||
|                         <div class="col-sm-8"> | ||||
|                             <input id="bis-link" name="link" class="form-control" placeholder="link to bis" onkeyup="disableSubmitBisButton()"> | ||||
|                             <input id="bis-link" name="link" class="form-control" placeholder="link to bis"> | ||||
|                         </div> | ||||
|                     </div> | ||||
|  | ||||
|                     <div class="modal-footer"> | ||||
|                         <button type="button" class="btn btn-danger" data-bs-dismiss="modal">close</button> | ||||
|                         <button id="submit-add-bis-btn" type="button" class="btn btn-primary" data-bs-dismiss="modal" onclick="addPiece()" disabled>add</button> | ||||
|                         <button id="submit-update-bis-btn" type="button" class="btn btn-primary" data-bs-dismiss="modal" onclick="setBis()" style="display: none" disabled>set</button> | ||||
|                         <button id="submit-add-bis-btn" type="submit" class="btn btn-primary">add</button> | ||||
|                         <button id="submit-set-bis-btn" type="submit" class="btn btn-primary" style="display: none">set</button> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </form> | ||||
| @ -171,7 +171,7 @@ | ||||
|         const updateButton = $("#update-btn"); | ||||
|  | ||||
|         const submitAddBisButton = $("#submit-add-bis-btn"); | ||||
|         const submitUpdateBisButton = $("#submit-update-bis-btn"); | ||||
|         const submitSetBisButton = $("#submit-set-bis-btn"); | ||||
|         const updateBisDialog = $("#update-bis-dialog"); | ||||
|  | ||||
|         const addPieceButton = $("#add-piece-btn"); | ||||
| @ -208,12 +208,8 @@ | ||||
|                 success: function (_) { reload(); }, | ||||
|                 error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); }, | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         function disableSubmitBisButton() { | ||||
|             const nonEmpty = (playerInput.val() !== null);  // well lol | ||||
|             submitUpdateBisButton.attr("disabled", !(nonEmpty && linkInput.val())); | ||||
|             submitAddBisButton.attr("disabled", !(nonEmpty)); | ||||
|             updateBisDialog.modal("hide"); | ||||
|             return true; // action expects boolean result | ||||
|         } | ||||
|  | ||||
|         function hideControls() { | ||||
| @ -222,20 +218,24 @@ | ||||
|         } | ||||
|  | ||||
|         function hideLinkPart() { | ||||
|             disableSubmitBisButton(); | ||||
|             bisLinkRow.hide(); | ||||
|             submitUpdateBisButton.hide(); | ||||
|             linkInput.prop("required", false); | ||||
|             submitSetBisButton.hide(); | ||||
|             pieceRow.show(); | ||||
|             pieceTypeRow.show(); | ||||
|             pieceInput.prop("required", true); | ||||
|             pieceTypeInput.prop("required", true); | ||||
|             submitAddBisButton.show(); | ||||
|         } | ||||
|  | ||||
|         function hidePiecePart() { | ||||
|             disableSubmitBisButton(); | ||||
|             bisLinkRow.show(); | ||||
|             submitUpdateBisButton.show(); | ||||
|             linkInput.prop("required", true); | ||||
|             submitSetBisButton.show(); | ||||
|             pieceRow.hide(); | ||||
|             pieceTypeRow.hide(); | ||||
|             pieceInput.prop("required", false); | ||||
|             pieceTypeInput.prop("required", false); | ||||
|             submitAddBisButton.hide(); | ||||
|         } | ||||
|  | ||||
| @ -269,7 +269,6 @@ | ||||
|                         return option; | ||||
|                     }); | ||||
|                     playerInput.empty().append(options); | ||||
|                     disableSubmitBisButton(); | ||||
|                 }, | ||||
|                 error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); }, | ||||
|             }); | ||||
| @ -327,6 +326,18 @@ | ||||
|                 success: function (_) { reload(); }, | ||||
|                 error: function (jqXHR, _, errorThrown) { requestAlert(jqXHR, errorThrown); }, | ||||
|             }); | ||||
|             updateBisDialog.modal("hide"); | ||||
|             return true; // action expects boolean result | ||||
|         } | ||||
|  | ||||
|         function updateBis() { | ||||
|             if (updateBisButton.is(":checked")) { | ||||
|                 return setBis(); | ||||
|             } | ||||
|             if (addPieceButton.is(":checked")) { | ||||
|                 return addPiece(); | ||||
|             } | ||||
|             return false; // should not happen | ||||
|         } | ||||
|  | ||||
|         $(function () { | ||||
| @ -344,6 +355,7 @@ | ||||
|  | ||||
|             table.bootstrapTable({}); | ||||
|             reload(); | ||||
|             reset(); | ||||
|         }); | ||||
|     </script> | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user