accounts: Show "contact through" cog when only email is given"

one portion of #233: When adding an email address to an account, the
admin (for now) will manually have to enable its use by clicking the cog icon and
enabling "contact through email". Only for now, currently some other
unfinished work is stopping me from committing the other portion of code
for this issue.
This commit is contained in:
Harvey Tindall 2023-01-30 13:55:38 +00:00
parent 47d00d1f27
commit ac25c9cd7f
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2
2 changed files with 22 additions and 6 deletions

View File

@ -192,6 +192,8 @@ func (app *appContext) loadRoutes(router *gin.Engine) {
api.GET(p+"/telegram/pin", app.TelegramGetPin)
api.GET(p+"/telegram/verified/:pin", app.TelegramVerified)
api.POST(p+"/users/telegram", app.TelegramAddUser)
}
if emailEnabled {
api.POST(p+"/users/contact", app.SetContactMethods)
}
if discordEnabled {

View File

@ -74,9 +74,11 @@ class user implements User {
const telegram = window.telegramEnabled && this._telegramUsername && this._telegramUsername != "";
const discord = window.discordEnabled && this._discordUsername && this._discordUsername != "";
const matrix = window.matrixEnabled && this._matrixID && this._matrixID != "";
const email = window.emailEnabled && this.email != "";
if (discord) return "discord";
if (matrix) return "matrix";
if (telegram) return "telegram";
if (email) return "email";
}
get selected(): boolean { return this._selected; }
@ -132,6 +134,15 @@ class user implements User {
} else {
this._email.textContent = value;
}
const lastNotifyMethod = this.lastNotifyMethod() == "email";
if (!value) {
this._notifyDropdown.querySelector(".accounts-area-email").classList.add("unfocused");
} else {
this._notifyDropdown.querySelector(".accounts-area-email").classList.remove("unfocused");
if (lastNotifyMethod) {
(this._email.parentElement as HTMLDivElement).appendChild(this._notifyDropdown);
}
}
}
get notify_email(): boolean { return this._notifyEmail; }
@ -146,17 +157,20 @@ class user implements User {
const telegram = this._telegramUsername != "";
const discord = this._discordUsername != "";
const matrix = this._matrixID != "";
if (!telegram && !discord && !matrix) return;
const email = this._emailAddress != "";
if (!telegram && !discord && !matrix && !email) return;
let innerHTML = `
<i class="icon ri-settings-2-line ml-2 dropdown-button"></i>
<div class="dropdown manual">
<div class="dropdown-display lg">
<div class="card ~neutral @low">
<span class="supra sm">${window.lang.strings("contactThrough")}</span>
<label class="row switch pb-4 mt-2">
<input type="checkbox" name="accounts-contact-${this.id}" class="accounts-contact-email mr-2">
</span>Email</span>
</label>
<div class="accounts-area-email">
<label class="row switch pb-4 mt-2">
<input type="checkbox" name="accounts-contact-${this.id}" class="accounts-contact-email mr-2">
</span>Email</span>
</label>
</div>
<div class="accounts-area-telegram">
<label class="row switch pb-4">
<input type="checkbox" name="accounts-contact-${this.id}" class="accounts-contact-telegram mr-2">
@ -857,7 +871,7 @@ export class accountsList {
this._disableEnable.classList.add("unfocused");
}
if (!showDisableEnable && anyNonExpiries) { break; }
if (!this._users[id].lastNotifyMethod() && !this._users[id].email) {
if (!this._users[id].lastNotifyMethod()) {
noContactCount++;
}
}