Commit ee842494 authored by Ted Trask's avatar Ted Trask

Changed checkselected to be a form

parent 7fe8cea6
......@@ -95,7 +95,7 @@ function downloadselected(self)
end
function checkselected(self)
return self.model.editselected(self.clientdata.chkdata)
return controllerfunctions.handle_form(self, self.model.geteditselected, self.model.editselected, self.clientdata, "Submit", "Submit select update", "Select fields updated")
end
function clearselected(self)
......
......@@ -1193,21 +1193,30 @@ local handleparameters = function(activelog, clientuserid, starttime, endtime, c
return result
end
function editselected(chkdata)
keycnt = 0
sql = "UPDATE pubweblog SET selected = "
databaseconnect(DatabaseOwner)
idarray = format.string_to_table(chkdata, "|")
for key,x in pairs(idarray) do
keycnt = keycnt + 1
if keycnt == 1 then
sql = sql..x.." WHERE id = "
else
sql = sql..x
function geteditselected()
local result = {}
result.select = cfe({ type="list", value={}, label="Entries to mark as selected" })
result.deselect = cfe({ type="list", value={}, label="Entries to mark as selected" })
return cfe({ type="group", value=result, label="Select / Deselect log entries" })
end
function editselected(data)
local res, err = pcall(function()
databaseconnect(DatabaseOwner)
con:execute("START TRANSACTION")
for i,sel in ipairs(data.value.select.value) do
con:execute("UPDATE pubweblog SET selected = true WHERE id = '"..escape(sel).."'")
end
for i,sel in ipairs(data.value.deselect.value) do
con:execute("UPDATE pubweblog SET selected = false WHERE id = '"..escape(sel).."'")
end
con:execute("COMMIT")
databasedisconnect()
end)
if not res then
data.errtxt = err
end
assert (con:execute(sql))
databasedisconnect()
return data
end
function clearselected()
......
......@@ -272,7 +272,8 @@ end
});
});
}
var chkdata = "";
var selectdata = "";
var deselectdata = "";
if (this.checked == true) {
$(this).closest('tr').css("background-color","#FC9A01");
var csv_list = "";
......@@ -280,8 +281,8 @@ end
$(this).closest('tr').each(function () {
$(this).find('td').each(function () {
if (csv_cnt == 1) {
chkdata = "true|" + $(this).text();
//alert("this is: " + chkdata);
selectdata = $(this).text();
//alert("this is: " + selectdata);
return false;
}
csv_cnt +=1;
......@@ -294,7 +295,7 @@ end
$(this).closest('tr').each(function () {
$(this).find('td').each(function () {
if (csv_cnt == 1) {
chkdata = "false|" + $(this).text();
deselectdata = $(this).text();
return false;
}
csv_cnt +=1;
......@@ -302,7 +303,7 @@ end
});
}
$.getJSON(
'<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/checkselected") %>?viewtype=ajax&chkdata='+chkdata,
'<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/checkselected") %>?viewtype=ajax&Submit=true&select='+selectdata+'&deselect='+deselectdata,
function(data) {}
);
});
......
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