From 9a5938272afb5e8f11696d5d2cd3d51bfac0f193 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sun, 15 Mar 2015 18:06:12 -0700 Subject: [PATCH] CRM-15706 - Loosen coupling between crmUiHelp and crmUiField. Document input "crmUiHelpFile". --- js/angular-crm-ui.js | 15 ++++++++++++--- js/angular-crmMailing/directives.js | 2 +- partials/crmMailing/mailing.html | 2 +- partials/crmUi/field.html | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/js/angular-crm-ui.js b/js/angular-crm-ui.js index 70f7519fe1..e68b3a10f7 100644 --- a/js/angular-crm-ui.js +++ b/js/angular-crm-ui.js @@ -114,6 +114,7 @@ // example:
{{mydata}}
// example:
// example:
+ // example:
{{mydata}}
.directive('crmUiField', function() { // Note: When writing new templates, the "label" position is particular. See/patch "var label" below. var templateUrls = { @@ -125,8 +126,11 @@ require: '^crmUiIdScope', restrict: 'EA', scope: { + // string, e.g. "myform.myfield" crmUiField: '@', + // string, an expression producing a printable title crmTitle: '@', + // string, an expression producing a help id crmHelp: '@' }, templateUrl: function(tElement, tAttrs){ @@ -139,6 +143,7 @@ scope.crmUiField = attrs.crmUiField; scope.crmTitle = attrs.crmTitle; scope.crmHelp = attrs.crmHelp; + scope.crmUiHelpFile = scope.$parent.crmUiHelpFile; } }; }) @@ -157,8 +162,12 @@ }; }) - // standalone: - // within crmUiField:
+ // Display a help icon which loads help from a *.hlp file. + // Example: Use a default *.hlp file + // JS: scope.crmUiHelpFile='CRM/Foo/Bar'; + // HTML: + // Example: Use an explicit *.hlp file + // HTML: .directive('crmUiHelp', function() { return { restrict: 'EA', @@ -172,7 +181,7 @@ .attr('href', '#') .on('click', function(e) { e.preventDefault(); - CRM.help(scope.crmUiHelp.title, {id: scope.crmUiHelp.id, file: scope.$parent.$parent.$parent.helpFile}); + CRM.help(scope.crmUiHelp.title, {id: scope.crmUiHelp.id, file: scope.crmUiHelp.file || scope.$parent.crmUiHelpFile}); }); } }; diff --git a/js/angular-crmMailing/directives.js b/js/angular-crmMailing/directives.js index 7db48d4c0e..646d285848 100644 --- a/js/angular-crmMailing/directives.js +++ b/js/angular-crmMailing/directives.js @@ -28,7 +28,7 @@ }); scope.crmMailingConst = CRM.crmMailing; scope.ts = CRM.ts(null); - scope.helpFile = 'CRM/Mailing/Form/Upload'; + scope.crmUiHelpFile = 'CRM/Mailing/Form/Upload'; scope[directiveName] = attr[directiveName] ? scope.$parent.$eval(attr[directiveName]) : {}; $q.when(crmMetadata.getFields('Mailing'), function(fields) { scope.mailingFields = fields; diff --git a/partials/crmMailing/mailing.html b/partials/crmMailing/mailing.html index 815bdf7b9c..79603b1b6e 100644 --- a/partials/crmMailing/mailing.html +++ b/partials/crmMailing/mailing.html @@ -21,7 +21,7 @@ It could perhaps be thinned by 30-60% by making more directives.
-
+