Skip to content
This repository has been archived by the owner on Jan 22, 2018. It is now read-only.

Commit

Permalink
Merge branch 'release/v0.7.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Kisiela committed Dec 1, 2015
2 parents 1649e54 + 49a52e9 commit 1c44056
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 97 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.7.1] - 2015-12-01
### Changed
- use bound for datepicker's minDate, maxDate and filterDate instead of template manipulator
- remove bound from slider's min, max and step attributes

## [0.7.0] - 2015-11-29
### Added
- support for npm and bower (angular-formly-material).

### Changed
- Unit testing using karma instead of velocity (with coverage reports)

Expand Down Expand Up @@ -80,6 +86,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## 0.0.1 - 2015-11-06

[0.7.1]: https://github.com/wieldo/angular-formly-templates-material/compare/v0.7.0...v0.7.1
[0.7.0]: https://github.com/wieldo/angular-formly-templates-material/compare/v0.6.0...v0.7.0
[0.6.0]: https://github.com/wieldo/angular-formly-templates-material/compare/v0.5.2...v0.6.0
[0.5.2]: https://github.com/wieldo/angular-formly-templates-material/compare/v0.5.1...v0.5.2
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FormlyMaterial

[![GitHub version](https://badge.fury.io/gh/wieldo%2Fangular-formly-templates-material.svg)](https://badge.fury.io/gh/wieldo%2Fangular-formly-templates-material)
[![Build Status](https://travis-ci.org/wieldo/angular-formly-templates-material.svg)](https://travis-ci.org/wieldo/angular-formly-templates-material)
[![Coverage Status](https://coveralls.io/repos/wieldo/angular-formly-templates-material/badge.svg?branch=master&service=github)](https://coveralls.io/github/wieldo/angular-formly-templates-material?branch=master)
[![Codacy Badge](https://api.codacy.com/project/badge/grade/a2cd4c7c2d74467281e309a65be49e8f)](https://www.codacy.com/app/mys-sterowiec/angular-formly-templates-material)

Material Design Templates for [Angular-Formly](http://angular-formly.com). Modern & flexible forms configured easily in a JSON object.
Expand Down
46 changes: 12 additions & 34 deletions dist/formly-material.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,18 @@ return /******/ (function(modules) { // webpackBootstrap
wrapper: ['messages'],
defaultOptions: {
ngModelAttrs: {
placeholder: { attribute: 'md-placeholder' }
placeholder: {
attribute: 'md-placeholder'
},
minDate: {
bound: 'md-min-date'
},
maxDate: {
bound: 'md-max-date'
},
filterDate: {
bound: 'md-date-filter'
}
}
},
apiCheck: function apiCheck(check) {
Expand All @@ -466,36 +477,6 @@ return /******/ (function(modules) { // webpackBootstrap
};
}
});

formlyConfigProvider.templateManipulators.preWrapper.push(function (template, options) {
if (angular.isDefined(options.templateOptions.minDate) || angular.isDefined(options.templateOptions.maxDate) || angular.isDefined(options.templateOptions.filterDate)) {

var dateConfig = {
min: options.templateOptions.minDate || undefined,
max: options.templateOptions.maxDate || undefined,
filter: options.templateOptions.filterDate || undefined
};
var node = document.createElement('div');

node.innerHTML = template;
var datepickerNode = node.querySelector('md-datepicker');

if (datepickerNode) {
if (dateConfig.min) {
datepickerNode.setAttribute('md-min-date', 'to.minDate');
}
if (dateConfig.max) {
datepickerNode.setAttribute('md-max-date', 'to.maxDate');
}
if (dateConfig.filter) {
datepickerNode.setAttribute('md-date-filter', 'to.filterDate');
}
}
return node.innerHTML;
}

return template;
});
};

module.exports = exports['default'];
Expand Down Expand Up @@ -655,15 +636,12 @@ return /******/ (function(modules) { // webpackBootstrap
defaultOptions: {
ngModelAttrs: {
min: {
bound: 'min',
attribute: 'min'
},
max: {
bound: 'max',
attribute: 'max'
},
step: {
bound: 'step',
attribute: 'step'
},
discrete: {
Expand Down
2 changes: 1 addition & 1 deletion dist/formly-material.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/formly-material.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var client = 'client';
Package.describe({
name: "wieldo:angular-formly-templates-material",
summary: "Material design templates for angular-formly",
version: "0.7.0",
version: "0.7.1",

documentation: 'README.md',
git: 'https://github.com/wieldo/angular-formly-templates-material.git'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-formly-material",
"version": "0.7.0",
"version": "0.7.1",
"description": "Material design templates for angular-formly",
"main": "dist/formly-material.js",
"scripts": {
Expand Down
46 changes: 12 additions & 34 deletions src/types/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@ export default (formlyConfigProvider) => {
wrapper: ['messages'],
defaultOptions: {
ngModelAttrs: {
placeholder: {attribute: 'md-placeholder'}
placeholder: {
attribute: 'md-placeholder'
},
minDate: {
bound: 'md-min-date'
},
maxDate: {
bound: 'md-max-date'
},
filterDate: {
bound: 'md-date-filter'
}
}
},
apiCheck: (check) => ({
Expand All @@ -19,37 +30,4 @@ export default (formlyConfigProvider) => {
}
})
});

formlyConfigProvider.templateManipulators.preWrapper.push((template, options) => {
if (angular.isDefined(options.templateOptions.minDate)
|| angular.isDefined(options.templateOptions.maxDate)
|| angular.isDefined(options.templateOptions.filterDate)) {

const dateConfig = {
min: options.templateOptions.minDate || undefined,
max: options.templateOptions.maxDate || undefined,
filter: options.templateOptions.filterDate || undefined
};
const node = document.createElement('div');

node.innerHTML = template;
const datepickerNode = node.querySelector('md-datepicker');

if (datepickerNode) {
if (dateConfig.min) {
datepickerNode.setAttribute('md-min-date', 'to.minDate');
}
if (dateConfig.max) {
datepickerNode.setAttribute('md-max-date', 'to.maxDate');
}
if (dateConfig.filter) {
datepickerNode.setAttribute('md-date-filter', 'to.filterDate');
}
}
return node.innerHTML;
}


return template;
});
}
3 changes: 0 additions & 3 deletions src/types/slider/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ export default (formlyConfigProvider) => {
defaultOptions: {
ngModelAttrs: {
min: {
bound: 'min',
attribute: 'min'
},
max: {
bound: 'max',
attribute: 'max'
},
step: {
bound: 'step',
attribute: 'step'
},
discrete: {
Expand Down
11 changes: 11 additions & 0 deletions tests/runs/md-theme-manipulator-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe("formlyMaterial - theme manipulator", () => {
}, options)];

let form = $compile(testUtils.getFormTemplate())($scope);

$scope.$digest();
element = form.find('[ng-model]');
field = $scope.fields[0];
Expand All @@ -50,7 +51,17 @@ describe("formlyMaterial - theme manipulator", () => {
});

it('should be able to add md-theme attribute', () => {
compile();
expect(element.attr('md-theme')).toBe('custom');
});

it("should be able to skip md-theme", () => {
compile({
extras: {
skipNgModelAttrsManipulator: true
}
});
expect(element.attr('md-theme')).toBeUndefined();
});

});
27 changes: 19 additions & 8 deletions tests/types/datepicker-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ describe("formlyMaterial - datepicker type", () => {
let form;
let element;
let field;
const minDate = new Date(2015, 10, 19);
const maxDate = new Date(2015, 11, 20);
const filterDate = () => true;

//
// helpers
//
Expand All @@ -24,11 +28,9 @@ describe("formlyMaterial - datepicker type", () => {
templateOptions: {
label: 'test field',
placeholder: "Pick a date",
minDate: new Date(2015, 11, 19),
maxDate: new Date(2015, 12, 20),
filterDate: (date) => {
return true;
}
minDate: minDate,
maxDate: maxDate,
filterDate: filterDate
}
}, options)];

Expand Down Expand Up @@ -63,15 +65,24 @@ describe("formlyMaterial - datepicker type", () => {
});

it('should have min date', () => {
expect(element.attr('md-min-date')).toBe('to.minDate');
const scope = angular.element(element).scope();

expect(element.attr('md-min-date')).toBe("options.templateOptions['minDate']");
expect(scope.options.templateOptions.minDate.toDateString()).toBe(minDate.toDateString());
});

it('should have max date', () => {
expect(element.attr('md-max-date')).toBe('to.maxDate');
const scope = angular.element(element).scope();

expect(element.attr('md-max-date')).toBe("options.templateOptions['maxDate']");
expect(scope.options.templateOptions.maxDate.toDateString()).toBe(maxDate.toDateString());
});

it('should have date filter', () => {
expect(element.attr('md-date-filter')).toBe('to.filterDate');
const scope = angular.element(element).scope();

expect(element.attr('md-date-filter')).toBe("options.templateOptions['filterDate']");
expect(scope.options.templateOptions.filterDate).toBe(filterDate);
});

});
32 changes: 18 additions & 14 deletions tests/types/slider-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@ describe("formlyMaterial - slider type", () => {
let form;
let element;
let field;
const fieldConfig = {
key: 'testField',
type: 'slider',
templateOptions: {
label: 'test field',
min: 1,
max: 5,
step: 0.5,
discrete: true
}
};
//
// helpers
//

function compile(options) {
$scope = $rootScope.$new();
$scope.fields = [angular.merge({}, {
key: 'testField',
type: 'slider',
templateOptions: {
label: 'test field',
min: 1,
max: 5,
step: 0.5,
discrete: true
}
}, options)];
$scope.fields = [angular.merge({}, fieldConfig, options)];

form = $compile(testUtils.getFormTemplate())($scope);
$scope.$digest();
Expand Down Expand Up @@ -57,19 +58,22 @@ describe("formlyMaterial - slider type", () => {
});

it('should support min option', () => {
expect(parseFloat(element.attr('min'))).toEqual(field.templateOptions.min);
expect(parseFloat(element.attr('min'))).toEqual(fieldConfig.templateOptions.min);
});

it('should support max option', () => {
expect(parseFloat(element.attr('max'))).toEqual(field.templateOptions.max);
expect(parseFloat(element.attr('max'))).toEqual(fieldConfig.templateOptions.max);
});

it('should support step option', () => {
expect(parseFloat(element.attr('step'))).toEqual(field.templateOptions.step);
expect(parseFloat(element.attr('step'))).toEqual(fieldConfig.templateOptions.step);
});

it('should support discrete option', () => {
const scope = angular.element(element).scope();

expect(element.attr('md-discrete')).toEqual("options.templateOptions['discrete']");
expect(scope.options.templateOptions.discrete).toBe(fieldConfig.templateOptions.discrete);
});

});

0 comments on commit 1c44056

Please sign in to comment.