From 9486c55f55fa2b913a49b62db99d7d1cc6fa3fe2 Mon Sep 17 00:00:00 2001 From: Diabeu Date: Wed, 27 Jul 2016 14:37:20 +0200 Subject: [PATCH 1/4] refactor(radio, select): change model in view types, add groups to select Change variables to manipulate easy on options and add groups if first item got label attribute. In older way if you would like to change option name you cannot do it properly. --- src/types/radio/radio.html | 12 +++++++----- src/types/select/select.html | 28 ++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/types/radio/radio.html b/src/types/radio/radio.html index f5c86ae..edfe0b4 100644 --- a/src/types/radio/radio.html +++ b/src/types/radio/radio.html @@ -1,8 +1,10 @@ - + - {{option[to.labelProp || 'name']}} + ng-repeat="option in to.options track by $index" + aria-label="{{to.options[$index].ariaLabel}}" + class="{{to.options[$index].className}}" + ng-disabled="(to.options[$index].disabled) || to.disabled" + ng-value="to.options[$index].value"> + {{to.options[$index].name}} diff --git a/src/types/select/select.html b/src/types/select/select.html index f613f40..880eecd 100644 --- a/src/types/select/select.html +++ b/src/types/select/select.html @@ -1,5 +1,29 @@ - - {{ option[to.labelProp || 'name'] }} + + + + {{to.options[$groupIndex].options[$optionIndex].name}} + + + + + {{to.options[$index].name}} From 2f70519e096ec0a7217b55b875eb358fee192e5f Mon Sep 17 00:00:00 2001 From: Diabeu Date: Thu, 11 Aug 2016 20:13:13 +0200 Subject: [PATCH 2/4] refactor(radioType): remove brackets --- src/types/radio/radio.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/radio/radio.html b/src/types/radio/radio.html index edfe0b4..53fc78f 100644 --- a/src/types/radio/radio.html +++ b/src/types/radio/radio.html @@ -3,7 +3,7 @@ ng-repeat="option in to.options track by $index" aria-label="{{to.options[$index].ariaLabel}}" class="{{to.options[$index].className}}" - ng-disabled="(to.options[$index].disabled) || to.disabled" + ng-disabled="to.options[$index].disabled || to.disabled" ng-value="to.options[$index].value"> {{to.options[$index].name}} From bedd971b2c95c0daf74a5a428f377d8d895918d1 Mon Sep 17 00:00:00 2001 From: Diabeu Date: Thu, 11 Aug 2016 20:15:19 +0200 Subject: [PATCH 3/4] refactor(radioTest): comment labelProp and valueProp, change disabled --- tests/types/radio-spec.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/types/radio-spec.js b/tests/types/radio-spec.js index bd0d1b9..6628052 100644 --- a/tests/types/radio-spec.js +++ b/tests/types/radio-spec.js @@ -82,7 +82,7 @@ describe('formlyMaterial - radio type', () => { expect(el.find('.md-label > span').html()).toContain(option.name); }); }); - + /* it('should handle valueProp', () => { compile({ templateOptions: { @@ -98,7 +98,8 @@ describe('formlyMaterial - radio type', () => { expect(el.find('.md-label > span').html()).toContain(option.name); }); }); - + */ + /* it('should handle labelProp', () => { compile({ templateOptions: { @@ -114,6 +115,7 @@ describe('formlyMaterial - radio type', () => { expect(el.find('.md-label > span').html()).toContain(option.nameUp); }); }); + */ it('should has disabled options', () => { compile({ @@ -127,7 +129,7 @@ describe('formlyMaterial - radio type', () => { field.templateOptions.options.forEach((option, key) => { const el = angular.element(optionsElements[key]); - expect(el.attr('ng-disabled')).toBe('to.disabled'); + expect(el.attr('ng-disabled')).toBe('to.options[$index].disabled || to.disabled'); expect(el.scope().to.disabled).toBe(true); }); }); From 88e2aa1eb7faa81a2ec2c58c586f2dad5c8ed9bc Mon Sep 17 00:00:00 2001 From: Diabeu Date: Thu, 11 Aug 2016 20:16:30 +0200 Subject: [PATCH 4/4] refactor(selectTest): remove labelProp and valueProp --- tests/types/select-spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/types/select-spec.js b/tests/types/select-spec.js index d9dbbe0..79f21bf 100644 --- a/tests/types/select-spec.js +++ b/tests/types/select-spec.js @@ -164,7 +164,7 @@ describe('formlyMaterial - select type', () => { expect(el.find('.md-text').html()).toContain(option.name); }); }); - + /* it('should have options with custom properties for name and value', () => { compile({ templateOptions: { @@ -182,5 +182,6 @@ describe('formlyMaterial - select type', () => { expect(el.find('.md-text').html()).toContain(option.nameUp); }); }); + */ }); });