summaryrefslogtreecommitdiffstats
path: root/gnats-editpr-html.lsp
blob: 21ae9ab112efb7c37fc138551c9f3bb55b0654fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<% local form = ... %>
<%
--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
io.write(html.cfe_unpack(form))
io.write("</span>")
--]]
%>

<%
function displayinfo(myform,tags,viewtype)
	for k,v in pairs(tags) do 
		if (myform[v]) and (myform[v]["value"]) then
			local val = myform[v] 
			io.write("\n\t<DT")
			if (val.errtxt) then 
				val.class = "error"
				io.write(" class='error'")
			end
			io.write(">" .. html.html_escape(val.label) .. "</DT>")
			io.write("\n\t\t<DD>")
			if (viewtype == "viewonly") then
				if not (val.value) or (val.value == "") then val.value = " " end
				io.write(html.html_escape(val.value))
			elseif (val.type == "radio") and (type(val.option) == "table") and (#val.option > 0) then
				io.write("<span style='display:inline' class='" .. html.html_escape(val.class) .. "'>")
				for k1,v1 in pairs(val.option) do
					io.write("\n\t\t\t"..html.html_escape(tostring(v1)) .. ":")
					io.write("<input style='margin-right:20px;margin-left:5px;' type='radio' class='" .. html.html_escape(val.class) .. "' name='" .. html.html_escape(val.name) .. "'")
					if (tostring(val.value) == tostring(v1)) then io.write(" checked='yes'") end
					io.write(" value='" .. html.html_escape(v1) .. "'>")
				end
				io.write("\n\t\t\t</input></span>")
			else
				io.write(html.form[val.type](val))
			end
			if (val.descr) and (#val.descr > 0) then io.write("\n\t\t<P CLASS='descr'>" .. string.gsub(html.html_escape(val.descr), "\n", "<BR>") .. "</P>") end
			if (val.errtxt) then io.write("\n\t\t<P CLASS='error'>" .. string.gsub(html.html_escape(val.errtxt), "\n", "<BR>") .. "</P>") end
			io.write("\n\t\t</DD>\n")
		end
	end
end
%>

<H1><% io.write(html.html_escape(form["query"]["sfields"]["category"]["value"] .. "/"))
io.write(html.html_escape(form["query"]["sfields"]["number"]["value"] .. ": " )) 
io.write(html.html_escape(form["query"]["sfields"]["synopsis"]["value"] or form["query"]["header"]["subject"]["value"] or "Qurery object")) %></H1>

<H2>Header</H2>
<DL>
<% 
local h = form.query.header
%>
<dt>From</dt><dd><%= html.html_escape(h.from.value) %></dd>
<dt>Date</dt><dd><%= html.html_escape(h.date.value) %></dd>
<dt>Subject</dt><dd><%= html.html_escape(h.subject.value) %></dd>
</DL>

<H2>Details</H2>
<DL>
<% 
local myform = form.query.sfields 
local tags = { "submitter_id", "class", "release", "state", "priority", "severity", "responsible", "arrival_date", "closed_date", "last_modified", "originator", }
displayinfo(myform,tags)
%>
</DL>

<%
local myform = form.query.mfields
local tags = {"organization", "environment", "description", "how_to_repeat", "fix", "release_note", }
for k,v in pairs(tags) do
	local myform=myform[v]
%>
<H2><% io.write(html.html_escape(myform.label)) %></H2>
<DL>
<% io.write(html.form[myform.type](myform)) %>
</DL>
<% end %>


<style>
table {margin:10px;margin-top:5px;border:1px solid #aaa;background:#eee;}
.Responsible-Changed-From-To {background: #fcc;}
.Responsible-Changed-From-To {background: #fcc;}
.State-Changed-From-To {background: #cfc;}
.From {background: #ccf;}
.Header {padding:3px;font-weight:bold;border-bottom:1px solid #665;}
</style>

<%
local myform = form.query["mfields"]["audit_trail"]
%>
<H2><% io.write(html.html_escape(myform.label)) %></H2>
<DL>
<%
for k,v in pairs(myform.option) do
	io.write("\n<TABLE STYLE='width:98%;'>")
	if (#v.label > 0) then 
		io.write("<TR CLASS='" .. html.html_escape(v.class) .. "'><TD COLSPAN=2 CLASS='Header'>" .. html.html_escape(v.label or "Uknown") .. "</TD></TR>")
	end
	for i=1,#v do
		io.write("<TR><TD WIDTH='100%'><PRE>" .. html.html_escape(v[i] or "Uknown") .. "</PRE></TD></TR>")
	end
	io.write("\n</TABLE>")
end
%>
</DL>

<%
local myform = form.query.mfields
local tags = {"unformatted", }
for k,v in pairs(tags) do
	local myform=myform[v]
%>
<H2><% io.write(html.html_escape(myform.label)) %></H2>
<DL>
<PRE><% io.write(html.html_escape(myform.value)) %></PRE>
</DL>
<% end %>

<H2>Save changes</H2>
<DL>
<% 
local myform = form.query 
local tags = { "cmdsave", }
displayinfo(myform,tags)
%>
</DL>