forked from extern/egroupware
Actually use template attribute when provided
This commit is contained in:
parent
8a2259ae99
commit
57d6132a37
@ -33,7 +33,8 @@ var et2_template = et2_DOMWidget.extend(
|
|||||||
"template": {
|
"template": {
|
||||||
"name": "Template",
|
"name": "Template",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Name / ID of template"
|
"description": "Name / ID of template",
|
||||||
|
"default": et2_no_init
|
||||||
},
|
},
|
||||||
"group": {
|
"group": {
|
||||||
// TODO: Not implemented
|
// TODO: Not implemented
|
||||||
@ -75,11 +76,13 @@ var et2_template = et2_DOMWidget.extend(
|
|||||||
|
|
||||||
this.div = document.createElement("div");
|
this.div = document.createElement("div");
|
||||||
|
|
||||||
if (this.id != "")
|
if (this.id != "" || this.options.template)
|
||||||
{
|
{
|
||||||
|
var template_name = this.options.template || this.id;
|
||||||
|
|
||||||
// Set the api instance to the first part of the name of the
|
// Set the api instance to the first part of the name of the
|
||||||
// template, if it's in app.function.template format
|
// template, if it's in app.function.template format
|
||||||
var splitted = this.id.split('.');
|
var splitted = template_name.split('.');
|
||||||
if(splitted.length >= 3)
|
if(splitted.length >= 3)
|
||||||
{
|
{
|
||||||
this.setApiInstance(egw(splitted[0], this._parent.egw().window));
|
this.setApiInstance(egw(splitted[0], this._parent.egw().window));
|
||||||
@ -88,14 +91,14 @@ var et2_template = et2_DOMWidget.extend(
|
|||||||
// Check to see if XML is known
|
// Check to see if XML is known
|
||||||
var xml = null;
|
var xml = null;
|
||||||
var templates = this.getRoot().getInstanceManager().templates;
|
var templates = this.getRoot().getInstanceManager().templates;
|
||||||
if(!(xml = templates[this.id]))
|
if(!(xml = templates[template_name]))
|
||||||
{
|
{
|
||||||
// Check to see if ID is short form
|
// Check to see if ID is short form
|
||||||
// eg: row instead of app.something.row
|
// eg: row instead of app.something.row
|
||||||
for(var key in templates)
|
for(var key in templates)
|
||||||
{
|
{
|
||||||
splitted = key.split('.');
|
splitted = key.split('.');
|
||||||
if(splitted[splitted.length-1] == this.id)
|
if(splitted[splitted.length-1] == template_name)
|
||||||
{
|
{
|
||||||
xml = templates[key];
|
xml = templates[key];
|
||||||
break;
|
break;
|
||||||
@ -104,7 +107,7 @@ var et2_template = et2_DOMWidget.extend(
|
|||||||
if(!xml)
|
if(!xml)
|
||||||
{
|
{
|
||||||
// Ask server
|
// Ask server
|
||||||
splitted = this.id.split('.');
|
splitted = template_name.split('.');
|
||||||
var path = this.egw().webserverUrl + "/" + splitted.shift() + "/templates/default/" + splitted.join('.') + ".xet";
|
var path = this.egw().webserverUrl + "/" + splitted.shift() + "/templates/default/" + splitted.join('.') + ".xet";
|
||||||
|
|
||||||
if(splitted.length)
|
if(splitted.length)
|
||||||
@ -119,7 +122,7 @@ var et2_template = et2_DOMWidget.extend(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read the XML structure of the requested template
|
// Read the XML structure of the requested template
|
||||||
this.loadFromXML(templates[this.id]);
|
this.loadFromXML(templates[template_name]);
|
||||||
|
|
||||||
// Inform the widget tree that it has been successfully loaded.
|
// Inform the widget tree that it has been successfully loaded.
|
||||||
this.loadingFinished();
|
this.loadingFinished();
|
||||||
@ -130,14 +133,14 @@ var et2_template = et2_DOMWidget.extend(
|
|||||||
}
|
}
|
||||||
if(xml !== null && typeof xml !== "undefined")
|
if(xml !== null && typeof xml !== "undefined")
|
||||||
{
|
{
|
||||||
this.egw().debug("log", "Loading template from XML: ", this.id);
|
this.egw().debug("log", "Loading template from XML: ", template_name);
|
||||||
this.loadFromXML(xml);
|
this.loadFromXML(xml);
|
||||||
// Don't call this here - premature
|
// Don't call this here - premature
|
||||||
//this.loadingFinished();
|
//this.loadingFinished();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.egw().debug("warn", "Unable to find XML for ", this.id);
|
this.egw().debug("warn", "Unable to find XML for ", template_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user