Skip to content

Update and streamline method and type names #584

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

Merged
merged 1 commit into from
Jun 19, 2017

Conversation

edgarmueller
Copy link
Contributor

Fixes #580:

  • Also updates test descriptions

@coveralls
Copy link

Coverage Status

Coverage remained the same at 98.399% when pulling 0bbefbd on edgarmueller:topic/namings into 9e7288d on eclipsesource:jsonforms2.

Copy link
Member

@eneufeld eneufeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix, just some small naming annotations

};

/**
* Global JSONForms object that holds services and registries.
*/
export class JsonFormsHolder {
export class JsonForms {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JsonForms is also not a perfect name. Is this maybe a JsonFormsConfiguration?
But as I don't have a better name for this, I'm fine with it, we just should think about how to name the global variable that is created by webpack

Copy link
Contributor Author

@edgarmueller edgarmueller Jun 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree regarding the name of the exported global variable that's created by webpack and I'd probably also name it JsonForms :)
I named it JsonForms because I was hoping that this will be the only globar var that is relevant from end-users perspective when extending JsonForms (e.g. when adding styles or UI schemata), but I have no hard opionion on this.

notifyChange(uischema: ControlElement, newValue: any): void {
if (uischema !== undefined && uischema !== null) {
const pair = getValuePropertyPair(this.data, uischema.scope.$ref);
notifyDataChangeListeners(controlElement: ControlElement, newValue: any): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion this name is not correct, as we are calling this on the dataservice in order to notify the dataservice about a datachange, so if a control renderer changes a value it notifies the dataservice.
So a better name would be notifyAboutDataChange ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, yes, true, I focused too much on the listener aspect here. Actually, we should probably rename and split this up to:

changeData(ControlElement, any) {
  // assign newValue as before
  notifyDataChangeListeners()
}

What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, the notifyDataChangeListeners() would be private then?

* @param {any} newValue the changed data value
* @param {any} data the current data value
*/
notifyChange(uischema: ControlElement, newValue: any, data: any): void;
dataChanged(uiSchema: ControlElement, newValue: any, data: any): void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we name "uiSchema" -> "controlElement"?

Copy link
Contributor Author

@edgarmueller edgarmueller Jun 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I missed a couple of those. Will update.

}

/**
* Resolve the ref of the given control against the root data.
*
* @param {ControlElement} uischema
* @param {ControlElement} uiSchema
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uiSchema -> controlElement

* @return {any} the de-referenced data chunk
*/
getValue(uischema: ControlElement): any {
const pair = getValuePropertyPair(this.data, uischema.scope.$ref);
getValue(uiSchema: ControlElement): any {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uiSchema -> controlElement

@@ -41,15 +41,15 @@ export class ArrayControlRenderer extends Renderer implements DataChangeListener
/**
* @inheritDoc
*/
isRelevantKey (uischema: ControlElement): boolean {
needsNotificationAbout (uischema: ControlElement): boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uiSchema -> controlElement

super.disconnectedCallback();
}

/**
* @inheritDoc
*/
isRelevantKey (uischema: ControlElement): boolean {
needsNotificationAbout (uischema: ControlElement): boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uiSchema -> controlElement

@@ -104,7 +104,7 @@ export abstract class BaseControl <T extends HTMLElement>
/**
* @inheritDoc
*/
notifyChange(uischema: ControlElement, newValue: any, data: any): void {
dataChanged(uischema: ControlElement, newValue: any, data: any): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uiSchema -> controlElement

@@ -161,7 +161,7 @@ export abstract class BaseControl <T extends HTMLElement>
*
* @returns {T} the created HTML input element
*/
protected abstract get inputElement(): T;
protected abstract get createInputElement(): T;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not be a getter maybe?

jsonForms.data = {name: 'foo'};
const dataSchema = {type: 'object', properties: {name: {type: 'string'}}} as JsonSchema;
jsonForms.dataSchema = dataSchema;
jsonForms.connectedCallback();
t.is(jsonForms.children.length, 0);
});
test.cb('jsonforms data and schema', t => {
test.cb('Connect JSON Forms element asynchronously with data and data schema set', t => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the async comes from the dataschema resolution, so it is just needed to run the test successfully

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but I couldn't think of any other name. Suggestions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can''t we simply omit the async text in the test? or we make all of them async

@edgarmueller edgarmueller force-pushed the topic/namings branch 2 times, most recently from e763ba3 to 743966c Compare June 14, 2017 14:53
@coveralls
Copy link

Coverage Status

Coverage remained the same at 98.399% when pulling 743966c on edgarmueller:topic/namings into 59be224 on eclipsesource:jsonforms2.

* Update and streamline methods names
* Update test descriptions
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.001%) to 98.397% when pulling 13aed85 on edgarmueller:topic/namings into 59be224 on eclipsesource:jsonforms2.

Copy link
Member

@eneufeld eneufeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you very much for the naming fix.
There are still some parameters named inconsistent, but this can be fixed in a separate PR if you like

* @returns whether this listener is interested in the given control element
*/
isRelevantKey(uischema: ControlElement): boolean;
needsNotificationAbout(uiSchema: ControlElement): boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uiSchema -> controlElement

}

/**
* @inheritDoc
*/
notifyChange(uischema: ControlElement, newValue: any, data: any): void {
dataChanged(uischema: ControlElement, newValue: any, data: any): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uischema -> controlElement

@@ -42,15 +42,15 @@ export class TableArrayControlRenderer extends Renderer implements DataChangeLis
/**
* @inheritDoc
*/
isRelevantKey (uischema: ControlElement): boolean {
needsNotificationAbout (uischema: ControlElement): boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uischema -> controlElement

return uischema === undefined || uischema === null
? false : (<ControlElement>this.uischema).scope.$ref === uischema.scope.$ref;
}

/**
* @inheritDoc
*/
notifyChange(uischema: ControlElement, newValue: any, data: any): void {
dataChanged(uischema: ControlElement, newValue: any, data: any): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uischema -> controlElement

@@ -126,12 +126,12 @@ export class TreeMasterDetailRenderer extends Renderer implements DataChangeList
this.renderFull();
return this;
}
isRelevantKey (uischema: ControlElement): boolean {
needsNotificationAbout (uischema: ControlElement): boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uischema -> controlElement

return uischema === undefined || uischema === null ? false :
(<ControlElement>this.uischema).scope.$ref === uischema.scope.$ref && !this.addingToRoot;
}

notifyChange(uischema: ControlElement, newValue: any, data: any): void {
dataChanged(uischema: ControlElement, newValue: any, data: any): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uischema -> controlElement

jsonForms.data = element;
jsonForms.dataSchema = schema;
// check needed for tests
if (jsonForms.addDataChangeListener) {
jsonForms.addDataChangeListener({
isRelevantKey: (uischema: ControlElement): boolean => {
needsNotificationAbout: (uischema: ControlElement): boolean => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uischema -> controlElement

return uischema !== null;
},
notifyChange: (uischema: ControlElement, newValue: any, data: any): void => {
dataChanged: (uischema: ControlElement, newValue: any, data: any): void => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uischema -> controlElement

@edgarmueller edgarmueller merged commit 5e6998d into eclipsesource:jsonforms2 Jun 19, 2017
@edgarmueller edgarmueller deleted the topic/namings branch March 8, 2018 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants