Skip to content

Commit

Permalink
Remove Description buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
jessewashburn committed Nov 22, 2024
1 parent 6266469 commit dde08c4
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/app/community/community.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,41 @@ <h3 style="text-align: right; margin-right: 0.5rem;">
</mat-card>
</div>
</mat-tab>






<mat-tab i18n-label label="Services">
<h2 i18n>Community Description</h2>
<ng-container *ngIf="!planetCode">
</ng-container>
<planet-markdown *ngIf="team.description; else noTeamDesc" [content]="team.description || ''"></planet-markdown>
<ng-template #noTeamDesc><p i18n>No description available.</p></ng-template>

<!-- Existing button for adding/editing the description -->
<button class="toggle-button" *planetAuthorizedRoles="''" (click)="openDescriptionDialog()" mat-stroked-button i18n>
{ servicesDescriptionLabel, select, Edit {Edit} Add {Add}} { configuration.planetType, select, community {Community} nation {Nation} center {Earth}} Description
</button>

<!-- Toggle button for description delete mode -->
<button (click)="toggleDescriptionDeleteMode()" mat-stroked-button>
<span *ngIf="!descriptionDeleteMode" i18n>Remove Description</span>
<span *ngIf="descriptionDeleteMode" i18n>Cancel</span>
</button>

<!-- Delete button, only visible when descriptionDeleteMode is active -->
<button *ngIf="descriptionDeleteMode && team.description" mat-icon-button color="warn" (click)="confirmDeleteDescription()">
<mat-icon>delete</mat-icon>
</button>


<ng-container *ngIf="!planetCode">
<div *planetAuthorizedRoles="''" class="action-buttons sticky-button">
</div>
</ng-container>

<ng-container>
<h2 i18n>Community Links</h2>
<span *ngIf="links?.length === 0" i18n><p>No links available.</p></span>
Expand All @@ -65,6 +86,13 @@ <h2 i18n>Community Links</h2>
<span *ngIf="deleteMode" i18n>Done Removing Links</span>
</button>
</mat-tab>







<mat-tab *ngIf="configuration.planetType==='nation'" i18n-label label="Communities">
<planet-community-list></planet-community-list>
</mat-tab>
Expand Down
32 changes: 32 additions & 0 deletions src/app/community/community.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class CommunityComponent implements OnInit, OnDestroy {
reports: any[] = [];
showNewsButton = true;
deleteMode = false;
descriptionDeleteMode = false;
onDestroy$ = new Subject<void>();
isCommunityLeader = this.user.isUserAdmin || this.user.roles.indexOf('leader') > -1;
planetCode: string | null;
Expand Down Expand Up @@ -311,6 +312,33 @@ export class CommunityComponent implements OnInit, OnDestroy {
});
}

confirmDeleteDescription() {
const deleteDialog = this.dialog.open(DialogsPromptComponent, {
data: {
okClick: {
request: this.teamsService.updateTeam({ ...this.team, description: null }).pipe(
switchMap((updatedTeam) => {
this.team = updatedTeam; // Update the team object with the latest revision
this.servicesDescriptionLabel = 'Add';
this.descriptionDeleteMode = false; // Deactivate description delete mode
return of(updatedTeam); // Return updated team for further processing if needed
})
),
onNext: () => {
this.planetMessageService.showMessage($localize`Description deleted successfully.`);
deleteDialog.close();
},
onError: () => {
this.planetMessageService.showAlert($localize`There was an error deleting the description.`);
}
},
changeType: 'delete',
type: 'description',
displayName: $localize`Community Description`
}
});
}

toggleShowButton(data) {
this.showNewsButton = data._id === 'root';
}
Expand All @@ -319,6 +347,10 @@ export class CommunityComponent implements OnInit, OnDestroy {
this.deleteMode = !this.deleteMode;
}

toggleDescriptionDeleteMode() {
this.descriptionDeleteMode = !this.descriptionDeleteMode;
}

openChangeTitleDialog({ member: councillor }) {
this.dialogsFormService.openDialogsForm(
councillor.doc.leadershipTitle ? $localize`Change Leader Title` : $localize`Add Leader Title`,
Expand Down

0 comments on commit dde08c4

Please sign in to comment.