mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
redoing the way groups manage their children and introducing repeat insert behavior. totally broke layout - but that's on purpose... i'll address it again once i reduce groups and finalize the xform document structure i want for repeats.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3800 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -32,6 +32,7 @@ dojo.declare("alfresco.xforms.Widget",
|
|||||||
this.node = node;
|
this.node = node;
|
||||||
this.id = this.node.getAttribute("id");
|
this.id = this.node.getAttribute("id");
|
||||||
},
|
},
|
||||||
|
parent: null,
|
||||||
_getBinding: function()
|
_getBinding: function()
|
||||||
{
|
{
|
||||||
return this.xform.getBinding(this.node);
|
return this.xform.getBinding(this.node);
|
||||||
@@ -39,7 +40,7 @@ dojo.declare("alfresco.xforms.Widget",
|
|||||||
isRequired: function()
|
isRequired: function()
|
||||||
{
|
{
|
||||||
var binding = this._getBinding();
|
var binding = this._getBinding();
|
||||||
var required = binding.required == "true()";
|
var required = binding && binding.required == "true()";
|
||||||
return required;
|
return required;
|
||||||
},
|
},
|
||||||
getInitialValue: function()
|
getInitialValue: function()
|
||||||
@@ -72,30 +73,6 @@ dojo.declare("alfresco.xforms.Widget",
|
|||||||
}
|
}
|
||||||
return dojo.dom.textContent(node);
|
return dojo.dom.textContent(node);
|
||||||
},
|
},
|
||||||
appendHTML: function(attach_point)
|
|
||||||
{
|
|
||||||
var row = document.createElement("tr");
|
|
||||||
attach_point.appendChild(row);
|
|
||||||
var cell = document.createElement("td");
|
|
||||||
row.appendChild(cell);
|
|
||||||
if (this.isRequired())
|
|
||||||
{
|
|
||||||
var req = document.createElement("img");
|
|
||||||
req.setAttribute("src", WEBAPP_CONTEXT + "/images/icons/required_field.gif");
|
|
||||||
req.setAttribute("style", "margin:5px");
|
|
||||||
cell.appendChild(req);
|
|
||||||
}
|
|
||||||
|
|
||||||
var cell = document.createElement("td");
|
|
||||||
row.appendChild(cell);
|
|
||||||
|
|
||||||
var label = this._getLabelNode();
|
|
||||||
if (label)
|
|
||||||
cell.appendChild(document.createTextNode(dojo.dom.textContent(label)));
|
|
||||||
cell = document.createElement("td");
|
|
||||||
row.appendChild(cell);
|
|
||||||
this._appendHTMLForWidgetCell(cell);
|
|
||||||
},
|
|
||||||
_getLabelNode: function()
|
_getLabelNode: function()
|
||||||
{
|
{
|
||||||
var labels = this.node.getElementsByTagName("label");
|
var labels = this.node.getElementsByTagName("label");
|
||||||
@@ -107,6 +84,11 @@ dojo.declare("alfresco.xforms.Widget",
|
|||||||
return labels[i];
|
return labels[i];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
},
|
||||||
|
getLabel: function()
|
||||||
|
{
|
||||||
|
var node = this._getLabelNode();
|
||||||
|
return node ? dojo.dom.textContent(node) : "";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -118,7 +100,7 @@ dojo.declare("alfresco.xforms.NumericStepper",
|
|||||||
this.inherited("initializer", [ xform, node ]);
|
this.inherited("initializer", [ xform, node ]);
|
||||||
this.stepper_type = stepper_type;
|
this.stepper_type = stepper_type;
|
||||||
},
|
},
|
||||||
_appendHTMLForWidgetCell: function(attach_point)
|
render: function(attach_point)
|
||||||
{
|
{
|
||||||
var nodeRef = document.createElement("div");
|
var nodeRef = document.createElement("div");
|
||||||
attach_point.appendChild(nodeRef);
|
attach_point.appendChild(nodeRef);
|
||||||
@@ -153,7 +135,7 @@ dojo.declare("alfresco.xforms.DatePicker",
|
|||||||
this.inherited("initializer", [ xform, node ]);
|
this.inherited("initializer", [ xform, node ]);
|
||||||
dojo.debug("created a TextField");
|
dojo.debug("created a TextField");
|
||||||
},
|
},
|
||||||
_appendHTMLForWidgetCell: function(attach_point)
|
render: function(attach_point)
|
||||||
{
|
{
|
||||||
var initial_value = this.getInitialValue() || dojo.widget.DatePicker.util.toRfcDate();
|
var initial_value = this.getInitialValue() || dojo.widget.DatePicker.util.toRfcDate();
|
||||||
var dateTextBoxDiv = document.createElement("div");
|
var dateTextBoxDiv = document.createElement("div");
|
||||||
@@ -201,7 +183,7 @@ dojo.declare("alfresco.xforms.TextField",
|
|||||||
this.inherited("initializer", [ xform, node ]);
|
this.inherited("initializer", [ xform, node ]);
|
||||||
dojo.debug("created a TextField");
|
dojo.debug("created a TextField");
|
||||||
},
|
},
|
||||||
_appendHTMLForWidgetCell: function(attach_point)
|
render: function(attach_point)
|
||||||
{
|
{
|
||||||
var nodeRef = document.createElement("div");
|
var nodeRef = document.createElement("div");
|
||||||
attach_point.appendChild(nodeRef);
|
attach_point.appendChild(nodeRef);
|
||||||
@@ -234,7 +216,7 @@ dojo.declare("alfresco.xforms.TextArea",
|
|||||||
this.inherited("initializer", [ xform, node ]);
|
this.inherited("initializer", [ xform, node ]);
|
||||||
dojo.debug("created a TextArea");
|
dojo.debug("created a TextArea");
|
||||||
},
|
},
|
||||||
_appendHTMLForWidgetCell: function(attach_point)
|
render: function(attach_point)
|
||||||
{
|
{
|
||||||
dojo.debug("xxx " + this.id);
|
dojo.debug("xxx " + this.id);
|
||||||
var nodeRef = document.createElement("div");
|
var nodeRef = document.createElement("div");
|
||||||
@@ -273,7 +255,7 @@ dojo.declare("alfresco.xforms.Select1",
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
_appendHTMLForWidgetCell: function(attach_point)
|
render: function(attach_point)
|
||||||
{
|
{
|
||||||
var values = this.getValues();
|
var values = this.getValues();
|
||||||
for (var i in values)
|
for (var i in values)
|
||||||
@@ -332,7 +314,7 @@ dojo.declare("alfresco.xforms.CheckBox",
|
|||||||
{
|
{
|
||||||
this.inherited("initializer", [ xform, node ]);
|
this.inherited("initializer", [ xform, node ]);
|
||||||
},
|
},
|
||||||
_appendHTMLForWidgetCell: function(attach_point)
|
render: function(attach_point)
|
||||||
{
|
{
|
||||||
var nodeRef = document.createElement("div");
|
var nodeRef = document.createElement("div");
|
||||||
attach_point.appendChild(nodeRef);
|
attach_point.appendChild(nodeRef);
|
||||||
@@ -359,22 +341,38 @@ dojo.declare("alfresco.xforms.Group",
|
|||||||
{
|
{
|
||||||
this.inherited("initializer", [ xform, node ]);
|
this.inherited("initializer", [ xform, node ]);
|
||||||
},
|
},
|
||||||
appendHTML: function(attach_point)
|
children: [],
|
||||||
|
domNode: null,
|
||||||
|
addChild: function(child)
|
||||||
|
{
|
||||||
|
this.children.push(child);
|
||||||
|
child.parent = this;
|
||||||
|
var d = document.createElement("div");
|
||||||
|
d.setAttribute("style", "border: 2px solid green; width: 100%;");
|
||||||
|
this.domNode.appendChild(d);
|
||||||
|
if (child.isRequired() && child.node.nodeName != "xforms:repeat")
|
||||||
{
|
{
|
||||||
var n = attach_point;
|
var requiredImage = document.createElement("img");
|
||||||
if (attach_point.nodeName.toLowerCase() == "table")
|
requiredImage.setAttribute("src", WEBAPP_CONTEXT + "/images/icons/required_field.gif");
|
||||||
{
|
requiredImage.setAttribute("style", "margin:5px");
|
||||||
var tr = document.createElement("tr");
|
requiredImage.setAttribute("alt", "node Name " + child.node.nodeName);
|
||||||
var td = document.createElement("td");
|
d.appendChild(requiredImage);
|
||||||
td.setAttribute("colspan", "3");
|
}
|
||||||
tr.appendChild(td);
|
var label = child._getLabelNode();
|
||||||
attach_point.appendChild(tr);
|
if (label)
|
||||||
n = td;
|
d.appendChild(document.createTextNode(dojo.dom.textContent(label)));
|
||||||
}
|
var s = document.createElement("span");
|
||||||
var table = document.createElement("table");
|
d.appendChild(s);
|
||||||
table.setAttribute("style", "width:100%; border: 0px solid blue;");
|
child.render(s);
|
||||||
n.appendChild(table);
|
},
|
||||||
return table;
|
render: function(attach_point)
|
||||||
|
{
|
||||||
|
this.domNode = document.createElement("div");
|
||||||
|
this.domNode.setAttribute("style", "width:100%; border: 0px solid blue;");
|
||||||
|
if (parent)
|
||||||
|
this.domNode.style.marginLeft = "10px";
|
||||||
|
attach_point.appendChild(this.domNode);
|
||||||
|
return this.domNode;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -385,15 +383,10 @@ dojo.declare("alfresco.xforms.Submit",
|
|||||||
{
|
{
|
||||||
this.inherited("initializer", [ xform, node ]);
|
this.inherited("initializer", [ xform, node ]);
|
||||||
},
|
},
|
||||||
appendHTML: function(attach_point)
|
render: function(attach_point)
|
||||||
{
|
{
|
||||||
var row = document.createElement("tr");
|
|
||||||
attach_point.appendChild(row);
|
|
||||||
var cell = document.createElement("td");
|
|
||||||
cell.setAttribute("colspan", "3");
|
|
||||||
row.appendChild(cell);
|
|
||||||
var nodeRef = document.createElement("div");
|
var nodeRef = document.createElement("div");
|
||||||
cell.appendChild(nodeRef);
|
attach_point.appendChild(nodeRef);
|
||||||
var w = dojo.widget.createWidget("Button",
|
var w = dojo.widget.createWidget("Button",
|
||||||
{
|
{
|
||||||
widgetId: this.id,
|
widgetId: this.id,
|
||||||
@@ -401,8 +394,32 @@ dojo.declare("alfresco.xforms.Submit",
|
|||||||
},
|
},
|
||||||
nodeRef);
|
nodeRef);
|
||||||
w.hide();
|
w.hide();
|
||||||
document.submitTrigger = w;
|
w.onClick = function()
|
||||||
document.submitTrigger.done = false;
|
{
|
||||||
|
document.submitTrigger = w;
|
||||||
|
document.submitTrigger.done = false;
|
||||||
|
fireAction(w.widgetId);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dojo.declare("alfresco.xforms.Trigger",
|
||||||
|
alfresco.xforms.Widget,
|
||||||
|
{
|
||||||
|
initializer: function(xform, node)
|
||||||
|
{
|
||||||
|
this.inherited("initializer", [ xform, node ]);
|
||||||
|
},
|
||||||
|
render: function(attach_point)
|
||||||
|
{
|
||||||
|
var nodeRef = document.createElement("div");
|
||||||
|
attach_point.appendChild(nodeRef);
|
||||||
|
var w = dojo.widget.createWidget("Button",
|
||||||
|
{
|
||||||
|
widgetId: this.id,
|
||||||
|
caption: this.getLabel() + " " + this.id
|
||||||
|
},
|
||||||
|
nodeRef);
|
||||||
w.onClick = function()
|
w.onClick = function()
|
||||||
{
|
{
|
||||||
fireAction(w.widgetId);
|
fireAction(w.widgetId);
|
||||||
@@ -485,8 +502,10 @@ function xforms_init()
|
|||||||
? bindings[i].parent.id
|
? bindings[i].parent.id
|
||||||
: 'null'));
|
: 'null'));
|
||||||
}
|
}
|
||||||
|
var alfUI = document.getElementById("alf-ui");
|
||||||
load_body(xform, xform.getBody(), document.getElementById("alf-ui"));
|
var root = new alfresco.xforms.Group(xform, document.getElementById("alf-ui"));
|
||||||
|
root.render(alfUI);
|
||||||
|
load_body(xform, xform.getBody(), root);
|
||||||
},
|
},
|
||||||
error: function(type, e)
|
error: function(type, e)
|
||||||
{
|
{
|
||||||
@@ -496,20 +515,27 @@ function xforms_init()
|
|||||||
dojo.io.bind(req);
|
dojo.io.bind(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
function load_body(xform, currentNode, domNode)
|
function load_body(xform, currentNode, parentWidget)
|
||||||
{
|
{
|
||||||
dojo.lang.forEach(currentNode.childNodes, function(o)
|
dojo.lang.forEach(currentNode.childNodes, function(o)
|
||||||
{
|
{
|
||||||
dojo.debug("loading " + o + " NN " + o.nodeName);
|
dojo.debug("loading " + o + " NN " + o.nodeName + " into " + parentWidget);
|
||||||
switch (o.nodeName.toLowerCase())
|
switch (o.nodeName.toLowerCase())
|
||||||
{
|
{
|
||||||
case "xforms:group":
|
case "xforms:group":
|
||||||
var w = new alfresco.xforms.Group(xform, o);
|
var w = new alfresco.xforms.Group(xform, o);
|
||||||
load_body(xform, o, w.appendHTML(domNode));
|
dojo.debug("adding " + w + " to " + parentWidget);
|
||||||
|
parentWidget.addChild(w);
|
||||||
|
load_body(xform, o, w);
|
||||||
|
break;
|
||||||
|
case "xforms:repeat":
|
||||||
|
var w = new alfresco.xforms.Group(xform, o);
|
||||||
|
parentWidget.addChild(w);
|
||||||
|
load_body(xform, o, w);
|
||||||
break;
|
break;
|
||||||
case "xforms:textarea":
|
case "xforms:textarea":
|
||||||
var w = new alfresco.xforms.TextArea(xform, o);
|
var w = new alfresco.xforms.TextArea(xform, o);
|
||||||
w.appendHTML(domNode);
|
parentWidget.addChild(w);
|
||||||
break;
|
break;
|
||||||
case "xforms:input":
|
case "xforms:input":
|
||||||
var type = xform.getType(o);
|
var type = xform.getType(o);
|
||||||
@@ -528,24 +554,27 @@ function load_body(xform, currentNode, domNode)
|
|||||||
default:
|
default:
|
||||||
var w = new alfresco.xforms.TextField(xform, o);
|
var w = new alfresco.xforms.TextField(xform, o);
|
||||||
}
|
}
|
||||||
w.appendHTML(domNode);
|
parentWidget.addChild(w);
|
||||||
break;
|
break;
|
||||||
case "xforms:select1":
|
case "xforms:select1":
|
||||||
var w = (xform.getType(o) == "boolean"
|
var w = (xform.getType(o) == "boolean"
|
||||||
? new alfresco.xforms.CheckBox(xform, o)
|
? new alfresco.xforms.CheckBox(xform, o)
|
||||||
: new alfresco.xforms.Select1(xform, o));
|
: new alfresco.xforms.Select1(xform, o));
|
||||||
w.appendHTML(domNode);
|
parentWidget.addChild(domNode);
|
||||||
break;
|
break;
|
||||||
case "xforms:submit":
|
case "xforms:submit":
|
||||||
var w = new alfresco.xforms.Submit(xform, o);
|
var w = new alfresco.xforms.Submit(xform, o);
|
||||||
w.appendHTML(domNode);
|
parentWidget.addChild(w);
|
||||||
break;
|
break;
|
||||||
case "xforms:repeat":
|
case "xforms:trigger":
|
||||||
var w = new alfresco.xforms.Group(xform, o);
|
var w = new alfresco.xforms.Trigger(xform, o);
|
||||||
load_body(xform, o, w.appendHTML(domNode));
|
parentWidget.addChild(w);
|
||||||
|
break;
|
||||||
|
case "chiba:data":
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
load_body(xform, o, domNode);
|
load_body(xform, o, parentWidget);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -558,9 +587,12 @@ function fireAction(id)
|
|||||||
mimetype: "text/xml",
|
mimetype: "text/xml",
|
||||||
load: function(type, data, evt)
|
load: function(type, data, evt)
|
||||||
{
|
{
|
||||||
|
if (document.submitTrigger)
|
||||||
|
{
|
||||||
document.submitTrigger.done = true;
|
document.submitTrigger.done = true;
|
||||||
document.submitTrigger.currentButton.click();
|
document.submitTrigger.currentButton.click();
|
||||||
document.submitTrigger.currentButton = null;
|
document.submitTrigger.currentButton = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error: function(type, e)
|
error: function(type, e)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user