source: trunk/www/admin/clients/help/edit_help.jsp @ 2753

Last change on this file since 2753 was 2753, checked in by Nicklas Nordborg, 17 years ago

Fixes #404: Replace deprecated Values class with the new one in all JSP pages

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 5.8 KB
Line 
1<%-- $Id: edit_help.jsp 2753 2006-10-20 11:04:36Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) Authors contributing to this file.
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 2
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24
25  @author Nicklas
26  @version 2.0
27--%>
28<%@ page
29  import="net.sf.basedb.core.SessionControl"
30  import="net.sf.basedb.core.DbControl"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.SystemItems"
34  import="net.sf.basedb.core.Permission"
35  import="net.sf.basedb.core.Include"
36  import="net.sf.basedb.core.Client"
37  import="net.sf.basedb.core.Help"
38  import="net.sf.basedb.core.ItemQuery"
39  import="net.sf.basedb.core.ItemResultList"
40  import="net.sf.basedb.core.PermissionDeniedException"
41  import="net.sf.basedb.core.BaseException"
42  import="net.sf.basedb.core.query.Orders"
43  import="net.sf.basedb.core.query.Hql"
44  import="net.sf.basedb.clients.web.Base"
45  import="net.sf.basedb.clients.web.util.HTML"
46  import="net.sf.basedb.util.Values"
47  import="java.util.List"
48  import="java.util.Set"
49  import="java.util.HashSet"
50  import="java.util.Date"
51%>
52<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
53<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
54<%
55final Item itemType = Item.HELP;
56final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
57final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
58final int itemId = cc.getId();
59final int clientId = Values.getInt(request.getParameter("client_id"));
60final String ID = sc.getId();
61final float scale = Base.getScale(sc);
62final DbControl dc = sc.newDbControl();
63try
64{
65  String title = null;
66  Client client = null;
67  Help help = null;
68  String externalId = null;
69 
70  if (itemId == 0)
71  {
72    title = "Create help";
73    cc.removeObject("item");
74    client = Client.getById(dc, clientId);
75    externalId = Values.getString(request.getParameter("external_id"), 
76      cc.getPropertyValue("externalId"));
77  }
78  else
79  {
80    help = Help.getById(dc, itemId);
81    cc.setObject("item", help);
82    title = "Edit help text -- " + HTML.encodeTags(help.getName());
83    externalId = help.getExternalId();
84  }
85  if (help != null) help.checkPermission(Permission.WRITE);
86  final String clazz = "class=\"text\"";
87  final String requiredClazz = "class=\"text required\"";
88  %>
89
90  <base:page type="popup" title="<%=title%>">
91  <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
92    <script language="JavaScript">
93    // Validate the "Help" tab
94    function validateHelp()
95    {
96      var frm = document.forms['help'];
97      if (Main.trimString(frm.name.value) == '')
98      {
99        alert("You must enter a name");
100        frm.name.focus();
101        return false;
102      }
103      else if (Main.trimString(frm.external_id.value) == '')
104      {
105        alert("You must enter an external ID");
106        frm.external_id.focus();
107        return false;
108      }
109      return true;
110    }
111
112    // Submit the form
113    function saveSettings()
114    {
115      var frm = document.forms['help'];
116      if (TabControl.validateActiveTab('settings'))
117      {
118        frm.submit();
119      }
120    }
121 
122    function init()
123    {
124      var frm = document.forms['help'];
125      <%
126      if (help == null)
127      {
128        %>
129        frm.name.focus();
130        frm.name.select();
131        <%
132      }
133      %>
134    }
135    </script>
136  </base:head>
137  <base:body onload="init()">
138    <p>
139    <form action="index.jsp?ID=<%=ID%>" method="post" name="help" onsubmit="return false;">
140    <input type="hidden" name="cmd" value="UpdateItem">
141    <input type="hidden" name="client_id" value="<%=clientId%>">
142
143    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
144    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*260)+"px;"%>" 
145      position="bottom" remember="<%=help != null%>">
146    <t:tab id="info" title="Help text" validate="validateHelp()" helpid="help.edit">
147      <table class="form" cellspacing=0>
148      <tr>
149        <td class="prompt">Title</td>
150        <td><input <%=requiredClazz%> type="text" name="name" 
151          value="<%=HTML.encodeTags(help == null ? Values.getString(cc.getPropertyValue("name"), "New help") : help.getName())%>" 
152          size="40" maxlength="<%=Help.MAX_NAME_LENGTH%>"></td>
153      </tr>
154      <tr>
155        <td class="prompt">External ID</td>
156        <td><input <%=requiredClazz%> type="text" name="external_id" 
157          value="<%=HTML.encodeTags(externalId)%>"
158          size="40" maxlength="<%=Help.MAX_EXTERNAL_ID_LENGTH%>"></td>
159      </tr>
160      <tr valign=top>
161        <td class="prompt">Help text</td>
162        <td nowrap>
163          <textarea <%=clazz%> rows="12" cols="60" name="description" wrap="virtual"
164            ><%=HTML.encodeTags(help == null ? cc.getPropertyValue("description") : help.getDescription())%></textarea>
165          <a href="javascript:Main.zoom('Help text', 'help', 'description')"
166            title="Edit in larger window"><base:icon image="zoom.gif" /></a>
167        </td>
168      </tr>
169      </table>
170      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
171    </t:tab>
172    </t:tabcontrol>
173
174    <table align="center">
175    <tr>
176      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
177      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
178    </tr>
179    </table>
180    </form>
181  </base:body>
182  </base:page>
183  <%
184}
185finally
186{
187  if (dc != null) dc.close();
188}
189%>
Note: See TracBrowser for help on using the repository browser.