0.0.6 | Built motion from commit ffa9431.
[motion.git] / public / assets / plugins / angular-elastic-builder-back / src / directives / RuleTypes.js
1 /**
2  * angular-elastic-builder
3  *
4  * /src/directives/RuleTypes.js
5  *
6  * Determines which Rule type should be displayed
7  */
8
9 (function(angular) {
10   'use strict';
11
12   var app = angular.module('angular-elastic-builder');
13
14   app.directive('elasticType', [
15
16     function() {
17       return {
18         scope: {
19           type: '=elasticType',
20           rule: '=',
21           guide: '=',
22         },
23
24         template: '<ng-include src="getTemplateUrl()" />',
25
26         link: function(scope) {
27           scope.getTemplateUrl = function() {
28             var type = scope.type;
29             if (!type) {
30               return;
31             }
32
33             type = type.charAt(0).toUpperCase() + type.slice(1);
34
35             return 'angular-elastic-builder/types/' + type + '.html';
36           };
37
38           // This is a weird hack to make sure these are numbers
39           scope.booleans = ['False', 'True'];
40           scope.booleansOrder = ['True', 'False'];
41
42           scope.inputNeeded = function() {
43             var needs = [
44               'equals',
45               'notEquals',
46
47               '$gt',
48               '$gte',
49               '$lt',
50               '$lte',
51             ];
52
53             return ~needs.indexOf(scope.rule.subType);
54           };
55         },
56       };
57     }
58
59   ]);
60
61 })(window.angular);