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

Grey-out buttons after submission #457

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

shikhavani
Copy link

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Shikha Vani seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@pjmonks pjmonks linked an issue Feb 5, 2022 that may be closed by this pull request
Copy link
Contributor

@pjmonks pjmonks left a comment

Choose a reason for hiding this comment

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

Generally the solution looks good, thank you. Please could you review my comments though to fix up a couple of things.

Also, there are linting issues found in your changes which our build picked up on. If you run this command you will get a HTML report, you'll only need to care about the errors found (there will be lots of warnings, please ignore those):

npm run eslint -- --format html -o eslint_report.html

@jamesrwelch You've mentioned that there may be more places where a submission button should be disabled whilst saving, perhaps the issue should be updated to list these places to clearly identify them? Then this PR could cover all those cases too.

@@ -51,6 +51,7 @@ export class DataModelMainComponent implements OnInit {
private folders: FolderService,
private title: Title) { }

disabledSave = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be moved to above the constructor please? So directly below the field parentFolder? This will keep all fields organised the same way.

Also, I would suggest renaming this to isSaving to give more semantic meaning.

this.stateHandler.Go('datamodel', { id: response.body.id }, { reload: true, location: true });
}, error => {
this.disabledSave = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a shorter way of setting this flag back to false without having to duplicate it. There is an rxjs operator called finalize() which, if included in the pipe(), will always be called regardless of whether it was successful or not. Including something like the following would then you only need to set this flag once:

.addToFolder()
.pipe(
  catchError(error => {
    // Error case
  }),
  finalize(() => this.disabledSave = false)  // Always called at the end
)
.subscribe((response) => {
  // Success case
});

@shikhavani
Copy link
Author

shikhavani commented Feb 7, 2022 via email

@joe-crawford
Copy link
Contributor

Thanks for your PR @shikhavani. Sorry for the delay, we'd missed this update. Would you be able to sign the Contributor Licence Agreement for this to be merged?

Link to the CLA: https://cla-assistant.io/MauroDataMapper/mdm-ui?pullRequest=457

cc @jamesrwelch

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.

Grey-out buttons after submission
4 participants