-
Notifications
You must be signed in to change notification settings - Fork 395
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
Update and streamline method and type names #584
Conversation
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
src/core/data.service.ts
Outdated
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 { |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
src/core/data.service.ts
Outdated
* @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; |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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.
src/core/data.service.ts
Outdated
} | ||
|
||
/** | ||
* Resolve the ref of the given control against the root data. | ||
* | ||
* @param {ControlElement} uischema | ||
* @param {ControlElement} uiSchema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uiSchema -> controlElement
src/core/data.service.ts
Outdated
* @return {any} the de-referenced data chunk | ||
*/ | ||
getValue(uischema: ControlElement): any { | ||
const pair = getValuePropertyPair(this.data, uischema.scope.$ref); | ||
getValue(uiSchema: ControlElement): any { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
test/json-forms.test.ts
Outdated
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 => { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
e763ba3
to
743966c
Compare
* Update and streamline methods names * Update test descriptions
743966c
to
13aed85
Compare
There was a problem hiding this 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; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uischema -> controlElement
Fixes #580: