1 (function(angular
, $, _
) {
2 // Declare a list of dependencies.
3 angular
.module('afCore', CRM
.angRequires('afCore'));
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
) {
10 d
.scope
.options
= '=';
12 pre: function($scope
, $el
, $attr
) {
13 $scope
.ts
= CRM
.ts(camelName
);
15 $scope
.crmApi4
= crmApi4
;
16 $scope
.crmStatus
= crmStatus
;
17 $scope
.crmUiAlert
= crmUiAlert
;
18 $scope
.crmUrl
= CRM
.url
;
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
;
25 $scope
.$parent
.afformTitle
= meta
.title
;
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
;
37 })(angular
, CRM
.$, CRM
._
);