mirror of
https://github.com/bitwarden/desktop.git
synced 2024-11-28 12:35:40 +01:00
detect other times nav away from dirty input
This commit is contained in:
parent
f8a378b26d
commit
4e9759cd62
2
jslib
2
jslib
@ -1 +1 @@
|
|||||||
Subproject commit b3d1e9d233aa7ed235d6ec0b26cdba41afa065ae
|
Subproject commit 57e49207e9ad57c71576fc487a38513a4d0fe120
|
8
package-lock.json
generated
8
package-lock.json
generated
@ -1581,12 +1581,12 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"async": {
|
"async": {
|
||||||
"version": "2.6.1",
|
"version": "2.6.3",
|
||||||
"resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz",
|
||||||
"integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==",
|
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"lodash": "^4.17.10"
|
"lodash": "^4.17.14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"async-done": {
|
"async-done": {
|
||||||
|
@ -91,16 +91,16 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
switch (message.command) {
|
switch (message.command) {
|
||||||
case 'newLogin':
|
case 'newLogin':
|
||||||
this.addCipher(CipherType.Login);
|
await this.addCipher(CipherType.Login);
|
||||||
break;
|
break;
|
||||||
case 'newCard':
|
case 'newCard':
|
||||||
this.addCipher(CipherType.Card);
|
await this.addCipher(CipherType.Card);
|
||||||
break;
|
break;
|
||||||
case 'newIdentity':
|
case 'newIdentity':
|
||||||
this.addCipher(CipherType.Identity);
|
await this.addCipher(CipherType.Identity);
|
||||||
break;
|
break;
|
||||||
case 'newSecureNote':
|
case 'newSecureNote':
|
||||||
this.addCipher(CipherType.SecureNote);
|
await this.addCipher(CipherType.SecureNote);
|
||||||
break;
|
break;
|
||||||
case 'newFolder':
|
case 'newFolder':
|
||||||
await this.addFolder();
|
await this.addFolder();
|
||||||
@ -190,12 +190,12 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
const cipherView = new CipherView();
|
const cipherView = new CipherView();
|
||||||
cipherView.id = params.cipherId;
|
cipherView.id = params.cipherId;
|
||||||
if (params.action === 'edit') {
|
if (params.action === 'edit') {
|
||||||
this.editCipher(cipherView);
|
await this.editCipher(cipherView);
|
||||||
} else {
|
} else {
|
||||||
this.viewCipher(cipherView);
|
await this.viewCipher(cipherView);
|
||||||
}
|
}
|
||||||
} else if (params.action === 'add') {
|
} else if (params.action === 'add') {
|
||||||
this.addCipher();
|
await this.addCipher();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.favorites) {
|
if (params.favorites) {
|
||||||
@ -226,18 +226,8 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
async viewCipher(cipher: CipherView) {
|
async viewCipher(cipher: CipherView) {
|
||||||
if (this.action === 'view' && this.cipherId === cipher.id) {
|
if (this.action === 'view' && this.cipherId === cipher.id) {
|
||||||
return;
|
return;
|
||||||
} else if (
|
} else if (this.dirtyInput() && await this.wantsToSaveChanges()) {
|
||||||
(this.action == 'add' || this.action === 'edit')
|
return;
|
||||||
&& document.getElementById('details').getElementsByClassName('ng-dirty').length > 0
|
|
||||||
) {
|
|
||||||
const confirmed = await this.platformUtilsService.showDialog(
|
|
||||||
this.i18nService.t('unsavedChangesConfirmation'),
|
|
||||||
this.i18nService.t('unsavedChangesTitle'),
|
|
||||||
this.i18nService.t('yes'),
|
|
||||||
this.i18nService.t('no'),
|
|
||||||
'warning'
|
|
||||||
);
|
|
||||||
if (!confirmed) return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cipherId = cipher.id;
|
this.cipherId = cipher.id;
|
||||||
@ -313,9 +303,11 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
menu.popup({ window: remote.getCurrentWindow() });
|
menu.popup({ window: remote.getCurrentWindow() });
|
||||||
}
|
}
|
||||||
|
|
||||||
editCipher(cipher: CipherView) {
|
async editCipher(cipher: CipherView) {
|
||||||
if (this.action === 'edit' && this.cipherId === cipher.id) {
|
if (this.action === 'edit' && this.cipherId === cipher.id) {
|
||||||
return;
|
return;
|
||||||
|
} else if (this.dirtyInput() && await this.wantsToSaveChanges()) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cipherId = cipher.id;
|
this.cipherId = cipher.id;
|
||||||
@ -323,9 +315,11 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
this.go();
|
this.go();
|
||||||
}
|
}
|
||||||
|
|
||||||
addCipher(type: CipherType = null) {
|
async addCipher(type: CipherType = null) {
|
||||||
if (this.action === 'add') {
|
if (this.action === 'add') {
|
||||||
return;
|
return;
|
||||||
|
} else if (this.dirtyInput() && await this.wantsToSaveChanges()) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addType = type;
|
this.addType = type;
|
||||||
@ -578,6 +572,18 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private dirtyInput(): boolean {
|
||||||
|
return (this.action === 'add' || this.action === 'edit') &&
|
||||||
|
document.querySelectorAll('app-vault-add-edit .ng-dirty').length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async wantsToSaveChanges(): Promise<boolean> {
|
||||||
|
const confirmed = await this.platformUtilsService.showDialog(
|
||||||
|
this.i18nService.t('unsavedChangesConfirmation'), this.i18nService.t('unsavedChangesTitle'),
|
||||||
|
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
|
||||||
|
return !confirmed;
|
||||||
|
}
|
||||||
|
|
||||||
private clearFilters() {
|
private clearFilters() {
|
||||||
this.folderId = null;
|
this.folderId = null;
|
||||||
this.collectionId = null;
|
this.collectionId = null;
|
||||||
|
@ -1269,9 +1269,9 @@
|
|||||||
"message": "Privacy Policy"
|
"message": "Privacy Policy"
|
||||||
},
|
},
|
||||||
"unsavedChangesConfirmation": {
|
"unsavedChangesConfirmation": {
|
||||||
"message": "Are you sure you want to leave? If you leave now then your current information won't be saved"
|
"message": "Are you sure you want to leave? If you leave now then your current information will not be saved."
|
||||||
},
|
},
|
||||||
"unsavedChangesTitle": {
|
"unsavedChangesTitle": {
|
||||||
"message": "There Are Unsaved Changes"
|
"message": "Unsaved Changes"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user