mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-12 07:57: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
|
||||
var compiledTemplate = $q.defer();
|
||||
|
||||
// Attempt to retrieve template HTML
|
||||
templateRequest(fieldType.templateUrl)
|
||||
// Use raw HTML template if provided
|
||||
if (fieldType.template)
|
||||
compiledTemplate.resolve($compile(fieldType.template)(scope));
|
||||
|
||||
// Resolve with compiled HTML upon success
|
||||
.then(function templateRetrieved(html) {
|
||||
compiledTemplate.resolve($compile(html)(scope));
|
||||
})
|
||||
// If no raw HTML template is provided, retrieve template from URL
|
||||
else {
|
||||
|
||||
// Reject on failure
|
||||
['catch'](function templateError() {
|
||||
compiledTemplate.reject();
|
||||
});
|
||||
// Attempt to retrieve template HTML
|
||||
templateRequest(fieldType.templateUrl)
|
||||
|
||||
// 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 compiledTemplate.promise;
|
||||
|
Reference in New Issue
Block a user