Skip to content

Commit

Permalink
Add disableEnterKeySave option for editor.config
Browse files Browse the repository at this point in the history
  • Loading branch information
Myles Fang committed Mar 27, 2019
1 parent 53ea3a9 commit 019a81d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/app/pages/documentation/documentation.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ <h3><a id="configuration" class="anchor" href="#configuration" aria-hidden="true
Editor configuration settings. Mandatory only for editor types <span class="highlight">completer</span>, <span class="highlight">list</span>
</td>
</tr>
<tr>
<td><span class="nested-obj">editor.config</span>.disableEnterKeySave</td>
<td><span class="highlight">boolean</span></td>
<td>false</td>
<td>
Only on editor types <span class="highlight">text</span>, <span class="highlight">textarea</span>, <span class="highlight">select</span>.<br>
Whether hitting ENTER key should trigger saving.
</td>
</tr>
<tr>
<td><span class="nested-obj">editor.config</span>.true</td>
<td><span class="highlight">string</span></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export class DefaultEditor implements Editor {
@Output() onStopEditing = new EventEmitter<any>();
@Output() onEdited = new EventEmitter<any>();
@Output() onClick = new EventEmitter<any>();

get disableEnterKeySave(): boolean {
return this.cell.getColumn().getConfig() && this.cell.getColumn().getConfig().disableEnterKeySave;
}
}

export interface Editor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DefaultEditor } from './default-editor';
[placeholder]="cell.getTitle()"
[disabled]="!cell.isEditable()"
(click)="onClick.emit($event)"
(keydown.enter)="onEdited.emit($event)"
(keydown.enter)="disableEnterKeySave || onEdited.emit($event)"
(keydown.esc)="onStopEditing.emit()">
`,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { DefaultEditor } from './default-editor';
[name]="cell.getId()"
[disabled]="!cell.isEditable()"
(click)="onClick.emit($event)"
(keydown.enter)="onEdited.emit($event)"
(keydown.enter)="disableEnterKeySave || onEdited.emit($event)"
(keydown.esc)="onStopEditing.emit()">
<option *ngFor="let option of cell.getColumn().getConfig()?.list" [value]="option.value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DefaultEditor } from './default-editor';
[disabled]="!cell.isEditable()"
[placeholder]="cell.getTitle()"
(click)="onClick.emit($event)"
(keydown.enter)="onEdited.emit($event)"
(keydown.enter)="disableEnterKeySave || onEdited.emit($event)"
(keydown.esc)="onStopEditing.emit()">
</textarea>
`,
Expand Down

0 comments on commit 019a81d

Please sign in to comment.