-
Notifications
You must be signed in to change notification settings - Fork 7
feat(oui-select): allow items to be disabled #291
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job :)
Some improvements are needed (documentation and checks). Do you have some unit tests too for this feature ?
@@ -17,6 +17,7 @@ export default () => ({ | |||
title: "@?", | |||
placeholder: "@?", | |||
items: "<", | |||
disabledItems: "<", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property should be optional: <?
Don't forget to update the API table too :)
packages/oui-select/README.md
Outdated
data-title="Select a country" | ||
placeholder="Select a country..." | ||
items="$ctrl.countries" | ||
disabled-items="['Algeria', 'Canada', 'France', 'United States']" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that you should add a note under/above these examples about the fact that disabled-items
need an array of values based on the match :)
Since match
is optional, how will work this property in the case of the property is not defined ?
This should be documented too.
@@ -29,6 +32,14 @@ export default class { | |||
matchElement.html("{{$select.selected}}"); | |||
} | |||
|
|||
if (isArray(this.disabledItems)) { | |||
this.items = angular.copy(this.items).map(item => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use another property like this.sortedItems
to keep the value of this.item
.
What will happened when items
or disabled-items
is updated after the init ?
@@ -29,6 +32,14 @@ export default class { | |||
matchElement.html("{{$select.selected}}"); | |||
} | |||
|
|||
if (isArray(this.disabledItems)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in $onInit
instead :)
0c951a1
to
4d464fc
Compare
@@ -17,6 +17,7 @@ export default class { | |||
$onInit () { | |||
addBooleanParameter(this, "disabled"); | |||
addBooleanParameter(this, "required"); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this blank space :)
4d464fc
to
0daac4c
Compare
Allow items from oui-select to be disabled