Skip to content

Commit

Permalink
Merge pull request #32 from jianghengle/hengle/fix_bug
Browse files Browse the repository at this point in the history
Hengle/fix bug
  • Loading branch information
fridgerator committed Oct 4, 2018
2 parents 0ce6b07 + c6011f5 commit 40f0560
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 22 deletions.
4 changes: 4 additions & 0 deletions public/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,7 @@
input[placeholder] {
text-overflow: ellipsis;
}

.field-value {
white-space: pre-wrap;
}
2 changes: 1 addition & 1 deletion src/CrectoAdmin/init_admin.cr
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def self.init_admin
next if access[0].nil? || access[1].empty?
query = access[0].as(Crecto::Repo::Query)
model_attributes = access[1]
selection = model_attributes.map(&.to_s)
selection = resource[:model_attributes].map(&.to_s)
query = query.select(selection).where(model.primary_key_field_symbol, ctx.params.url["pid_id"])
data = repo.all(model, query).not_nil!
next if data.empty?
Expand Down
20 changes: 11 additions & 9 deletions src/CrectoAdmin/views/admin_layout.ecr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html class="has-navbar-fixed-top">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
Expand All @@ -19,7 +19,7 @@
<script defer src="https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script>
</head>
<body>
<nav class="navbar has-shadow">
<nav class="navbar has-shadow is-fixed-top">
<div class="container">
<div class="navbar-brand">
<a class="navbar-item is-size-4 has-text-weight-bold has-text-black" href="/admin">
Expand All @@ -28,6 +28,13 @@
</a>
</div>
<div class="navbar-menu is-active">
<div class="navbar-start">
<% if CrectoAdmin.admin_signed_in?(ctx) %>
<a class="navbar-item" href="/admin/resources">
Dashboard
</a>
<% end %>
</div>
<div class="navbar-end">
<% if CrectoAdmin.config.auth_enabled && CrectoAdmin.admin_signed_in?(ctx) %>
<a class="navbar-item">
Expand Down Expand Up @@ -59,23 +66,18 @@
<div class="column is-narrow">
<aside class="menu left-siebar-nav">
<ul class="menu-list has-text-weight-bold">
<% if CrectoAdmin.current_table(ctx) == "resources" %>
<li><a class="is-active" href="/admin/resources">Dashboard</a></li>
<% else %>
<li><a href="/admin/resources">Dashboard</a></li>
<% end %>
<% CrectoAdmin.resources.each do |resource| %>
<% access = accesses[resource[:index]] %>
<% next if access[0].nil? %>
<% next if access[1].empty? %>
<li>
<% if CrectoAdmin.current_table(ctx) == resource[:index].to_s %>
<a class="is-active" href="/admin/resources/<%= resource[:index] %>">
<%= resource[:model].table_name.split('_').map(&.capitalize).join(' ') %>
<%= resource[:model].table_name %>
</a>
<% else %>
<a href="/admin/resources/<%= resource[:index] %>">
<%= resource[:model].table_name.split('_').map(&.capitalize).join(' ') %>
<%= resource[:model].table_name %>
</a>
<% end %>
</li>
Expand Down
8 changes: 4 additions & 4 deletions src/CrectoAdmin/views/dashboard.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<thead>
<tr>
<th>Index</th>
<th>Model</th>
<th>Attributes</th>
<th>Records</th>
<th>Table</th>
<th>Columns</th>
<th>Rows</th>
</tr>
</thead>

Expand All @@ -20,7 +20,7 @@
<% next if access[1].empty? %>
<tr class="item-row" data-href="/admin/resources/<%= resource[:index] %>">
<th><%= resource[:index] %></th>
<th><%= resource[:model].table_name.split('_').map(&.capitalize).join(' ') %></th>
<th><%= resource[:model].table_name %></th>
<td><%= resource[:model_attributes].map(&.to_s).join(", ") %></td>
<td><%= counts[resource[:index]] %></td>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions src/CrectoAdmin/views/edit.ecr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div class="is-size-4 has-text-weight-bold">
<%= resource[:model].table_name.split('_').map(&.capitalize).join(' ') %>
<%= resource[:model].table_name %>
</div>

<div class="columns no-margin-bottom">
<div class="column">
<span class="is-size-6 has-text-weight-bold text-inline">
<%= item.responds_to?(:name) ? item.name : item.pkey_value %>
<%= item.pkey_value %>
</span>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/CrectoAdmin/views/index.ecr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="is-size-4 has-text-weight-bold">
<%= resource[:model].table_name.split('_').map(&.capitalize).join(' ') %>
<%= resource[:model].table_name %>
</div>

<div class="columns no-margin-bottom">
Expand Down
2 changes: 1 addition & 1 deletion src/CrectoAdmin/views/new.ecr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="is-size-4 has-text-weight-bold">
<%= resource[:model].table_name.split('_').map(&.capitalize).join(' ') %>
<%= resource[:model].table_name %>
</div>

<div class="columns no-margin-bottom">
Expand Down
8 changes: 4 additions & 4 deletions src/CrectoAdmin/views/show.ecr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div class="is-size-4 has-text-weight-bold">
<%= resource[:model].table_name.split('_').map(&.capitalize).join(' ') %>
<%= resource[:model].table_name %>
</div>

<div class="columns no-margin-bottom">
<div class="column">
<span class="is-size-6 has-text-weight-bold text-inline">
<%= item.responds_to?(:name) ? item.name : item.pkey_value %>
<%= item.pkey_value %>
</span>
</div>
</div>
Expand Down Expand Up @@ -35,15 +35,15 @@
<div class="field">
<label class="label"><%= resource[:model].primary_key_field_symbol %></label>
<div class="control">
<pre><%= item.pkey_value %></pre>
<pre class="field-value"><%= item.pkey_value %></pre>
</div>
</div>
<% model_attributes.each do |attr| %>
<% next if attr == resource[:model].primary_key_field_symbol %>
<div class="field">
<label class="label"><%= attr %></label>
<div class="control">
<pre><%= query_hash[attr] %></pre>
<pre class="field-value"><%= query_hash[attr] %></pre>
</div>
</div>
<% end %>
Expand Down

0 comments on commit 40f0560

Please sign in to comment.