mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-1176: Allow field types to define hard-coded HTML templates (without a URL).
This commit is contained in:
@@ -241,18 +241,27 @@ angular.module('form').provider('formService', function formServiceProvider() {
|
|||||||
// Defer compilation of template pending successful retrieval
|
// Defer compilation of template pending successful retrieval
|
||||||
var compiledTemplate = $q.defer();
|
var compiledTemplate = $q.defer();
|
||||||
|
|
||||||
// Attempt to retrieve template HTML
|
// Use raw HTML template if provided
|
||||||
templateRequest(fieldType.templateUrl)
|
if (fieldType.template)
|
||||||
|
compiledTemplate.resolve($compile(fieldType.template)(scope));
|
||||||
|
|
||||||
// Resolve with compiled HTML upon success
|
// If no raw HTML template is provided, retrieve template from URL
|
||||||
.then(function templateRetrieved(html) {
|
else {
|
||||||
compiledTemplate.resolve($compile(html)(scope));
|
|
||||||
})
|
|
||||||
|
|
||||||
// Reject on failure
|
// Attempt to retrieve template HTML
|
||||||
['catch'](function templateError() {
|
templateRequest(fieldType.templateUrl)
|
||||||
compiledTemplate.reject();
|
|
||||||
});
|
// Resolve with compiled HTML upon success
|
||||||
|
.then(function templateRetrieved(html) {
|
||||||
|
compiledTemplate.resolve($compile(html)(scope));
|
||||||
|
})
|
||||||
|
|
||||||
|
// Reject on failure
|
||||||
|
['catch'](function templateError() {
|
||||||
|
compiledTemplate.reject();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Return promise which resolves to the compiled template
|
// Return promise which resolves to the compiled template
|
||||||
return compiledTemplate.promise;
|
return compiledTemplate.promise;
|
||||||
|
@@ -38,9 +38,19 @@ angular.module('form').factory('FieldType', [function defineFieldType() {
|
|||||||
// Use empty object by default
|
// Use empty object by default
|
||||||
template = template || {};
|
template = template || {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The raw HTML of the template that should be injected into the DOM of
|
||||||
|
* a form using this field type. If provided, this will be used instead
|
||||||
|
* of templateUrl.
|
||||||
|
*
|
||||||
|
* @type String
|
||||||
|
*/
|
||||||
|
this.template = template.template;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL of the template that should be injected into the DOM of a
|
* The URL of the template that should be injected into the DOM of a
|
||||||
* form using this field type.
|
* form using this field type. This property will be ignored if a raw
|
||||||
|
* HTML template is supplied via the template property.
|
||||||
*
|
*
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user