Make tile vm support disambiguation
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
b8542c6754
commit
bcb46fc54a
1 changed files with 32 additions and 4 deletions
|
@ -4,19 +4,47 @@ export class MemberTileViewModel extends ViewModel {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
this._member = this._options.member;
|
this._member = this._options.member;
|
||||||
this._shouldDisambiguate = options.shouldDisambiguate;
|
this._previousName = null;
|
||||||
|
this._nameChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() {
|
get name() {
|
||||||
return this._member.name;
|
return `${this._member.name}${this._disambiguationPart}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
get _disambiguationPart() {
|
||||||
|
return this._disambiguate ? ` (${this.userId})` : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
get userId() {
|
get userId() {
|
||||||
return this._member.userId;
|
return this._member.userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateFrom(newMember) {
|
get previousName() {
|
||||||
this._member = newMember;
|
return this._previousName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get nameChanged() {
|
||||||
|
return this._nameChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
_updatePreviousName(newName) {
|
||||||
|
const currentName = this._member.name;
|
||||||
|
if (currentName !== newName) {
|
||||||
|
this._previousName = currentName;
|
||||||
|
this._nameChanged = true;
|
||||||
|
} else {
|
||||||
|
this._nameChanged = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setDisambiguation(status) {
|
||||||
|
this._disambiguate = status;
|
||||||
|
this.emitChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateFrom(newMember) {
|
||||||
|
this._updatePreviousName(newMember.name);
|
||||||
|
this._member = newMember;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue