Skip to content

Commit

Permalink
Indicate deleted members (fixes #5945)
Browse files Browse the repository at this point in the history
  • Loading branch information
Haoran Hu committed May 16, 2020
1 parent a56d99a commit c1cd86d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/news/news-list-item.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
item.doc.user.firstName + ((' ' + item.doc.user.middleName) || '') + ' ' + item.doc.user.lastName :
item.doc.user.name}}
</a>
<span *ngIf=!isActiveMember >(no longer member)</span>
</mat-card-title>
<mat-card-subtitle>
<p class="primary-text-color" *ngIf="item.doc.createdOn !== planetCode"><ng-container i18n>Member of Planet</ng-container> {{item.doc.createdOn}}</p>
Expand Down
17 changes: 17 additions & 0 deletions src/app/news/news-list-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class NewsListItemComponent implements OnChanges, AfterViewChecked {
@Input() isMainPostShared = true;
@Input() showRepliesButton = true;
@Input() editable = true;
@Input() userListeners: any[] = [];
@Input() shareTarget: 'community' | 'nation' | 'center';
@Output() changeReplyViewing = new EventEmitter<any>();
@Output() updateNews = new EventEmitter<any>();
Expand All @@ -30,6 +31,7 @@ export class NewsListItemComponent implements OnChanges, AfterViewChecked {
showExpand = false;
showLess = true;
showShare = false;
isActiveMember = true;
planetCode = this.stateService.configuration.code;
targetLocalPlanet = true;
labels = { listed: [], all: [ 'help', 'offer', 'advice' ] };
Expand All @@ -47,6 +49,7 @@ export class NewsListItemComponent implements OnChanges, AfterViewChecked {
ngOnChanges() {
this.targetLocalPlanet = this.shareTarget === this.stateService.configuration.planetType;
this.showShare = this.shouldShowShare();
this.isActiveMember = !this.shouldShowIndication();
this.labels.listed = this.labels.all.filter(label => (this.item.doc.labels || []).indexOf(label) === -1);
}

Expand Down Expand Up @@ -131,4 +134,18 @@ export class NewsListItemComponent implements OnChanges, AfterViewChecked {
(!this.targetLocalPlanet || (!this.newsService.postSharedWithCommunity(this.item) && this.isMainPostShared));
}

shouldShowIndication() {
if (this.shareTarget === this.planetCode) {
this.userListeners.forEach(listener => {
const user_id = listener._id;
const joinDate = listener.joinDate;
if (this.currentUser._id === user_id && this.currentUser.joinDate === joinDate) {
return true;
}
})
return false;
}
return false;
}

}
2 changes: 2 additions & 0 deletions src/app/news/news-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
[replyObject]="replyObject"
[showRepliesButton]="false"
[editable]="editable"
[userListeners]="activeMembers"
(changeReplyViewing)="showReplies($event)"
(updateNews)="openUpdateDialog($event)"
(deleteNews)="openDeleteDialog($event)"
Expand All @@ -22,6 +23,7 @@
[replyObject]="replyObject"
[editable]="editable"
[shareTarget]="shareTarget"
[userListeners]="activeMembers"
(changeReplyViewing)="showReplies($event)"
(updateNews)="openUpdateDialog($event)"
(deleteNews)="openDeleteDialog($event)"
Expand Down
5 changes: 5 additions & 0 deletions src/app/news/news-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MatDialog, MatDialogRef } from '@angular/material';
import { DialogsFormService } from '../shared/dialogs/dialogs-form.service';
import { DialogsLoadingService } from '../shared/dialogs/dialogs-loading.service';
import { NewsService } from './news.service';
import { UsersService } from '../users/users.service';
import { PlanetMessageService } from '../shared/planet-message.service';
import { CustomValidators } from '../validators/custom-validators';
import { DialogsPromptComponent } from '../shared/dialogs/dialogs-prompt.component';
Expand All @@ -29,6 +30,7 @@ export class NewsListComponent implements OnChanges {
@Input() shareTarget: 'community' | 'nation' | 'center';
displayedItems: any[] = [];
replyObject: any = {};
activeMembers: any[] = [];
isMainPostShared = true;
replyViewing: any = { _id: 'root' };
deleteDialog: any;
Expand All @@ -40,6 +42,7 @@ export class NewsListComponent implements OnChanges {
private dialogsFormService: DialogsFormService,
private dialogsLoadingService: DialogsLoadingService,
private newsService: NewsService,
private usersService: UsersService,
private planetMessageService: PlanetMessageService
) {}

Expand All @@ -52,6 +55,8 @@ export class NewsListComponent implements OnChanges {
if (this.replyViewing._id !== 'root') {
this.replyViewing = this.items.find(item => item._id === this.replyViewing._id);
}
this.usersService.requestUsers();
this.activeMembers = this.usersService.usersListener();
}

showReplies(news) {
Expand Down

0 comments on commit c1cd86d

Please sign in to comment.