Skip to content

Commit 11d1fba

Browse files
committed
@output naming styling
* Renames @output to follow convention from https://angular.io/docs/ts/latest/guide/style-guide.html#!#05-16
1 parent 6e84e4c commit 11d1fba

17 files changed

+34
-35
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ Then add it to your module's `imports`.
3838
### Use
3939

4040
```html
41-
<json-editor [config]="config" [schema]="mySchema" [record]="myRecord" (onRecordChange)="doStuffWithNewRecord($event)"></json-editor>
41+
<json-editor [config]="config" [schema]="mySchema" [record]="myRecord" (recordChange)="doStuffWithNewRecord($event)"></json-editor>
4242
```
4343

4444
- `config` : configuration object. See [configuration docs](https://inveniosoftware-contrib.github.io/ng2-json-editor/docs/interfaces/_json_editor_config_.jsoneditorconfig.html) for options.
4545
- `schema` : valid json-schema for the record. See [json schema limitations](#json-schema-limitations)
4646
- `record` : valid json to be edited.
47-
- `onRecordChange` emitted when record change, `$event` is the edited record.
47+
- `recordChange` emitted when record change, `$event` is the edited record.
4848
- `errorMap (={})`: errors for individual parts of the record (format should be [errors-map.json](./example/assets/mock-data/error-map.json)
4949
- `templates: { [templateName: string]: TemplateRef<any> }`: Templates with name, to be used by configured fields for example autocomplete result item.
5050

example/app/app.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { AppConfig } from './app.config';
3737
<json-editor *ngIf="record && schema"
3838
[config]="config.jsonEditorConfig"
3939
[record]="record"
40-
(onRecordChange)="onRecordChange($event)"
40+
(recordChange)="onRecordChange($event)"
4141
[schema]="schema">
4242
</json-editor>
4343
`

src/add-field-dropdown/add-field-dropdown.component.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ describe('AddFieldToObjectDropdownComponent', () => {
102102
showDropdownButton.dispatchEvent(new Event('click'));
103103
let anchor = nativeEl.querySelector('li a') as HTMLAnchorElement;
104104
expect(component.fields.has(anchor.textContent)).toBeFalsy();
105-
spyOn(component.onFieldAdd, 'emit');
105+
spyOn(component.fieldAdd, 'emit');
106106
anchor.dispatchEvent(new Event('click'));
107-
expect(component.onFieldAdd.emit).toHaveBeenCalledWith(anchor.textContent);
107+
expect(component.fieldAdd.emit).toHaveBeenCalledWith(anchor.textContent);
108108
});
109109
});

src/add-field-dropdown/add-field-dropdown.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class AddFieldDropdownComponent {
4040
@Input() fields: Set<string>;
4141
@Input() pathString: string;
4242

43-
@Output() onFieldAdd: EventEmitter<string> = new EventEmitter<string>();
43+
@Output() fieldAdd: EventEmitter<string> = new EventEmitter<string>();
4444

4545
expression = '';
4646

@@ -59,7 +59,7 @@ export class AddFieldDropdownComponent {
5959
}
6060

6161
onFieldSelect(field: string) {
62-
this.onFieldAdd.emit(field);
62+
this.fieldAdd.emit(field);
6363

6464
let newFieldPathString = `${this.pathString}${this.pathUtilService.separator}${field}`;
6565
this.domUtilService.focusAndSelectFirstEditableChildById(newFieldPathString);
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="autocomplete-container">
2-
<input attr.data-path="{{pathString}}" [ngModel]="value" (ngModelChange)="onModelChange($event)" (keypress)="onKeypress.emit($event)"
3-
(blur)="onBlur.emit()" [typeahead]="dataSource" [typeaheadOptionsLimit]="autocompletionConfig.size" [typeaheadOptionField]="typeaheadOptionField"
2+
<input attr.data-path="{{pathString}}" [ngModel]="value" (ngModelChange)="onModelChange($event)" (keypress)="keypress.emit($event)"
3+
(blur)="blur.emit()" [typeahead]="dataSource" [typeaheadOptionsLimit]="autocompletionConfig.size" [typeaheadOptionField]="typeaheadOptionField"
44
[typeaheadItemTemplate]="customItemTemplate" (typeaheadOnSelect)="onCompletionSelect($event.item)" [typeaheadWaitMs]="200" [tabindex]="tabIndex"
55
placeholder="{{placeholder}}">
66
</div>

src/autocomplete-input/autocomplete-input.component.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ export class AutocompleteInputComponent implements OnInit {
4545
@Input() tabIndex: number;
4646
@Input() placeholder: string;
4747

48-
@Output() onValueChange: EventEmitter<string> = new EventEmitter<any>();
49-
@Output() onKeypress: EventEmitter<KeyboardEvent> = new EventEmitter<any>();
50-
@Output() onBlur: EventEmitter<any> = new EventEmitter<any>();
48+
@Output() valueChange: EventEmitter<string> = new EventEmitter<any>();
49+
@Output() keypress: EventEmitter<KeyboardEvent> = new EventEmitter<any>();
50+
@Output() blur: EventEmitter<any> = new EventEmitter<any>();
5151

5252
dataSource: Observable<string> | Array<string>;
5353
typeaheadOptionField: string;
@@ -78,7 +78,7 @@ export class AutocompleteInputComponent implements OnInit {
7878

7979
onModelChange(value: string) {
8080
this.value = value;
81-
this.onValueChange.emit(value);
81+
this.valueChange.emit(value);
8282
}
8383

8484
onCompletionSelect(completionItem: AutocompletionResult) {

src/complex-list-field/complex-list-field.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<div *ngFor="let pIndex of paginatedIndices; let i = index; trackBy:trackByIndex">
4343
<div class="complex-list-field-wrapper">
4444
<object-field [value]="values.get(pIndex)" [schema]="schema.items" [path]="getElementPath(pIndex)">
45-
<list-action-group (onMove)="moveElement(i, $event)" (onDelete)="deleteElement(i)" [canMove]="schema.sortable"></list-action-group>
45+
<list-action-group (move)="moveElement(i, $event)" (delete)="deleteElement(i)" [canMove]="schema.sortable"></list-action-group>
4646
</object-field>
4747
</div>
4848
</div>

src/json-editor.component.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="row editor-container">
22
<div class="col-md-2 menu-container">
33
<tree-menu [record]="_record" [schema]="schema"></tree-menu>
4-
<add-field-dropdown [fields]="keys" [pathString]="''" (onFieldAdd)="onFieldAdd($event)" [schema]="schema">Add field</add-field-dropdown>
4+
<add-field-dropdown [fields]="keys" [pathString]="''" (fieldAdd)="onFieldAdd($event)" [schema]="schema">Add field</add-field-dropdown>
55
<div *ngIf="config.enableAdminModeSwitch" class="admin-mode" tooltip="Allows editing all fields (use with care)">
66
<input id="admin-mode-checkbox" type="checkbox" [(ngModel)]="appGlobalsService.adminMode" />
77
<label class="admin-mode" for="admin-mode-checkbox">Enable Admin Mode</label>
@@ -11,10 +11,10 @@
1111
<tabset *ngIf="config.tabsConfig">
1212
<tab *ngFor="let tabName of tabNames; trackBy:trackByElement" [heading]="tabName" (select)="activeTabName = tabName" [active]="isActiveTab(tabName)">
1313
<sub-record [value]="_record" [tabName]="tabName" [schema]="tabNameToSubSchema[tabName]" [keys]="tabNameToKeys[tabName]"
14-
(onDeleteKey)="onDeleteKey($event)"></sub-record>
14+
(deleteKey)="onDeleteKey($event)"></sub-record>
1515
</tab>
1616
</tabset>
17-
<sub-record *ngIf="!config.tabsConfig" [value]="_record" [schema]="schema" (onDeleteKey)="onDeleteKey($event)" [keys]="keys"></sub-record>
17+
<sub-record *ngIf="!config.tabsConfig" [value]="_record" [schema]="schema" (deleteKey)="onDeleteKey($event)" [keys]="keys"></sub-record>
1818
</div>
1919
<div id="right-main-container" *ngIf="!isPreviewerDisabled" [ngClass]="rightContainerColMdClass" class="main-container">
2020
<button id="btn-preview-toggle" type="button" class="btn btn-default btn-toggle" (click)="isPreviewerHidden = !isPreviewerHidden">{{isPreviewerHidden ? "Show Preview" : "Hide Preview"}}</button>

src/json-editor.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class JsonEditorComponent extends AbstractTrackerComponent implements OnI
7171
@Input() templates: { [templateName: string]: TemplateRef<any> } = {};
7272

7373

74-
@Output() onRecordChange: EventEmitter<Object> = new EventEmitter<Object>();
74+
@Output() recordChange: EventEmitter<Object> = new EventEmitter<Object>();
7575

7676
_record: Map<string, any>;
7777
tabNameToSubSchema: {};
@@ -126,7 +126,7 @@ export class JsonEditorComponent extends AbstractTrackerComponent implements OnI
126126
.subscribe(json => {
127127
this._record = json;
128128
// emit the change as plain JS object
129-
this.onRecordChange.emit(json.toJS());
129+
this.recordChange.emit(json.toJS());
130130
});
131131
this.jsonSchemaService.setSchema(this.schema);
132132

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<div>
2-
<button type="button" class="editor-btn-delete" (click)="onDelete.emit()">
2+
<button type="button" class="editor-btn-delete" (click)="delete.emit()">
33
<i class="fa fa-times"></i>
44
</button>
5-
<button *ngIf="canMove" type="button" class="editor-btn-move-up" (click)="onMove.emit(-1)">
5+
<button *ngIf="canMove" type="button" class="editor-btn-move-up" (click)="move.emit(-1)">
66
<i class="fa fa-chevron-up"></i>
77
</button>
8-
<button *ngIf="canMove" type="button" class="editor-btn-move-down" (click)="onMove.emit(1)">
8+
<button *ngIf="canMove" type="button" class="editor-btn-move-down" (click)="move.emit(1)">
99
<i class="fa fa-chevron-down"></i>
1010
</button>
1111
</div>

src/list-action-group/list-action-group.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import {
4343
export class ListActionGroupComponent {
4444

4545
@Input() canMove: boolean;
46-
@Output() onDelete = new EventEmitter<void>();
47-
@Output() onMove = new EventEmitter<number>();
46+
@Output() delete = new EventEmitter<void>();
47+
@Output() move = new EventEmitter<number>();
4848

4949
}

src/object-field/object-field.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<!-- ADD SUB FIELD FROM SCHEMA DROPDOWN -->
2222
<tr>
2323
<td class="button-holder">
24-
<add-field-dropdown [fields]="keys" [pathString]="pathString" (onFieldAdd)="onFieldAdd($event)" [schema]="schema">
24+
<add-field-dropdown [fields]="keys" [pathString]="pathString" (fieldAdd)="onFieldAdd($event)" [schema]="schema">
2525
<i class="fa fa-plus"></i>
2626
</add-field-dropdown>
2727
</td>

src/primitive-field/primitive-field.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
</div>
1717
<div *ngSwitchCase="'enum'">
1818
<searchable-dropdown [pathString]="pathString" [value]="value" [placeholder]="schema.title" [items]="schema.enum" [shortcutMap]="schema.enumShorcutMap"
19-
(onSelect)="onSearchableDropdownSelect($event)" [tabIndex]="tabIndex" (onBlur)="domUtilService.clearHighlight()"></searchable-dropdown>
19+
(select)="onSearchableDropdownSelect($event)" [tabIndex]="tabIndex" (onBlur)="domUtilService.clearHighlight()"></searchable-dropdown>
2020
</div>
2121
<div *ngSwitchCase="'autocomplete'">
2222
<autocomplete-input [pathString]="pathString" [value]="value" [path]="path" [autocompletionConfig]="schema.autocompletionConfig"
23-
(onBlur)="commitValueChange()" (onKeypress)="onKeypress($event)" (onValueChange)="onAutocompleteInputValueChange($event)"
23+
(blur)="commitValueChange()" (keypress)="onKeypress($event)" (valueChange)="onAutocompleteInputValueChange($event)"
2424
[placeholder]="schema.title" [tabIndex]="tabIndex"></autocomplete-input>
2525
</div>
2626
<div *ngSwitchCase="'integer'">

src/primitive-list-field/primitive-list-field.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<primitive-field [value]="value" [schema]="schema.items" [path]="getElementPath(i)"></primitive-field>
77
</td>
88
<td *ngIf="values.size > 0" class="button-holder" [ngClass]="sortableClass">
9-
<list-action-group (onMove)="moveElement(i, $event)" (onDelete)="deleteElement(i)" [canMove]="schema.sortable"></list-action-group>
9+
<list-action-group (move)="moveElement(i, $event)" (delete)="deleteElement(i)" [canMove]="schema.sortable"></list-action-group>
1010
</td>
1111
</tr>
1212
</table>

src/searchable-dropdown/searchable-dropdown.component.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ export class SearchableDropdownComponent implements OnInit {
4141
expression = '';
4242
status: { isOpen: boolean } = { isOpen: false };
4343

44-
@Output() onSelect = new EventEmitter<string>();
44+
@Output() select = new EventEmitter<string>();
4545
@Output() onBlur = new EventEmitter<void>();
4646

47-
4847
ngOnInit() {
4948
this.placeholder = this.value || this.placeholder || '';
5049
}
@@ -63,7 +62,7 @@ export class SearchableDropdownComponent implements OnInit {
6362

6463
onItemClick(item: string) {
6564
this.value = item;
66-
this.onSelect.emit(item);
65+
this.select.emit(item);
6766
}
6867

6968
onKeypress(key: string) {

src/sub-record/sub-record.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class SubRecordComponent implements OnInit, OnChanges {
4141
@Input() tabName = '';
4242
@Input() keys: Set<string>;
4343

44-
@Output() onDeleteKey: EventEmitter<string> = new EventEmitter<string>();
44+
@Output() deleteKey: EventEmitter<string> = new EventEmitter<string>();
4545

4646
keysByType: { others: Set<string>, toggles: Set<string> };
4747
pathCache: PathCache = {};
@@ -66,7 +66,7 @@ export class SubRecordComponent implements OnInit, OnChanges {
6666

6767
// delete only work for others, not toggles (UPDATE: config comment if this changes)
6868
deleteField(field: string) {
69-
this.onDeleteKey.emit(field);
69+
this.deleteKey.emit(field);
7070
this.jsonStoreService.removeIn(this.getPathForField(field));
7171
}
7272

src/table-list-field/table-list-field.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{key | underscoreToSpace}}
99
</th>
1010
<th class="button-holder" [ngClass]="sortableClass">
11-
<add-field-dropdown *ngIf="values.size > 0" [fields]="keys" [pathString]="getElementPathString(0)" (onFieldAdd)="onFieldAdd($event)"
11+
<add-field-dropdown *ngIf="values.size > 0" [fields]="keys" [pathString]="getElementPathString(0)" (fieldAdd)="onFieldAdd($event)"
1212
[schema]="schema.items">
1313
<i class="fa fa-plus"></i>
1414
</add-field-dropdown>
@@ -18,7 +18,7 @@
1818
<tr *ngFor="let value of values; let i = index; trackBy:trackByIndex" table-item-field [id]="getElementPathString(i)" [value]="value"
1919
[schema]="schema.items" [path]="getElementPath(i)" [keys]="keys">
2020
<td *ngIf="values.size > 0" class="button-holder" [ngClass]="sortableClass">
21-
<list-action-group (onMove)="moveElement(i, $event)" (onDelete)="deleteElement(i)" [canMove]="schema.sortable"></list-action-group>
21+
<list-action-group (move)="moveElement(i, $event)" (delete)="deleteElement(i)" [canMove]="schema.sortable"></list-action-group>
2222
</td>
2323
</tr>
2424
</table>

0 commit comments

Comments
 (0)