Merge pull request #22977 from eileenmcnaughton/issetit
[civicrm-core.git] / ext / afform / core / ang / afCore.js
1 (function(angular, $, _) {
2 // Declare a list of dependencies.
3 angular.module('afCore', CRM.angRequires('afCore'));
4
5 // Use `afCoreDirective(string name)` to generate an AngularJS directive.
6 angular.module('afCore').service('afCoreDirective', function($location, crmApi4, crmStatus, crmUiAlert) {
7 return function(camelName, meta, d) {
8 d.restrict = 'E';
9 d.scope = {};
10 d.scope.options = '=';
11 d.link = {
12 pre: function($scope, $el, $attr) {
13 $scope.ts = CRM.ts(camelName);
14 $scope.meta = meta;
15 $scope.crmApi4 = crmApi4;
16 $scope.crmStatus = crmStatus;
17 $scope.crmUiAlert = crmUiAlert;
18 $scope.crmUrl = CRM.url;
19
20 // Afforms do not use routing, but some forms get input from search params
21 $scope.$watch(function() {return $location.search();}, function(params) {
22 $scope.routeParams = params;
23 });
24
25 $scope.$parent.afformTitle = meta.title;
26
27 // Prepends a string to the afform title
28 // Provides contextual titles to search Afforms in standalone mode
29 $scope.addTitle = function(addition) {
30 $scope.$parent.afformTitle = addition + ' ' + meta.title;
31 };
32 }
33 };
34 return d;
35 };
36 });
37 })(angular, CRM.$, CRM._);