You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by jm...@apache.org on 2016/12/06 04:54:53 UTC
[1/2] incubator-guacamole-client git commit: GUACAMOLE-136: Ensure
field template is in DOM prior to invoking controller.
Repository: incubator-guacamole-client
Updated Branches:
refs/heads/master 18565d171 -> b4ea239b5
GUACAMOLE-136: Ensure field template is in DOM prior to invoking controller.
Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/6eda36cd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/6eda36cd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/6eda36cd
Branch: refs/heads/master
Commit: 6eda36cd4e184e87b5cc88606808fdee8414803b
Parents: 32e5c3e
Author: Michael Jumper <mj...@apache.org>
Authored: Thu Dec 1 00:52:57 2016 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Mon Dec 5 20:16:57 2016 -0800
----------------------------------------------------------------------
.../webapp/app/form/directives/formField.js | 6 +--
.../webapp/app/form/services/formService.js | 54 ++++++++++++--------
2 files changed, 35 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/6eda36cd/guacamole/src/main/webapp/app/form/directives/formField.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/form/directives/formField.js b/guacamole/src/main/webapp/app/form/directives/formField.js
index 8833be2..2de0d49 100644
--- a/guacamole/src/main/webapp/app/form/directives/formField.js
+++ b/guacamole/src/main/webapp/app/form/directives/formField.js
@@ -104,10 +104,8 @@ angular.module('form').directive('guacFormField', [function formField() {
// Append field content
if (field) {
- formService.createFieldElement(field.type, $scope)
- .then(function fieldElementCreated(element) {
- fieldContent.append(element);
- });
+ formService.insertFieldElement(fieldContent[0],
+ field.type, $scope);
}
});
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/6eda36cd/guacamole/src/main/webapp/app/form/services/formService.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/form/services/formService.js b/guacamole/src/main/webapp/app/form/services/formService.js
index 5931d86..d761480 100644
--- a/guacamole/src/main/webapp/app/form/services/formService.js
+++ b/guacamole/src/main/webapp/app/form/services/formService.js
@@ -201,6 +201,10 @@ angular.module('form').provider('formService', function formServiceProvider() {
* model:
* The current String value of the field, if any.
*
+ * @param {Element} fieldContainer
+ * The DOM Element whose contents should be replaced with the
+ * compiled field template.
+ *
* @param {String} fieldTypeName
* The name of the field type defining the nature of the element to be
* created.
@@ -212,43 +216,51 @@ angular.module('form').provider('formService', function formServiceProvider() {
* A Promise which resolves to the compiled Element. If an error occurs
* while retrieving the field type, this Promise will be rejected.
*/
- service.createFieldElement = function createFieldElement(fieldTypeName, scope) {
+ service.insertFieldElement = function insertFieldElement(fieldContainer,
+ fieldTypeName, scope) {
// Ensure field type is defined
var fieldType = provider.fieldTypes[fieldTypeName];
if (!fieldType)
return $q.reject();
- // Populate scope using defined controller
- if (fieldType.module && fieldType.controller) {
- var $controller = angular.injector(['ng', fieldType.module]).get('$controller');
- $controller(fieldType.controller, {'$scope' : scope});
+ var templateRequest;
+
+ // Use raw HTML template if provided
+ if (fieldType.template) {
+ var deferredTemplate = $q.defer();
+ deferredTemplate.resolve(fieldType.template);
+ templateRequest = deferredTemplate.promise;
}
+ // If no raw HTML template is provided, retrieve template from URL
+ else
+ templateRequest = $templateRequest(fieldType.templateUrl);
+
// Defer compilation of template pending successful retrieval
var compiledTemplate = $q.defer();
- // Use raw HTML template if provided
- if (fieldType.template)
- compiledTemplate.resolve($compile(fieldType.template)(scope));
+ // Resolve with compiled HTML upon success
+ templateRequest.then(function templateRetrieved(html) {
- // If no raw HTML template is provided, retrieve template from URL
- else {
+ // Insert template into DOM
+ fieldContainer.innerHTML = html;
- // Attempt to retrieve template HTML
- $templateRequest(fieldType.templateUrl)
+ // Populate scope using defined controller
+ if (fieldType.module && fieldType.controller) {
+ var $controller = angular.injector(['ng', fieldType.module]).get('$controller');
+ $controller(fieldType.controller, {'$scope' : scope});
+ }
- // Resolve with compiled HTML upon success
- .then(function templateRetrieved(html) {
- compiledTemplate.resolve($compile(html)(scope));
- })
+ // Compile DOM with populated scope
+ compiledTemplate.resolve($compile(fieldContainer.childNodes)(scope));
- // Reject on failure
- ['catch'](function templateError() {
- compiledTemplate.reject();
- });
+ })
- }
+ // Reject on failure
+ ['catch'](function templateError() {
+ compiledTemplate.reject();
+ });
// Return promise which resolves to the compiled template
return compiledTemplate.promise;
[2/2] incubator-guacamole-client git commit: GUACAMOLE-136: Merge
template compilation ordering fix for custom field types.
Posted by jm...@apache.org.
GUACAMOLE-136: Merge template compilation ordering fix for custom field types.
Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/b4ea239b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/b4ea239b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/b4ea239b
Branch: refs/heads/master
Commit: b4ea239b5f1ce9776616ddbe748e43934e323579
Parents: 18565d1 6eda36c
Author: James Muehlner <ja...@guac-dev.org>
Authored: Mon Dec 5 20:53:04 2016 -0800
Committer: James Muehlner <ja...@guac-dev.org>
Committed: Mon Dec 5 20:53:04 2016 -0800
----------------------------------------------------------------------
.../webapp/app/form/directives/formField.js | 6 +--
.../webapp/app/form/services/formService.js | 54 ++++++++++++--------
2 files changed, 35 insertions(+), 25 deletions(-)
----------------------------------------------------------------------