Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
acf-db
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ACF
acf-db
Commits
b38802fa
Commit
b38802fa
authored
Oct 27, 2014
by
Ted Trask
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reworked the code to allow passing in connection parameters
parent
375ed538
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
277 additions
and
120 deletions
+277
-120
db-listdatabases-html.lsp
db-listdatabases-html.lsp
+25
-7
db-listtables-html.lsp
db-listtables-html.lsp
+19
-7
db-viewtable-html.lsp
db-viewtable-html.lsp
+43
-8
dbmodelfunctions.lua
dbmodelfunctions.lua
+190
-98
No files found.
db-listdatabases-html.lsp
View file @
b38802fa
...
...
@@ -2,7 +2,7 @@
<% htmlviewfunctions = require("htmlviewfunctions") %>
<% html = require("acf.html") %>
<% if
#form
.value>0 then %>
<% if
form.value.databases and #form.value.databases
.value>0 then %>
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"><\/script>');
...
...
@@ -23,21 +23,39 @@
<% end %>
<% local header_level = htmlviewfunctions.displaysectionstart(form, page_info) %>
<% htmlviewfunctions.displayinfo(form) %>
<% if #form.value>0 then %>
<% if form.value.connection then
-- hide the database, user, and password, since we don't need them to list databases
form.value.connection.value.database = nil
form.value.connection.value.user = nil
form.value.connection.value.password = nil
end %>
<% if form.value.connection and next(form.value.connection.value) ~= nil then
htmlviewfunctions.displayformstart(form, page_info)
htmlviewfunctions.displayitem(form.value.connection, page_info, htmlviewfunctions.incrementheader(header_level), "connection")
form.option = "Update"
htmlviewfunctions.displayformend(form, htmlviewfunctions.incrementheader(header_level))
end %>
<% if form.value.databases and #form.value.databases.value>0 then %>
<table id="listdatabases" class="tablesorter"><thead>
<tr>
<th>Action</th>
<th>Database</th>
</tr>
</thead><tbody>
<% local database = cfe({ type="hidden" }) %>
<% for i,dbase in ipairs(form.value) do %>
<% database.value = dbase %>
<% -- We need to pass the connection key values to listtables
local formvalues = {}
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
form.value.connection.value.database = cfe({ type="hidden" })
%>
<% for i,dbase in ipairs(form.value.databases.value) do %>
<% formvalues.connection.value.database.value = dbase %>
<tr>
<td>
<% if viewlibrary.check_permission("listtables") then %>
<% htmlviewfunctions.displayitem(cfe({type="link", value=
{database=database}
, label="", option="View", action="listtables"}), page_info, -1) %>
<% htmlviewfunctions.displayitem(cfe({type="link", value=
formvalues
, label="", option="View", action="listtables"}), page_info, -1) %>
<% end %>
</td>
<td><%= html.html_escape(dbase) %></td>
...
...
db-listtables-html.lsp
View file @
b38802fa
...
...
@@ -2,7 +2,7 @@
<% htmlviewfunctions = require("htmlviewfunctions") %>
<% html = require("acf.html") %>
<% if
#form
.value>0 then %>
<% if
form.value.tables and #form.value.tables
.value>0 then %>
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"><\/script>');
...
...
@@ -25,21 +25,33 @@
<% htmlviewfunctions.displaycommandresults({"createdatabase"}, session) %>
<% local header_level = htmlviewfunctions.displaysectionstart(form, page_info) %>
<% htmlviewfunctions.displayinfo(form) %>
<% if #form.value>0 then %>
<% if form.value.connection and next(form.value.connection.value) ~= nil then
htmlviewfunctions.displayformstart(form, page_info)
htmlviewfunctions.displayitem(form.value.connection, page_info, htmlviewfunctions.incrementheader(header_level), "connection")
form.option = "Update"
htmlviewfunctions.displayformend(form, htmlviewfunctions.incrementheader(header_level))
end %>
<% if form.value.tables and #form.value.tables.value>0 then %>
<table id="listtables" class="tablesorter"><thead>
<tr>
<th>Action</th>
<th>Table</th>
</tr>
</thead><tbody>
<% local table = cfe({ type="hidden" }) %>
<% for i,tab in ipairs(form.value) do %>
<% table.value = tab %>
<% -- We will reuse the form connection structure to pass key values to viewtable
local formvalues = {}
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
formvalues.table = cfe({ type="hidden" })
%>
<% for i,tab in ipairs(form.value.tables.value) do %>
<% formvalues.table.value = tab %>
<tr>
<td>
<% if viewlibrary.check_permission("viewtable") then %>
<% htmlviewfunctions.displayitem(cfe({type="link", value=
{table=table}
, label="", option="View", action="viewtable"}), page_info, -1) %>
<% htmlviewfunctions.displayitem(cfe({type="link", value=
formvalues
, label="", option="View", action="viewtable"}), page_info, -1) %>
<% end %>
</td>
<td><%= html.html_escape(tab) %></td>
...
...
db-viewtable-html.lsp
View file @
b38802fa
...
...
@@ -21,13 +21,34 @@
});
</script>
<% local redir = cfe({ type="hidden", value=page_info.orig_action.."?table="..html.url_encode(form.value.table.value) }) %>
<%
local redir = cfe({ type="hidden", value=page_info.orig_action.."?table="..html.url_encode(form.value.table.value) })
local keyvalues = {table=form.value.table.value}
if form.value.connection then
keyvalues.connection = {}
for n,v in pairs(form.value.connection.value) do
redir.value = redir.value.."&connection."..n.."="..html.url_encode(v.value)
keyvalues.connection[n] = v.value
end
end
keyvalues.redir = redir.value
%>
<% htmlviewfunctions.displaycommandresults({"deletetableentry", "updatetableentry"}, session) %>
<% htmlviewfunctions.displaycommandresults({"createtableentry"}, session, true) %>
<%
form.label = form.label.." - "..form.value.table.value
%>
<%
if form.value.table.value ~= "" then form.label = form.label.." - "..form.value.table.value end
%>
<% local header_level = htmlviewfunctions.displaysectionstart(form, page_info) %>
<%
local header_level2 = htmlviewfunctions.incrementheader(header_level)
htmlviewfunctions.displayformstart(form, page_info)
if form.value.connection and next(form.value.connection.value) ~= nil then
htmlviewfunctions.displayitem(form.value.connection, page_info, header_level2, "connection")
end
htmlviewfunctions.displayitem(form.value.table, page_info, header_level2, "table")
form.option = "Update"
htmlviewfunctions.displayformend(form, htmlviewfunctions.incrementheader(header_level))
%>
<table id="list" class="tablesorter"><thead>
<tr>
<% if viewlibrary.check_permission("deletetableentry") or viewlibrary.check_permission("updatetableentry") then %>
...
...
@@ -38,18 +59,32 @@
<% end %>
</tr>
</thead><tbody>
<% local table = cfe({ type="hidden", value=form.value.table.value }) %>
<% local id = cfe({ type="hidden" }) %>
<% -- We will reuse the form connection structure to pass key values to updatetableentry and deletetableentry
local formvalues = {}
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
if form.value.fields then
formvalues.fields = cfe({ type="group", value={} })
for i,f in ipairs(form.value.fields.value) do
formvalues.fields.value[f] = cfe({ type="hidden" })
end
end
formvalues.table = form.value.table
form.value.table.type = "hidden"
formvalues.redir = redir
%>
<% for i,tableentry in ipairs(form.value.entries.value) do %>
<tr>
<% if viewlibrary.check_permission("deletetableentry") or viewlibrary.check_permission("updatetableentry") then %>
<% id.value = tableentry.id %>
<%
formvalues.fields.value.
id.value = tableentry.id %>
<td>
<% if viewlibrary.check_permission("updatetableentry") then %>
<% htmlviewfunctions.displayitem(cfe({type="link", value=
{table=table, id=id, redir=redir}
, label="", option="Update", action="updatetableentry"}), page_info, -1) %>
<% htmlviewfunctions.displayitem(cfe({type="link", value=
formvalues
, label="", option="Update", action="updatetableentry"}), page_info, -1) %>
<% end %>
<% if viewlibrary.check_permission("deletetableentry") then %>
<% htmlviewfunctions.displayitem(cfe({type="form", value=
{table=table, id=id, redir=redir}
, label="", option="Delete", action="deletetableentry", class="deletetableentry"}), page_info, -1) %>
<% htmlviewfunctions.displayitem(cfe({type="form", value=
formvalues
, label="", option="Delete", action="deletetableentry", class="deletetableentry"}), page_info, -1) %>
<% end %>
</td>
<% end %>
...
...
@@ -66,5 +101,5 @@
<% htmlviewfunctions.displaysectionend(header_level) %>
<% 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, redir=redir.value}
)
viewlibrary.dispatch_component("createtableentry",
keyvalues
)
end %>
dbmodelfunctions.lua
View file @
b38802fa
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment