forked from mystiq/hydrogen-web
Basic barebones of memberlist view
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
7177fc1a03
commit
69237fce85
4 changed files with 52 additions and 0 deletions
24
src/domain/session/rightpanel/MemberListViewModel.js
Normal file
24
src/domain/session/rightpanel/MemberListViewModel.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
import {ViewModel} from "../../ViewModel.js";
|
||||
import {MemberTileViewModel} from "./MemberTileViewModel.js";
|
||||
|
||||
function comparator(member, otherMember) {
|
||||
return member.displayName?.localeCompare(otherMember.displayName);
|
||||
}
|
||||
|
||||
export class MemberListViewModel extends ViewModel {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this.memberTileViewModels = this._mapTileViewModels(this._filterJoinedMembers(options.members))
|
||||
.sortValues(comparator);
|
||||
}
|
||||
|
||||
_filterJoinedMembers(members) {
|
||||
return members.filterValues(member => member.membership === "join");
|
||||
}
|
||||
|
||||
_mapTileViewModels(members) {
|
||||
return members.mapValues((member, emitChange) => {
|
||||
return new MemberTileViewModel(this.childOptions({member, emitChange}));
|
||||
});
|
||||
}
|
||||
}
|
12
src/domain/session/rightpanel/MemberTileViewModel.js
Normal file
12
src/domain/session/rightpanel/MemberTileViewModel.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import {ViewModel} from "../../ViewModel.js";
|
||||
|
||||
export class MemberTileViewModel extends ViewModel {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this.member = options.member;
|
||||
}
|
||||
|
||||
get displayName() {
|
||||
return this.member.displayName;
|
||||
}
|
||||
}
|
9
src/platform/web/ui/session/rightpanel/MemberListView.js
Normal file
9
src/platform/web/ui/session/rightpanel/MemberListView.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
import {TemplateView} from "../../general/TemplateView.js";
|
||||
import {ListView} from "../../general/ListView.js";
|
||||
import {MemberTileView} from "./MemberTileView.js";
|
||||
|
||||
export class MemberListView extends TemplateView {
|
||||
render(t, vm) {
|
||||
return t.view(new ListView({list: vm.memberTileViewModels}, tileViewModel => new MemberTileView(tileViewModel)));
|
||||
}
|
||||
}
|
7
src/platform/web/ui/session/rightpanel/MemberTileView.js
Normal file
7
src/platform/web/ui/session/rightpanel/MemberTileView.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
import {TemplateView} from "../../general/TemplateView.js";
|
||||
|
||||
export class MemberTileView extends TemplateView {
|
||||
render(t, vm) {
|
||||
return t.div(vm.displayName);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue