├── .eslintrc
├── .gitignore
├── LICENSE.md
├── README.md
├── bower.json
├── dist
├── angular-elastic-builder.js
└── angular-elastic-builder.min.js
├── examples
├── index.html
├── index.js
└── js
│ └── exampleApp.js
├── gulpfile.js
├── package.json
├── screenshot.png
└── src
├── directives
├── BuilderDirective.js
├── Chooser.js
├── Group.js
├── Rule.js
└── RuleTypes.js
├── module.js
├── services
├── GroupClassHelper.js
└── QueryService.js
└── tmpl
├── BuilderDirective.html
├── ChooserDirective.html
├── ElasticBuilderTemplates.js
├── GroupDirective.html
├── RuleDirective.html
└── types
├── Boolean.html
├── Date.html
├── Multi.html
├── Number.html
└── Term.html
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "node": true,
4 | "browser": true,
5 | "builtin": true
6 | },
7 | "rules": {
8 |
9 |
10 | /**
11 | * Possible Errors
12 | */
13 | "comma-dangle": [ 2, "always-multiline" ],
14 | "no-cond-assign": [ 2, "except-parens" ],
15 | "no-debugger": 2,
16 | "no-dupe-args": 2,
17 | "no-dupe-keys": 2,
18 | "no-duplicate-case": 2,
19 | "no-empty": 2,
20 | "no-empty-character-class": 2,
21 | "no-ex-assign": 2,
22 | "no-extra-boolean-cast": 2,
23 | // "no-extra-parens": 2,
24 | "no-extra-semi": 2,
25 | "no-irregular-whitespace": 2,
26 | "no-obj-calls": 2,
27 | "no-unexpected-multiline": 2,
28 | "no-unreachable": 2,
29 | // "valid-jsdoc": 2,
30 | "valid-typeof": 2,
31 |
32 |
33 | /**
34 | * Best Practices
35 | */
36 | "block-scoped-var": 2,
37 | "curly": [ 2, "multi-line" ],
38 | "dot-location": [ 2, "property" ],
39 | "dot-notation": 2,
40 | "eqeqeq": [ 2, "allow-null" ],
41 | "guard-for-in": 2,
42 | "no-alert": 2,
43 | "no-caller": 2,
44 | "no-div-regex": 2,
45 | "no-else-return": 2,
46 | "no-eq-null": 2,
47 | "no-eval": 2,
48 | "no-extend-native": 2,
49 | "no-extra-bind": 2,
50 | "no-floating-decimal": 2,
51 | "no-iterator": 2,
52 | "no-labels": 2,
53 | "no-lone-blocks": 2,
54 | // "no-loop-func": 2,
55 | "no-multi-spaces": 2,
56 | "no-multi-str": 2,
57 | "no-native-reassign": 2,
58 | "no-new": 2,
59 | "no-new-func": 2,
60 | "no-new-wrappers": 2,
61 | "no-octal": 2,
62 | "no-octal-escape": 2,
63 | "no-proto": 2,
64 | "no-return-assign": [ 1, "except-parens" ],
65 | "no-script-url": 2,
66 | "no-self-compare": 2,
67 | "no-sequences": 2,
68 | "no-throw-literal": 2,
69 | "no-useless-concat": 2,
70 | "no-warning-comments": [ 1, { "location": "anywhere" }],
71 | "no-with": 2,
72 | "wrap-iife": [ 2, "inside" ],
73 |
74 |
75 | /**
76 | * Stylistic Issues
77 | */
78 | "block-spacing": 2,
79 | "brace-style": [ 2, "1tbs", { "allowSingleLine": true }],
80 | "camelcase": [ 2, { "properties": "never" }],
81 | "comma-spacing": [ 2, { "before": false, "after": true }],
82 | "comma-style": [
83 | 2,
84 | "first",
85 | {
86 | "exceptions": {
87 | "ArrayExpression": true,
88 | "ObjectExpression": true
89 | }
90 | }
91 | ],
92 | "computed-property-spacing": [ 2, "never" ],
93 | "eol-last": 2,
94 | "indent": [2, 2, { "SwitchCase": 1 }],
95 | "key-spacing": 2,
96 | "keyword-spacing": [
97 | 2
98 | ],
99 | "lines-around-comment": [ 2, {
100 | "beforeBlockComment": true,
101 | "beforeLineComment": false,
102 | "allowBlockStart": true,
103 | "allowBlockEnd": true
104 | }],
105 | "linebreak-style": [ 2, "unix" ],
106 | "new-cap": 2,
107 | "new-parens": 2,
108 | "no-array-constructor": 2,
109 | "no-lonely-if": 2,
110 | "no-mixed-spaces-and-tabs": 2,
111 | "no-multiple-empty-lines": [ 2, { "max": 3 }],
112 | "no-nested-ternary": 2,
113 | "no-new-object": 2,
114 | "no-spaced-func": 2,
115 | "no-trailing-spaces": 2,
116 | "no-unneeded-ternary": 2,
117 | "operator-linebreak": [ 2, "before" ],
118 | "quotes": [ 2, "single" ],
119 | "semi": [ 2, "always" ],
120 | "semi-spacing": 2,
121 | "space-infix-ops": 2,
122 | "space-unary-ops": 2,
123 |
124 |
125 | /**
126 | * Variables
127 | */
128 | "no-catch-shadow": 2,
129 | "no-delete-var": 2,
130 | "no-shadow-restricted-names": 2,
131 | "no-undef-init": 2,
132 | "no-undef": 2,
133 | "no-unused-vars": 2,
134 | "no-use-before-define": [ 2, "nofunc" ],
135 |
136 |
137 | /**
138 | * Node / CommonJS
139 | */
140 | "handle-callback-err": 2,
141 | "no-mixed-requires": [ 1, true ],
142 | "no-path-concat": 2,
143 | "no-process-exit": 2
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | b-cov
2 | *.seed
3 | *.log
4 | *.csv
5 | *.dat
6 | *.out
7 | *.pid
8 | *.gz
9 | .idea
10 |
11 | pids
12 | logs
13 | results
14 | build
15 |
16 | npm-debug.log
17 | node_modules
18 |
19 | aws-keys.json
20 | .DS_Store
21 |
22 |
23 | *.iml
24 | *.sublime-project
25 | *.sublime-workspace
26 |
27 | release
28 | buildversion
29 | version.prop
30 | npm-shrinkwrap.json
31 |
32 | test/reports
33 | .npmrc
34 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright © 2014 by Intellectual Reserve, Inc.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
9 | Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization.
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Angular Elasticsearch Query Builder
2 |
3 | [![NPM version][npm-image]][npm-url]
4 | ![Bower version][bower-image]
5 | [![Downloads][downloads-image]][downloads-url]
6 | [![Tips][gratipay-image]][gratipay-url]
7 |
8 | This is an Angular.js directive for building an [Elasticsearch](https://www.elastic.co/) query.
9 | You just give it the fields and can generate a query for it. Its layout is defined using [Bootstrap](http://getbootstrap.com/) classes, but you may also choose to just style it yourself.
10 |
11 | It's still pretty early on, as it doesn't support a whole lot of use-cases, but we need to make it awesome. Contributions accepted.
12 |
13 | ## Try it Out
14 | [View an example here](http://dncrews.com/angular-elastic-builder/examples/)
15 |
16 | ## Usage
17 |
18 | ### Dependency
19 | Notice: this plugin requires:
20 | - the [Angular Recursion](https://github.com/marklagendijk/angular-recursion) module.
21 | - the [Angular directives for Bootstrap](https://github.com/angular-ui/bootstrap) module to display the Calendar (ui.bootstrap.datepicker)
22 |
23 | ### Installation
24 | First you'll need to download the [dist](https://github.com/dncrews/angular-elastic-builder/tree/master/dist) files and include this JS file to your app (don't forget to substitute `x.x.x` with the current version number), along with the RecursionHelper, if you're not already using it.
25 | ```html
26 |
27 |
28 |
29 | ```
30 |
31 | Then make sure that it's included in your app's dependencies during module creation.
32 |
33 | ```js
34 | angularmodule('appName', [ 'angular-elastic-builder' ]);
35 | ```
36 |
37 | Then you can use it in your app
38 | ```js
39 | /* Controller code */
40 |
41 | /**
42 | * The elasticBuilderData object will be modified in place so that you can use
43 | * your own $watch, and/or your own saving mechanism
44 | */
45 | $scope.elasticBuilderData = {};
46 | $scope.elasticBuilderData.query = [];
47 |
48 | /**
49 | * This object is the lookup for what fields
50 | * are available in your database, as well as definitions of what kind
51 | * of data they are
52 | */
53 | $scope.elasticBuilderData.fields = {
54 | 'test.number': { type: 'number', minimum: 650 },
55 | 'test.term': { type: 'term' },
56 | 'test.boolean': { type: 'term', subType: 'boolean' },
57 | 'test.state.multi': { type: 'multi', choices: [ 'AZ', 'CA', 'CT' ]},
58 | 'test.date': { type: 'date' },
59 | 'test.otherdate': { type: 'date' }
60 | };
61 | ```
62 |
63 | ```html
64 |
65 | ```
66 |
67 | The above elasticFields would allow you create the following form:
68 | ![Screenshot][screenshot-image]
69 |
70 | Which represents the following Elasticsearch Query:
71 | ```json
72 | [
73 | {
74 | "and": [
75 | {
76 | "term": {
77 | "test.date": "2016-04-08T10:44:06"
78 | }
79 | },
80 | {
81 | "range": {
82 | "test.number": {
83 | "gte": 650
84 | }
85 | }
86 | },
87 | {
88 | "range": {
89 | "test.number": {
90 | "lt": 850
91 | }
92 | }
93 | }
94 | ]
95 | },
96 | {
97 | "term": {
98 | "test.boolean": 0
99 | }
100 | },
101 | {
102 | "terms": {
103 | "test.state.multi": [ "AZ", "CT" ]
104 | }
105 | },
106 | {
107 | "not": {
108 | "filter": {
109 | "term": {
110 | "test.term": "asdfasdf"
111 | }
112 | }
113 | }
114 | },
115 | {
116 | "exists": {
117 | "field": "test.term"
118 | }
119 | },
120 | {
121 | "range": {
122 | "test.otherdate": {
123 | "gte": "now",
124 | "lte": "now+7d"
125 | }
126 | }
127 | }
128 | ]
129 | ```
130 |
131 |
132 | ### Field Options
133 | - `type`: This determines how the fields are displayed in the form.
134 | - Currently supported:
135 | - `'number'`: in addition to Generic Options, gets ">", "≥", "<", "≤", "="
136 | - `'term'`: in addition to Generic Options, gets "Equals" and "! Equals"
137 | - `'boolean'`: Does not get Generic Options. Gets `true` and `false`
138 | - These are actually "equals 0" and "equals 1" for the database query
139 | - `'date'`: in addition to Generic Options, gets ">", "≥", "<", "≤", "="
140 |
141 | Generic Options
142 | - In addition to any specific options for fields, all fields also get a "Exists" and "! Exists" option
143 |
144 |
145 | ## External Changes && Initial State
146 | If you want to pass in an initial state (or if you make changes to the query externally), you'll need to
147 | set the configuration flag `needsUpdate` to `true`. Any time this flag changes to `true`, this directive
148 | will overwrite the current state and data with whatever is now defined in your configuration object.
149 |
150 |
151 | ## Local Development
152 | To work on this module locally, you will need to clone it and run `gulp watch`. This will ensure that your changes get compiled properly. You will also need to make sure you run `gulp` to build the "dist" files before commit.
153 |
154 |
155 | [npm-image]: https://img.shields.io/npm/v/angular-elastic-builder.svg
156 | [npm-url]: https://www.npmjs.org/package/angular-elastic-builder
157 | [bower-image]: https://img.shields.io/bower/v/angular-elastic-builder.svg
158 | [downloads-image]: https://img.shields.io/npm/dm/angular-elastic-builder.svg
159 | [downloads-url]: https://www.npmjs.org/package/angular-elastic-builder
160 | [gratipay-image]: https://img.shields.io/gratipay/dncrews.svg
161 | [gratipay-url]: https://www.gratipay.com/dncrews/
162 | [screenshot-image]: ./screenshot.png
163 |
164 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-elastic-builder",
3 | "homepage": "https://github.com/dncrews/angular-elastic-builder",
4 | "authors": [
5 | "Dan Crews "
6 | ],
7 | "description": "Angular Module for building an Elasticsearch Query",
8 | "main": "dist/angular-elastic-builder.js",
9 | "keywords": [
10 | "elasticsearch",
11 | "angular"
12 | ],
13 | "license": "MIT",
14 | "ignore": [
15 | "**/.*",
16 | "node_modules",
17 | "bower_components",
18 | "test",
19 | "tests"
20 | ]
21 | }
22 |
--------------------------------------------------------------------------------
/dist/angular-elastic-builder.js:
--------------------------------------------------------------------------------
1 | /**
2 | * # angular-elastic-builder
3 | * ## Angular Module for building an Elasticsearch Query
4 | *
5 | * @version v1.5.0
6 | * @link https://github.com/dncrews/angular-elastic-builder.git
7 | * @license MIT
8 | * @author Dan Crews
9 | */
10 |
11 | /**
12 | * angular-elastic-builder
13 | *
14 | * /src/module.js
15 | *
16 | * Angular Module for building an Elasticsearch query
17 | */
18 |
19 | (function(angular) {
20 | 'use strict';
21 |
22 | angular.module('angular-elastic-builder', [
23 | 'RecursionHelper',
24 | 'ui.bootstrap',
25 | ]);
26 |
27 | })(window.angular);
28 |
29 | /**
30 | * angular-elastic-builder
31 | *
32 | * /src/directives/BuilderDirective.js
33 | *
34 | * Angular Directive for injecting a query builder form.
35 | */
36 |
37 | (function(angular) {
38 | 'use strict';
39 |
40 | angular.module('angular-elastic-builder')
41 | .directive('elasticBuilder', [
42 | 'elasticQueryService',
43 |
44 | function EB(elasticQueryService) {
45 |
46 | return {
47 | scope: {
48 | data: '=elasticBuilder',
49 | },
50 |
51 | templateUrl: 'angular-elastic-builder/BuilderDirective.html',
52 |
53 | link: function(scope) {
54 | var data = scope.data;
55 |
56 | scope.filters = [];
57 |
58 | /**
59 | * Removes either Group or Rule
60 | */
61 | scope.removeChild = function(idx) {
62 | scope.filters.splice(idx, 1);
63 | };
64 |
65 | /**
66 | * Adds a Single Rule
67 | */
68 | scope.addRule = function() {
69 | scope.filters.push({});
70 | };
71 |
72 | /**
73 | * Adds a Group of Rules
74 | */
75 | scope.addGroup = function() {
76 | scope.filters.push({
77 | type: 'group',
78 | subType: 'and',
79 | rules: [],
80 | });
81 | };
82 |
83 | /**
84 | * Any time "outside forces" change the query, they should tell us so via
85 | * `data.needsUpdate`
86 | */
87 | scope.$watch('data.needsUpdate', function(curr) {
88 | if (!curr) return;
89 |
90 | scope.filters = elasticQueryService.toFilters(data.query, scope.data.fields);
91 | scope.data.needsUpdate = false;
92 | });
93 |
94 | /**
95 | * Changes on the page update the Query
96 | */
97 | scope.$watch('filters', function(curr) {
98 | if (!curr) return;
99 |
100 | data.query = elasticQueryService.toQuery(scope.filters, scope.data.fields);
101 | }, true);
102 | },
103 | };
104 | },
105 |
106 | ]);
107 |
108 | })(window.angular);
109 |
110 | /**
111 | * angular-elastic-builder
112 | *
113 | * /src/directives/Chooser.js
114 | *
115 | * This file is to help recursively, to decide whether to show a group or rule
116 | */
117 |
118 | (function(angular) {
119 | 'use strict';
120 |
121 | var app = angular.module('angular-elastic-builder');
122 |
123 | app.directive('elasticBuilderChooser', [
124 | 'RecursionHelper',
125 | 'groupClassHelper',
126 |
127 | function elasticBuilderChooser(RH, groupClassHelper) {
128 |
129 | return {
130 | scope: {
131 | elasticFields: '=',
132 | item: '=elasticBuilderChooser',
133 | onRemove: '&',
134 | },
135 |
136 | templateUrl: 'angular-elastic-builder/ChooserDirective.html',
137 |
138 | compile: function (element) {
139 | return RH.compile(element, function(scope, el, attrs) {
140 | var depth = scope.depth = (+attrs.depth)
141 | , item = scope.item;
142 |
143 | scope.getGroupClassName = function() {
144 | var level = depth;
145 | if (item.type === 'group') level++;
146 |
147 | return groupClassHelper(level);
148 | };
149 | });
150 | },
151 | };
152 | },
153 |
154 | ]);
155 |
156 | })(window.angular);
157 |
158 | /**
159 | * angular-elastic-builder
160 | *
161 | * /src/directives/Group.js
162 | */
163 |
164 | (function(angular) {
165 | 'use strict';
166 |
167 | var app = angular.module('angular-elastic-builder');
168 |
169 | app.directive('elasticBuilderGroup', [
170 | 'RecursionHelper',
171 | 'groupClassHelper',
172 |
173 | function elasticBuilderGroup(RH, groupClassHelper) {
174 |
175 | return {
176 | scope: {
177 | elasticFields: '=',
178 | group: '=elasticBuilderGroup',
179 | onRemove: '&',
180 | },
181 |
182 | templateUrl: 'angular-elastic-builder/GroupDirective.html',
183 |
184 | compile: function(element) {
185 | return RH.compile(element, function(scope, el, attrs) {
186 | var depth = scope.depth = (+attrs.depth);
187 | var group = scope.group;
188 |
189 | scope.addRule = function() {
190 | group.rules.push({});
191 | };
192 | scope.addGroup = function() {
193 | group.rules.push({
194 | type: 'group',
195 | subType: 'and',
196 | rules: [],
197 | });
198 | };
199 |
200 | scope.removeChild = function(idx) {
201 | group.rules.splice(idx, 1);
202 | };
203 |
204 | scope.getGroupClassName = function() {
205 | return groupClassHelper(depth + 1);
206 | };
207 | });
208 | },
209 | };
210 | },
211 |
212 | ]);
213 |
214 | })(window.angular);
215 |
216 | /**
217 | * angular-elastic-builder
218 | *
219 | * /src/directives/Rule.js
220 | */
221 |
222 | (function(angular) {
223 | 'use strict';
224 |
225 | var app = angular.module('angular-elastic-builder');
226 |
227 | app.directive('elasticBuilderRule', [
228 |
229 | function elasticBuilderRule() {
230 | return {
231 | scope: {
232 | elasticFields: '=',
233 | rule: '=elasticBuilderRule',
234 | onRemove: '&',
235 | },
236 |
237 | templateUrl: 'angular-elastic-builder/RuleDirective.html',
238 |
239 | link: function(scope) {
240 | scope.getType = function() {
241 | var fields = scope.elasticFields
242 | , field = scope.rule.field;
243 |
244 | if (!fields || !field) return;
245 |
246 | if (fields[field].subType === 'boolean') return 'boolean';
247 |
248 | return fields[field].type;
249 | };
250 | },
251 | };
252 | },
253 |
254 | ]);
255 |
256 | })(window.angular);
257 |
258 | /**
259 | * angular-elastic-builder
260 | *
261 | * /src/directives/RuleTypes.js
262 | *
263 | * Determines which Rule type should be displayed
264 | */
265 |
266 | (function(angular) {
267 | 'use strict';
268 |
269 | var app = angular.module('angular-elastic-builder');
270 |
271 | app.directive('elasticType', [
272 |
273 | function() {
274 | return {
275 | scope: {
276 | type: '=elasticType',
277 | rule: '=',
278 | guide: '=',
279 | },
280 |
281 | template: '',
282 |
283 | link: function(scope) {
284 | scope.getTemplateUrl = function() {
285 | var type = scope.type;
286 | if (!type) return;
287 |
288 | type = type.charAt(0).toUpperCase() + type.slice(1);
289 |
290 | return 'angular-elastic-builder/types/' + type + '.html';
291 | };
292 |
293 | // This is a weird hack to make sure these are numbers
294 | scope.booleans = [ 'False', 'True' ];
295 | scope.booleansOrder = [ 'True', 'False' ];
296 |
297 | scope.inputNeeded = function() {
298 | var needs = [
299 | 'equals',
300 | 'notEquals',
301 |
302 | 'gt',
303 | 'gte',
304 | 'lt',
305 | 'lte',
306 | ];
307 |
308 | return ~needs.indexOf(scope.rule.subType);
309 | };
310 |
311 | scope.numberNeeded = function() {
312 | var needs = [
313 | 'last',
314 | 'next',
315 | ];
316 |
317 | return ~needs.indexOf(scope.rule.subType);
318 | };
319 |
320 | scope.today = function() {
321 | scope.rule.date = new Date();
322 | };
323 | scope.today();
324 |
325 | scope.clear = function() {
326 | scope.rule.date = null;
327 | };
328 |
329 | scope.dateOptions = {
330 | dateDisabled: disabled,
331 | formatYear: 'yy',
332 | maxDate: new Date(2018, 1, 13),
333 | minDate: new Date(),
334 | startingDay: 1,
335 | };
336 |
337 | // Disable weekend selection
338 | function disabled(data) {
339 | var date = data.date
340 | , mode = data.mode;
341 | return mode === 'day' && (date.getDay() === 0 || date.getDay() === 6);
342 | }
343 |
344 | scope.open1 = function() {
345 | scope.popup1.opened = true;
346 | };
347 |
348 | scope.setDate = function(year, month, day) {
349 | scope.rule.date = new Date(year, month - 1, day);
350 | };
351 |
352 | scope.formats = [
353 | 'yyyy-MM-ddTHH:mm:ss',
354 | 'yyyy-MM-ddTHH:mm:ssZ',
355 | 'yyyy-MM-dd',
356 | 'dd-MMMM-yyyy',
357 | 'yyyy/MM/dd',
358 | 'shortDate',
359 | ];
360 | scope.rule.dateFormat = scope.formats[0];
361 | scope.format = scope.rule.dateFormat;
362 |
363 | scope.altInputFormats = ['M!/d!/yyyy'];
364 |
365 | scope.popup1 = { opened: false };
366 | },
367 |
368 | };
369 | },
370 |
371 | ]);
372 |
373 | })(window.angular);
374 |
375 | /**
376 | * angular-elastic-builder
377 | *
378 | * /src/services/GroupClassHelper.js
379 | *
380 | * This keeps all of the groups colored correctly
381 | */
382 |
383 | (function(angular) {
384 | 'use strict';
385 |
386 | angular.module('angular-elastic-builder')
387 | .factory('groupClassHelper', function groupClassHelper() {
388 |
389 | return function(level) {
390 | var levels = [
391 | '',
392 | 'list-group-item-info',
393 | 'list-group-item-success',
394 | 'list-group-item-warning',
395 | 'list-group-item-danger',
396 | ];
397 |
398 | return levels[level % levels.length];
399 | };
400 | });
401 |
402 | })(window.angular);
403 |
404 | /**
405 | * angular-elastic-builder
406 | *
407 | * /src/services/QueryService.js
408 | *
409 | * This file is used to convert filters into queries, and vice versa
410 | */
411 |
412 | (function(angular) {
413 | 'use strict';
414 |
415 | angular.module('angular-elastic-builder')
416 | .factory('elasticQueryService', [
417 | '$filter',
418 |
419 | function($filter) {
420 |
421 | return {
422 | toFilters: toFilters,
423 | toQuery: function(filters, fieldMap) {
424 | return toQuery(filters, fieldMap, $filter);
425 | },
426 | };
427 | },
428 | ]);
429 |
430 | function toFilters(query, fieldMap){
431 | var filters = query.map(parseQueryGroup.bind(query, fieldMap));
432 | return filters;
433 | }
434 |
435 | function toQuery(filters, fieldMap, $filter){
436 | var query = filters.map(parseFilterGroup.bind(filters, fieldMap, $filter)).filter(function(item) {
437 | return !!item;
438 | });
439 | return query;
440 | }
441 |
442 | function parseQueryGroup(fieldMap, group, truthy) {
443 | if (truthy !== false) truthy = true;
444 |
445 | var key = Object.keys(group)[0]
446 | , typeMap = {
447 | or: 'group',
448 | and: 'group',
449 | range: 'number',
450 | }
451 | , type = typeMap[key] || 'item'
452 | , obj = getFilterTemplate(type);
453 |
454 | switch (key) {
455 | case 'or':
456 | case 'and':
457 | obj.rules = group[key].map(parseQueryGroup.bind(group, fieldMap));
458 | obj.subType = key;
459 | break;
460 | case 'missing':
461 | case 'exists':
462 | obj.field = group[key].field;
463 | obj.subType = {
464 | exists: 'exists',
465 | missing: 'notExists',
466 | }[key];
467 | delete obj.value;
468 | break;
469 | case 'term':
470 | case 'terms':
471 | obj.field = Object.keys(group[key])[0];
472 | var fieldData = fieldMap[Object.keys(group[key])[0]];
473 |
474 | if (fieldData.type === 'multi') {
475 | var vals = group[key][obj.field];
476 | if (typeof vals === 'string') vals = [ vals ];
477 | obj.values = fieldData.choices.reduce(function(prev, choice) {
478 | prev[choice] = truthy === (~group[key][obj.field].indexOf(choice));
479 | return prev;
480 | }, {});
481 | } else {
482 | obj.subType = truthy ? 'equals' : 'notEquals';
483 | obj.value = group[key][obj.field];
484 |
485 | if (typeof obj.value === 'number') {
486 | obj.subType = 'boolean';
487 | }
488 | }
489 | break;
490 | case 'range':
491 | var date, parts;
492 | obj.field = Object.keys(group[key])[0];
493 | obj.subType = Object.keys(group[key][obj.field])[0];
494 |
495 | if (angular.isNumber(group[key][obj.field][obj.subType])) {
496 | obj.value = group[key][obj.field][obj.subType];
497 | break;
498 | }
499 |
500 | if (angular.isDefined(Object.keys(group[key][obj.field])[1])) {
501 | date = group[key][obj.field].gte;
502 |
503 | if (~date.indexOf('now-')) {
504 | obj.subType = 'last';
505 | obj.value = parseInt(date.split('now-')[1].split('d')[0]);
506 | break;
507 | }
508 |
509 | if (~date.indexOf('now')) {
510 | obj.subType = 'next';
511 | date = group[key][obj.field].lte;
512 | obj.value = parseInt(date.split('now+')[1].split('d')[0]);
513 | break;
514 | }
515 |
516 | obj.subType = 'equals';
517 | parts = date.split('T')[0].split('-');
518 | obj.date = parts[2] + '/' + parts[1] + '/' + parts[0];
519 | break;
520 | }
521 |
522 | date = group[key][obj.field][obj.subType];
523 | parts = date.split('T')[0].split('-');
524 | obj.date = parts[2] + '/' + parts[1] + '/' + parts[0];
525 | break;
526 |
527 | case 'not':
528 | obj = parseQueryGroup(fieldMap, group[key].filter, false);
529 | break;
530 | default:
531 | obj.field = Object.keys(group[key])[0];
532 | break;
533 | }
534 |
535 | return obj;
536 | }
537 |
538 | function parseFilterGroup(fieldMap, $filter, group) {
539 | var obj = {};
540 | if (group.type === 'group') {
541 | obj[group.subType] = group.rules.map(parseFilterGroup.bind(group, fieldMap, $filter)).filter(function(item) {
542 | return !!item;
543 | });
544 | return obj;
545 | }
546 |
547 | var fieldName = group.field;
548 | var fieldData = fieldMap[fieldName];
549 |
550 |
551 | if (!fieldName) return;
552 |
553 | switch (fieldData.type) {
554 | case 'term':
555 | if (fieldData.subType === 'boolean') group.subType = 'boolean';
556 |
557 | if (!group.subType) return;
558 | switch (group.subType) {
559 | case 'equals':
560 | case 'boolean':
561 | if (group.value === undefined) return;
562 | obj.term = {};
563 | obj.term[fieldName] = group.value;
564 | break;
565 | case 'notEquals':
566 | if (group.value === undefined) return;
567 | obj.not = { filter: { term: {}}};
568 | obj.not.filter.term[fieldName] = group.value;
569 | break;
570 | case 'exists':
571 | obj.exists = { field: fieldName };
572 | break;
573 | case 'notExists':
574 | obj.missing = { field: fieldName };
575 | break;
576 | default:
577 | throw new Error('unexpected subtype ' + group.subType);
578 | }
579 | break;
580 |
581 | case 'number':
582 | obj.range = {};
583 | obj.range[fieldName] = {};
584 | obj.range[fieldName][group.subType] = group.value;
585 | break;
586 |
587 | case 'date':
588 | if (!group.subType) return;
589 |
590 | switch (group.subType) {
591 | case 'equals':
592 | if (!angular.isDate(group.date)) return;
593 | obj.term = {};
594 | obj.term[fieldName] = formatDate($filter, group.date, group.dateFormat);
595 | break;
596 | case 'lt':
597 | case 'lte':
598 | if (!angular.isDate(group.date)) return;
599 | obj.range = {};
600 | obj.range[fieldName] = {};
601 | obj.range[fieldName][group.subType] = formatDate($filter, group.date, group.dateFormat);
602 | break;
603 | case 'gt':
604 | case 'gte':
605 | if (!angular.isDate(group.date)) return;
606 | obj.range = {};
607 | obj.range[fieldName] = {};
608 | obj.range[fieldName][group.subType] = formatDate($filter, group.date, group.dateFormat);
609 | break;
610 | case 'last':
611 | if (!angular.isNumber(group.value)) return;
612 | obj.range = {};
613 | obj.range[fieldName] = {};
614 | obj.range[fieldName].gte = 'now-' + group.value + 'd';
615 | obj.range[fieldName].lte = 'now';
616 | break;
617 | case 'next':
618 | if (!angular.isNumber(group.value)) return;
619 | obj.range = {};
620 | obj.range[fieldName] = {};
621 | obj.range[fieldName].gte = 'now';
622 | obj.range[fieldName].lte = 'now+' + group.value + 'd';
623 | break;
624 | case 'exists':
625 | obj.exists = { field: fieldName };
626 | break;
627 | case 'notExists':
628 | obj.missing = { field: fieldName };
629 | break;
630 | default:
631 | throw new Error('unexpected subtype ' + group.subType);
632 | }
633 | break;
634 |
635 | case 'multi':
636 | obj.terms = {};
637 | obj.terms[fieldName] = Object.keys(group.values || {}).reduce(function(prev, key) {
638 | if (group.values[key]) prev.push(key);
639 |
640 | return prev;
641 | }, []);
642 | break;
643 |
644 | default:
645 | throw new Error('unexpected type');
646 | }
647 |
648 | return obj;
649 | }
650 |
651 | function getFilterTemplate(type) {
652 | var templates = {
653 | group: {
654 | type: 'group',
655 | subType: '',
656 | rules: [],
657 | },
658 | item: {
659 | field: '',
660 | subType: '',
661 | value: '',
662 | },
663 | number: {
664 | field: '',
665 | subType: '',
666 | value: null,
667 | },
668 | };
669 |
670 | return angular.copy(templates[type]);
671 | }
672 |
673 | function formatDate($filter, date, dateFormat) {
674 | if (!angular.isDate(date)) return false;
675 | var fDate = $filter('date')(date, dateFormat);
676 | return fDate;
677 | }
678 |
679 | })(window.angular);
680 |
681 | (function(angular) {"use strict"; angular.module("angular-elastic-builder").run(["$templateCache", function($templateCache) {$templateCache.put("angular-elastic-builder/BuilderDirective.html","\n");
682 | $templateCache.put("angular-elastic-builder/ChooserDirective.html","\n");
683 | $templateCache.put("angular-elastic-builder/GroupDirective.html","\n
If\n \n of these conditions are met\n
\n
\n\n
\n\n
\n \n \n
\n");
684 | $templateCache.put("angular-elastic-builder/RuleDirective.html","\n");
685 | $templateCache.put("angular-elastic-builder/types/Boolean.html","\n Equals\n\n \n \n\n");
686 | $templateCache.put("angular-elastic-builder/types/Date.html","\n \n\n \n\n \n \n \n \n
\n \n\n \n days\n \n\n\n");
687 | $templateCache.put("angular-elastic-builder/types/Multi.html","\n \n \n \n\n");
688 | $templateCache.put("angular-elastic-builder/types/Number.html","\n \n\n \n \n\n");
689 | $templateCache.put("angular-elastic-builder/types/Term.html","\n \n \n\n");}]);})(window.angular);
--------------------------------------------------------------------------------
/dist/angular-elastic-builder.min.js:
--------------------------------------------------------------------------------
1 | !function(e){"use strict";e.module("angular-elastic-builder",["RecursionHelper","ui.bootstrap"])}(window.angular),function(e){"use strict";e.module("angular-elastic-builder").directive("elasticBuilder",["elasticQueryService",function(e){return{scope:{data:"=elasticBuilder"},templateUrl:"angular-elastic-builder/BuilderDirective.html",link:function(t){var n=t.data;t.filters=[],t.removeChild=function(e){t.filters.splice(e,1)},t.addRule=function(){t.filters.push({})},t.addGroup=function(){t.filters.push({type:"group",subType:"and",rules:[]})},t.$watch("data.needsUpdate",function(a){a&&(t.filters=e.toFilters(n.query,t.data.fields),t.data.needsUpdate=!1)}),t.$watch("filters",function(a){a&&(n.query=e.toQuery(t.filters,t.data.fields))},!0)}}}])}(window.angular),function(e){"use strict";var t=e.module("angular-elastic-builder");t.directive("elasticBuilderChooser",["RecursionHelper","groupClassHelper",function(e,t){return{scope:{elasticFields:"=",item:"=elasticBuilderChooser",onRemove:"&"},templateUrl:"angular-elastic-builder/ChooserDirective.html",compile:function(n){return e.compile(n,function(e,n,a){var i=e.depth=+a.depth,l=e.item;e.getGroupClassName=function(){var e=i;return"group"===l.type&&e++,t(e)}})}}}])}(window.angular),function(e){"use strict";var t=e.module("angular-elastic-builder");t.directive("elasticBuilderGroup",["RecursionHelper","groupClassHelper",function(e,t){return{scope:{elasticFields:"=",group:"=elasticBuilderGroup",onRemove:"&"},templateUrl:"angular-elastic-builder/GroupDirective.html",compile:function(n){return e.compile(n,function(e,n,a){var i=e.depth=+a.depth,l=e.group;e.addRule=function(){l.rules.push({})},e.addGroup=function(){l.rules.push({type:"group",subType:"and",rules:[]})},e.removeChild=function(e){l.rules.splice(e,1)},e.getGroupClassName=function(){return t(i+1)}})}}}])}(window.angular),function(e){"use strict";var t=e.module("angular-elastic-builder");t.directive("elasticBuilderRule",[function(){return{scope:{elasticFields:"=",rule:"=elasticBuilderRule",onRemove:"&"},templateUrl:"angular-elastic-builder/RuleDirective.html",link:function(e){e.getType=function(){var t=e.elasticFields,n=e.rule.field;if(t&&n)return"boolean"===t[n].subType?"boolean":t[n].type}}}}])}(window.angular),function(e){"use strict";var t=e.module("angular-elastic-builder");t.directive("elasticType",[function(){return{scope:{type:"=elasticType",rule:"=",guide:"="},template:'',link:function(e){function t(e){var t=e.date,n=e.mode;return"day"===n&&(0===t.getDay()||6===t.getDay())}e.getTemplateUrl=function(){var t=e.type;if(t)return t=t.charAt(0).toUpperCase()+t.slice(1),"angular-elastic-builder/types/"+t+".html"},e.booleans=["False","True"],e.booleansOrder=["True","False"],e.inputNeeded=function(){var t=["equals","notEquals","gt","gte","lt","lte"];return~t.indexOf(e.rule.subType)},e.numberNeeded=function(){var t=["last","next"];return~t.indexOf(e.rule.subType)},e.today=function(){e.rule.date=new Date},e.today(),e.clear=function(){e.rule.date=null},e.dateOptions={dateDisabled:t,formatYear:"yy",maxDate:new Date(2018,1,13),minDate:new Date,startingDay:1},e.open1=function(){e.popup1.opened=!0},e.setDate=function(t,n,a){e.rule.date=new Date(t,n-1,a)},e.formats=["yyyy-MM-ddTHH:mm:ss","yyyy-MM-ddTHH:mm:ssZ","yyyy-MM-dd","dd-MMMM-yyyy","yyyy/MM/dd","shortDate"],e.rule.dateFormat=e.formats[0],e.format=e.rule.dateFormat,e.altInputFormats=["M!/d!/yyyy"],e.popup1={opened:!1}}}}])}(window.angular),function(e){"use strict";e.module("angular-elastic-builder").factory("groupClassHelper",function(){return function(e){var t=["","list-group-item-info","list-group-item-success","list-group-item-warning","list-group-item-danger"];return t[e%t.length]}})}(window.angular),function(e){"use strict";function t(e,t){var n=e.map(a.bind(e,t));return n}function n(e,t,n){var a=e.map(i.bind(e,t,n)).filter(function(e){return!!e});return a}function a(t,n,i){i!==!1&&(i=!0);var r=Object.keys(n)[0],s={or:"group",and:"group",range:"number"},u=s[r]||"item",o=l(u);switch(r){case"or":case"and":o.rules=n[r].map(a.bind(n,t)),o.subType=r;break;case"missing":case"exists":o.field=n[r].field,o.subType={exists:"exists",missing:"notExists"}[r],delete o.value;break;case"term":case"terms":o.field=Object.keys(n[r])[0];var d=t[Object.keys(n[r])[0]];if("multi"===d.type){var p=n[r][o.field];"string"==typeof p&&(p=[p]),o.values=d.choices.reduce(function(e,t){return e[t]=i===~n[r][o.field].indexOf(t),e},{})}else o.subType=i?"equals":"notEquals",o.value=n[r][o.field],"number"==typeof o.value&&(o.subType="boolean");break;case"range":var c,f;if(o.field=Object.keys(n[r])[0],o.subType=Object.keys(n[r][o.field])[0],e.isNumber(n[r][o.field][o.subType])){o.value=n[r][o.field][o.subType];break}if(e.isDefined(Object.keys(n[r][o.field])[1])){if(c=n[r][o.field].gte,~c.indexOf("now-")){o.subType="last",o.value=parseInt(c.split("now-")[1].split("d")[0]);break}if(~c.indexOf("now")){o.subType="next",c=n[r][o.field].lte,o.value=parseInt(c.split("now+")[1].split("d")[0]);break}o.subType="equals",f=c.split("T")[0].split("-"),o.date=f[2]+"/"+f[1]+"/"+f[0];break}c=n[r][o.field][o.subType],f=c.split("T")[0].split("-"),o.date=f[2]+"/"+f[1]+"/"+f[0];break;case"not":o=a(t,n[r].filter,!1);break;default:o.field=Object.keys(n[r])[0]}return o}function i(t,n,a){var l={};if("group"===a.type)return l[a.subType]=a.rules.map(i.bind(a,t,n)).filter(function(e){return!!e}),l;var s=a.field,u=t[s];if(s){switch(u.type){case"term":if("boolean"===u.subType&&(a.subType="boolean"),!a.subType)return;switch(a.subType){case"equals":case"boolean":if(void 0===a.value)return;l.term={},l.term[s]=a.value;break;case"notEquals":if(void 0===a.value)return;l.not={filter:{term:{}}},l.not.filter.term[s]=a.value;break;case"exists":l.exists={field:s};break;case"notExists":l.missing={field:s};break;default:throw new Error("unexpected subtype "+a.subType)}break;case"number":l.range={},l.range[s]={},l.range[s][a.subType]=a.value;break;case"date":if(!a.subType)return;switch(a.subType){case"equals":if(!e.isDate(a.date))return;l.term={},l.term[s]=r(n,a.date,a.dateFormat);break;case"lt":case"lte":if(!e.isDate(a.date))return;l.range={},l.range[s]={},l.range[s][a.subType]=r(n,a.date,a.dateFormat);break;case"gt":case"gte":if(!e.isDate(a.date))return;l.range={},l.range[s]={},l.range[s][a.subType]=r(n,a.date,a.dateFormat);break;case"last":if(!e.isNumber(a.value))return;l.range={},l.range[s]={},l.range[s].gte="now-"+a.value+"d",l.range[s].lte="now";break;case"next":if(!e.isNumber(a.value))return;l.range={},l.range[s]={},l.range[s].gte="now",l.range[s].lte="now+"+a.value+"d";break;case"exists":l.exists={field:s};break;case"notExists":l.missing={field:s};break;default:throw new Error("unexpected subtype "+a.subType)}break;case"multi":l.terms={},l.terms[s]=Object.keys(a.values||{}).reduce(function(e,t){return a.values[t]&&e.push(t),e},[]);break;default:throw new Error("unexpected type")}return l}}function l(t){var n={group:{type:"group",subType:"",rules:[]},item:{field:"",subType:"",value:""},number:{field:"",subType:"",value:null}};return e.copy(n[t])}function r(t,n,a){if(!e.isDate(n))return!1;var i=t("date")(n,a);return i}e.module("angular-elastic-builder").factory("elasticQueryService",["$filter",function(e){return{toFilters:t,toQuery:function(t,a){return n(t,a,e)}}}])}(window.angular),function(e){"use strict";e.module("angular-elastic-builder").run(["$templateCache",function(e){e.put("angular-elastic-builder/BuilderDirective.html",'\n'),e.put("angular-elastic-builder/ChooserDirective.html",'\n'),e.put("angular-elastic-builder/GroupDirective.html",'\n
If\n \n of these conditions are met\n
\n
\n\n
\n\n
\n \n \n
\n'),e.put("angular-elastic-builder/RuleDirective.html",'\n'),e.put("angular-elastic-builder/types/Boolean.html",'\n Equals\n\n \n \n\n'),e.put("angular-elastic-builder/types/Date.html",'\n \n\n \n\n \n \n \n \n
\n \n\n \n days\n \n\n\n'),e.put("angular-elastic-builder/types/Multi.html",'\n \n \n \n\n'),e.put("angular-elastic-builder/types/Number.html",'\n \n\n \n \n\n'),e.put("angular-elastic-builder/types/Term.html",'\n \n \n\n')}])}(window.angular);
--------------------------------------------------------------------------------
/examples/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Angular Elastic Builder
5 |
6 |
7 |
8 |
9 |
10 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/index.js:
--------------------------------------------------------------------------------
1 | var path = require('path');
2 | var express = require('express');
3 |
4 | var app = express();
5 |
6 | app.use(express.static(__dirname));
7 | app.use('/js', express.static(path.join(__dirname, '../dist')));
8 | app.use('/angular-recursion', express.static(path.join(__dirname, '../node_modules/angular-recursion')));
9 | app.use('/angular-ui-bootstrap', express.static(path.join(__dirname, '../node_modules/angular-ui-bootstrap/dist')));
10 |
11 | app.listen(process.env.PORT || 3000, function() {
12 | console.log('listening on ' + ( process.env.PORT || 3000));
13 | });
14 |
--------------------------------------------------------------------------------
/examples/js/exampleApp.js:
--------------------------------------------------------------------------------
1 | (function(angular) {
2 |
3 | var app = angular.module('exampleApp', [
4 | 'angular-elastic-builder',
5 | ]);
6 |
7 | app.controller('BasicController', function() {
8 |
9 | var data = this.data = {};
10 |
11 | data.query = [
12 | {
13 | 'and': [
14 | {
15 | 'term': {
16 | 'test.date': '2016-04-08T09:16:48'
17 | }
18 | },
19 | {
20 | 'range': {
21 | 'test.number': {
22 | 'gte': 650
23 | }
24 | }
25 | },
26 | {
27 | 'range': {
28 | 'test.number': {
29 | 'lt': 850
30 | }
31 | }
32 | }
33 | ]
34 | },
35 | {
36 | 'term': {
37 | 'test.boolean': 0
38 | }
39 | },
40 | {
41 | 'terms': {
42 | 'test.state.multi': [ 'AZ', 'CT' ]
43 | }
44 | },
45 | {
46 | 'not': {
47 | 'filter': {
48 | 'term': {
49 | 'test.term': 'asdfasdf'
50 | }
51 | }
52 | }
53 | },
54 | {
55 | 'exists': {
56 | 'field': 'test.term'
57 | }
58 | },
59 | {
60 | 'range': {
61 | 'test.otherdate': {
62 | 'gte': 'now',
63 | 'lte': 'now+7d'
64 | }
65 | }
66 | }
67 | ];
68 |
69 | data.fields = {
70 | 'test.number': { type: 'number', minimum: 650 },
71 | 'test.term': { type: 'term' },
72 | 'test.boolean': { type: 'term', subType: 'boolean' },
73 | 'test.state.multi': { type: 'multi', choices: [ 'AZ', 'CA', 'CT' ]},
74 | 'test.date': { type: 'date' },
75 | 'test.otherdate': { type: 'date' }
76 | };
77 |
78 | data.needsUpdate = true;
79 |
80 | this.showQuery = function() {
81 | var queryToShow = {
82 | size: 0,
83 | filter: { and : data.query }
84 | };
85 |
86 | return JSON.stringify(queryToShow, null, 2);
87 | };
88 |
89 | });
90 |
91 | })(window.angular);
92 |
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Package Dependencies
3 | */
4 | var concat = require('gulp-concat')
5 | , del = require('del')
6 | , header = require('gulp-header')
7 | , gulp = require('gulp')
8 | , templateCache = require('gulp-angular-templatecache')
9 | , rename = require('gulp-rename')
10 | , uglify = require('gulp-uglifyjs')
11 | , util = require('util')
12 | , eslint = require('gulp-eslint');
13 |
14 | /**
15 | * Local Dependencies
16 | */
17 | var pkg = require('./package.json');
18 | var banner = ['/**'
19 | , ' * # <%= pkg.name %>'
20 | , ' * ## <%= pkg.description %>'
21 | , ' *'
22 | , ' * @version v<%= pkg.version %>'
23 | , ' * @link <%= pkg.repository.url %>'
24 | , ' * @license <%= pkg.license %>'
25 | , ' * @author <%= pkg.author %>'
26 | , ' */'
27 | , ''
28 | , ''].join('\n');
29 |
30 | var filename = util.format('%s.js', pkg.name)
31 | , dest = 'dist/' + filename;
32 |
33 | gulp.task('build', ['uglify']);
34 | gulp.task('default', ['uglify']);
35 |
36 |
37 | gulp.task('clean', function(done) {
38 | del('./dist', done);
39 | });
40 |
41 | gulp.task('concat', [ 'templatecache' ], function() {
42 | return gulp.src(['./src/module.js', './src/**/*.js'])
43 | .pipe(concat(filename))
44 | .pipe(gulp.dest('./dist'));
45 | });
46 |
47 | gulp.task('header', [ 'concat' ], function() {
48 | return gulp.src('./dist/*.js')
49 | .pipe(header(banner, { pkg: pkg }))
50 | .pipe(gulp.dest('./dist'));
51 | });
52 |
53 | gulp.task('uglify', [ 'header' ], function() {
54 | return gulp.src('./dist/*.js')
55 | .pipe(uglify(dest.replace(/\.js$/, '.min.js')))
56 | .pipe(gulp.dest('./'));
57 | });
58 |
59 | gulp.task('templatecache', [ 'clean' ], function() {
60 | var TEMPLATE_HEADER = '(function(angular) {"use strict"; angular.module("<%= module %>"<%= standalone %>).run(["$templateCache", function($templateCache) {'
61 | , TEMPLATE_FOOTER = '}]);})(window.angular);';
62 |
63 | return gulp.src('src/tmpl/**/*.html')
64 | .pipe(templateCache({
65 | root: 'angular-elastic-builder',
66 | module: 'angular-elastic-builder',
67 | templateHeader: TEMPLATE_HEADER,
68 | templateFooter: TEMPLATE_FOOTER,
69 | }))
70 | .pipe(rename('ElasticBuilderTemplates.js'))
71 | .pipe(gulp.dest('src/tmpl'));
72 | });
73 |
74 | gulp.task('lint', function() {
75 | return gulp.src([
76 | 'src/**/**.js',
77 | '!src/tmpl/ElasticBuilderTemplates.js',
78 | ])
79 | .pipe(eslint())
80 | .pipe(eslint.format())
81 | .pipe(eslint.failAfterError());
82 | });
83 |
84 | gulp.task('watch', [ 'templatecache', 'build' ], function() {
85 | gulp.watch('src/tmpl/**/*.html', [ 'templatecache', 'build' ]);
86 | gulp.watch(['src/**/**.js','!src/tmpl/ElasticBuilderTemplates.js'], [ 'build' ]);
87 | });
88 |
89 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-elastic-builder",
3 | "version": "1.5.1",
4 | "description": "Angular Module for building an Elasticsearch Query",
5 | "author": "Dan Crews ",
6 | "license": "MIT",
7 | "keywords": [
8 | "angular",
9 | "elasticsearch"
10 | ],
11 | "repository": {
12 | "type": "git",
13 | "url": "https://github.com/dncrews/angular-elastic-builder.git"
14 | },
15 | "devDependencies": {
16 | "angular-recursion": "^1.0.5",
17 | "angular-ui-bootstrap": "^1.2.5",
18 | "del": "^1.2.1",
19 | "eslint": "^2.7.0",
20 | "express": "^4.13.4",
21 | "gulp": "^3.9.1",
22 | "gulp-angular-templatecache": "^1.6.0",
23 | "gulp-concat": "^2.6.0",
24 | "gulp-eslint": "^2.0.0",
25 | "gulp-header": "^1.2.2",
26 | "gulp-rename": "^1.2.2",
27 | "gulp-uglifyjs": "^0.6.1"
28 | },
29 | "scripts": {
30 | "example": "node examples",
31 | "test": "echo \"Error: no test specified\" && exit 1",
32 | "gulp": "gulp"
33 | },
34 | "dependencies": {}
35 | }
36 |
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dncrews/angular-elastic-builder/923822b8ad7ca762e6124dd247050b1b8f2f0d90/screenshot.png
--------------------------------------------------------------------------------
/src/directives/BuilderDirective.js:
--------------------------------------------------------------------------------
1 | /**
2 | * angular-elastic-builder
3 | *
4 | * /src/directives/BuilderDirective.js
5 | *
6 | * Angular Directive for injecting a query builder form.
7 | */
8 |
9 | (function(angular) {
10 | 'use strict';
11 |
12 | angular.module('angular-elastic-builder')
13 | .directive('elasticBuilder', [
14 | 'elasticQueryService',
15 |
16 | function EB(elasticQueryService) {
17 |
18 | return {
19 | scope: {
20 | data: '=elasticBuilder',
21 | },
22 |
23 | templateUrl: 'angular-elastic-builder/BuilderDirective.html',
24 |
25 | link: function(scope) {
26 | var data = scope.data;
27 |
28 | scope.filters = [];
29 |
30 | /**
31 | * Removes either Group or Rule
32 | */
33 | scope.removeChild = function(idx) {
34 | scope.filters.splice(idx, 1);
35 | };
36 |
37 | /**
38 | * Adds a Single Rule
39 | */
40 | scope.addRule = function() {
41 | scope.filters.push({});
42 | };
43 |
44 | /**
45 | * Adds a Group of Rules
46 | */
47 | scope.addGroup = function() {
48 | scope.filters.push({
49 | type: 'group',
50 | subType: 'and',
51 | rules: [],
52 | });
53 | };
54 |
55 | /**
56 | * Any time "outside forces" change the query, they should tell us so via
57 | * `data.needsUpdate`
58 | */
59 | scope.$watch('data.needsUpdate', function(curr) {
60 | if (!curr) return;
61 |
62 | scope.filters = elasticQueryService.toFilters(data.query, scope.data.fields);
63 | scope.data.needsUpdate = false;
64 | });
65 |
66 | /**
67 | * Changes on the page update the Query
68 | */
69 | scope.$watch('filters', function(curr) {
70 | if (!curr) return;
71 |
72 | data.query = elasticQueryService.toQuery(scope.filters, scope.data.fields);
73 | }, true);
74 | },
75 | };
76 | },
77 |
78 | ]);
79 |
80 | })(window.angular);
81 |
--------------------------------------------------------------------------------
/src/directives/Chooser.js:
--------------------------------------------------------------------------------
1 | /**
2 | * angular-elastic-builder
3 | *
4 | * /src/directives/Chooser.js
5 | *
6 | * This file is to help recursively, to decide whether to show a group or rule
7 | */
8 |
9 | (function(angular) {
10 | 'use strict';
11 |
12 | var app = angular.module('angular-elastic-builder');
13 |
14 | app.directive('elasticBuilderChooser', [
15 | 'RecursionHelper',
16 | 'groupClassHelper',
17 |
18 | function elasticBuilderChooser(RH, groupClassHelper) {
19 |
20 | return {
21 | scope: {
22 | elasticFields: '=',
23 | item: '=elasticBuilderChooser',
24 | onRemove: '&',
25 | },
26 |
27 | templateUrl: 'angular-elastic-builder/ChooserDirective.html',
28 |
29 | compile: function (element) {
30 | return RH.compile(element, function(scope, el, attrs) {
31 | var depth = scope.depth = (+attrs.depth)
32 | , item = scope.item;
33 |
34 | scope.getGroupClassName = function() {
35 | var level = depth;
36 | if (item.type === 'group') level++;
37 |
38 | return groupClassHelper(level);
39 | };
40 | });
41 | },
42 | };
43 | },
44 |
45 | ]);
46 |
47 | })(window.angular);
48 |
--------------------------------------------------------------------------------
/src/directives/Group.js:
--------------------------------------------------------------------------------
1 | /**
2 | * angular-elastic-builder
3 | *
4 | * /src/directives/Group.js
5 | */
6 |
7 | (function(angular) {
8 | 'use strict';
9 |
10 | var app = angular.module('angular-elastic-builder');
11 |
12 | app.directive('elasticBuilderGroup', [
13 | 'RecursionHelper',
14 | 'groupClassHelper',
15 |
16 | function elasticBuilderGroup(RH, groupClassHelper) {
17 |
18 | return {
19 | scope: {
20 | elasticFields: '=',
21 | group: '=elasticBuilderGroup',
22 | onRemove: '&',
23 | },
24 |
25 | templateUrl: 'angular-elastic-builder/GroupDirective.html',
26 |
27 | compile: function(element) {
28 | return RH.compile(element, function(scope, el, attrs) {
29 | var depth = scope.depth = (+attrs.depth);
30 | var group = scope.group;
31 |
32 | scope.addRule = function() {
33 | group.rules.push({});
34 | };
35 | scope.addGroup = function() {
36 | group.rules.push({
37 | type: 'group',
38 | subType: 'and',
39 | rules: [],
40 | });
41 | };
42 |
43 | scope.removeChild = function(idx) {
44 | group.rules.splice(idx, 1);
45 | };
46 |
47 | scope.getGroupClassName = function() {
48 | return groupClassHelper(depth + 1);
49 | };
50 | });
51 | },
52 | };
53 | },
54 |
55 | ]);
56 |
57 | })(window.angular);
58 |
--------------------------------------------------------------------------------
/src/directives/Rule.js:
--------------------------------------------------------------------------------
1 | /**
2 | * angular-elastic-builder
3 | *
4 | * /src/directives/Rule.js
5 | */
6 |
7 | (function(angular) {
8 | 'use strict';
9 |
10 | var app = angular.module('angular-elastic-builder');
11 |
12 | app.directive('elasticBuilderRule', [
13 |
14 | function elasticBuilderRule() {
15 | return {
16 | scope: {
17 | elasticFields: '=',
18 | rule: '=elasticBuilderRule',
19 | onRemove: '&',
20 | },
21 |
22 | templateUrl: 'angular-elastic-builder/RuleDirective.html',
23 |
24 | link: function(scope) {
25 | scope.getType = function() {
26 | var fields = scope.elasticFields
27 | , field = scope.rule.field;
28 |
29 | if (!fields || !field) return;
30 |
31 | if (fields[field].subType === 'boolean') return 'boolean';
32 |
33 | return fields[field].type;
34 | };
35 | },
36 | };
37 | },
38 |
39 | ]);
40 |
41 | })(window.angular);
42 |
--------------------------------------------------------------------------------
/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: '',
25 |
26 | link: function(scope) {
27 | scope.getTemplateUrl = function() {
28 | var type = scope.type;
29 | if (!type) return;
30 |
31 | type = type.charAt(0).toUpperCase() + type.slice(1);
32 |
33 | return 'angular-elastic-builder/types/' + type + '.html';
34 | };
35 |
36 | // This is a weird hack to make sure these are numbers
37 | scope.booleans = [ 'False', 'True' ];
38 | scope.booleansOrder = [ 'True', 'False' ];
39 |
40 | scope.inputNeeded = function() {
41 | var needs = [
42 | 'equals',
43 | 'notEquals',
44 |
45 | 'gt',
46 | 'gte',
47 | 'lt',
48 | 'lte',
49 | ];
50 |
51 | return ~needs.indexOf(scope.rule.subType);
52 | };
53 |
54 | scope.numberNeeded = function() {
55 | var needs = [
56 | 'last',
57 | 'next',
58 | ];
59 |
60 | return ~needs.indexOf(scope.rule.subType);
61 | };
62 |
63 | scope.today = function() {
64 | scope.rule.date = new Date();
65 | };
66 | scope.today();
67 |
68 | scope.clear = function() {
69 | scope.rule.date = null;
70 | };
71 |
72 | scope.dateOptions = {
73 | dateDisabled: disabled,
74 | formatYear: 'yy',
75 | maxDate: new Date(2018, 1, 13),
76 | minDate: new Date(),
77 | startingDay: 1,
78 | };
79 |
80 | // Disable weekend selection
81 | function disabled(data) {
82 | var date = data.date
83 | , mode = data.mode;
84 | return mode === 'day' && (date.getDay() === 0 || date.getDay() === 6);
85 | }
86 |
87 | scope.open1 = function() {
88 | scope.popup1.opened = true;
89 | };
90 |
91 | scope.setDate = function(year, month, day) {
92 | scope.rule.date = new Date(year, month - 1, day);
93 | };
94 |
95 | scope.formats = [
96 | 'yyyy-MM-ddTHH:mm:ss',
97 | 'yyyy-MM-ddTHH:mm:ssZ',
98 | 'yyyy-MM-dd',
99 | 'dd-MMMM-yyyy',
100 | 'yyyy/MM/dd',
101 | 'shortDate',
102 | ];
103 | scope.rule.dateFormat = scope.formats[0];
104 | scope.format = scope.rule.dateFormat;
105 |
106 | scope.altInputFormats = ['M!/d!/yyyy'];
107 |
108 | scope.popup1 = { opened: false };
109 | },
110 |
111 | };
112 | },
113 |
114 | ]);
115 |
116 | })(window.angular);
117 |
--------------------------------------------------------------------------------
/src/module.js:
--------------------------------------------------------------------------------
1 | /**
2 | * angular-elastic-builder
3 | *
4 | * /src/module.js
5 | *
6 | * Angular Module for building an Elasticsearch query
7 | */
8 |
9 | (function(angular) {
10 | 'use strict';
11 |
12 | angular.module('angular-elastic-builder', [
13 | 'RecursionHelper',
14 | 'ui.bootstrap',
15 | ]);
16 |
17 | })(window.angular);
18 |
--------------------------------------------------------------------------------
/src/services/GroupClassHelper.js:
--------------------------------------------------------------------------------
1 | /**
2 | * angular-elastic-builder
3 | *
4 | * /src/services/GroupClassHelper.js
5 | *
6 | * This keeps all of the groups colored correctly
7 | */
8 |
9 | (function(angular) {
10 | 'use strict';
11 |
12 | angular.module('angular-elastic-builder')
13 | .factory('groupClassHelper', function groupClassHelper() {
14 |
15 | return function(level) {
16 | var levels = [
17 | '',
18 | 'list-group-item-info',
19 | 'list-group-item-success',
20 | 'list-group-item-warning',
21 | 'list-group-item-danger',
22 | ];
23 |
24 | return levels[level % levels.length];
25 | };
26 | });
27 |
28 | })(window.angular);
29 |
--------------------------------------------------------------------------------
/src/services/QueryService.js:
--------------------------------------------------------------------------------
1 | /**
2 | * angular-elastic-builder
3 | *
4 | * /src/services/QueryService.js
5 | *
6 | * This file is used to convert filters into queries, and vice versa
7 | */
8 |
9 | (function(angular) {
10 | 'use strict';
11 |
12 | angular.module('angular-elastic-builder')
13 | .factory('elasticQueryService', [
14 | '$filter',
15 |
16 | function($filter) {
17 |
18 | return {
19 | toFilters: toFilters,
20 | toQuery: function(filters, fieldMap) {
21 | return toQuery(filters, fieldMap, $filter);
22 | },
23 | };
24 | },
25 | ]);
26 |
27 | function toFilters(query, fieldMap){
28 | var filters = query.map(parseQueryGroup.bind(query, fieldMap));
29 | return filters;
30 | }
31 |
32 | function toQuery(filters, fieldMap, $filter){
33 | var query = filters.map(parseFilterGroup.bind(filters, fieldMap, $filter)).filter(function(item) {
34 | return !!item;
35 | });
36 | return query;
37 | }
38 |
39 | function parseQueryGroup(fieldMap, group, truthy) {
40 | if (truthy !== false) truthy = true;
41 |
42 | var key = Object.keys(group)[0]
43 | , typeMap = {
44 | or: 'group',
45 | and: 'group',
46 | range: 'number',
47 | }
48 | , type = typeMap[key] || 'item'
49 | , obj = getFilterTemplate(type);
50 |
51 | switch (key) {
52 | case 'or':
53 | case 'and':
54 | obj.rules = group[key].map(parseQueryGroup.bind(group, fieldMap));
55 | obj.subType = key;
56 | break;
57 | case 'missing':
58 | case 'exists':
59 | obj.field = group[key].field;
60 | obj.subType = {
61 | exists: 'exists',
62 | missing: 'notExists',
63 | }[key];
64 | delete obj.value;
65 | break;
66 | case 'term':
67 | case 'terms':
68 | obj.field = Object.keys(group[key])[0];
69 | var fieldData = fieldMap[Object.keys(group[key])[0]];
70 |
71 | if (fieldData.type === 'multi') {
72 | var vals = group[key][obj.field];
73 | if (typeof vals === 'string') vals = [ vals ];
74 | obj.values = fieldData.choices.reduce(function(prev, choice) {
75 | prev[choice] = group[key][obj.field].indexOf(choice) !== -1;
76 | return prev;
77 | }, {});
78 | } else {
79 | obj.subType = truthy ? 'equals' : 'notEquals';
80 | obj.value = group[key][obj.field];
81 |
82 | if (typeof obj.value === 'number') {
83 | obj.subType = 'boolean';
84 | }
85 | }
86 | break;
87 | case 'range':
88 | var date, parts;
89 | obj.field = Object.keys(group[key])[0];
90 | obj.subType = Object.keys(group[key][obj.field])[0];
91 |
92 | if (angular.isNumber(group[key][obj.field][obj.subType])) {
93 | obj.value = group[key][obj.field][obj.subType];
94 | break;
95 | }
96 |
97 | if (angular.isDefined(Object.keys(group[key][obj.field])[1])) {
98 | date = group[key][obj.field].gte;
99 |
100 | if (~date.indexOf('now-')) {
101 | obj.subType = 'last';
102 | obj.value = parseInt(date.split('now-')[1].split('d')[0]);
103 | break;
104 | }
105 |
106 | if (~date.indexOf('now')) {
107 | obj.subType = 'next';
108 | date = group[key][obj.field].lte;
109 | obj.value = parseInt(date.split('now+')[1].split('d')[0]);
110 | break;
111 | }
112 |
113 | obj.subType = 'equals';
114 | parts = date.split('T')[0].split('-');
115 | obj.date = parts[2] + '/' + parts[1] + '/' + parts[0];
116 | break;
117 | }
118 |
119 | date = group[key][obj.field][obj.subType];
120 | parts = date.split('T')[0].split('-');
121 | obj.date = parts[2] + '/' + parts[1] + '/' + parts[0];
122 | break;
123 |
124 | case 'not':
125 | obj = parseQueryGroup(fieldMap, group[key].filter, false);
126 | break;
127 | default:
128 | obj.field = Object.keys(group[key])[0];
129 | break;
130 | }
131 |
132 | return obj;
133 | }
134 |
135 | function parseFilterGroup(fieldMap, $filter, group) {
136 | var obj = {};
137 | if (group.type === 'group') {
138 | obj[group.subType] = group.rules.map(parseFilterGroup.bind(group, fieldMap, $filter)).filter(function(item) {
139 | return !!item;
140 | });
141 | return obj;
142 | }
143 |
144 | var fieldName = group.field;
145 | var fieldData = fieldMap[fieldName];
146 |
147 |
148 | if (!fieldName) return;
149 |
150 | switch (fieldData.type) {
151 | case 'term':
152 | if (fieldData.subType === 'boolean') group.subType = 'boolean';
153 |
154 | if (!group.subType) return;
155 | switch (group.subType) {
156 | case 'equals':
157 | case 'boolean':
158 | if (group.value === undefined) return;
159 | obj.term = {};
160 | obj.term[fieldName] = group.value;
161 | break;
162 | case 'notEquals':
163 | if (group.value === undefined) return;
164 | obj.not = { filter: { term: {}}};
165 | obj.not.filter.term[fieldName] = group.value;
166 | break;
167 | case 'exists':
168 | obj.exists = { field: fieldName };
169 | break;
170 | case 'notExists':
171 | obj.missing = { field: fieldName };
172 | break;
173 | default:
174 | throw new Error('unexpected subtype ' + group.subType);
175 | }
176 | break;
177 |
178 | case 'number':
179 | obj.range = {};
180 | obj.range[fieldName] = {};
181 | obj.range[fieldName][group.subType] = group.value;
182 | break;
183 |
184 | case 'date':
185 | if (!group.subType) return;
186 |
187 | switch (group.subType) {
188 | case 'equals':
189 | if (!angular.isDate(group.date)) return;
190 | obj.term = {};
191 | obj.term[fieldName] = formatDate($filter, group.date, group.dateFormat);
192 | break;
193 | case 'lt':
194 | case 'lte':
195 | if (!angular.isDate(group.date)) return;
196 | obj.range = {};
197 | obj.range[fieldName] = {};
198 | obj.range[fieldName][group.subType] = formatDate($filter, group.date, group.dateFormat);
199 | break;
200 | case 'gt':
201 | case 'gte':
202 | if (!angular.isDate(group.date)) return;
203 | obj.range = {};
204 | obj.range[fieldName] = {};
205 | obj.range[fieldName][group.subType] = formatDate($filter, group.date, group.dateFormat);
206 | break;
207 | case 'last':
208 | if (!angular.isNumber(group.value)) return;
209 | obj.range = {};
210 | obj.range[fieldName] = {};
211 | obj.range[fieldName].gte = 'now-' + group.value + 'd';
212 | obj.range[fieldName].lte = 'now';
213 | break;
214 | case 'next':
215 | if (!angular.isNumber(group.value)) return;
216 | obj.range = {};
217 | obj.range[fieldName] = {};
218 | obj.range[fieldName].gte = 'now';
219 | obj.range[fieldName].lte = 'now+' + group.value + 'd';
220 | break;
221 | case 'exists':
222 | obj.exists = { field: fieldName };
223 | break;
224 | case 'notExists':
225 | obj.missing = { field: fieldName };
226 | break;
227 | default:
228 | throw new Error('unexpected subtype ' + group.subType);
229 | }
230 | break;
231 |
232 | case 'multi':
233 | obj.terms = {};
234 | obj.terms[fieldName] = Object.keys(group.values || {}).reduce(function(prev, key) {
235 | if (group.values[key]) prev.push(key);
236 |
237 | return prev;
238 | }, []);
239 | break;
240 |
241 | default:
242 | throw new Error('unexpected type');
243 | }
244 |
245 | return obj;
246 | }
247 |
248 | function getFilterTemplate(type) {
249 | var templates = {
250 | group: {
251 | type: 'group',
252 | subType: '',
253 | rules: [],
254 | },
255 | item: {
256 | field: '',
257 | subType: '',
258 | value: '',
259 | },
260 | number: {
261 | field: '',
262 | subType: '',
263 | value: null,
264 | },
265 | };
266 |
267 | return angular.copy(templates[type]);
268 | }
269 |
270 | function formatDate($filter, date, dateFormat) {
271 | if (!angular.isDate(date)) return false;
272 | var fDate = $filter('date')(date, dateFormat);
273 | return fDate;
274 | }
275 |
276 | })(window.angular);
277 |
--------------------------------------------------------------------------------
/src/tmpl/BuilderDirective.html:
--------------------------------------------------------------------------------
1 |
21 |
--------------------------------------------------------------------------------
/src/tmpl/ChooserDirective.html:
--------------------------------------------------------------------------------
1 |
4 |
5 |
10 |
11 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/tmpl/ElasticBuilderTemplates.js:
--------------------------------------------------------------------------------
1 | (function(angular) {"use strict"; angular.module("angular-elastic-builder").run(["$templateCache", function($templateCache) {$templateCache.put("angular-elastic-builder/BuilderDirective.html","\n");
2 | $templateCache.put("angular-elastic-builder/ChooserDirective.html","\n");
3 | $templateCache.put("angular-elastic-builder/GroupDirective.html","\n
If\n \n of these conditions are met\n
\n
\n\n
\n\n
\n \n \n
\n");
4 | $templateCache.put("angular-elastic-builder/RuleDirective.html","\n");
5 | $templateCache.put("angular-elastic-builder/types/Boolean.html","\n Equals\n\n \n \n\n");
6 | $templateCache.put("angular-elastic-builder/types/Date.html","\n \n\n \n\n \n \n \n \n
\n \n\n \n days\n \n\n\n");
7 | $templateCache.put("angular-elastic-builder/types/Multi.html","\n \n \n \n\n");
8 | $templateCache.put("angular-elastic-builder/types/Number.html","\n \n\n \n \n\n");
9 | $templateCache.put("angular-elastic-builder/types/Term.html","\n \n \n\n");}]);})(window.angular);
--------------------------------------------------------------------------------
/src/tmpl/GroupDirective.html:
--------------------------------------------------------------------------------
1 |
2 |
If
3 |
7 | of these conditions are met
8 |
9 |
15 |
16 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/tmpl/RuleDirective.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/tmpl/types/Boolean.html:
--------------------------------------------------------------------------------
1 |
2 | Equals
3 |
4 |
5 |
10 |
11 |
--------------------------------------------------------------------------------
/src/tmpl/types/Date.html:
--------------------------------------------------------------------------------
1 |
2 |
21 |
22 |
40 |
41 |
42 |
43 |
44 |
49 |
50 |
51 |
52 |
53 | days
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/src/tmpl/types/Multi.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/tmpl/types/Number.html:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
24 |
25 |
--------------------------------------------------------------------------------
/src/tmpl/types/Term.html:
--------------------------------------------------------------------------------
1 |
2 |
16 |
21 |
22 |
--------------------------------------------------------------------------------