-
Notifications
You must be signed in to change notification settings - Fork 90
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
How should the public API be? We want your feedback #58
Comments
Very excited to see these enhancements, @xxxTonixxx! The new inputs and event bindings are extremely useful. We are trying to understand how to invoke methods in the API but I don't see any examples to follow nor documentation of the API. How does one get a reference to a given |
@KeithGillette you would use the events the following way:
|
Thanks for the fast response, @Caballerog. I understand how to invoke my methods upon a given event from the inline-editor as you have shown. My question is how to put a given |
Thanks @KeithGillette for your interest! 😄 The actual documentation (the If you want to get an instance of Here you have a complete code-example: import { Component, ViewChild, AfterViewInit } from '@angular/core';
import { InlineEditorComponent, InlineEditorEvent } from '@qontu/ngx-inline-editor';
import { InputTextConfig } from '@qontu/ngx-inline-editor/configs';
@Component({
selector: 'app-root',
template: `
<inline-editor #myInlineEditorInstance [(ngModel)]="test" [config]="config"></inline-editor>
<inline-editor #myInlineEditorRefFromTemplate [(ngModel)]="test" [config]="config"></inline-editor>
<button (click)="myInlineEditorRefFromTemplate.edit({editing: true, event: $event})">
Edit the 2º inline-editor without create the property into class
</button>
<button (click)="myInlineEditorRefFromTemplate.cancel()">
Remove the editable state from the 2º inline-editor without create the property into class
</button>
<button (click)="logg(myInlineEditorRefFromTemplate)">
Console.log of inline-editor's value passing editor by parameter to function
</button>
`,
})
export class AppComponent implements AfterViewInit {
test = 'hi';
// The input instance, it is available on AfterViewInit hook
@ViewChild('myInlineEditorInstance') myInlineEditorInstance: InlineEditorComponent;
config: InputTextConfig = {
type: 'text',
};
ngAfterViewInit(): void {
// the input became to editable and focused when the page load
setTimeout(
() => this.myInlineEditorInstance.edit({ editing: true, doFocus: true }),
);
}
logg(inlineEditor: InlineEditorComponent) {
const { value } = inlineEditor.state.getState();
console.log(`This is the value of inline-editor getting the inline-editor instance from parameter: ${value}`);
}
} We would appreciate a lot your feedback! 👍 |
This is outstanding. Thanks for the fast response and detailed example, @xxxTonixxx! My use-case is a bit more complex, but I think I just figured out a solution. Within the template for my component, we have dynamically generated InlineEditorComponent instances (inside of a treeview). I can dynamically assign each a unique id in the @ViewChildren(InlineEditorComponent) private inlineEditorViewChildren: QueryList<InlineEditorComponent>; In my methods, I can then perform a find on the QueryList to identify the correct InlineEditorComponent on which to invoke the public API calls: public editNode(nodeId): void {
const inlineEditorToInvoke =
this.inlineEditorViewChildren.find((inlineEditorComponent: InlineEditorComponent) => {
return inlineEditorComponent.name === nodeId;
});
inlineEditorToInvoke.edit({editing: true, doFocus: true});
} |
First, thank you, @xxxTonixxx and @Caballerog for this useful component and these recent API enhancements which have made it much more versatile. Since you're requesting feedback on these changes, here are a couple of suggestions that have occurred to me in using the new API in my project: Select on EditAdd .edit( { editing: boolean, focus: boolean, select: boolean } ) (I know the current property is Pass
|
By order:
And thanks a lot for your feedback, it make me so happy! 😄 |
Another bit of feedback on this extremely useful component: I have discovered that one can pass additional arguments to the controller methods invoked by the public API from the template bindings, such as |
Hi! @KeithGillette, yes, it's an expected behavior and I've written some examples doing something similar. However, we should add some information about inline-editor's instance which is executing the method, based on this PR #72 Thanks for your feedback again, we appreciate them a lot 😄 |
Great! So here's another piece of feedback: I think calling manually I have a dynamically generated set of inline-editor instances repeated in my component template. I want the inline-editor to be invoked by selecting However, to make this work, I have to also set |
@KeithGillette , I think what you need to use is the Is it what you need? 👍 |
Yes, thanks, that is indeed exactly what I need, @xxxTonixxx! So please amend my last feedback post to this: The public API should be, well, public, since I think your last reply is the only place |
Hi @KeithGillette I have created a new PR with the docs 😄 Can you give us some feedback? #79 it's in WIP too, but that is the way 😉 |
Hi @xxxTonixxx. Apologies on the delay in responding. I've just returned from vacation this week. The new documentation site looks great! As you say, it's a work-in-progress, as it's lacking coverage of the bindable events and methods from the new public API. FYI: I noticed a few small wording changes that might make the documentation clearer but when I clicked the |
Thanks @KeithGillette for your review!! 😄 Yeah, I hope to have it ready soon 😅 And thanks for your interest in improve the docs, it fails because the link points to |
I'm on to my next use case for this component and back with another recommendation for the API: The This would allow for the creation of a very fluent keyboard-driven user experience. In my case, I have a TreeView of InlineEditorComponents and want to propagate up/down arrow presses to the parent TreeViewNode so that even when the InlineEditor is active, the user can navigate the tree. |
Hi @KeithGillette, sorry for my delay. Could you open a new issue with your request? Thanks for your feedback and improvements! 👍 |
With the last PR (#57), the public API is going to change and it would be good opinions and way of to do this.
At the moment, the public API is something like this:
All events return an
ExternalEvent
(exported asInlineEvent
) ->An
state
is the state of input when this one changed (the new state), for example: if I click an input, its state will change fromediting: false
toediting: true
, and if I type'a'
, its state will change fromvalue: ''
tovalue: 'a'
. These states are in hot, until I do click onsave
, this changes will not reflect in the model (ngModel
) and I will receive it using the events ((onChange)="todoSomething($event)"
, etc.).InlineError | InlineError[]
->{ type: string, message: string }
save( { event: Event, state: InlineState }: ExternalEvent )
saveAndClose( { event: Event, state: InlineState }: ExternalEvent )
edit( { editing: boolean, doFocus: boolean } )
cancel( { event: Event, state: InlineState }: ExternalEvent )
getHotState(): InlineState // This returns state from input (no saved)
Are the methods user friendly? is this the correct approach? Please, give us your feedback 👍
The text was updated successfully, but these errors were encountered: