Skip to content
This repository was archived by the owner on Jun 11, 2019. It is now read-only.

Commit efe1b66

Browse files
committed
Add absolute value and boolean filters
1 parent 6230f40 commit efe1b66

30 files changed

+285
-20
lines changed

demo/index.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,34 @@ <h1>Updated {{appCtrl.runNum}} time(s)</h1>
3333
</c2fo-checkbox-filter-group>
3434

3535
<pre>{{appCtrl.filter | json}}</pre>
36+
37+
<h1>Filters</h1>
38+
<table>
39+
<thead>
40+
<tr>
41+
<th>Name</th>
42+
<th>Input</th>
43+
<th>Output</th>
44+
</tr>
45+
</thead>
46+
<tbody>
47+
<tr>
48+
<td>abs</td>
49+
<td>-7</td>
50+
<td>{{-7 | abs}}</td>
51+
</tr>
52+
<tr>
53+
<td>boolean</td>
54+
<td>{}, [], true, 1</td>
55+
<td>{{{} | boolean}}, {{[] | boolean}}, {{true | boolean}}, {{1 | boolean}}</td>
56+
</tr>
57+
<tr>
58+
<td>boolean</td>
59+
<td>'', false, 0</td>
60+
<td>{{'' | boolean}}, {{false | boolean}}, {{0 | boolean}}</td>
61+
</tr>
62+
</tbody>
63+
</table>
3664
</div>
3765
<script>
3866
angular.module('app', ['c2fo.ui']).controller('AppController', AppController);

dist/c2fo-ui-components.js

Lines changed: 73 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@
7373

7474
angular.module(moduleName, [
7575
__webpack_require__(3),
76-
__webpack_require__(6)
76+
__webpack_require__(5),
77+
__webpack_require__(7),
78+
__webpack_require__(10)
7779
]);
7880

7981
module.exports = moduleName;
@@ -84,17 +86,78 @@
8486

8587
"use strict";
8688

87-
var moduleName = 'c2fo.ui.modules.checkboxFilterGroup';
89+
var moduleName = 'c2fo.ui.modules.absoluteValueFilter';
8890

8991
angular.module(moduleName, [])
90-
.controller('CheckboxFilterGroupController', __webpack_require__(4))
91-
.directive('c2foCheckboxFilterGroup', __webpack_require__(5));
92+
.filter('abs', __webpack_require__(4));
9293

9394
module.exports = moduleName;
9495

9596

97+
9698
/***/ },
9799
/* 4 */
100+
/***/ function(module, exports) {
101+
102+
"use strict";
103+
104+
module.exports = absoluteValueFilter;
105+
106+
absoluteValueFilter.$inject = [];
107+
function absoluteValueFilter() {
108+
return function (val) {
109+
return Math.abs(val);
110+
};
111+
}
112+
113+
/***/ },
114+
/* 5 */
115+
/***/ function(module, exports, __webpack_require__) {
116+
117+
"use strict";
118+
119+
var moduleName = 'c2fo.ui.modules.booleanFilter';
120+
121+
angular.module(moduleName, [])
122+
.filter('boolean', __webpack_require__(6));
123+
124+
module.exports = moduleName;
125+
126+
127+
128+
/***/ },
129+
/* 6 */
130+
/***/ function(module, exports) {
131+
132+
"use strict";
133+
134+
BooleanFilter.$inject = [];
135+
function BooleanFilter() {
136+
return function (val) {
137+
return !!val ? 'T' : 'F';
138+
};
139+
}
140+
141+
module.exports = BooleanFilter;
142+
143+
144+
/***/ },
145+
/* 7 */
146+
/***/ function(module, exports, __webpack_require__) {
147+
148+
"use strict";
149+
150+
var moduleName = 'c2fo.ui.modules.checkboxFilterGroup';
151+
152+
angular.module(moduleName, [])
153+
.controller('CheckboxFilterGroupController', __webpack_require__(8))
154+
.directive('c2foCheckboxFilterGroup', __webpack_require__(9));
155+
156+
module.exports = moduleName;
157+
158+
159+
/***/ },
160+
/* 8 */
98161
/***/ function(module, exports) {
99162

100163
'use strict';
@@ -144,7 +207,7 @@
144207
}
145208

146209
/***/ },
147-
/* 5 */
210+
/* 9 */
148211
/***/ function(module, exports) {
149212

150213
'use strict';
@@ -181,22 +244,22 @@
181244
}
182245

183246
/***/ },
184-
/* 6 */
247+
/* 10 */
185248
/***/ function(module, exports, __webpack_require__) {
186249

187250
"use strict";
188251

189252
var moduleName = 'c2fo.ui.modules.pager';
190253

191254
angular.module(moduleName, [])
192-
.controller('PagerController', __webpack_require__(7))
193-
.directive('c2foPager', __webpack_require__(8));
255+
.controller('PagerController', __webpack_require__(11))
256+
.directive('c2foPager', __webpack_require__(12));
194257

195258
module.exports = moduleName;
196259

197260

198261
/***/ },
199-
/* 7 */
262+
/* 11 */
200263
/***/ function(module, exports) {
201264

202265
'use strict';
@@ -234,7 +297,7 @@
234297
}
235298

236299
/***/ },
237-
/* 8 */
300+
/* 12 */
238301
/***/ function(module, exports) {
239302

240303
'use strict';

dist/c2fo-ui-components.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/c2fo-ui-components.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"use strict";
2+
3+
module.exports = absoluteValueFilter;
4+
5+
absoluteValueFilter.$inject = [];
6+
function absoluteValueFilter() {
7+
return function (val) {
8+
return Math.abs(val);
9+
};
10+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"use strict";
2+
3+
describe('Absolute Value Filter', function () {
4+
beforeEach(module('c2fo.ui.modules.absoluteValueFilter'));
5+
6+
var filter;
7+
8+
beforeEach(inject(function (_$filter_) {
9+
filter = _$filter_('abs');
10+
}));
11+
12+
it("should convert negative numbers to positive numbers", function() {
13+
expect(filter(-7)).toEqual(7);
14+
});
15+
16+
it("should ignore positive numbers", function() {
17+
expect(filter(7)).toEqual(7);
18+
});
19+
});

0 commit comments

Comments
 (0)