Skip to content
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(modal): add initial version of the modal service #609

Closed
wants to merge 3 commits into from
Closed

feat(modal): add initial version of the modal service #609

wants to merge 3 commits into from

Conversation

pkozlowski-opensource
Copy link
Member

@pkozlowski-opensource pkozlowski-opensource commented Aug 18, 2016

Very rough implementation of the NgbModal service. Opening this PR early on so we can discuss the details. Check discussion in #3 (comment) for more details / remaining work.

Even if there is still more work that needs to be done I believe that this is the first good shoot witch should have stable API (I mean, remaining work shouldn't have non-backward compatible API changes). As such I think that we can go ahead and land it so users can play with it.

Please review.

@@ -16,13 +17,14 @@ import {NgbTooltipModule} from './tooltip';
import {NgbTypeaheadModule} from './typeahead';

export {NgbPanelChangeEvent} from './accordion';
export {NgbModal} from './modal';
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't NgbModalRef and NgbModalOptions be exported too? They're the return type and the argument type of NgbModal.open(), which is the public API, so client code should be able to refer to these types, too, shouldn't they?

Copy link
Member Author

Choose a reason for hiding this comment

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

They should, I thought I've exported them. This is still WIP so thx for catching this one!

@pkozlowski-opensource pkozlowski-opensource changed the title WIP: feat(modal): add initial version of the modal service feat(modal): add initial version of the modal service Aug 24, 2016
});
}

private _getContentNodes(content: string | TemplateRef<any>, context: ModalContentContext) {
Copy link
Member

Choose a reason for hiding this comment

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

What type of object is this returning?

Copy link
Member Author

Choose a reason for hiding this comment

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

An array of DOM nodes. Will add return type.

@wesleycho
Copy link
Member

This LGTM - it's possible I missed something, so one other person reviewing probably would be a good idea.

this.modalService.open(content).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed with: ${reason}`;
Copy link
Member

Choose a reason for hiding this comment

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

escape and backdrop click return 1 and 0 as dismiss reasons which are NgbDismissReasons values. But it looks strange in the demo → should switch over enum values and display text?

Copy link
Member Author

Choose a reason for hiding this comment

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

changed

@maxokorokov
Copy link
Member

LGTM, some comments in the code plus:

  • had a feeling that any vs concrete type usage looks a bit messy in general, feel free to ignore :)
  • dynamic component creation looks like a lot of boilerplate and similar to PopupService, but what can you do with it right now?...

const nodes = this._getContentNodes(content, modalContentContext);
const windowCmptRef = this._viewContainerRef.createComponent(this._windowFactory, 0, this._injector, nodes);
let backdropCmptRef;
let ngbModalRef;
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 type this var and the previous one?

@Foxandxss
Copy link
Member

Nothing against, minus a minimal nitpick.

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.

None yet

5 participants