-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
feat(config): Support for custom error component & positioning #15
Conversation
I have updated the sample app to show how the two new configuration settings can be used. While I'm somewhat sure about the correctness of the My sample shows repositioning the error component using DOM manipulation, which I'm not so certain is the Angular way of doing things. I resorted to this approach as I couldn't figure out an Angular API to do it cleanly, ie, using their well defined interfaces. Perhaps there's one. If there's, please share. Tks. |
projects/ngneat/error-tailor/src/lib/control-error.component.ts
Outdated
Show resolved
Hide resolved
projects/ngneat/error-tailor/src/lib/control-error.component.ts
Outdated
Show resolved
Hide resolved
I have completed the changes that you requested along with the necessary updates to the README. I also created a sample Ionic project which is here. It currently statically links the amended source, but once the PR is merged, I'll change that to use the npm package. If you want to merge or refer to this sample in the README, pls let me know. Thanks. |
projects/ngneat/error-tailor/src/lib/control-error.component.ts
Outdated
Show resolved
Hide resolved
projects/ngneat/error-tailor/src/lib/control-error.directive.spec.ts
Outdated
Show resolved
Hide resolved
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.
Great changes.
Made all the changes as per your suggestions except for a test for the destroy function (see reply to your comment). Let me know if I missed out something. Thanks again an apologies for the slight delay. |
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.
LGTM. I'll play with the code later and keep you update.
src/app/app.module.ts
Outdated
@@ -23,7 +39,9 @@ import { ErrorTailorModule } from '@ngneat/error-tailor'; | |||
}; | |||
}, | |||
deps: [] | |||
} | |||
}, | |||
controlErrorComponent: CustomControlErrorComponent, // Uncomment to see errors being rendered using a custom component |
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.
Uncomment again :)
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.
oops
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.
Shall I remove the whole custom control specification from the sample app? Sample code for this in the README and I believe is well captured there. So may be it's not necessary?
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.
No, just put it in a comment. It's good for testing.
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.
Ok
Resolve the conflicts, please. |
README.md
Outdated
// Custom error component that will replace the standard DefaultControlErrorComponent. | ||
@Component({ | ||
template: ` | ||
<ion-item lines="none" class="ion-text-wrap" [class.hide-control]="hide"> |
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.
Let's make the public properties more readable for the consumers:
hide => hideError
_tpl => errorTemplate
_text => errorText
context => errorContext
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.
Excellent idea. Small things like this can go a long way to ease the pain of using a library!
] | ||
}) | ||
export class CustomControlErrorComponent extends DefaultControlErrorComponent { | ||
constructor(cdr: ChangeDetectorRef, host: ElementRef<HTMLElement>) { |
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.
Omit the constructor
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.
Done.
README.md
Outdated
export class AppModule {} | ||
``` | ||
|
||
### Per Control Config |
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.
Remove this section. It's in the inputs section.
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.
Got it. I also removed the redundant Global Config subsection.
README.md
Outdated
@@ -210,6 +210,7 @@ The library adds a `form-submitted` to the submitted form. You can use it to sty | |||
|
|||
## Config | |||
|
|||
### Global Config |
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.
remove ### Global Config
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.
Done
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.
Add yourself to the contributors' list by running npm run contributors:add
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #14
What is the new behavior?
Introduces two new global config options --
controlErrorComponent
&controlErrorComponentAnchorFn
. Both are documented.Does this PR introduce a breaking change?
Other information