SearchKit - Contextual "View" button
[civicrm-core.git] / ext / search_kit / ang / crmSearchAdmin / crmSearchAdminLinkSelect.component.js
CommitLineData
f9cf8797
CW
1(function(angular, $, _) {
2 "use strict";
3
4 angular.module('crmSearchAdmin').component('crmSearchAdminLinkSelect', {
5 bindings: {
2dbf2d72 6 link: '<',
c7e96654 7 apiEntity: '<',
daa4e55a 8 apiParams: '<',
2dbf2d72
CW
9 links: '<',
10 onChange: '&'
30d895a9 11 },
f9cf8797 12 templateUrl: '~/crmSearchAdmin/crmSearchAdminLinkSelect.html',
daa4e55a 13 controller: function ($scope, $element, $timeout) {
33e81cf6 14 var ts = $scope.ts = CRM.ts('org.civicrm.search_kit'),
f9cf8797
CW
15 ctrl = this;
16
f28a6f18
CW
17 this.$onInit = function() {
18 $element.on('hidden.bs.dropdown', function() {
19 $scope.$apply(function() {
20 ctrl.menuOpen = false;
21 });
22 });
23 };
24
30a8f784 25 this.setValue = function(val) {
9446fbaa 26 if (val.path) {
2dbf2d72
CW
27 $timeout(function () {
28 $('input[type=text]', $element).focus();
29 });
f9cf8797 30 }
9446fbaa 31 ctrl.onChange({newLink: val});
f9cf8797
CW
32 };
33
9446fbaa
CW
34 this.getLink = function() {
35 return _.findWhere(ctrl.links, {action: ctrl.link.action, join: ctrl.link.join, entity: ctrl.link.entity});
f9cf8797
CW
36 };
37
38 }
39 });
40
41})(angular, CRM.$, CRM._);