Commit 57f6d90a authored by Ted Trask's avatar Ted Trask

Remove all calls to 'module' in preparation for move to Lua 5.2

Use mymodule parameter for module definition.
parent 064ab9ab
module(..., package.seeall)
local mymodule = {}
function listdatabases(self)
function mymodule.listdatabases(self)
return self.model.list_databases(self, self.clientdata)
end
function listtables(self)
function mymodule.listtables(self)
return self.model.list_tables(self, self.clientdata)
end
function viewtable(self)
function mymodule.viewtable(self)
return self.model.list_table_entries(self, self.clientdata)
end
function deletetableentry(self)
function mymodule.deletetableentry(self)
return self.handle_form(self, self.model.get_delete_table_entry, self.model.delete_table_entry, self.clientdata, "Delete", "Delete Table Entry", "Table Entry deleted")
end
function updatetableentry(self)
function mymodule.updatetableentry(self)
return self.handle_form(self, self.model.get_table_entry, self.model.update_table_entry, self.clientdata, "Update", "Update Table Entry", "Entry updated")
end
function createtableentry(self)
function mymodule.createtableentry(self)
return self.handle_form(self, self.model.get_new_table_entry, self.model.create_table_entry, self.clientdata, "Create", "Create New Table Entry", "Entry created")
end
return mymodule
module(..., package.seeall)
local mymodule = {}
-- Helper library for model functions for viewing and editing database entries
-- Relies heavily on the acf-lib/db.lua library (db object passed into each function)
function list_databases(db, self, clientdata)
function mymodule.list_databases(db, self, clientdata)
local retval = {}
local errtxt
local res, err = pcall(function()
......@@ -15,7 +15,7 @@ function list_databases(db, self, clientdata)
return cfe({ type="list", value=retval, label="List of Databases", errtxt=errtxt })
end
function list_tables(db, self, clientdata)
function mymodule.list_tables(db, self, clientdata)
local retval = {}
local errtxt
local res, err = pcall(function()
......@@ -30,7 +30,7 @@ function list_tables(db, self, clientdata)
return cfe({ type="list", value=retval, label="List of Database Tables", errtxt=errtxt })
end
function list_table_entries(db, self, clientdata)
function mymodule.list_table_entries(db, self, clientdata)
local table = clientdata.table
local retval = {}
retval.table = cfe({ value=table or "", label="Table" })
......@@ -59,7 +59,7 @@ function list_table_entries(db, self, clientdata)
return cfe({ type="group", value=retval, label="Database Table Entries", errtxt=errtxt })
end
function get_new_table_entry(db, self, clientdata)
function mymodule.get_new_table_entry(db, self, clientdata)
local retval = {}
retval.table = cfe({ value=clientdata.table or "", label="Table", errtxt="Table does not exist", readonly=true, seq=0 })
local errtxt = "Table does not exist"
......@@ -93,8 +93,8 @@ function get_new_table_entry(db, self, clientdata)
return cfe({ type="group", value=retval, label="Database Table Entry", errtxt=errtxt })
end
function get_table_entry(db, self, clientdata)
local retval = get_new_table_entry(db, self, clientdata)
function mymodule.get_table_entry(db, self, clientdata)
local retval = mymodule.get_new_table_entry(db, self, clientdata)
if not retval.value.table.errtxt and retval.value.id then
retval.value.id.type = "text"
local res, err = pcall(function()
......@@ -127,11 +127,11 @@ function get_table_entry(db, self, clientdata)
return retval
end
function create_table_entry(db, self, entry, action)
return update_table_entry(db, self, entry, action, true)
function mymodule.create_table_entry(db, self, entry, action)
return mymodule.update_table_entry(db, self, entry, action, true)
end
function update_table_entry(db, self, entry, action, create)
function mymodule.update_table_entry(db, self, entry, action, create)
local success = true
local errtxt
-- Validate the settings
......@@ -203,14 +203,14 @@ function update_table_entry(db, self, entry, action, create)
return entry
end
function get_delete_table_entry(db, self, clientdata)
function mymodule.get_delete_table_entry(db, self, clientdata)
local retval = {}
retval.table = cfe({ value=clientdata.table or "", label="Table", seq=0 })
retval.id = cfe({ value=clientdata.id or "", label="ID", seq=1 })
return cfe({ type="group", value=retval, label="Delete Database Table Entry" })
end
function delete_table_entry(db, self, entry)
function mymodule.delete_table_entry(db, self, entry)
entry.errtxt = "Failed to delete table entry"
if entry.value.table.value == "" then
entry.value.table.errtxt = "Invalid table"
......@@ -241,3 +241,5 @@ function delete_table_entry(db, self, entry)
return entry
end
return mymodule
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