From e3f8780934093cbf4618bfa39f69f25920dfb28e Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Wed, 22 Oct 2008 18:50:22 +0000 Subject: Modified viewfunctions to split displayform, creating displayformstart and displayformend, to provide flexibility while still using the library. Also added support for hidden fields - including a common redir field. Removed redirectOnSuccess from controllerfunctions handle_form, and replaced it with the redir field. Removed redirectOnSuccess from controllers that used it and added handlecommandresults and redir entries to links and forms throughout many views. This will cause a redirect to the originating view when a form is successfully completed. acf_www-controller now includes orig_action in page_info to report the original action launched by the user. git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@1560 ab2d0c66-481e-0410-8bed-d214d4d58bed --- tinydns-controller.lua | 2 +- tinydns-edit-html.lsp | 8 ++++---- tinydns-listfiles-html.lsp | 8 ++++---- tinydns-listpermissions-html.lsp | 9 ++++++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/tinydns-controller.lua b/tinydns-controller.lua index bcaffa4..7155612 100644 --- a/tinydns-controller.lua +++ b/tinydns-controller.lua @@ -23,7 +23,7 @@ end function newfile(self) return controllerfunctions.handle_form(self, self.model.getnewconfigfile, function(value) return self.model.createconfigfile(self, value, sessiondata.userinfo.userid) - end, self.clientdata, "Create", "Create New Config File", "Config File Created", "listfiles") + end, self.clientdata, "Create", "Create New Config File", "Config File Created") end function listfiles(self) diff --git a/tinydns-edit-html.lsp b/tinydns-edit-html.lsp index a4754e1..f8d8dbb 100644 --- a/tinydns-edit-html.lsp +++ b/tinydns-edit-html.lsp @@ -123,7 +123,7 @@ } file = file + elem.text() + "\n"; }); - $("input:eq(1)").val(file); + $("input[name='filecontent']").val(file); } $(function(){ @@ -168,9 +168,9 @@ displayitem(form.value.mtime) <% if form.value.filecontent.errtxt then %>

<%= string.gsub(form.value.filecontent.errtxt, "\n", "
") %>

<% end %> -
" method="POST"> +<% form.action = page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action %> +<% displayformstart(form) %>

Save and Apply Above Settings

-
-
+<% displayformend(form) %> diff --git a/tinydns-listfiles-html.lsp b/tinydns-listfiles-html.lsp index 0046d91..e700b3c 100644 --- a/tinydns-listfiles-html.lsp +++ b/tinydns-listfiles-html.lsp @@ -9,7 +9,7 @@ io.write("") --]] %> -<% displaycommandresults({"delete"}, session) %> +<% displaycommandresults({"delete", "edit", "editfile"}, session) %>

Configuration

Edit/View existing Domains

@@ -26,8 +26,8 @@ io.write("") <% if session.permissions.tinydns.delete then io.write(html.link{value = "delete?filename=" .. file.value.filename.value, label="Delete " }) end io.write(html.link{value = "view?filename=" .. file.value.filename.value, label="View " }) - if session.permissions.tinydns.edit then io.write(html.link{value = "edit?filename=" .. file.value.filename.value, label="Edit " }) end - if session.permissions.tinydns.editfile then io.write(html.link{value = "editfile?filename=" .. file.value.filename.value, label="Expert " }) end + if session.permissions.tinydns.edit then io.write(html.link{value = "edit?filename=" .. file.value.filename.value.."&redir="..page_info.orig_action, label="Edit " }) end + if session.permissions.tinydns.editfile then io.write(html.link{value = "editfile?filename=" .. file.value.filename.value.."&redir="..page_info.orig_action, label="Expert " }) end %> <%= file.value.filesize.value %> @@ -41,6 +41,6 @@ io.write("") local newfileform = viewlibrary.dispatch_component("newfile", nil, true) %>

Create new Domain

<% - newfileform.action = "newfile" + newfileform.action = page_info.script .. page_info.prefix .. page_info.controller .. "/newfile" displayform(newfileform) end %> diff --git a/tinydns-listpermissions-html.lsp b/tinydns-listpermissions-html.lsp index 355e49e..fc80db9 100644 --- a/tinydns-listpermissions-html.lsp +++ b/tinydns-listpermissions-html.lsp @@ -1,15 +1,18 @@ -<% local view, viewlibrary, page_info = ... %> +<% local view, viewlibrary, page_info, session = ... %> +<% require("viewfunctions") %> <% --[[ io.write(html.cfe_unpack(view)) --]] %> +<% displaycommandresults({"edituserpermisisons", "editrolepermissions"}, session) %> +

<%= view.label %>

User Permissions

<% for i,user in ipairs(view.value.user) do %> -
UserPermissions
<%= html.link{value=page_info.script .. page_info.prefix .. page_info.controller .. "/edituserpermissions?userid=" .. user.id, label=user.id} %> +
<%= html.link{value=page_info.script .. page_info.prefix .. page_info.controller .. "/edituserpermissions?userid=" .. user.id .. "&redir="..page_info.orig_action, label=user.id} %> <% for y,allowed in pairs(user.allowed) do print(allowed, "
") end %> @@ -21,7 +24,7 @@ <% for i,role in ipairs(view.value.role) do %> -
RolePermissions
<%= html.link{value=page_info.script .. page_info.prefix .. page_info.controller .. "/editrolepermissions?role=" .. role.id, label=role.id} %> +
<%= html.link{value=page_info.script .. page_info.prefix .. page_info.controller .. "/editrolepermissions?role=" .. role.id .. "&redir="..page_info.orig_action, label=role.id} %> <% for y,allowed in pairs(role.allowed) do print(allowed, "
") end %> -- cgit v1.2.3