Skip to content

Commit

Permalink
Focus name inputForm when Add modal of propertydefinitions is shown
Browse files Browse the repository at this point in the history
Signed-off-by: Philipp Meyer <meyer.github@gmail.com>
  • Loading branch information
meyerpp committed Oct 11, 2017
1 parent 41fea37 commit f6b2577
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Expand Up @@ -37,7 +37,8 @@
<div>
<div *ngIf="(resourceApiData.selectedValue === propertiesEnum.Element
|| resourceApiData.selectedValue === propertiesEnum.Type)">
<ng-select [items]="selectItems" (selected)="xmlValueSelected($event)" [active]="[activeElement]"></ng-select>
<ng-select [items]="selectItems" (selected)="xmlValueSelected($event)"
[active]="[activeElement]"></ng-select>
</div>

<div *ngIf="resourceApiData.selectedValue === propertiesEnum.Custom">
Expand All @@ -60,22 +61,25 @@
[(ngModel)]="resourceApiData.winerysPropertiesDefinition.elementName">
</div>
<div class="wrapperTabButtom">
<winery-namespace-selector [(ngModel)]="resourceApiData.winerysPropertiesDefinition.namespace"></winery-namespace-selector>
<winery-namespace-selector
[(ngModel)]="resourceApiData.winerysPropertiesDefinition.namespace"></winery-namespace-selector>
</div>
</tab>
</tabset>
</div>
</div>
</div>

<winery-modal bsModal #addModal="bs-modal" [modalRef]="addModal">
<winery-modal bsModal #addModal="bs-modal" [modalRef]="addModal"
(onShown)="onAddModalShown();" (onHide)="addPropertyFrom.reset();">
<winery-modal-header [title]="'Add Property'">
</winery-modal-header>
<winery-modal-body>
<form #addPropertyFrom="ngForm" id="addPropertyForm">
<div class="form-group">
<label class="control-label" for="key">Name</label>
<input #propName="ngModel"
<input #nameInputForm
#propName="ngModel"
id="key"
class="form-control"
type="text"
Expand Down
Expand Up @@ -6,7 +6,7 @@
* and are available at http://www.eclipse.org/legal/epl-v20.html
* and http://www.apache.org/licenses/LICENSE-2.0
*/
import { Component, OnInit, ViewChild } from '@angular/core';
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { InstanceService } from '../../instance.service';
import { PropertiesDefinitionService } from './propertiesDefinition.service';
import {
Expand Down Expand Up @@ -49,6 +49,7 @@ export class PropertiesDefinitionComponent implements OnInit {
validatorObject: WineryValidatorObject;
@ViewChild('confirmDeleteModal') confirmDeleteModal: ModalDirective;
@ViewChild('addModal') addModal: ModalDirective;
@ViewChild('nameInputForm') nameInputForm: ElementRef;

constructor(private sharedData: InstanceService, private service: PropertiesDefinitionService,
private notify: WineryNotificationService) {
Expand Down Expand Up @@ -234,6 +235,10 @@ export class PropertiesDefinitionComponent implements OnInit {
this.elementToRemove = null;
}

onAddModalShown() {
this.nameInputForm.nativeElement.focus();
}

// endregion

// region ########## Private Methods ##########
Expand Down

0 comments on commit f6b2577

Please sign in to comment.