-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding check-box component #11550
Adding check-box component #11550
Changes from 2 commits
71af7d6
733b536
f4cefc8
9cbe587
12f5f78
f724bf5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './selectable_row'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<input | ||
type="checkbox" | ||
class="kuiCheckBox" | ||
ng-click="selectableRow.onSelectChange(selectableRow.id, selectableRow.isSelected)" | ||
ng-model="selectableRow.isSelected" | ||
> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { uiModules } from 'ui/modules'; | ||
import template from './selectable_row.html'; | ||
|
||
const app = uiModules.get('kibana'); | ||
|
||
app.directive('selectableRow', function () { | ||
return { | ||
restrict: 'E', | ||
replace: true, | ||
transclude: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need this property, do we? |
||
template: template, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could just be |
||
scope: { | ||
id: '=', | ||
isSelected: '=', | ||
onSelectChange: '=', | ||
}, | ||
controllerAs: 'selectableRow', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You may have already settled on a convention about this, but my 2c are that this may not be necessary. IMO the template is just as readable (if not slightly more so) like this: <input
type="checkbox"
class="kuiCheckBox"
ng-click="this.onSelectChange(this.id, this.isSelected)"
ng-model="this.isSelected"
> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we have an established convention around this in Kibana at the moment. I think the main pattern we are trying to avoid here is hanging properties directly of @BigFunger Do you have a strong opinion either way on this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had received direction from @spalger a while ago to implement There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kind of like the way that That said, naming is hard. My preference, in order, is:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Moving @cjcenizal's comment into this thread to keep the discussion flow) Ah I see. I agree with you Spencer. I think "controllerAs: this" is really There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the discussion, folks. I'm going with option 1, which means keeping the code in this PR as-is. |
||
bindToController: true, | ||
controller: class SelectableRowController { | ||
} | ||
}; | ||
}); |
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.
Looks good! Thought tbh, from looking at the interface and implementation, wouldn't it make more sense to just call this directive
check-box
orkui-check-box
? I think we'll end up implementing a React component that does the same thing, and we'll probably just call itKuiCheckBox
because that's pretty much all it's concerned with. It could be used in a table row, a form, etc.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.
Yeah, I'm good with your proposal. It also eliminates the need for another component that I was about to promote into OSS Kibana:
selectable-column
, which is intended to be used for a "select all" functionality. It makes sense to me that there should be a generic check box component that could be used in various contexts.So I'm +1 for calling this component
check-box
(looking through other Angular directives in Kibana, we don't have thekui
prefix convention anywhere so I don't want to introduce it now).@BigFunger Your thoughts before I make this broad change affecting multiple places in this PR?
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 do not have a problem with it. Don't remember if there was a solid reason for making this two components initially, but the functionality of them does seem to have converged. Let me/us know if you find any weirdness as you implement the change.