Skip to content

Commit

Permalink
improve input box widget
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksii Orel <oorel@redhat.com>
  • Loading branch information
olexii4 committed Jun 23, 2017
1 parent f3d58b0 commit ccafe82
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
27 changes: 13 additions & 14 deletions dashboard/src/components/widget/input/che-input-box.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,36 +51,35 @@ export class CheInputBox {


compile(element: ng.IRootElementService, attrs: ng.IAttributes) {
const keys = Object.keys(attrs);
const avoidAttrs = ['ng-model'];
const avoidStartWithAttrs: Array<string> = ['$', 'che-'];

const keys = Object.keys(attrs.$attr);
// search the input field
const inputJqEl = element.find('input');
let tabIndex;
keys.forEach((key: string) => {
// don't reapply internal properties
if (key.indexOf('$') === 0) {
const attr = attrs.$attr[key];
if (!attr) {
return;
}
// don't reapply internal element properties
if (key.indexOf('che') === 0) {
if (avoidStartWithAttrs.find((avoidStartWithAttr: string) => {
return attr.indexOf(avoidStartWithAttr) === 0;
})) {
return;
}
// avoid model
if ('ngModel' === key) {
if (avoidAttrs.indexOf(attr) !== -1) {
return;
}
let value = attrs[key];
// remember tabindex
if (key === 'tabindex') {
if (attr === 'tabindex') {
tabIndex = value;
}
// handle empty values as boolean
if (value === '') {
value = 'true';
}
// set the value of the attribute
inputJqEl.attr(attrs.$attr[key], value);
inputJqEl.attr(attr, value);
// add also the material version of max length (only one the first input which is the md-input)
element.removeAttr(attrs.$attr[key]);
element.removeAttr(attr);
});
// the focusable element is the input, remove tabIndex from top-level element
element.attr('tabindex', -1);
Expand Down
1 change: 0 additions & 1 deletion dashboard/src/components/widget/input/che-input-box.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
ng-if="labelName"><span>{{labelName}}</span></label>
<div class="che-input-area">
<input ng-trim="false" name="{{inputName}}"
ng-model-options="{allowInvalid: true}"
ng-change="onChange({$value: valueModel})"
ng-readonly="isReadonly"
ng-model="valueModel">
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/components/widget/input/che-input-box.styl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.che-input-box > div
max-width 800px
min-height 70px
.che-input-box-desktop
display flex
margin 0
Expand Down

0 comments on commit ccafe82

Please sign in to comment.