mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
fixing some bugs with setting repeat indices. tinymce was blocking capture of click events so it was never setting repeat indexes so that was causing issues. secondly, for nested repeats, now setting the full hierarchy of repeats in order to avoid any blocking issues when events aren't being properly propogated. a bit brute force, but does seem to make things more stable.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4778 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -320,18 +320,20 @@ public class XFormsBean
|
|||||||
* @param value the new value
|
* @param value the new value
|
||||||
* @return the list of events that may result through this action
|
* @return the list of events that may result through this action
|
||||||
*/
|
*/
|
||||||
public void setRepeatIndex()
|
public void setRepeatIndeces()
|
||||||
throws XFormsException, IOException
|
throws XFormsException, IOException
|
||||||
{
|
{
|
||||||
final FacesContext context = FacesContext.getCurrentInstance();
|
final FacesContext context = FacesContext.getCurrentInstance();
|
||||||
final Map requestParameters = context.getExternalContext().getRequestParameterMap();
|
final Map requestParameters = context.getExternalContext().getRequestParameterMap();
|
||||||
final String id = (String)requestParameters.get("id");
|
final String repeatIds = (String)requestParameters.get("repeatIds");
|
||||||
final int index = Integer.parseInt((String)requestParameters.get("index"));
|
LOGGER.debug(this + ".setRepeatIndeces(" + repeatIds + ")");
|
||||||
|
for (String id : repeatIds.split(","))
|
||||||
LOGGER.debug(this + ".setRepeatIndex(" + id + ", " + index + ")");
|
{
|
||||||
final ChibaBean chibaBean = this.xformsSession.chibaBean;
|
final int index = Integer.parseInt((String)requestParameters.get(id));
|
||||||
chibaBean.updateRepeatIndex(id, index);
|
LOGGER.debug(this + ".setRepeatIndex(" + id + ", " + index + ")");
|
||||||
|
final ChibaBean chibaBean = this.xformsSession.chibaBean;
|
||||||
|
chibaBean.updateRepeatIndex(id, index);
|
||||||
|
}
|
||||||
final ResponseWriter out = context.getResponseWriter();
|
final ResponseWriter out = context.getResponseWriter();
|
||||||
XMLUtil.print(this.getEventLog(), out);
|
XMLUtil.print(this.getEventLog(), out);
|
||||||
out.close();
|
out.close();
|
||||||
|
@@ -239,23 +239,14 @@ dojo.declare("alfresco.xforms.Widget",
|
|||||||
_handleMoveComplete: function() {},
|
_handleMoveComplete: function() {},
|
||||||
getRepeatIndices: function()
|
getRepeatIndices: function()
|
||||||
{
|
{
|
||||||
function RepeatIndexData(repeat, index)
|
|
||||||
{
|
|
||||||
this.repeat = repeat;
|
|
||||||
this.index = index;
|
|
||||||
this.toString = function()
|
|
||||||
{
|
|
||||||
return "{" + this.repeat.id + " = " + this.index + "}";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
var result = [];
|
var result = [];
|
||||||
var w = this;
|
var w = this;
|
||||||
while (w.parent)
|
while (w.parent)
|
||||||
{
|
{
|
||||||
if (w.parent instanceof alfresco.xforms.Repeat)
|
if (w.parent instanceof alfresco.xforms.Repeat)
|
||||||
{
|
{
|
||||||
result.push(new RepeatIndexData(w.parent,
|
result.push(new alfresco.xforms.RepeatIndexData(w.parent,
|
||||||
w.parent.getChildIndex(w)));
|
w.parent.getChildIndex(w)));
|
||||||
}
|
}
|
||||||
w = w.parent;
|
w = w.parent;
|
||||||
}
|
}
|
||||||
@@ -426,6 +417,7 @@ dojo.declare("alfresco.xforms.TextArea",
|
|||||||
{
|
{
|
||||||
initializer: function(xform, xformsNode)
|
initializer: function(xform, xformsNode)
|
||||||
{
|
{
|
||||||
|
this.focused = false;
|
||||||
},
|
},
|
||||||
render: function(attach_point)
|
render: function(attach_point)
|
||||||
{
|
{
|
||||||
@@ -473,6 +465,32 @@ dojo.declare("alfresco.xforms.TextArea",
|
|||||||
{
|
{
|
||||||
var widget = event.target.widget;
|
var widget = event.target.widget;
|
||||||
widget.xform.setXFormsValue(widget.id, widget.getValue());
|
widget.xform.setXFormsValue(widget.id, widget.getValue());
|
||||||
|
this.focused = false;
|
||||||
|
},
|
||||||
|
_tinyMCE_focusHandler: function(event)
|
||||||
|
{
|
||||||
|
var widget = event.target.widget;
|
||||||
|
var repeatIndices = widget.getRepeatIndices();
|
||||||
|
if (repeatIndices.length != 0 && !this.focused)
|
||||||
|
{
|
||||||
|
var r = repeatIndices[repeatIndices.length - 1].repeat;
|
||||||
|
var p = widget;
|
||||||
|
while (p && p.parent != r)
|
||||||
|
{
|
||||||
|
if (p.parent instanceof alfresco.xforms.Repeat)
|
||||||
|
{
|
||||||
|
throw new Error("unexpected parent repeat " + p.parent.id);
|
||||||
|
}
|
||||||
|
p = p.parent;
|
||||||
|
}
|
||||||
|
if (!p)
|
||||||
|
{
|
||||||
|
throw new Error("unable to find parent repeat " + r.id +
|
||||||
|
" of " + widget.id);
|
||||||
|
}
|
||||||
|
repeatIndices[repeatIndices.length - 1].repeat.setFocusedChild(p);
|
||||||
|
}
|
||||||
|
this.focused = true;
|
||||||
},
|
},
|
||||||
_destroy: function()
|
_destroy: function()
|
||||||
{
|
{
|
||||||
@@ -503,6 +521,7 @@ dojo.declare("alfresco.xforms.TextArea",
|
|||||||
var editorDocument = tinyMCE.getInstanceById(this.id).getDoc();
|
var editorDocument = tinyMCE.getInstanceById(this.id).getDoc();
|
||||||
editorDocument.widget = this;
|
editorDocument.widget = this;
|
||||||
tinyMCE.addEvent(editorDocument, "blur", this._tinyMCE_blurHandler);
|
tinyMCE.addEvent(editorDocument, "blur", this._tinyMCE_blurHandler);
|
||||||
|
tinyMCE.addEvent(editorDocument, "focus", this._tinyMCE_focusHandler);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1069,6 +1088,16 @@ dojo.declare("alfresco.xforms.Group",
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
alfresco.xforms.RepeatIndexData = function(repeat, index)
|
||||||
|
{
|
||||||
|
this.repeat = repeat;
|
||||||
|
this.index = index;
|
||||||
|
this.toString = function()
|
||||||
|
{
|
||||||
|
return "{" + this.repeat.id + " = " + this.index + "}";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
dojo.declare("alfresco.xforms.Repeat",
|
dojo.declare("alfresco.xforms.Repeat",
|
||||||
alfresco.xforms.Group,
|
alfresco.xforms.Group,
|
||||||
{
|
{
|
||||||
@@ -1321,9 +1350,13 @@ dojo.declare("alfresco.xforms.Repeat",
|
|||||||
},
|
},
|
||||||
setFocusedChild: function(child)
|
setFocusedChild: function(child)
|
||||||
{
|
{
|
||||||
|
var repeatIndices = this.getRepeatIndices();
|
||||||
if (!child)
|
if (!child)
|
||||||
this.xform.setRepeatIndex(this.id, 0);
|
{
|
||||||
else
|
repeatIndices.push(new alfresco.xforms.RepeatIndexData(this, 0));
|
||||||
|
this.xform.setRepeatIndeces(repeatIndices);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
var index = this.getChildIndex(child);
|
var index = this.getChildIndex(child);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
@@ -1334,8 +1367,11 @@ dojo.declare("alfresco.xforms.Repeat",
|
|||||||
if (this.getSelectedIndex() == -1 && index == 0)
|
if (this.getSelectedIndex() == -1 && index == 0)
|
||||||
this.handleIndexChanged(0);
|
this.handleIndexChanged(0);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
repeatIndices.push(new alfresco.xforms.RepeatIndexData(this, index));
|
||||||
// xforms repeat indexes are 1-based
|
// xforms repeat indexes are 1-based
|
||||||
this.xform.setRepeatIndex(this.id, index + 1);
|
this.xform.setRepeatIndeces(repeatIndices);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
render: function(attach_point)
|
render: function(attach_point)
|
||||||
@@ -1782,12 +1818,20 @@ dojo.declare("alfresco.xforms.XForm",
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
setRepeatIndex: function(id, index)
|
setRepeatIndeces: function(repeatIndeces)
|
||||||
{
|
{
|
||||||
dojo.debug("setting repeat index " + index + " on " + id);
|
dojo.debug("setting repeat indeces [" + repeatIndeces.join(", ") + "]");
|
||||||
|
var params = { };
|
||||||
|
params["repeatIds"] = [];
|
||||||
|
for (var i = 0; i < repeatIndeces.length; i++)
|
||||||
|
{
|
||||||
|
params.repeatIds.push(repeatIndeces[i].repeat.id);
|
||||||
|
params[repeatIndeces[i].repeat.id] = repeatIndeces[i].index + 1;
|
||||||
|
}
|
||||||
|
params.repeatIds = params.repeatIds.join(",");
|
||||||
var req = create_ajax_request(this,
|
var req = create_ajax_request(this,
|
||||||
"setRepeatIndex",
|
"setRepeatIndeces",
|
||||||
{ id: id, index: index },
|
params,
|
||||||
function(type, data, evt)
|
function(type, data, evt)
|
||||||
{
|
{
|
||||||
this.target._handleEventLog(data.documentElement);
|
this.target._handleEventLog(data.documentElement);
|
||||||
|
Reference in New Issue
Block a user