tiep v0.1.1
tiep
Custom filter to map a data type to a valid type of an input
Introduction
This AngularJS custom filter enables to map a data type to a valid type value of an HTML input. Just pass in a string or an object containing the data type and get the valid value.
The only dependencies are AngularJS and lodash. Tested against v1.5.6 but other versions should work.
Installation
For installation use the Node Package Manager:
$ npm install --save tiep
or clone the repository:
$ git clone https://github.com/felixheck/tiep
Usage
Integration
Include tiep and lodash into your application:
<!DOCTYPE html>
<html ng-app="yourApp">
<head>
...
</head>
<body>
...
<script src="../tiep.js"></script>
<script src="../lodash.min.js"></script>
</body>
</html>
Declare a dependency on the uXess module:
angular.module('yourApp', [
'tiep'
]);
In JavaScript
var dataType = 'boolean';
$filter('tiep')(dataType); // 'checkbox'
In HTML Template Binding
{{ 'boolean' | tiep }} // 'checkbox'
API
$filter('tiep')(input, [accessKey], [mapping])
input {string | Object}
- The source object containing the data type.accessKey {string | number}
- A custom key to access the passed in object. Default:type
.mapping {Object.<?string>}
- A custom dataType/type mapping.
The default mapping is:
{
boolean: 'checkbox',
date: 'date',
number: 'number',
integer: 'number',
string: 'text'
}
Testing
First you have to install all dependencies:
$ npm install
To execute all unit tests based on file watcher, use:
$ npm test
// or
$ npm start
Contribution
Fork this repository and push in your ideas.
Do not forget to add corresponding tests to keep up 100% test coverage.
In case of questions or suggestions just open an issue.
License
The MIT License
Copyright (c) 2016 Felix Heck
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.