Skip to content

Commit

Permalink
Merge branch 'master' into 8085-community-reports-no-snackbar-for-add…
Browse files Browse the repository at this point in the history
…ing-editing-deleting
  • Loading branch information
dogi authored Jan 15, 2025
2 parents 707fc71 + 5c19534 commit 379c8a9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/app/news/news-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { dedupeShelfReduce } from '../shared/utils';
export class NewsListComponent implements OnChanges {

@Input() items: any[] = [];
@Input() editSuccessMessage = $localize`News has been updated successfully.`;
@Input() editSuccessMessage = $localize`Message updated successfully.`;
@Input() viewableBy = 'community';
@Input() viewableId: string;
@Input() editable = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
<span class="margin-lr-8" i18n>OR</span>
</ng-container>
<button mat-raised-button mat-dialog-close i18n>Cancel</button>
<button color="primary" mat-raised-button [disabled]="okDisabled" (click)="ok()" i18n>OK</button>
<button color="primary" mat-raised-button [disabled]="okDisabled || isSubmitting" (click)="ok()" i18n>OK</button>
</mat-dialog-actions>
11 changes: 9 additions & 2 deletions src/app/shared/dialogs/dialogs-add-resources.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Inject, ViewChild, AfterViewInit } from '@angular/core';
import { Component, Inject, ViewChild, AfterViewInit, ChangeDetectorRef } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { ResourcesComponent } from '../../resources/resources.component';
import { ResourcesAddComponent } from '../../resources/resources-add.component';
Expand All @@ -16,11 +16,13 @@ export class DialogsAddResourcesComponent implements AfterViewInit {
okDisabled = true;
updateResource = false;
existingResource: any = {};
isSubmitting = false;

constructor(
public dialogRef: MatDialogRef<DialogsAddResourcesComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
private dialogsLoadingService: DialogsLoadingService
private dialogsLoadingService: DialogsLoadingService,
private cdr: ChangeDetectorRef
) {
this.linkInfo = this.data.db ? { [this.data.db]: this.data.linkId } : undefined;
if (this.data.resource) {
Expand All @@ -32,9 +34,14 @@ export class DialogsAddResourcesComponent implements AfterViewInit {

ngAfterViewInit() {
this.initOkDisableChange();
this.cdr.detectChanges();
}

ok() {
if (this.isSubmitting) {
return;
}
this.isSubmitting = true;
this.dialogsLoadingService.start();
switch (this.view) {
case 'resources':
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/dialogs/dialogs-prompt.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
user {member}
change {change}
team {team}
enterprise {enterprise}
task {task}
certification {certification}
event {event}
Expand Down
4 changes: 2 additions & 2 deletions src/app/shared/forms/planet-tag-input-dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@ export class PlanetTagInputDialogComponent {
onNext: (data) => {
this.data.initTags();
this.deleteDialog.close();
this.planetMessageService.showMessage($localize`Tag deleted: ${tag.name}`);
this.planetMessageService.showMessage($localize`Collection deleted: ${tag.name}`);
this.resetValidationAndCheck(this.addTagForm);
},
onError: (error) => this.planetMessageService.showAlert($localize`There was a problem deleting this tag.`)
onError: (error) => this.planetMessageService.showAlert($localize`There was a problem deleting this collection.`)
};
}

Expand Down
17 changes: 10 additions & 7 deletions src/app/teams/teams.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ export class TeamsComponent implements OnInit, AfterViewInit {
this.teamsService.addTeamDialog(this.user._id, this.mode, { ...team, teamType }).subscribe(() => {
this.getTeams();
const action = $localize`${team._id ? 'updated' : 'created'}`;
const msg = $localize`${toProperCase(this.mode)} ${action} successfully`;
const entityType = this.mode === 'enterprise' ? 'Enterprise' : 'Team';
const msg = $localize`${entityType} ${action} successfully`;
this.planetMessageService.showMessage(msg);
});
}
Expand All @@ -220,12 +221,13 @@ export class TeamsComponent implements OnInit, AfterViewInit {
onNext: () => {
this.leaveDialog.close();
this.teams.data = this.teamList(this.teams.data);
const msg = 'left';
this.planetMessageService.showMessage($localize`You have ${msg} ${team.name}`);
const entityType = this.mode === 'enterprise' ? 'enterprise' : 'team';
const msg = $localize`You have left ${entityType} ${team.name}`;
this.planetMessageService.showMessage(msg);
},
},
changeType: 'leave',
type: 'team',
type: this.mode === 'enterprise' ? 'enterprise' : 'team',
displayName: team.name
}
});
Expand All @@ -240,7 +242,7 @@ export class TeamsComponent implements OnInit, AfterViewInit {
this.planetMessageService.showMessage($localize`You have deleted ${entityType} ${team.name}.`);
this.removeTeamFromTable(team);
},
onError: () => this.planetMessageService.showAlert($localize`There was a problem deleting this team.`)
onError: () => this.planetMessageService.showAlert($localize`There was a problem deleting this ${this.mode === 'enterprise' ? 'enterprise' : 'team'}.`)
};
}

Expand All @@ -249,7 +251,7 @@ export class TeamsComponent implements OnInit, AfterViewInit {
data: {
okClick: this.archiveTeam(team),
changeType: 'delete',
type: 'team',
type: this.mode === 'enterprise' ? 'enterprise' : 'team',
displayName: team.name
}
});
Expand All @@ -268,7 +270,8 @@ export class TeamsComponent implements OnInit, AfterViewInit {
finalize(() => this.dialogsLoadingService.stop())
).subscribe(() => {
this.teams.data = this.teamList(this.teams.data);
this.planetMessageService.showMessage($localize`Request to join ${team.name} sent`);
const entityType = this.mode === 'enterprise' ? 'enterprise' : 'team';
this.planetMessageService.showMessage($localize`Request to join ${entityType} ${team.name} sent`);
});
}

Expand Down

0 comments on commit 379c8a9

Please sign in to comment.