summaryrefslogtreecommitdiffstats
path: root/db-viewtable-html.lsp
diff options
context:
space:
mode:
Diffstat (limited to 'db-viewtable-html.lsp')
-rw-r--r--db-viewtable-html.lsp55
1 files changed, 55 insertions, 0 deletions
diff --git a/db-viewtable-html.lsp b/db-viewtable-html.lsp
new file mode 100644
index 0000000..e1531d0
--- /dev/null
+++ b/db-viewtable-html.lsp
@@ -0,0 +1,55 @@
+<% local form, viewlibrary, page_info, session = ... %>
+<% require("htmlviewfunctions") %>
+<% html = require("acf.html") %>
+
+<% htmlviewfunctions.displaycommandresults({"deletetableentry", "updatetableentry"}, session) %>
+<% htmlviewfunctions.displaycommandresults({"createtableentry"}, session, true) %>
+
+<H1><%= html.html_escape(form.label) %> - <%= html.html_escape(form.value.table.value) %></H1>
+<DL>
+<TABLE>
+ <TR style="background:#eee;font-weight:bold;">
+ <% if viewlibrary.check_permission("deletetableentry") or viewlibrary.check_permission("updatetableentry") then %>
+ <TD style="padding-right:20px;white-space:nowrap;" class="header">Action</TD>
+ <% end %>
+ <% for i,f in ipairs(form.value.fields.value) do %>
+ <TD style="padding-right:20px;white-space:nowrap;" class="header"><%= html.html_escape(f) %></TD>
+ <% end %>
+ </TR>
+
+<% for i,tableentry in ipairs(form.value.entries.value) do %>
+ <TR>
+ <% if viewlibrary.check_permission("deletetableentry") or viewlibrary.check_permission("updatetableentry") then %>
+ <TD style="padding-right:20px;white-space:nowrap;">
+ <% if viewlibrary.check_permission("updatetableentry") then %>
+ <form action="updatetableentry" method="POST">
+ <input class="hidden" type="hidden" name="table" value="<%= html.html_escape(form.value.table.value) %>">
+ <input class="hidden" type="hidden" name="id" value="<%= html.html_escape(tableentry.id) %>">
+ <input class="hidden" type="hidden" name="redir" value="<%= html.html_escape(page_info.orig_action.."?table="..form.value.table.value) %>">
+ <input class="submit" type="submit" value="Update"></form>
+ <% end %>
+ <% if viewlibrary.check_permission("deletetableentry") then %>
+ <form action="deletetableentry" method="POST">
+ <input class="hidden" type="hidden" name="table" value="<%= html.html_escape(form.value.table.value) %>">
+ <input class="hidden" type="hidden" name="id" value="<%= html.html_escape(tableentry.id) %>">
+ <input class="submit" type="submit" name="submit" value="Delete"></form>
+ <% end %>
+ </TD>
+ <% end %>
+ <% for i,f in ipairs(form.value.fields.value) do %>
+ <TD><%= html.html_escape(tableentry[f]) %></TD>
+ <% end %>
+ </TR>
+<% end %>
+</TABLE>
+<% if form.errtxt then %>
+<p class="error"><%= html.html_escape(form.errtxt) %></p>
+<% end %>
+<% if #form.value.entries.value == 0 then %>
+<p>No entries found</p>
+<% end %>
+</DL>
+
+<% if page_info.action == "viewtable" and viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("createtableentry") then
+ viewlibrary.dispatch_component("createtableentry", {table=form.value.table.value})
+end %>