Hi devs,
In the past we use to pass the wiki, space and page as 3 variables to JS code. For example
in dashboard.js we currently have:
this.sourcePage = this.element.down('.metadata .sourcepage').innerHTML;
this.sourceSpace = this.element.down('.metadata .sourcespace').innerHTML;
this.sourceWiki = this.element.down('.metadata .sourcewiki').innerHTML;
Now that we need to handle Nested Spaces, it’s more complex and I’m proposing to change
our best practice and instead to pass a full reference, as in:
this.sourceReference = XWiki.Model.resolve(this.element.down('.metadata
.source').innerHTML, XWiki.EntityType.DOCUMENT);
More generally the idea would be to do the same as we do in Java code, i.e. to start
stopping passing several parameters to functions and instead to use XWiki.EntityReference
(or XWiki.DocumentReference, etc).
For example for dashboard.js this allows to replace:
var link = new Element('a', {'href' : this.sourceURL});
link.update(this.sourceWiki + ':' + this.sourceSpace + '.' +
this.sourcePage);
With:
var link = new Element('a', {'href' : this.sourceURL});
link.update(XWiki.Model.serialize(this.sourceReference));
WDYT?
Thanks
-Vincent