Skip to content

Commit 84b34cc

Browse files
committed
Add keyword search
1 parent bda5e21 commit 84b34cc

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed
Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
11
jQuery ->
2-
$("#skmz_search_table_name").on "change blur", () ->
3-
console.log $(this).val()
2+
change_tr_display = ->
3+
table_name = $("#skmz_search_table_name").val()
4+
column_type = $("#skmz_search_column_type").val()
5+
column_name = $("#skmz_search_column_name").val()
6+
$("tr.skmz_row").show()
7+
# TODO jQueryのオブジェクトが見つからなかった際のエラーに対応する
8+
if table_name?.trim()
9+
$("tr.skmz_row").each ->
10+
regexp = new RegExp("skmz_table_name .*" + table_name + ".*")
11+
unless $(this).find("td.skmz_table_name:first").attr("class").match(regexp)
12+
$(this).hide()
13+
if column_type?.trim()
14+
$("tr.skmz_row").each ->
15+
regexp = new RegExp("skmz_column_type .*" + column_type + ".*")
16+
unless $(this).find("td.skmz_column_type:first").attr("class").match(regexp)
17+
$(this).hide()
18+
if column_name?.trim()
19+
$("tr.skmz_row").each ->
20+
regexp = new RegExp("skmz_column_name .*" + column_name + ".*")
21+
unless $(this).find("td.skmz_column_name:first").attr("class").match(regexp)
22+
$(this).hide()
23+
24+
$("#skmz_search_table_name").on "keyup", ->
25+
change_tr_display()
26+
27+
$("#skmz_search_column_type").on "change", ->
28+
change_tr_display()
29+
30+
$("#skmz_search_column_name").on "keyup", ->
31+
change_tr_display()
32+

app/views/skmz/info/schemas/index.html.erb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
<% @schema.tables.each do |table| %>
1919
<tbody>
2020
<% table.columns.each_with_index do |column, i| %>
21-
<tr class="<%= "skmz_#{table.name} skmz_#{column.type} skmz_#{column.name}" %>">
22-
<td><%= table.name %></td>
23-
<td><%= column.type %></td>
24-
<td><%= column.name %></td>
21+
<tr class="skmz_row">
22+
<td class="<%= "skmz_table_name #{table.name}" %>"><%= table.name %></td>
23+
<td class="<%= "skmz_column_type #{column.type}" %>"><%= column.type %></td>
24+
<td class="<%= "skmz_column_name #{column.name}" %>"><%= column.name %></td>
2525
</tr>
2626
<% end %>
2727
</tbody>

0 commit comments

Comments
 (0)