Commit b0148d55 authored by Ted Trask's avatar Ted Trask

Hide the update option in viewtable HTML view if all fields are key fields

parent dd629c93
......@@ -65,19 +65,30 @@ if form.value.connection then
formvalues.connection = form.value.connection
for n,v in pairs(form.value.connection.value) do v.type="hidden" end
end
local reversekeyfields = {}
if form.value.keyfields then
formvalues.fields = cfe({ type="group", value={} })
for i,f in ipairs(form.value.keyfields.value) do
formvalues.fields.value[f] = cfe({ type="hidden" })
reversekeyfields[f] = i
end
end
formvalues.table = form.value.table
form.value.table.type = "hidden"
formvalues.redir = redir
-- We will hide the update link if all fields are key fields
local allowupdate = false
for i,f in ipairs(form.value.fields.value) do
if not reversekeyfields[f] then
allowupdate = true
break
end
end
allowupdate = allowupdate and viewlibrary.check_permission("updatetableentry")
%>
<% for i,tableentry in ipairs(form.value.entries.value) do %>
<tr>
<% if viewlibrary.check_permission("deletetableentry") or viewlibrary.check_permission("updatetableentry") then %>
<% if viewlibrary.check_permission("deletetableentry") or allowupdate then %>
<%
if formvalues.fields then
for i,f in ipairs(form.value.keyfields.value) do
......@@ -86,7 +97,7 @@ formvalues.redir = redir
end
%>
<td>
<% if viewlibrary.check_permission("updatetableentry") then %>
<% if allowupdate then %>
<% htmlviewfunctions.displayitem(cfe({type="link", value=formvalues, label="", option="Update", action="updatetableentry"}), page_info, -1) %>
<% end %>
<% if viewlibrary.check_permission("deletetableentry") then %>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment