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

[API change] ConfigurableNavigationMode proposal #211

Merged
merged 14 commits into from May 16, 2019

Conversation

earshinov
Copy link
Contributor

@earshinov earshinov commented May 11, 2019

Initial proposal in madoar/angular-archwizard-demo#31 (comment)

This PR offers a new ConfigurableNavigationMode class which

  • takes navigateBackward and navigateForward policies
  • is configurable via a new [awNavigationMode] directive like this:
<!-- default navigation mode -->
<aw-wizard>...</aw-wizard>

<!-- default navigation mode -->
<aw-wizard [awNavigationMode]>...</aw-wizard> 

<!-- allow the user  navigate forward, like `SemiStrictNavigationMode` or `FreeNavigationMode` -->
<aw-wizard [awNavigationMode] navigateForward="allow">...</aw-wizard> 

<!-- custom navigation mode -->
<aw-wizard [awNavigationMode]="customNavigationMode"></aw-wizard>

Benefits of this approach:

  • ConfigurableNavigationMode replaces former StrictNavigationMode, SemiStrictNavigationMode, FreeNavigationMode, making the code more compact
  • ConfigurableNavigationMode can be extended to support navigationForward="visited" to make the custom navigation mode A demo for custom navigation mode angular-archwizard-demo#31 a part of the library

Correspondence to the old NavigationMode classes:

  • StrictNavigationMode (default) - "navigateBackward"="allow" navigateForward="deny" (default)
  • SemiStrictNavigationMode - "navigateBackward"="allow" navigateForward="allow"
  • FreeNavigationMode - "navigateBackward"="allow" navigateForward="allow" (same as SemiStrictNavigationMode, see relevant discussion)

} else {
return false;
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: Simplify this code after "navigationForward"="visited" is implemented.

@earshinov
Copy link
Contributor Author

@madoar , Please do an initial review. After that I will make changes to the demo project, if needed.

Copy link
Owner

@madoar madoar left a comment

Choose a reason for hiding this comment

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

I like the PR overall. I'll take a more detailed look at it later today!

@earshinov earshinov changed the title ConfigurableNavigationMode proposal [API change] ConfigurableNavigationMode proposal May 12, 2019
src/lib/components/wizard.component.ts Outdated Show resolved Hide resolved
export class ConfigurableNavigationMode extends BaseNavigationMode {

constructor(
private navigateBackward: 'allow'|'deny'|null = null,
Copy link
Owner

Choose a reason for hiding this comment

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

Do we require the = null here?

Copy link
Owner

Choose a reason for hiding this comment

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

After looking at the line again I think I can answer that question myself: yes we do, because 'allow'|'deny'|null doesn't allow for undefined

Copy link
Contributor Author

@earshinov earshinov May 14, 2019

Choose a reason for hiding this comment

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

No, this answer is not exactly right :)

You are not using TypeScript in strict mode (not using strict or, more specifically, strictNullChecks compiler option in tsconfig.json). So, in angular-archwizard's codebase, undefined is assignable to null. Not only that, you would also be able to assign either null or undefined to a variable declared as simply 'allow'|'deny'. I have included |null into the type signature 1) to be explicit; 2) because I am used to strict mode.

So, if we are not concerned with being strict, private navigateBackward: 'allow'|'deny'|null = null could be alternatively declared as private navigateBackward?: 'allow'|'deny', the only difference being that the default value would be undefined rather than null.

Copy link
Owner

Choose a reason for hiding this comment

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

About strict mode: I've nothing about changing the angular-archwizard code base to use strict mode if we are able to. I'm always in favor of preventing bugs, which I think we can achieve by using strict mode. So if you think it is a good idea to change the project to use strict mode feel free to do so!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I welcome the idea to switch to strict mode, but it can wait till another time.

Copy link
Owner

@madoar madoar left a comment

Choose a reason for hiding this comment

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

Ok, I think the only thing that is missing is updating the README file. I think the following points need to be changed:

@earshinov
Copy link
Contributor Author

README updated in 171d344

@earshinov
Copy link
Contributor Author

@madoar , FYI, I will be on vacation until the beginning of June, away from phone and Internet. Please do not expect a reply from me until 2019-06-04.

@madoar madoar merged commit 57900c5 into madoar:develop May 16, 2019
@madoar
Copy link
Owner

madoar commented May 16, 2019

@earshinov thanks for telling me! I wish you a nice and restful vacation!

@madoar
Copy link
Owner

madoar commented May 16, 2019

It seems like this PR contains a bug that displays the step indicators of completion steps with red color instead of with dark green color after they are entered:

grafik

@madoar
Copy link
Owner

madoar commented May 16, 2019

I've opened a new issue (#213) for the problem with my current findings.
The issue may be unrelated to this PR, because this PR doesn't change the scss styles nor the related css class assignment code.

@earshinov earshinov deleted the configurable-nav-mode branch June 9, 2019 14:58
earshinov added a commit to earshinov/angular-archwizard that referenced this pull request Jun 11, 2019
It makes little sense to have tests for StrictNavigationMode, SemiStrictNavigationMode, FreeNavigationMode after the corresponding classes have been removed in madoar#211
madoar pushed a commit that referenced this pull request Jun 11, 2019
* Extract test-utils.ts with checkWizardState function
* Clean up navigation unit tests
   It makes little sense to have tests for StrictNavigationMode, SemiStrictNavigationMode, FreeNavigationMode after the corresponding classes have been removed in #211
* Fix issues reported by Codacy, except 'magic numbers' which seem inevitable in unit tests
* Remove trailing commas
* Provide comments for the `checkWizardStep` function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants