r1290 - xwiki-sandbox/formeditor
Nebojsa Miletic
mileticn at users.forge.objectweb.org
Thu Sep 7 01:22:37 CEST 2006
Author: mileticn
Date: 2006-09-07 01:20:36 +0200 (Thu, 07 Sep 2006)
New Revision: 1290
Modified:
xwiki-sandbox/formeditor/formEditor.vm
Log:
Modified: xwiki-sandbox/formeditor/formEditor.vm
===================================================================
--- xwiki-sandbox/formeditor/formEditor.vm 2006-09-06 18:36:49 UTC (rev 1289)
+++ xwiki-sandbox/formeditor/formEditor.vm 2006-09-06 23:20:36 UTC (rev 1290)
@@ -5,19 +5,26 @@
<script language="javascript" type="text/javascript" src="/xwiki/bin/download/Main/WebHome/main.js"></script>
<script language="javascript" type="text/javascript" src="/xwiki/bin/download/Main/WebHome/editBoxFunctions.js"></script>
<script language="javascript" type="text/javascript" src="/xwiki/bin/download/Main/WebHome/getters.js"></script>
-
+{/pre}
+1 XWiki FormEditor
+<br><br>
+{pre}
#macro (selectclassform)
+Please, select one of the available sheets:
<form id="frmSelectClass">
<select name="xWikiClassName">
#foreach ($classname in $xwiki.classList)
#if ($xwiki.hasAccessLevel("edit", $classname))
#set($classdoc = $xwiki.getDocument($classname))
-<option value='$classname'>$classname</option>
+#set($sheetname = "${classname}Sheet")
+#set($sheet = $xwiki.getDocument($sheetname))
+<option value='$classname'>$sheetname</option>
#end
#end
</select>
-<input type='submit' value='use class' onclick='location = this.form.xWikiClassName.value'>
+<input type='submit' value='Open sheet' onclick='location = this.form.xWikiClassName.value'>
</form>
+<br><br><br><br>
#end
@@ -26,6 +33,8 @@
var input = [
#set($classname = $request.xWikiClassName)
#set($classdoc = $xwiki.getDocument($classname))
+#set($sheetname = "${classname}Sheet")
+#set($sheet = $xwiki.getDocument($sheetname))
#set($class = $classdoc.getxWikiClass())
#foreach ($prop in $class.properties)
#if ($prop.xWikiClass.name == "com.xpn.xwiki.objects.classes.NumberClass")
@@ -120,27 +129,37 @@
}
function saveResult(html) {
if(html=="SUCCESS") {
- alert("Form saved as ${classname}Sheet")
- //location = "SaveSheet";
+ var b = confirm("The form is saved as ${sheetname}.\n Do you want to load the form?");
+ if (b) {
+ var sheetname = '$sheetname';
+ var ind = sheetname.indexOf('.');
+ var space = sheetname.substring(0, ind);
+ var page = sheetname.substring(ind+1);
+ location = "../" + space + "/" + page;
+ }
}
else {
alert("Error saving.")
- alert(html);
+ alert(html.innerHTML);
}
}
function save(form) {
generateVelocity();
var code = $('velocityCode').value;
var url = "SaveSheet?xpage=plain&classname=" + escape(form.classname.value) + "Sheet" + "&content=" + escape(code);
- alert(url)
+// var url = "SaveSheet?xpage=plain&classname=Main.ArticleClassSheet" + "&content=" + escape(code);
+// var pars = "xpage=plain&classname=Main.ArticleClassSheet" + "&content=" + escape(code);
+// var url = "http://formeditorprototype.xwiki.com/xwiki/bin/view/Main/SaveSheet";
+// new Ajax.Updater('velocityCode', url, {method: 'get', parameters: pars, onComplete: saveResult});
+ //alert(url)
executeCommand(url, saveResult);
return false;
}
</script>
<form method='post' action="">
-<input type="button" value="Edit mode" onclick="viewMode()" >
-<input type="button" value="Preview mode" onclick="generateFormPreview()" >
-<input type="button" value="Velocity mode" onclick="generateVelocity()" >
+<input type="button" value="Edit form" onclick="viewMode()" >
+<input type="button" value="Preview form" onclick="generateFormPreview()" >
+<input type="button" value="View velocity code" onclick="generateVelocity()" >
<input type="hidden" name="xpage" value="plain" />
<input type="hidden" name="classname" value="$!classname" />
@@ -148,6 +167,9 @@
<input type='button' value='Save form' onclick="save(this.form); return false;">
</form>
+<table cellpadding=20 style='margin-left: -210px;'><tbody style='font-size: 12px;'>
+<tr>
+<td valign='top'>
@@ -157,7 +179,7 @@
<table style="font-size: 12px;"><tbody>
<tr>
<td>Table cols:</td><td><input id="colsCount" class='editingInput' size="10"></td>
- <td rowspan="2"><button width=70 onclick="createTable()">Add</button></td>
+ <td rowspan="2"><button width=70 onclick="createTable(parseInt($('colsCount').value), parseInt($('rowsCount').value))">Add</button></td>
</tr>
<tr>
<td>Table rows: </td><td><input id="rowsCount" class='editingInput' size="10"></td>
@@ -191,7 +213,7 @@
</fieldset>
<div id="paramsEditor" class="paramsEditor" >
- <fieldset class='editingFields' style="width: 100%; height: 200px; ">
+ <fieldset class='editingFields' style="width: 100%; height: 275px; ">
<div style="font-size: 12px;" id='selectCellNote'>
Form parameters can be changed only if some cell is selected.
</div>
@@ -201,12 +223,15 @@
<tr><td>Presentation text:</td><td><input id="editPresentationTextInput" class="editingInput" onchange='setGroupPresentationText()'></td></tr>
<tr><td>Row height:</td><td><input id="editRowHeightInput" class="editingInput" onchange="setRowHeight()"></td></tr>
<tr id='editCellText'><td>Cell text:</td><td><input id="editCellTextInput" class="editingInput" onchange="setCellText()"></td></tr>
- <tr id='editDeleteField'><td colspan=2><a href="#" class='editingText' onclick='emptyCell()'>Delete field from cell</a></td></tr>
- <tr id='editAddSeparator'><td colspan=2><a href="#" class='editingText' onclick='addSeparator()'>Add separator below the row</a></td></tr>
- <tr id='editRemoveSeparator'><td colspan=2><a href="#" class='editingText' onclick='removeSeparator()'>Remove separator below the row</a></td></tr>
- <tr id='editSpanCell'><td colspan=2><a href="#" class='editingText' onclick='spanCell()'>Span to adjacent cell</a></td></tr>
- <tr id='editSplitCell'><td colspan=2><a href="#" class='editingText' onclick='splitCell()'>Split cell</a></td></tr>
- <tr><td colspan=2><a href="#" class='editingText' onclick='deleteGroup()'>Delete group</a></td></tr>
+ <tr id='editCellText'><td>Cell text:</td><td><input id="editCellTextInput" class="editingInput" onchange="setCellText()"></td></tr>
+ <tr id='editAddRow'><td colspan=2 onmouseover="mouseOverEditBoxField(event);" onmouseout="mouseOutEditBoxField(event);" class='editingText' onclick='addRow()'>Add row below the cell</td></tr>
+ <tr id='editAddColumn'><td colspan=2 onmouseover="mouseOverEditBoxField(event);" onmouseout="mouseOutEditBoxField(event);" class='editingText' onclick='addColumn()'>Add column to the left of the cell</td></tr>
+ <tr id='editDeleteField'><td colspan=2 onmouseover="mouseOverEditBoxField(event);" onmouseout="mouseOutEditBoxField(event);" class='editingText' onclick='emptyCell()'>Delete field from cell</td></tr>
+ <tr id='editAddSeparator'><td colspan=2 onmouseover="mouseOverEditBoxField(event);" onmouseout="mouseOutEditBoxField(event);" class='editingText' onclick='addSeparator()'>Add separator below the row</td></tr>
+ <tr id='editRemoveSeparator'><td colspan=2 onmouseover="mouseOverEditBoxField(event);" onmouseout="mouseOutEditBoxField(event);" class='editingText' onclick='removeSeparator()'>Remove separator below the row</td></tr>
+ <tr id='editSpanCell'><td colspan=2 onmouseover="mouseOverEditBoxField(event);" onmouseout="mouseOutEditBoxField(event);" class='editingText' onclick='spanCell()'>Span to adjacent cell</td></tr>
+ <tr id='editSplitCell'><td colspan=2 onmouseover="mouseOverEditBoxField(event);" onmouseout="mouseOutEditBoxField(event);" class='editingText' onclick='splitCell()'>Split cell</td></tr>
+ <tr><td colspan=2 onmouseover="mouseOverEditBoxField(event);" onmouseout="mouseOutEditBoxField(event);" class='editingText' onclick='deleteGroup()'>Delete group</td></tr>
</tbody></table>
</fieldset>
</div>
@@ -219,14 +244,35 @@
</div>
</div>
+</td>
+<td valign="top" style="padding-left: 10px;">
+
<div id='divForm' style="float:right; display: none; margin-right: -100px; background-color: white; width: 870px;"></div>
<div id='previewForm' style="float:right; display: none; margin-right: -100px; background-color: white; width: 870px;"></div>
<div id='velocityZone' style="float:right; display: none; margin-right:- 100px; background-color: white; ">
<textarea cols = 80 rows = 30 id='velocityCode'></textarea>
</div>
+</td>
+</tr>
+</tbody></table>
+<!-- MUST BE HIDDEN -->
+<div id='formModel' style='display:none' >
+$xwiki.getDocument("${classname}Sheet").getContent()
+</div>
+
+#if ($xwiki.exists($sheetname))
<script language="javascript" type="text/javascript" >
+var descriptor = {
+ version: '$xwiki.getDocument("$sheetname").version',
+ date: '$xwiki.getDocument("$sheetname").date'
+}
+
+var formModel = document.getElementById('formModel');
+init(input, '$classname', formModel, descriptor);
+#else
init(input, '$classname');
+#end
</script>
#end
## end za veliki makro
More information about the Xwiki-notifications
mailing list