Skip to content

Commit d3c358e

Browse files
author
Kamshory, MT
committed
Add entity and column selection
1 parent 08ddd14 commit d3c358e

File tree

7 files changed

+94
-53
lines changed

7 files changed

+94
-53
lines changed

index.html

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<script src="js/sql-wasm.min.js"></script>
2424
<script src="js/Main.min.js"></script>
2525
<style>
26-
.erd-wrapper, #erd-description, #entity-selection{
26+
.erd-wrapper, #erd-selection, #entity-primary-key{
2727
position: relative;
2828
max-height: 320px;
2929
overflow: auto;
@@ -68,13 +68,13 @@ <h4 class="mb-0">Spring GraphQL Project Generator</h4>
6868
</button>
6969
</li>
7070
<li class="nav-item" role="presentation">
71-
<button class="nav-link" id="description-tab" data-bs-toggle="tab" data-bs-target="#description" type="button" role="tab" aria-controls="description" aria-selected="false">
72-
Description
71+
<button class="nav-link" id="selection-tab" data-bs-toggle="tab" data-bs-target="#selection" type="button" role="tab" aria-controls="description" aria-selected="false">
72+
Selection
7373
</button>
7474
</li>
7575
<li class="nav-item" role="presentation">
76-
<button class="nav-link" id="selection-tab" data-bs-toggle="tab" data-bs-target="#selection" type="button" role="tab" aria-controls="description" aria-selected="false">
77-
Selection
76+
<button class="nav-link" id="primaty-key-tab" data-bs-toggle="tab" data-bs-target="#primaty-key" type="button" role="tab" aria-controls="description" aria-selected="false">
77+
Primary Keys
7878
</button>
7979
</li>
8080
</ul>
@@ -87,34 +87,33 @@ <h4 class="mb-0">Spring GraphQL Project Generator</h4>
8787
</div>
8888
</div>
8989

90-
<!-- Tab: Description -->
91-
<div class="tab-pane fade" id="description" role="tabpanel" aria-labelledby="description-tab">
90+
<!-- Tab: Selection -->
91+
<div class="tab-pane fade" id="selection" role="tabpanel" aria-labelledby="selection-tab">
9292
<!-- Anda bisa isi tabel deskripsi di sini -->
93-
<div id="erd-description">
93+
<div id="erd-selection">
9494
<table class="table table-sm table-striped align-middle">
9595
<thead>
9696
<tr>
9797
<th>Column</th><th>Type</th><th>PK</th><th>Nullable</th><th>Default</th>
9898
</tr>
9999
</thead>
100-
<tbody id="erd-description-body"></tbody>
100+
<tbody id="erd-selection-body"></tbody>
101101
</table>
102102
</div>
103103
</div>
104104

105105

106-
<!-- Tab: Selection -->
107-
<div class="tab-pane fade" id="selection" role="tabpanel" aria-labelledby="selection-tab">
108-
<div id="entity-selection">
106+
<!-- Tab: Primary Keys -->
107+
<div class="tab-pane fade" id="primaty-key" role="tabpanel" aria-labelledby="primaty-key-tab">
108+
<div id="entity-primary-key">
109109
<table class="table table-sm table-striped align-middle">
110110
<thead>
111111
<tr>
112-
<th width="20"><input type="checkbox" class="check-all" checked></th>
113112
<th width="50%">Entity Name</th>
114113
<th>Primary Keys</th>
115114
</tr>
116115
</thead>
117-
<tbody id="entity-selection-body"></tbody>
116+
<tbody id="entity-primary-key-body"></tbody>
118117
</table>
119118
</div>
120119
</div>

js/EntityRenderer.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -840,13 +840,22 @@ class EntityRenderer {
840840
addDescription(entity, wrapper) {
841841
let container = document.createElement("div");
842842
container.classList.add("mb-4");
843+
844+
let entitySelector = document.createElement("input");
845+
entitySelector.type = "checkbox";
846+
entitySelector.className = "entity-selector";
847+
entitySelector.value = entity.name;
848+
entitySelector.checked = true;
843849

844850
let title = document.createElement("h5");
845-
title.textContent = entity.name;
851+
title.appendChild(entitySelector);
852+
title.appendChild(document.createTextNode(" "));
853+
title.appendChild(document.createTextNode(entity.name));
846854
container.appendChild(title);
847855

848856
let table = document.createElement("table");
849857
table.className = "table table-bordered table-striped table-sm";
858+
table.dataset.entity = entity.name;
850859

851860
// Tambahkan styling khusus
852861
table.style.width = "100%";
@@ -855,11 +864,12 @@ class EntityRenderer {
855864
let thead = document.createElement("thead");
856865
thead.innerHTML = `
857866
<tr>
858-
<th style="width: 25%;">Column</th>
867+
<th style="width: 23px;"><input type="checkbox" class="check-all" onchange="checkAllColumns(this)" checked></th>
868+
<th style="width: 24%;">Column</th>
859869
<th style="width: 20%;">Type</th>
860870
<th style="width: 10%;">PK</th>
861871
<th style="width: 10%;">Serial</th>
862-
<th style="width: 15%;">Nullable</th>
872+
<th style="width: 14%;">Nullable</th>
863873
<th style="width: 20%;">Default</th>
864874
</tr>
865875
`;
@@ -877,10 +887,11 @@ class EntityRenderer {
877887
}
878888

879889
tr.innerHTML = `
890+
<td><input type="checkbox" class="check-column" value="${col.name || ''}" checked></td>
880891
<td>${col.name || ""}</td>
881892
<td>${typeDisplay}</td>
882-
<td style="text-align: center;">${col.primaryKey ? "" : ""}</td>
883-
<td style="text-align: center;">${col.autoIncrement ? "" : ""}</td>
893+
<td style="text-align: center;">${col.primaryKey ? "YES" : "NO"}</td>
894+
<td style="text-align: center;">${col.autoIncrement ? "YES" : "NO"}</td>
884895
<td style="text-align: center;">${col.nullable ? "YES" : "NO"}</td>
885896
<td>${col.defaultValue != null ? col.defaultValue : ""}</td>
886897
`;

0 commit comments

Comments
 (0)