Browse Source

Confirm dialog for assets.

pull/501/head
Sebastian 6 years ago
parent
commit
3f8a4b7c50
  1. 4
      frontend/app/framework/angular/forms/confirm-click.directive.ts
  2. 35
      frontend/app/shared/components/assets/asset.component.ts
  3. 6
      frontend/app/shared/components/comments/comment.component.ts

4
frontend/app/framework/angular/forms/confirm-click.directive.ts

@ -79,10 +79,10 @@ export class ConfirmClickDirective implements OnDestroy {
const subscription =
this.dialogs.confirm(this.confirmTitle, this.confirmText)
.subscribe(result => {
.subscribe(confiormed => {
this.isOpen = false;
if (result) {
if (confiormed) {
this.clickConfirmed.delayEmit();
}

35
frontend/app/shared/components/assets/asset.component.ts

@ -105,22 +105,27 @@ export class AssetComponent implements OnInit {
public updateFile(files: FileList) {
if (files.length === 1 && this.asset.canUpload) {
this.setProgress(1);
this.assetUploader.uploadAsset(this.asset, files[0])
.subscribe(asset => {
if (Types.isNumber(asset)) {
this.setProgress(asset);
} else {
this.setProgress(0);
this.setAsset(asset);
this.dialogs.confirm('Replace asset?', `Do you really want to replace asset **${this.asset.fileName}** with a newer version`)
.subscribe(confirmed => {
if (confirmed) {
this.setProgress(1);
this.assetUploader.uploadAsset(this.asset, files[0])
.subscribe(asset => {
if (Types.isNumber(asset)) {
this.setProgress(asset);
} else {
this.setProgress(0);
this.setAsset(asset);
}
}, error => {
this.dialogs.notifyError(error);
this.setProgress(0);
}, () => {
this.setProgress(0);
});
}
}, error => {
this.dialogs.notifyError(error);
this.setProgress(0);
}, () => {
this.setProgress(0);
});
}
}

6
frontend/app/shared/components/comments/comment.component.ts

@ -105,8 +105,10 @@ export class CommentComponent implements OnChanges {
if (!text || text.length === 0) {
this.dialogs.confirm('Delete comment', 'Do you really want to delete the comment?')
.subscribe(() => {
this.delete();
.subscribe(confirmed => {
if (confirmed) {
this.delete();
}
});
} else {
this.commentsState.update(this.comment, text);

Loading…
Cancel
Save