forked from mystiq/hydrogen-web
Create vm and view
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
7e481080b5
commit
fdd4caa0b7
2 changed files with 50 additions and 0 deletions
38
src/domain/session/rightpanel/MemberDetailsViewModel.js
Normal file
38
src/domain/session/rightpanel/MemberDetailsViewModel.js
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
import {ViewModel} from "../../ViewModel.js";
|
||||||
|
import {avatarInitials, getIdentifierColorNumber, getAvatarHttpUrl} from "../../avatar.js";
|
||||||
|
|
||||||
|
export class MemberDetailsViewModel extends ViewModel {
|
||||||
|
constructor(options) {
|
||||||
|
super(options);
|
||||||
|
this._observableMember = options.observableMember;
|
||||||
|
this._mediaRepository = options.mediaRepository;
|
||||||
|
this._member = this._observableMember.get();
|
||||||
|
this.track(this._observableMember.subscribe( () => this._onMemberChange()));
|
||||||
|
}
|
||||||
|
|
||||||
|
get name() { return this._member.name; }
|
||||||
|
get userId() { return this._member.userId; }
|
||||||
|
|
||||||
|
get type() { return "member-details"; }
|
||||||
|
|
||||||
|
_onMemberChange() {
|
||||||
|
this._member = this._observableMember.get();
|
||||||
|
this.emitChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
get avatarLetter() {
|
||||||
|
return avatarInitials(this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
get avatarColorNumber() {
|
||||||
|
return getIdentifierColorNumber(this.userId)
|
||||||
|
}
|
||||||
|
|
||||||
|
avatarUrl(size) {
|
||||||
|
return getAvatarHttpUrl(this._member.avatarUrl, size, this.platform, this._mediaRepository);
|
||||||
|
}
|
||||||
|
|
||||||
|
get avatarTitle() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
}
|
12
src/platform/web/ui/session/rightpanel/MemberDetailsView.js
Normal file
12
src/platform/web/ui/session/rightpanel/MemberDetailsView.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import {AvatarView} from "../../AvatarView.js";
|
||||||
|
import {TemplateView} from "../../general/TemplateView.js";
|
||||||
|
|
||||||
|
export class MemberDetailsView extends TemplateView {
|
||||||
|
render(t, vm) {
|
||||||
|
return t.div({ className: "MemberDetailsView" },
|
||||||
|
[ t.view(new AvatarView(vm, 128)),
|
||||||
|
t.div({ className: "MemberDetailsView_name" }, vm.name),
|
||||||
|
t.div({ className: "MemberDetailsView_userId" }, vm.userId)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue