diff options
author | Ted Trask <ttrask01@yahoo.com> | 2014-10-30 01:13:12 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2014-10-30 01:13:12 +0000 |
commit | b0148d55cc8571542ef62b67ad019f0f75401635 (patch) | |
tree | b4add36b50e2c3f6e6145eb2989a00d7ae1b29e1 | |
parent | dd629c93fd55a2766655e857b75c58a7eaae6040 (diff) | |
download | acf-db-b0148d55cc8571542ef62b67ad019f0f75401635.tar.bz2 acf-db-b0148d55cc8571542ef62b67ad019f0f75401635.tar.xz |
Hide the update option in viewtable HTML view if all fields are key fields
-rw-r--r-- | lib/db-viewtable-html.lsp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/db-viewtable-html.lsp b/lib/db-viewtable-html.lsp index 3bde35e..bd4f051 100644 --- a/lib/db-viewtable-html.lsp +++ b/lib/db-viewtable-html.lsp @@ -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 %> |