From 987e0ddd4e88f885530230d8e0383a8b7a298ccd Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Tue, 25 Jan 2022 15:27:16 +0000 Subject: [PATCH] accounts: show "Set expiry" button for non-disabled users previously hidden in a dropdown on the "re-enable" button for disabled users only, now can be used on active ones. --- lang/admin/en-us.json | 4 ++++ ts/modules/accounts.ts | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lang/admin/en-us.json b/lang/admin/en-us.json index 824431e..f946dc0 100644 --- a/lang/admin/en-us.json +++ b/lang/admin/en-us.json @@ -205,6 +205,10 @@ "singular": "Extend expiry for {n} user", "plural": "Extend expiry for {n} users" }, + "setExpiry": { + "singular": "Set expiry for {n} user", + "plural": "Set expiry for {n} users" + }, "extendedExpiry": { "singular": "Extended expiry for {n} user.", "plural": "Extended expiry for {n} users." diff --git a/ts/modules/accounts.ts b/ts/modules/accounts.ts index e9ee48c..c4ce256 100644 --- a/ts/modules/accounts.ts +++ b/ts/modules/accounts.ts @@ -699,6 +699,9 @@ export class accountsList { private _addUserEmail = this._addUserForm.querySelector("input[type=email]") as HTMLInputElement; private _addUserPassword = this._addUserForm.querySelector("input[type=password]") as HTMLInputElement; + // Whether the "Extend expiry" is extending or setting an expiry. + private _settingExpiry = false; + private _count = 30; private _populateNumbers = () => { const fieldIDs = ["months", "days", "hours", "minutes"]; @@ -836,6 +839,7 @@ export class accountsList { this._announceButton.classList.remove("unfocused"); } let anyNonExpiries = list.length == 0 ? true : false; + let allNonExpiries = true; let noContactCount = 0; // Only show enable/disable button if all selected have the same state. this._shouldEnable = this._users[list[0]].disabled @@ -845,6 +849,9 @@ export class accountsList { anyNonExpiries = true; this._extendExpiry.classList.add("unfocused"); } + if (this._users[id].expiry) { + allNonExpiries = false; + } if (showDisableEnable && this._users[id].disabled != this._shouldEnable) { showDisableEnable = false; this._disableEnable.classList.add("unfocused"); @@ -854,8 +861,15 @@ export class accountsList { noContactCount++; } } - if (!anyNonExpiries) { + this._settingExpiry = false; + if (!anyNonExpiries && !allNonExpiries) { this._extendExpiry.classList.remove("unfocused"); + this._extendExpiry.textContent = window.lang.strings("extendExpiry"); + } + if (allNonExpiries) { + this._extendExpiry.classList.remove("unfocused"); + this._extendExpiry.textContent = window.lang.strings("setExpiry"); + this._settingExpiry = true; } // Only show "Send PWR" if a maximum of 1 user selected doesn't have a contact method if (noContactCount > 1) { @@ -1317,6 +1331,9 @@ export class accountsList { this._enableExpiryNotify.parentElement.classList.remove("unfocused"); this._enableExpiryNotify.checked = false; this._enableExpiryReason.value = ""; + } else if (this._settingExpiry) { + header = window.lang.quantity("setExpiry", list.length); + this._enableExpiryNotify.parentElement.classList.add("unfocused"); } else { header = window.lang.quantity("extendExpiry", applyList.length); this._enableExpiryNotify.parentElement.classList.add("unfocused");