[open-ils-commits] r894 - conifer/branches/rel_1_6_0/xul/server/admin (risard)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Jun 17 14:07:58 EDT 2010
Author: risard
Date: 2010-06-17 14:07:54 -0400 (Thu, 17 Jun 2010)
New Revision: 894
Modified:
conifer/branches/rel_1_6_0/xul/server/admin/hours.xhtml
conifer/branches/rel_1_6_0/xul/server/admin/index.xhtml
Log:
updated the hours of operation interface to use dijit
Modified: conifer/branches/rel_1_6_0/xul/server/admin/hours.xhtml
===================================================================
--- conifer/branches/rel_1_6_0/xul/server/admin/hours.xhtml 2010-06-11 16:18:03 UTC (rev 893)
+++ conifer/branches/rel_1_6_0/xul/server/admin/hours.xhtml 2010-06-17 18:07:54 UTC (rev 894)
@@ -1,145 +1,208 @@
-<?xml version='1.0' encoding="UTF-8"?>
-
-<!DOCTYPE html PUBLIC
- "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [
- <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
-]>
-
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude">
-
-<head>
-<title>Hours of Operation</title>
-
-<link type='text/css' rel='stylesheet' href='admin.css'/>
-
-<!-- Include required scripts for basic OpenSRF-over-HTTP -->
-<script type='text/javascript' src='/opac/common/js/opensrf.js'></script>
-<script type='text/javascript' src='/opac/common/js/opensrf_xhr.js'></script>
-<script type='text/javascript' src='/opac/common/js/JSON_v1.js'></script>
-<script type='text/javascript' src='/opac/common/js/md5.js'></script>
-<script language='javascript' src='adminlib.js'> </script>
-
-<script type='text/javascript' src='/js/dojo/dojo/dojo.js' djConfig='parseOnLoad: true, isDebug:false'></script>
-
-<script type='text/javascript'>
-
-dojo.require('dojo.cookie');
-dojo.require('openils.User');
-dojo.require('openils.PermaCrud');
-
-var myToken;
-var myOuid;
-
-function initPage(){
-
- myToken = dojo.cookie('ses'); //need to catch if this goes wrong
- var user = new openils.User({authtoken:myToken});
- var pcrud = new openils.PermaCrud({"authtoken":myToken});
- var myOu = pcrud.retrieve("aou", user.user.ws_ou());
- myOuid = user.user.ws_ou();
-
- document.getElementById("title_tag").innerHTML = "<h2>Hours of operation for: " + myOu.shortname() + "</h2>";
-
- setHours("display");
-}
-
-
-function setHours(action){
-
- var pcrud = new openils.PermaCrud({"authtoken":myToken});
- var myHours = pcrud.retrieve("aouhoo", myOuid);
- var form_count = document.formHours.elements.length;
- var elem;
- var i = 0;
-
- while (elem = document.formHours.elements[i++]){
- if (action == 'update'){
- myHours[elem.id](elem.value); //need to add some validation code here when i have a minute
- }else{
- elem.value = myHours[elem.id](); //if update then sync
- }
- }
-
- if (action == 'update'){
- pcrud.update(myHours);
- document.getElementById("status_tag").innerHTML = "<b>Update Sucessful</b>"; //should check sucess first, don't know how though
- }
-
-}
-
-
-
-</script>
-
-
-</head>
-<body onload='initPage()'>
-<div id='title_tag'></div>
-<div id='status_tag'></div>
-<div id='divHours' name='divHours'>
- <form name='formHours' id='formHours'>
- <table border='0'>
- <tr>
- <td></td>
- <td>From:</td>
- <td></td>
- <td>To:</td>
- </tr>
- <tr>
- <td>Sunday</td>
- <td><input type='text' id='dow_0_open' name='dow_0_open' size='8' maxlength='8'></input></td>
- <td></td>
- <td><input type='text' id='dow_0_close' name='dow_0_close' size='8' maxlength='8'></input></td>
- </tr>
- <tr>
- <td>Monday</td>
- <td><input type='text' id='dow_1_open' name='dow_1_open' size='8' maxlength='8'></input></td>
- <td></td>
- <td><input type='text' id='dow_1_close' name='dow_1_close' size='8' maxlength='8'></input></td>
- </tr>
- <tr>
- <td>Tuesday</td>
- <td><input type='text' id='dow_2_open' name='dow_2_open' size='8' maxlength='8'></input></td>
- <td></td>
- <td><input type='text' id='dow_2_close' name='dow_2_close' size='8' maxlength='8'></input></td>
- </tr>
- <tr>
- <td>Wednesday</td>
- <td><input type='text' id='dow_3_open' name='dow_3_open' size='8' maxlength='8'></input></td>
- <td></td>
- <td><input type='text' id='dow_3_close' name='dow_3_close' size='8' maxlength='8'></input></td>
- </tr>
- <tr>
- <td>Thursday</td>
- <td><input type='text' id='dow_4_open' name='dow_4_open' size='8' maxlength='8'></input></td>
- <td></td>
- <td><input type='text' id='dow_4_close' name='dow_4_close' size='8' maxlength='8'></input></td>
- </tr>
- <tr>
- <td>Friday</td>
- <td><input type='text' id='dow_5_open' name='dow_5_open' size='8' maxlength='8'></input></td>
- <td></td>
- <td><input type='text' id='dow_5_close' name='dow_5_close' size='8' maxlength='8'></input></td>
- </tr>
- <tr>
- <td>Saturday</td>
- <td><input type='text' id='dow_6_open' name='dow_6_open' size='8' maxlength='8'></input></td>
- <td></td>
- <td><input type='text' id='dow_6_close' name='dow_6_close' size='8' maxlength='8'></input></td>
- </tr>
- <tr>
- <td></td>
- </tr>
- </table>
- </form>
-<input type='button' name='submit' id='submit' value='submit' onclick='setHours("update")'></input>
-</div>
-
-
-
-
-
-
-</body>
-</html>
+<?xml version='1.0' encoding="UTF-8"?>
+
+<!DOCTYPE html PUBLIC
+ "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [
+ <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
+]>
+
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude">
+
+<head>
+<title>Hours of Operation</title>
+
+<!-- STYLES - note this contains a reference to tundra.css which is the basis of the dijit widgets -->
+<link type='text/css' rel='stylesheet' href='admin.css'/>
+
+<!-- Include required scripts for basic OpenSRF-over-HTTP -->
+<script type='text/javascript' src='/opac/common/js/opensrf.js'></script>
+<script type='text/javascript' src='/opac/common/js/opensrf_xhr.js'></script>
+<script type='text/javascript' src='/opac/common/js/JSON_v1.js'></script>
+<script type='text/javascript' src='/opac/common/js/md5.js'></script>
+
+<!-- Includes required to try and retrieve the org unit name -->
+<!-- script type='text/javascript' src='/opac/common/js/org_utils.js'></script -->
+<!-- script type='text/javascript' src='/opac/common/js/<!--#echo var="locale"-->/OrgTree.js'></script -->
+<!-- script language='javascript' src='adminlib.js'> </script -->
+
+<!-- Dojo / digit libs -->
+<script type='text/javascript' src='/js/dojo/dojo/dojo.js' djConfig='parseOnLoad: true, isDebug:false'></script>
+<script type="text/javascript" src="js/dojotoolkit/dojo/dojo.js" djConfig="parseOnLoad:true, isDebug:true"></script>
+
+<!-- DEBUG -->
+<script type='text/javascript' src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
+
+
+<script type='text/javascript'>
+
+dojo.require('dojo.cookie');
+dojo.require('openils.User');
+dojo.require('openils.PermaCrud');
+dojo.require('dijit.form.Button');
+dojo.require('dijit.form.Form');
+dojo.require("dijit.form.TimeTextBox");
+
+var myToken;
+var myOuid;
+
+function initPage(){
+
+ myToken = dojo.cookie('ses'); //need to catch if this goes wrong
+ var user = new openils.User({authtoken:myToken});
+ myOuid = user.user.ws_ou();
+
+ var f = new dijit.form.Form({id:"formHours"}, "formHours");
+ var oConstraints = {timePattern: "HH:mm:ss", clickableIncrement: "T00:15:00", visibleIncrement: "T00:15:00", visibleRange: "T01:00:00"};
+
+
+ var oDow_0_open = new dijit.form.TimeTextBox({id:"dow_0_open", constraints: oConstraints}, "dow_0_open");
+
+ var oDow_0_close = new dijit.form.TimeTextBox({id:"dow_0_close", constraints: oConstraints}, "dow_0_close");
+
+ var oDow_1_open = new dijit.form.TimeTextBox({id:"dow_1_open", constraints: oConstraints}, "dow_1_open");
+ var oDow_1_close = new dijit.form.TimeTextBox({id:"dow_1_close", constraints: oConstraints}, "dow_1_close");
+
+ var oDow_2_open = new dijit.form.TimeTextBox({id:"dow_2_open", constraints: oConstraints}, "dow_2_open");
+ var oDow_2_close = new dijit.form.TimeTextBox({id:"dow_2_close", constraints: oConstraints}, "dow_2_close");
+
+ var oDow_3_open = new dijit.form.TimeTextBox({id:"dow_3_open", constraints: oConstraints}, "dow_3_open");
+ var oDow_3_close = new dijit.form.TimeTextBox({id:"dow_3_close", constraints: oConstraints}, "dow_3_close");
+
+ var oDow_4_open = new dijit.form.TimeTextBox({id:"dow_4_open", constraints: oConstraints}, "dow_4_open");
+ var oDow_4_close = new dijit.form.TimeTextBox({id:"dow_4_close", constraints: oConstraints}, "dow_4_close");
+
+ var oDow_5_open = new dijit.form.TimeTextBox({id:"dow_5_open", constraints: oConstraints}, "dow_5_open");
+ var oDow_5_close = new dijit.form.TimeTextBox({id:"dow_5_close", constraints: oConstraints}, "dow_5_close");
+
+ var oDow_6_open = new dijit.form.TimeTextBox({id:"dow_6_open", constraints: oConstraints}, "dow_6_open");
+ var oDow_6_close = new dijit.form.TimeTextBox({id:"dow_6_close", constraints: oConstraints}, "dow_6_close");
+
+ var oButton = new dijit.form.Button({id:"submit",
+ label:"submit",
+ onClick:function(){
+ setHours("update");
+ }},
+ "submit");
+
+ document.getElementById("title_tag").innerHTML = "<h2>Hours of operation for: " + myOuid + "</h2>";
+
+ setHours("display");
+}
+
+
+function setHours(action){
+
+ var pcrud = new openils.PermaCrud({"authtoken":myToken});
+ var myHours = pcrud.retrieve("aouhoo", myOuid);
+
+ if (myHours == null){
+ var default_hours = new aouhoo();
+ default_hours.id(myOuid);
+ pcrud.create(default_hours);
+ myHours = pcrud.retrieve("aouhoo", myOuid);
+}
+
+
+ if (myHours.id() != myOuid) {
+ document.getElementById("status_tag").innerHTML = "<b>You are trying to edit the hours of a branch you don't work at.</b>";
+ return;
+ }
+
+ switch(action){
+ case 'display':
+ dojo.query("input[id^='dow']").forEach(
+ function (item) {
+ item.value = myHours[item.id]();
+ }
+ );
+ break;
+
+ case 'update':
+ dojo.query("input[id^='dow']").forEach(
+ function (item) {
+ myHours[item.id](item.value);
+ }
+ );
+
+ pcrud.update(myHours);
+ document.getElementById("status_tag").innerHTML = "<b>Update Sucessful</b>"; //should check sucess first, don't know how though
+ break;
+ }
+
+
+}
+
+
+dojo.addOnLoad(initPage);
+
+
+</script>
+
+
+</head>
+<body class='tundra'>
+<div id='title_tag'></div>
+<div id='status_tag'></div>
+<div id='divHours' name='divHours'>
+ <form name='formHours' id='formHours'>
+ <table border='0'>
+ <tr>
+ <td></td>
+ <td>From:</td>
+ <td></td>
+ <td>To:</td>
+ </tr>
+ <tr>
+ <td>Sunday</td>
+ <td><input id='dow_0_open'></input></td>
+ <td></td>
+ <td><input id='dow_0_close'></input></td>
+ </tr>
+ <tr>
+ <td>Monday</td>
+ <td><input id='dow_1_open'></input></td>
+ <td></td>
+ <td><input id='dow_1_close'></input></td>
+ </tr>
+ <tr>
+ <td>Tuesday</td>
+ <td><input id='dow_2_open'></input></td>
+ <td></td>
+ <td><input id='dow_2_close'></input></td>
+ </tr>
+ <tr>
+ <td>Wednesday</td>
+ <td><input id='dow_3_open'></input></td>
+ <td></td>
+ <td><input id='dow_3_close'></input></td>
+ </tr>
+ <tr>
+ <td>Thursday</td>
+ <td><input id='dow_4_open'></input></td>
+ <td></td>
+ <td><input id='dow_4_close'></input></td>
+ </tr>
+ <tr>
+ <td>Friday</td>
+ <td><input id='dow_5_open'></input></td>
+ <td></td>
+ <td><input id='dow_5_close'></input></td>
+ </tr>
+ <tr>
+ <td>Saturday</td>
+ <td><input id='dow_6_open'></input></td>
+ <td></td>
+ <td><input id='dow_6_close'></input></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td><button id='submit' name='abutton'></button></td>
+ </tr>
+ </table>
+ </form>
+</div>
+
+
+
+</body>
+</html>
Modified: conifer/branches/rel_1_6_0/xul/server/admin/index.xhtml
===================================================================
--- conifer/branches/rel_1_6_0/xul/server/admin/index.xhtml 2010-06-11 16:18:03 UTC (rev 893)
+++ conifer/branches/rel_1_6_0/xul/server/admin/index.xhtml 2010-06-17 18:07:54 UTC (rev 894)
@@ -57,12 +57,11 @@
<a href='javascript:_l("closed_dates.xhtml");'>&staff.server.admin.index.closed_dates;</a>
</div>
<div style='padding: 8px;'>
- <a href='javascript:_l("hours.xhtml");'>Hours of Operation</a> <span style="color: red">&staff.server.admin.index.testing;</span>
-
- </div>
- <div style='padding: 8px;'>
<a href='javascript:_l("copy_locations.xhtml");'>&staff.server.admin.index.copy_locations;</a>
</div>
+ <div style='padding: 8px;'>
+ <a href='javascript:_l("hours.xhtml");'>Hours</a>
+ </div>
<div style='padding: 8px;'>
<a href='javascript:_l("org_unit_settings.xhtml");'>&staff.server.admin.index.library_settings;</a>
</div>
More information about the open-ils-commits
mailing list