Skip to content

Commit

Permalink
Merge pull request #63 from gewaer/development
Browse files Browse the repository at this point in the history
Update master to v0.2.20
  • Loading branch information
Carlos Polanco authored May 25, 2021
2 parents 5ee2364 + 7ccc41b commit 33863cf
Show file tree
Hide file tree
Showing 10 changed files with 232 additions and 147 deletions.
166 changes: 98 additions & 68 deletions dist/gw-settings.common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/gw-settings.common.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/gw-settings.css

Large diffs are not rendered by default.

166 changes: 98 additions & 68 deletions dist/gw-settings.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/gw-settings.umd.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/gw-settings.umd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/gw-settings.umd.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gewaer/gw-settings",
"version": "0.2.19",
"version": "0.2.20",
"description": "Base settings component for the Gewaer platform.",
"main": "./dist/gw-settings.umd.min.js",
"files": [
Expand Down
27 changes: 26 additions & 1 deletion src/components/users/profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,26 @@ export default {
languages: state => state.Application.languages,
locales: state => state.Application.locales,
userDataState: state => state.User.data
})
}),
hasUnsavedChanges() {
return this.$validator._base.fields.items.some((item) => item.flags.changed);
}
},
watch: {
hasUnsavedChanges(hasChanges) {
if (hasChanges) {
window.addEventListener("beforeunload", this.handleBeforeUnloadListener);
} else {
this.unattachBeforeUnload();
}
}
},
created() {
this.initialize();
},
beforeDestroy() {
this.unattachBeforeUnload();
},
beforeRouteLeave(to, from, next) {
const formFields = this.$refs.profileForm.getChangedFields();
this.checkForUnsavedChanges(formFields, next);
Expand Down Expand Up @@ -292,6 +307,7 @@ export default {
text: "Your information has been updated successfully!",
type: "success"
});
this.unattachBeforeUnload();
}).catch((error) => {
this.$notify({
title: "Error",
Expand Down Expand Up @@ -328,6 +344,15 @@ export default {
this.clearChangedFields();
this.update();
},
unattachBeforeUnload() {
window.removeEventListener("beforeunload", this.handleBeforeUnloadListener);
},
handleBeforeUnloadListener(event) {
// Compatible with new versions of browsers
event.preventDefault();
// Compatible chrome, safari, firefox 4+, opera 12+, ie 9+
return event.returnValue = "";
}
}
};
Expand Down

0 comments on commit 33863cf

Please sign in to comment.