Changes copy behavior to reload list rather than navigate to edit form. Shows toast message on successful copy.

This commit is contained in:
mabashian
2018-07-19 16:04:18 -04:00
parent eb22e09e4d
commit 6b3f45bc26
8 changed files with 134 additions and 35 deletions

View File

@@ -6,10 +6,10 @@
export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', 'GetBasePath',
'Wait', '$state', '$filter', 'rbacUiControlService', 'Dataset', 'credentialType', 'i18n',
'CredentialModel', 'CredentialsStrings',
'CredentialModel', 'CredentialsStrings', 'ngToast',
function($scope, Rest, CredentialList, Prompt,
ProcessErrors, GetBasePath, Wait, $state, $filter, rbacUiControlService, Dataset,
credentialType, i18n, Credential, CredentialsStrings) {
credentialType, i18n, Credential, CredentialsStrings, ngToast) {
const credential = new Credential();
@@ -93,9 +93,21 @@ export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', '
Wait('start');
new Credential('get', credential.id)
.then(model => model.copy())
.then(({ id }) => {
const params = { credential_id: id };
$state.go('credentials.edit', params, { reload: true });
.then((copiedCred) => {
ngToast.success({
content: `
<div class="Toast-wrapper">
<div class="Toast-icon">
<i class="fa fa-check-circle Toast-successIcon"></i>
</div>
<div>
${CredentialsStrings.get('SUCCESSFUL_CREATION', copiedCred.name)}
</div>
</div>`,
dismissButton: false,
dismissOnTimeout: true
});
$state.go('.', null, { reload: true });
})
.catch(({ data, status }) => {
const params = { hdr: 'Error!', msg: `Call to copy failed. Return status: ${status}` };