mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
implementing chiba-item-delete.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3815 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -814,23 +814,26 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
|
|||||||
|
|
||||||
protected String setXFormsId(final Element el)
|
protected String setXFormsId(final Element el)
|
||||||
{
|
{
|
||||||
long count = 0;
|
return this.setXFormsId(el, null);
|
||||||
final String name = el.getLocalName();
|
|
||||||
final Long l = (Long) counter.get(name);
|
|
||||||
|
|
||||||
if (l != null)
|
|
||||||
count = l.longValue();
|
|
||||||
//increment the counter
|
|
||||||
counter.put(name, new Long(count + 1));
|
|
||||||
|
|
||||||
return this.setXFormsId(el, name + "_" + count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String setXFormsId(final Element el, final String id)
|
protected String setXFormsId(final Element el, String id)
|
||||||
{
|
{
|
||||||
if (el.hasAttributeNS(SchemaFormBuilder.XFORMS_NS, "id"))
|
if (el.hasAttributeNS(SchemaFormBuilder.XFORMS_NS, "id"))
|
||||||
el.removeAttributeNS(SchemaFormBuilder.XFORMS_NS, "id");
|
el.removeAttributeNS(SchemaFormBuilder.XFORMS_NS, "id");
|
||||||
|
if (id == null)
|
||||||
|
{
|
||||||
|
long count = 0;
|
||||||
|
final String name = el.getLocalName();
|
||||||
|
final Long l = (Long) counter.get(name);
|
||||||
|
|
||||||
|
if (l != null)
|
||||||
|
count = l.longValue();
|
||||||
|
//increment the counter
|
||||||
|
counter.put(name, new Long(count + 1));
|
||||||
|
|
||||||
|
id = name + "_" + count;
|
||||||
|
}
|
||||||
el.setAttributeNS(SchemaFormBuilder.XFORMS_NS,
|
el.setAttributeNS(SchemaFormBuilder.XFORMS_NS,
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "id",
|
SchemaFormBuilder.XFORMS_NS_PREFIX + "id",
|
||||||
id);
|
id);
|
||||||
@@ -2422,13 +2425,14 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Element createTriggerForRepeat(final Document xForm,
|
private Element createTriggerForRepeat(final Document xForm,
|
||||||
|
final String id,
|
||||||
final String label,
|
final String label,
|
||||||
final Element action)
|
final Element action)
|
||||||
{
|
{
|
||||||
final Element trigger =
|
final Element trigger =
|
||||||
xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
|
xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "trigger");
|
SchemaFormBuilder.XFORMS_NS_PREFIX + "trigger");
|
||||||
this.setXFormsId(trigger);
|
this.setXFormsId(trigger, id != null ? id : null);
|
||||||
|
|
||||||
//label insert
|
//label insert
|
||||||
final Element triggerLabel =
|
final Element triggerLabel =
|
||||||
@@ -2482,8 +2486,6 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
|
|||||||
Element action =
|
Element action =
|
||||||
xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
|
xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "insert");
|
SchemaFormBuilder.XFORMS_NS_PREFIX + "insert");
|
||||||
this.setXFormsId(action);
|
|
||||||
|
|
||||||
//insert: bind & other attributes
|
//insert: bind & other attributes
|
||||||
if (bindId != null)
|
if (bindId != null)
|
||||||
action.setAttributeNS(SchemaFormBuilder.XFORMS_NS,
|
action.setAttributeNS(SchemaFormBuilder.XFORMS_NS,
|
||||||
@@ -2500,12 +2502,14 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
|
|||||||
"1");
|
"1");
|
||||||
|
|
||||||
final Element trigger_insert_before =
|
final Element trigger_insert_before =
|
||||||
this.createTriggerForRepeat(xForm, "insert at beginning", action);
|
this.createTriggerForRepeat(xForm,
|
||||||
|
repeatId != null ? repeatId + "-insert_before" : null,
|
||||||
|
"insert at beginning",
|
||||||
|
action);
|
||||||
|
|
||||||
|
|
||||||
action = xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
|
action = xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "insert");
|
SchemaFormBuilder.XFORMS_NS_PREFIX + "insert");
|
||||||
this.setXFormsId(action);
|
|
||||||
|
|
||||||
//insert: bind & other attributes
|
//insert: bind & other attributes
|
||||||
if (bindId != null)
|
if (bindId != null)
|
||||||
@@ -2523,13 +2527,15 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
|
|||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "index('" + repeatId + "')");
|
SchemaFormBuilder.XFORMS_NS_PREFIX + "index('" + repeatId + "')");
|
||||||
|
|
||||||
final Element trigger_insert_after =
|
final Element trigger_insert_after =
|
||||||
this.createTriggerForRepeat(xForm, "insert after selected", action);
|
this.createTriggerForRepeat(xForm,
|
||||||
|
repeatId != null ? repeatId + "-insert_after" : null,
|
||||||
|
"insert after selected",
|
||||||
|
action);
|
||||||
|
|
||||||
///////////// delete //////////////////
|
///////////// delete //////////////////
|
||||||
//trigger delete
|
//trigger delete
|
||||||
action = xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
|
action = xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "delete");
|
SchemaFormBuilder.XFORMS_NS_PREFIX + "delete");
|
||||||
this.setXFormsId(action);
|
|
||||||
|
|
||||||
//delete: bind & other attributes
|
//delete: bind & other attributes
|
||||||
if (bindId != null)
|
if (bindId != null)
|
||||||
@@ -2544,14 +2550,17 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
|
|||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "index('" + repeatId + "')");
|
SchemaFormBuilder.XFORMS_NS_PREFIX + "index('" + repeatId + "')");
|
||||||
|
|
||||||
final Element trigger_delete =
|
final Element trigger_delete =
|
||||||
this.createTriggerForRepeat(xForm, "delete selected", action);
|
this.createTriggerForRepeat(xForm,
|
||||||
|
repeatId != null ? repeatId + "-delete" : null,
|
||||||
|
"delete selected",
|
||||||
|
action);
|
||||||
|
|
||||||
|
|
||||||
//add the triggers
|
//add the triggers
|
||||||
final Element wrapper_triggers =
|
final Element wrapper_triggers =
|
||||||
_wrapper.createControlsWrapper(trigger_insert_before);
|
_wrapper.createControlsWrapper(trigger_insert_before);
|
||||||
|
|
||||||
if (wrapper_triggers == trigger_insert_after)
|
if (wrapper_triggers == trigger_insert_before)
|
||||||
{
|
{
|
||||||
//no wrapper
|
//no wrapper
|
||||||
formSection.appendChild(trigger_insert_before);
|
formSection.appendChild(trigger_insert_before);
|
||||||
@@ -2565,7 +2574,7 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
|
|||||||
|
|
||||||
if (insert_parent != null)
|
if (insert_parent != null)
|
||||||
{
|
{
|
||||||
insert_parent.appendChild(trigger_insert_before);
|
insert_parent.appendChild(trigger_insert_after);
|
||||||
insert_parent.appendChild(trigger_delete);
|
insert_parent.appendChild(trigger_delete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2597,37 +2606,30 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
|
|||||||
|
|
||||||
XSTypeDefinition parentType = type.getBaseType();
|
XSTypeDefinition parentType = type.getBaseType();
|
||||||
|
|
||||||
if (parentType != null &&
|
if (parentType == null ||
|
||||||
type.getTypeCategory() == parentType.getTypeCategory())
|
type.getTypeCategory() != parentType.getTypeCategory())
|
||||||
|
return;
|
||||||
|
if (type != parentType &&
|
||||||
|
(parentType.getName() == null || !parentType.getName().equals("anyType")))
|
||||||
{
|
{
|
||||||
if (type != parentType &&
|
|
||||||
(parentType.getName() == null || !parentType.getName().equals("anyType")))
|
|
||||||
{
|
|
||||||
|
|
||||||
//TreeSet newDescendents=new TreeSet(descendents);
|
//TreeSet newDescendents=new TreeSet(descendents);
|
||||||
TreeSet newDescendents = new TreeSet(this.typeExtensionSorter);
|
TreeSet newDescendents = new TreeSet(this.typeExtensionSorter);
|
||||||
newDescendents.addAll(descendents);
|
newDescendents.addAll(descendents);
|
||||||
|
|
||||||
//extension (we only add it to "newDescendants" because we don't want
|
//extension (we only add it to "newDescendants" because we don't want
|
||||||
//to have a type descendant to itself, but to consider it for the parent
|
//to have a type descendant to itself, but to consider it for the parent
|
||||||
if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE)
|
if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE)
|
||||||
{
|
{
|
||||||
XSComplexTypeDefinition complexType =
|
final XSComplexTypeDefinition complexType = (XSComplexTypeDefinition)type;
|
||||||
(XSComplexTypeDefinition) type;
|
if (complexType.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION &&
|
||||||
if (complexType.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION
|
!complexType.getAbstract() &&
|
||||||
&& !complexType.getAbstract()
|
!descendents.contains(type))
|
||||||
&& !descendents.contains(type) //to be tested
|
newDescendents.add(type);
|
||||||
//&& !descendents.contains(type.getName()) //to be tested
|
}
|
||||||
)
|
|
||||||
{
|
|
||||||
//newDescendents.add(type.getName());
|
|
||||||
newDescendents.add(type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//note: extensions are impossible on simpleTypes !
|
//note: extensions are impossible on simpleTypes !
|
||||||
|
|
||||||
buildTypeTree(parentType, newDescendents);
|
this.buildTypeTree(parentType, newDescendents);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2740,20 +2742,20 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
|
|||||||
//
|
//
|
||||||
// e.g. Please provide a valid value for 'Address'. 'Address' is a mandatory decimal field.
|
// e.g. Please provide a valid value for 'Address'. 'Address' is a mandatory decimal field.
|
||||||
//
|
//
|
||||||
Element alertElement = (Element)
|
// Element alertElement = (Element)
|
||||||
formControl.appendChild(xForm.createElementNS(XFORMS_NS,
|
// formControl.appendChild(xForm.createElementNS(XFORMS_NS,
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "alert"));
|
// SchemaFormBuilder.XFORMS_NS_PREFIX + "alert"));
|
||||||
this.setXFormsId(alertElement);
|
// this.setXFormsId(alertElement);
|
||||||
|
//
|
||||||
StringBuffer alert =
|
// StringBuffer alert =
|
||||||
new StringBuffer("Please provide a valid value for '" + caption + "'.");
|
// new StringBuffer("Please provide a valid value for '" + caption + "'.");
|
||||||
|
//
|
||||||
Element enveloppe = xForm.getDocumentElement();
|
// Element enveloppe = xForm.getDocumentElement();
|
||||||
alert.append(" '" + caption +
|
// alert.append(" '" + caption +
|
||||||
"' is " + (o.minimum == 0 ? "an optional" : "a required") + " '" +
|
// "' is " + (o.minimum == 0 ? "an optional" : "a required") + " '" +
|
||||||
createCaption(this.getXFormsTypeName(enveloppe, controlType)) +
|
// createCaption(this.getXFormsTypeName(enveloppe, controlType)) +
|
||||||
"' value.");
|
// "' value.");
|
||||||
alertElement.appendChild(xForm.createTextNode(alert.toString()));
|
// alertElement.appendChild(xForm.createTextNode(alert.toString()));
|
||||||
return formControl;
|
return formControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2898,11 +2900,13 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
|
|||||||
if (namespace != null && namespace.length() != 0)
|
if (namespace != null && namespace.length() != 0)
|
||||||
{
|
{
|
||||||
String prefix;
|
String prefix;
|
||||||
if ((prefix = (String) namespacePrefixes.get(namespace)) == null) {
|
if ((prefix = (String) namespacePrefixes.get(namespace)) == null)
|
||||||
|
{
|
||||||
String basePrefix = (namespace.substring(namespace.lastIndexOf('/', namespace.length()-2)+1));
|
String basePrefix = (namespace.substring(namespace.lastIndexOf('/', namespace.length()-2)+1));
|
||||||
int i=1;
|
int i=1;
|
||||||
prefix = basePrefix;
|
prefix = basePrefix;
|
||||||
while (namespacePrefixes.containsValue(prefix)) {
|
while (namespacePrefixes.containsValue(prefix))
|
||||||
|
{
|
||||||
prefix = basePrefix + (i++);
|
prefix = basePrefix + (i++);
|
||||||
}
|
}
|
||||||
namespacePrefixes.put(namespace, prefix);
|
namespacePrefixes.put(namespace, prefix);
|
||||||
|
@@ -445,12 +445,21 @@ dojo.declare("alfresco.xforms.Group",
|
|||||||
d.style.height = contentDiv.offsetHeight;
|
d.style.height = contentDiv.offsetHeight;
|
||||||
return d;
|
return d;
|
||||||
},
|
},
|
||||||
|
removeChildAt: function(position)
|
||||||
|
{
|
||||||
|
var child = this.getChildAt(position);
|
||||||
|
if (!child)
|
||||||
|
throw new Error("unabled to find child at " + position);
|
||||||
|
this.children.splice(position, 1);
|
||||||
|
dojo.dom.removeChildren(child.domContainer);
|
||||||
|
this.domNode.removeChild(child.domContainer);
|
||||||
|
},
|
||||||
isIndented: function()
|
isIndented: function()
|
||||||
{
|
{
|
||||||
return false && this.parent != null;
|
return false && this.parent != null;
|
||||||
},
|
},
|
||||||
render: function(attach_point)
|
render: function(attach_point)
|
||||||
{
|
{
|
||||||
this.domNode = document.createElement("div");
|
this.domNode = document.createElement("div");
|
||||||
this.domNode.setAttribute("id", this.id + "-domNode");
|
this.domNode.setAttribute("id", this.id + "-domNode");
|
||||||
this.domNode.widget = this;
|
this.domNode.widget = this;
|
||||||
@@ -459,16 +468,16 @@ dojo.declare("alfresco.xforms.Group",
|
|||||||
this.domNode.style.marginLeft = "10px";
|
this.domNode.style.marginLeft = "10px";
|
||||||
attach_point.appendChild(this.domNode);
|
attach_point.appendChild(this.domNode);
|
||||||
return this.domNode;
|
return this.domNode;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dojo.declare("alfresco.xforms.Repeat",
|
dojo.declare("alfresco.xforms.Repeat",
|
||||||
alfresco.xforms.Group,
|
alfresco.xforms.Group,
|
||||||
{
|
{
|
||||||
initializer: function(xform, node)
|
initializer: function(xform, node)
|
||||||
{
|
{
|
||||||
this.inherited("initializer", [ xform, node ]);
|
this.inherited("initializer", [ xform, node ]);
|
||||||
},
|
},
|
||||||
selectedIndex: null,
|
selectedIndex: null,
|
||||||
insertChildAt: function(child, position)
|
insertChildAt: function(child, position)
|
||||||
{
|
{
|
||||||
@@ -491,8 +500,8 @@ dojo.declare("alfresco.xforms.Repeat",
|
|||||||
var images = [
|
var images = [
|
||||||
{ src: "plus", action: this._insertRepeatItem_handler },
|
{ src: "plus", action: this._insertRepeatItem_handler },
|
||||||
{ src: "arrow_up", action: this._moveRepeatItemUp_handler },
|
{ src: "arrow_up", action: this._moveRepeatItemUp_handler },
|
||||||
{ src: "arrow_down", action: null },
|
{ src: "arrow_down", action: this._moveRepeatItemDown_handler },
|
||||||
{ src: "minus", action: null }
|
{ src: "minus", action: this._removeRepeatItem_handler }
|
||||||
];
|
];
|
||||||
for (var i in images)
|
for (var i in images)
|
||||||
{
|
{
|
||||||
@@ -505,20 +514,37 @@ dojo.declare("alfresco.xforms.Repeat",
|
|||||||
img.repeatItem = child;
|
img.repeatItem = child;
|
||||||
img.repeat = this;
|
img.repeat = this;
|
||||||
controls.appendChild(img);
|
controls.appendChild(img);
|
||||||
dojo.event.browser.addListener(img, "onclick", images[i].action);
|
dojo.event.connect(img, "onclick", this, images[i].action);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
removeChildAt: function(position)
|
||||||
|
{
|
||||||
|
this.inherited("removeChildAt", [ position ]);
|
||||||
|
if (this.selectedIndex == position)
|
||||||
|
this.handleIndexChanged(position);
|
||||||
|
},
|
||||||
_insertRepeatItem_handler: function(event)
|
_insertRepeatItem_handler: function(event)
|
||||||
{
|
{
|
||||||
alert("insert r=" + event.target.repeat.id +
|
var trigger = _findElementById(this.node.parentNode,
|
||||||
" item " + event.target.repeatItem.id);
|
this.id + "-insert_after");
|
||||||
|
this.xform.fireAction(trigger.getAttribute("id"));
|
||||||
|
},
|
||||||
|
_removeRepeatItem_handler: function(event)
|
||||||
|
{
|
||||||
|
var trigger = _findElementById(this.node.parentNode,
|
||||||
|
this.id + "-delete");
|
||||||
|
this.xform.fireAction(trigger.getAttribute("id"));
|
||||||
},
|
},
|
||||||
_moveRepeatItemUp_handler: function(event)
|
_moveRepeatItemUp_handler: function(event)
|
||||||
{
|
{
|
||||||
alert("moveUp " + event);
|
alert("moveUp " + event);
|
||||||
},
|
},
|
||||||
|
_moveRepeatItemDown_handler: function(event)
|
||||||
|
{
|
||||||
|
alert("moveDown " + event);
|
||||||
|
},
|
||||||
setFocusedChild: function(child)
|
setFocusedChild: function(child)
|
||||||
{
|
{
|
||||||
if (!child)
|
if (!child)
|
||||||
@@ -535,7 +561,6 @@ dojo.declare("alfresco.xforms.Repeat",
|
|||||||
this.handleIndexChanged(0);
|
this.handleIndexChanged(0);
|
||||||
// xforms repeat indexes are 1-based
|
// xforms repeat indexes are 1-based
|
||||||
this.xform.setRepeatIndex(this.id, index + 1);
|
this.xform.setRepeatIndex(this.id, index + 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isIndented: function()
|
isIndented: function()
|
||||||
@@ -543,58 +568,64 @@ dojo.declare("alfresco.xforms.Repeat",
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
render: function(attach_point)
|
render: function(attach_point)
|
||||||
{
|
{
|
||||||
this.domNode = this.inherited("render", [ attach_point ]);
|
this.domNode = this.inherited("render", [ attach_point ]);
|
||||||
this.domNode.style.borderColor = "black";
|
this.domNode.style.borderColor = "black";
|
||||||
this.domNode.style.borderWidth = "1px";
|
this.domNode.style.borderWidth = "1px";
|
||||||
|
|
||||||
var d = document.createElement("div");
|
var d = document.createElement("div");
|
||||||
d.repeat = this;
|
d.repeat = this;
|
||||||
this.domNode.appendChild(d);
|
this.domNode.appendChild(d);
|
||||||
d.setAttribute("style", "position: relative; line-height: 16px; background-color: #cddbe8; font-weight: bold;");
|
d.setAttribute("style", "position: relative; line-height: 16px; background-color: #cddbe8; font-weight: bold;");
|
||||||
dojo.event.browser.addListener(d, "onclick", function(event)
|
dojo.event.browser.addListener(d,
|
||||||
{
|
"onclick",
|
||||||
event.currentTarget.repeat.setFocusedChild(null);
|
function(event)
|
||||||
});
|
{
|
||||||
|
event.currentTarget.repeat.setFocusedChild(null);
|
||||||
|
});
|
||||||
|
|
||||||
var labelElement = document.createElement("div");
|
var labelElement = document.createElement("div");
|
||||||
d.appendChild(labelElement);
|
d.appendChild(labelElement);
|
||||||
labelElement.appendChild(document.createTextNode(this.parent.getLabel()));
|
labelElement.appendChild(document.createTextNode(this.parent.getLabel()));
|
||||||
labelElement.setAttribute("style", "position: relative; left: 5%; top: 0px;");
|
labelElement.setAttribute("style", "position: relative; left: 5%; top: 0px;");
|
||||||
|
|
||||||
var addElement = document.createElement("img");
|
var addElement = document.createElement("img");
|
||||||
d.appendChild(addElement);
|
d.appendChild(addElement);
|
||||||
addElement.setAttribute("src", WEBAPP_CONTEXT + "/images/icons/plus.gif");
|
addElement.setAttribute("src", WEBAPP_CONTEXT + "/images/icons/plus.gif");
|
||||||
addElement.style.width = "16px";
|
addElement.style.width = "16px";
|
||||||
addElement.style.height = "16px";
|
addElement.style.height = "16px";
|
||||||
addElement.style.position = "absolute";
|
addElement.style.position = "absolute";
|
||||||
addElement.style.top = "0px";
|
addElement.style.top = "0px";
|
||||||
addElement.style.left = "80%";
|
addElement.style.left = "80%";
|
||||||
|
|
||||||
dojo.event.browser.addListener(addElement, "onclick", function(event)
|
dojo.event.browser.addListener(addElement,
|
||||||
{
|
"onclick",
|
||||||
var repeat = event.currentTarget.parentNode.repeat;
|
function(event)
|
||||||
repeat.xform.fireAction("trigger_0");
|
{
|
||||||
});
|
var repeat = event.currentTarget.parentNode.repeat;
|
||||||
|
var trigger = _findElementById(repeat.node.parentNode,
|
||||||
|
repeat.id + "-insert_before");
|
||||||
|
repeat.xform.fireAction(trigger.getAttribute("id"));
|
||||||
|
});
|
||||||
|
|
||||||
return this.domNode;
|
return this.domNode;
|
||||||
},
|
},
|
||||||
handleIndexChanged: function(index)
|
handleIndexChanged: function(index)
|
||||||
|
{
|
||||||
|
dojo.debug(this.id + ".handleIndexChanged(" + index + ")");
|
||||||
|
if (this.selectedIndex != null && this.selectedIndex >= 0)
|
||||||
{
|
{
|
||||||
dojo.debug(this.id + ".handleIndexChanged(" + index + ")");
|
var child = this.getChildAt(this.selectedIndex);
|
||||||
if (this.selectedIndex != null && this.selectedIndex >= 0)
|
child.domContainer.style.backgroundColor = "white";
|
||||||
{
|
}
|
||||||
var child = this.getChildAt(this.selectedIndex);
|
|
||||||
child.domContainer.style.backgroundColor = "white";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
{
|
{
|
||||||
var child = this.getChildAt(index);
|
var child = this.getChildAt(index);
|
||||||
child.domContainer.style.backgroundColor = "orange";
|
child.domContainer.style.backgroundColor = "orange";
|
||||||
}
|
}
|
||||||
this.selectedIndex = index;
|
this.selectedIndex = index;
|
||||||
},
|
},
|
||||||
handlePrototypeCloned: function(prototypeId)
|
handlePrototypeCloned: function(prototypeId)
|
||||||
{
|
{
|
||||||
dojo.debug(this.id + ".handlePrototypeCloned("+ prototypeId +")");
|
dojo.debug(this.id + ".handlePrototypeCloned("+ prototypeId +")");
|
||||||
@@ -616,6 +647,11 @@ dojo.declare("alfresco.xforms.Repeat",
|
|||||||
var w = create_widget(this.xform, clonedPrototype);
|
var w = create_widget(this.xform, clonedPrototype);
|
||||||
this.insertChildAt(w, position);
|
this.insertChildAt(w, position);
|
||||||
load_body(this.xform, w.node, w);
|
load_body(this.xform, w.node, w);
|
||||||
|
},
|
||||||
|
handleItemDeleted: function(position)
|
||||||
|
{
|
||||||
|
dojo.debug(this.id + ".handleItemDeleted(" + position + ")");
|
||||||
|
this.removeChildAt(position);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -838,29 +874,15 @@ dojo.declare("alfresco.xforms.XForm",
|
|||||||
originalId = dojo.dom.textContent(originalId);
|
originalId = dojo.dom.textContent(originalId);
|
||||||
|
|
||||||
dojo.debug("handleIdGenerated(" + targetId + ", " + originalId + ")");
|
dojo.debug("handleIdGenerated(" + targetId + ", " + originalId + ")");
|
||||||
function applyId(node, oldId, newId)
|
|
||||||
{
|
|
||||||
dojo.debug("looking for " + oldId +
|
|
||||||
" in " + node.nodeName +
|
|
||||||
"(" + node.getAttribute("id") + ")");
|
|
||||||
if (node.getAttribute("id") == oldId)
|
|
||||||
{
|
|
||||||
dojo.debug("applying id " + newId +
|
|
||||||
" to " + node.nodeName + "(" + oldId + ")");
|
|
||||||
node.setAttribute("id", newId);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
for (var i = 0; i < node.childNodes.length; i++)
|
|
||||||
{
|
|
||||||
if (dojo.dom.isNode(node.childNodes[i]) &&
|
|
||||||
applyId(node.childNodes[i], oldId, newId))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var clone = prototypeClones[prototypeClones.length - 1];
|
var clone = prototypeClones[prototypeClones.length - 1];
|
||||||
if (!applyId(clone, originalId, targetId))
|
var node = _findElementById(clone, originalId);
|
||||||
|
if (node)
|
||||||
|
{
|
||||||
|
dojo.debug("applying id " + targetId +
|
||||||
|
" to " + node.nodeName + "(" + originalId + ")");
|
||||||
|
node.setAttribute("id", targetId);
|
||||||
|
}
|
||||||
|
else
|
||||||
throw new Error("unable to find " + originalId +
|
throw new Error("unable to find " + originalId +
|
||||||
" in clone " + dojo.dom.innerXML(clone));
|
" in clone " + dojo.dom.innerXML(clone));
|
||||||
break;
|
break;
|
||||||
@@ -879,6 +901,18 @@ dojo.declare("alfresco.xforms.XForm",
|
|||||||
target.handleItemInserted(clone, position);
|
target.handleItemInserted(clone, position);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "chiba-item-deleted":
|
||||||
|
{
|
||||||
|
var position = events.childNodes[i].getElementsByTagName("position")[0];
|
||||||
|
position = Number(dojo.dom.textContent(position)) - 1;
|
||||||
|
|
||||||
|
var targetDomNode = document.getElementById(targetId + "-domNode");
|
||||||
|
if (!targetDomNode)
|
||||||
|
throw new Error("unable to find node " + targetId + "-domNode");
|
||||||
|
var target = targetDomNode.widget;
|
||||||
|
target.handleItemDeleted(position);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
dojo.debug("unhandled event " + events.childNodes[i].nodeName);
|
dojo.debug("unhandled event " + events.childNodes[i].nodeName);
|
||||||
@@ -1002,3 +1036,22 @@ function addSubmitHandlerToButton(b)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _findElementById(node, id)
|
||||||
|
{
|
||||||
|
dojo.debug("looking for " + id +
|
||||||
|
" in " + node.nodeName +
|
||||||
|
"(" + node.getAttribute("id") + ")");
|
||||||
|
if (node.getAttribute("id") == id)
|
||||||
|
return node;
|
||||||
|
for (var i = 0; i < node.childNodes.length; i++)
|
||||||
|
{
|
||||||
|
if (dojo.dom.isNode(node.childNodes[i]))
|
||||||
|
{
|
||||||
|
var n = _findElementById(node.childNodes[i], id);
|
||||||
|
if (n)
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user