Skip to content

Commit 951e2a7

Browse files
committed
Simplify high-water mark UI and improve manual intake filter layout
- Remove confirmation checkbox from high-water mark setting, keeping details disclosure and unlock checkbox as sufficient protection - Reorganize filter form into 3 balanced rows: dates, person, course - Date presets use col-auto instead of fixed col-4 - Remove Record Status dropdown (not a real API filter)
1 parent cb9f0cd commit 951e2a7

File tree

3 files changed

+76
-88
lines changed

3 files changed

+76
-88
lines changed

classes/admin/setting_highwatermark.php

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525
namespace local_psaelmsync\admin;
2626

2727
/**
28-
* A protected integer setting that requires two confirmation checkboxes before saving.
28+
* A protected integer setting that requires unlocking before saving.
2929
*
30-
* The field is displayed read-only by default. The user must check an "unlock"
31-
* checkbox to reveal the input field, and then check a second "I understand"
32-
* confirmation before the new value will be saved.
30+
* The field is displayed read-only by default inside a collapsible section.
31+
* The user must check an "unlock" checkbox to enable the input field.
3332
*/
3433
class setting_highwatermark extends \admin_setting {
3534
/**
@@ -42,9 +41,9 @@ public function get_setting() {
4241
}
4342

4443
/**
45-
* Write the setting only if both confirmation checkboxes are checked.
44+
* Write the setting only if the unlock checkbox is checked.
4645
*
47-
* @param mixed $data The form data (array with 'value', 'unlock', 'confirm' keys).
46+
* @param mixed $data The form data (array with 'value' and 'unlock' keys).
4847
* @return string Empty on success, error message on failure.
4948
*/
5049
public function write_setting($data) {
@@ -54,7 +53,6 @@ public function write_setting($data) {
5453

5554
$newvalue = (int) ($data['value'] ?? 0);
5655
$unlock = !empty($data['unlock']);
57-
$confirm = !empty($data['confirm']);
5856
$currentvalue = (int) $this->get_setting();
5957

6058
// If the value hasn't changed, just accept it silently.
@@ -67,11 +65,6 @@ public function write_setting($data) {
6765
return get_string('highwatermark_err_unlock', 'local_psaelmsync');
6866
}
6967

70-
// Unlock checked but confirmation not checked.
71-
if (!$confirm) {
72-
return get_string('highwatermark_err_confirm', 'local_psaelmsync');
73-
}
74-
7568
// Validate: must be a non-negative integer.
7669
if ($newvalue < 0) {
7770
return get_string('highwatermark_err_negative', 'local_psaelmsync');
@@ -95,7 +88,6 @@ public function output_html($data, $query = '') {
9588

9689
$warning = get_string('highwatermark_warning', 'local_psaelmsync');
9790
$unlocklabel = get_string('highwatermark_unlock', 'local_psaelmsync');
98-
$confirmlabel = get_string('highwatermark_confirm', 'local_psaelmsync');
9991

10092
$html = '';
10193

@@ -162,48 +154,27 @@ public function output_html($data, $query = '') {
162154
'style' => 'max-width: 20rem;',
163155
]),
164156
['id' => $id . '_field', 'style' => 'margin-bottom: 0.5rem;']
165-
)
166-
// Step 2: Confirmation checkbox.
167-
. \html_writer::tag(
168-
'div',
169-
\html_writer::checkbox(
170-
$name . '[confirm]',
171-
1,
172-
false,
173-
'',
174-
['id' => $id . '_confirm']
175-
)
176-
. \html_writer::tag('label', $confirmlabel, [
177-
'for' => $id . '_confirm',
178-
'style' => 'font-weight: bold; color: #b94a48;',
179-
]),
180-
['id' => $id . '_confirmdiv', 'style' => 'margin-top: 0.25rem;']
181157
),
182158
[]
183159
),
184160
['id' => $id . '_details']
185161
);
186162

187-
// Progressive enhancement: hide field + confirm until unlock is checked.
163+
// Progressive enhancement: hide field until unlock is checked.
188164
$html .= \html_writer::script("
189165
(function() {
190166
var unlock = document.getElementById('" . $id . "_unlock');
191167
var fieldDiv = document.getElementById('" . $id . "_field');
192168
var input = document.getElementById('" . $id . "');
193-
var confirmDiv = document.getElementById('" . $id . "_confirmdiv');
194-
var confirmBox = document.getElementById('" . $id . "_confirm');
195169
196170
function toggle() {
197171
if (unlock.checked) {
198172
fieldDiv.style.display = '';
199173
input.disabled = false;
200-
confirmDiv.style.display = '';
201174
} else {
202175
fieldDiv.style.display = 'none';
203176
input.disabled = true;
204177
input.value = " . (int) $currentvalue . ";
205-
confirmDiv.style.display = 'none';
206-
confirmBox.checked = false;
207178
}
208179
}
209180

lang/en/local_psaelmsync.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@
6464
$string['errors'] = 'Errors';
6565
$string['from'] = 'From Date';
6666
$string['guid_cdata_lookup'] = 'GUID';
67-
$string['highwatermark_confirm'] = 'I understand that changing this value will affect which enrolment records are processed and may cause records to be skipped or re-processed.';
6867
$string['highwatermark_current'] = 'Current value:';
69-
$string['highwatermark_err_confirm'] = 'You must check the confirmation checkbox to acknowledge you understand the consequences of changing the high-water mark.';
7068
$string['highwatermark_err_negative'] = 'The high-water mark must be a non-negative integer.';
7169
$string['highwatermark_err_unlock'] = 'You must check the unlock checkbox before changing the high-water mark.';
7270
$string['highwatermark_modify'] = 'I need to modify the high-water mark...';

manual-intake.php

Lines changed: 70 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,17 @@
5757
// Get filter values (persisted across requests).
5858
$filterfrom = optional_param('from', '', PARAM_TEXT);
5959
$filterto = optional_param('to', '', PARAM_TEXT);
60+
61+
// Default display values for date pickers (today 06:00 to now).
62+
$defaultfrom = date('Y-m-d\T06:00');
63+
$defaultto = date('Y-m-d\TH:i');
64+
$displayfrom = !empty($filterfrom) ? $filterfrom : $defaultfrom;
65+
$displayto = !empty($filterto) ? $filterto : $defaultto;
66+
6067
$filteremail = optional_param('email', '', PARAM_TEXT);
6168
$filterguid = optional_param('guid', '', PARAM_TEXT);
6269
$filtercourse = optional_param('course', '', PARAM_TEXT);
6370
$filterstate = optional_param('state', '', PARAM_ALPHA);
64-
$filterstatus = optional_param('status', '', PARAM_ALPHA);
6571
$filterfirstname = optional_param('firstname', '', PARAM_TEXT);
6672
$filterlastname = optional_param('lastname', '', PARAM_TEXT);
6773
$filteroprid = optional_param('oprid', '', PARAM_TEXT);
@@ -838,14 +844,6 @@ function create_new_user_local($useremail, $firstname, $lastname, $userguid) {
838844
$isenrolled
839845
);
840846

841-
// Apply status filter if set.
842-
if (
843-
!empty($filterstatus)
844-
&& $statusinfo['status'] !== $filterstatus
845-
) {
846-
continue;
847-
}
848-
849847
$processedrecords[] = [
850848
'record' => $record,
851849
'user' => $user,
@@ -990,6 +988,15 @@ function create_new_user_local($useremail, $firstname, $lastname, $userguid) {
990988
gap: 0.5rem;
991989
align-items: end;
992990
}
991+
.date-presets {
992+
display: flex;
993+
gap: 0.25rem;
994+
flex-wrap: wrap;
995+
}
996+
.date-presets .btn {
997+
font-size: 0.75rem;
998+
padding: 0.2rem 0.5rem;
999+
}
9931000
.results-summary {
9941001
display: flex;
9951002
gap: 1rem;
@@ -1106,25 +1113,69 @@ function create_new_user_local($useremail, $firstname, $lastname, $userguid) {
11061113
<!-- Enhanced Filter Form -->
11071114
<div class="manual-intake-filters">
11081115
<form method="get" action="<?php echo $PAGE->url; ?>">
1116+
<!-- Row 1: Date range -->
11091117
<div class="row">
1110-
<div class="col-md-2">
1118+
<div class="col-md-3">
11111119
<div class="form-group">
11121120
<label for="from">From Date</label>
11131121
<input type="datetime-local" id="from"
11141122
name="from"
11151123
class="form-control form-control-sm"
1116-
value="<?php echo s($filterfrom); ?>">
1124+
step="60"
1125+
value="<?php echo s($displayfrom); ?>">
11171126
</div>
11181127
</div>
1119-
<div class="col-md-2">
1128+
<div class="col-md-3">
11201129
<div class="form-group">
11211130
<label for="to">To Date</label>
11221131
<input type="datetime-local" id="to"
11231132
name="to"
11241133
class="form-control form-control-sm"
1125-
value="<?php echo s($filterto); ?>">
1134+
step="60"
1135+
value="<?php echo s($displayto); ?>">
1136+
</div>
1137+
</div>
1138+
<div class="col-md-auto d-flex align-items-end">
1139+
<div class="date-presets mb-1" role="group"
1140+
aria-label="Date range presets">
1141+
<?php
1142+
$today06 = date('Y-m-d\T06:00');
1143+
$now = date('Y-m-d\TH:i');
1144+
$yesterday06 = date(
1145+
'Y-m-d\T06:00',
1146+
strtotime('-1 day')
1147+
);
1148+
$weekago06 = date(
1149+
'Y-m-d\T06:00',
1150+
strtotime('-7 days')
1151+
);
1152+
?>
1153+
<button type="button"
1154+
class="btn btn-outline-secondary btn-sm"
1155+
data-from="<?php echo $today06; ?>"
1156+
data-to="<?php echo $now; ?>"
1157+
onclick="document.getElementById('from').value=this.dataset.from;
1158+
document.getElementById('to').value=this.dataset.to;">
1159+
Today</button>
1160+
<button type="button"
1161+
class="btn btn-outline-secondary btn-sm"
1162+
data-from="<?php echo $yesterday06; ?>"
1163+
data-to="<?php echo $today06; ?>"
1164+
onclick="document.getElementById('from').value=this.dataset.from;
1165+
document.getElementById('to').value=this.dataset.to;">
1166+
Yesterday</button>
1167+
<button type="button"
1168+
class="btn btn-outline-secondary btn-sm"
1169+
data-from="<?php echo $weekago06; ?>"
1170+
data-to="<?php echo $now; ?>"
1171+
onclick="document.getElementById('from').value=this.dataset.from;
1172+
document.getElementById('to').value=this.dataset.to;">
1173+
Last 7 Days</button>
11261174
</div>
11271175
</div>
1176+
</div>
1177+
<!-- Row 2: Person lookup -->
1178+
<div class="row mt-2">
11281179
<div class="col-md-2">
11291180
<div class="form-group">
11301181
<label for="firstname">First Name</label>
@@ -1147,7 +1198,7 @@ class="form-control form-control-sm"
11471198
?>" placeholder="Haggett">
11481199
</div>
11491200
</div>
1150-
<div class="col-md-2">
1201+
<div class="col-md-3">
11511202
<div class="form-group">
11521203
<label for="email">Email</label>
11531204
<input type="email" id="email"
@@ -1169,8 +1220,6 @@ class="form-control form-control-sm"
11691220
?>" placeholder="5F421FC1A510...">
11701221
</div>
11711222
</div>
1172-
</div>
1173-
<div class="row mt-2">
11741223
<div class="col-md-2">
11751224
<div class="form-group">
11761225
<label for="oprid">OPRID</label>
@@ -1182,6 +1231,9 @@ class="form-control form-control-sm"
11821231
?>" placeholder="AHAGGETT">
11831232
</div>
11841233
</div>
1234+
</div>
1235+
<!-- Row 3: Course, filters, actions -->
1236+
<div class="row mt-2">
11851237
<div class="col-md-2">
11861238
<div class="form-group">
11871239
<label for="personid">PERSON_ID</label>
@@ -1221,37 +1273,8 @@ class="form-control form-control-sm">
12211273
</select>
12221274
</div>
12231275
</div>
1224-
<div class="col-md-2">
1225-
<div class="form-group">
1226-
<label for="status">Record Status</label>
1227-
<select id="status" name="status"
1228-
class="form-control form-control-sm">
1229-
<option value="">All</option>
1230-
<option value="ready" <?php
1231-
echo $filterstatus === 'ready'
1232-
? 'selected' : '';
1233-
?>>Ready to Process</option>
1234-
<option value="new_user" <?php
1235-
echo $filterstatus === 'new_user'
1236-
? 'selected' : '';
1237-
?>>New User</option>
1238-
<option value="mismatch" <?php
1239-
echo $filterstatus === 'mismatch'
1240-
? 'selected' : '';
1241-
?>>Email Mismatch</option>
1242-
<option value="blocked" <?php
1243-
echo $filterstatus === 'blocked'
1244-
? 'selected' : '';
1245-
?>>Blocked</option>
1246-
<option value="done" <?php
1247-
echo $filterstatus === 'done'
1248-
? 'selected' : '';
1249-
?>>Already Done</option>
1250-
</select>
1251-
</div>
1252-
</div>
1253-
<div class="col-md-2">
1254-
<div class="filter-actions">
1276+
<div class="col-md-2 d-flex align-items-end">
1277+
<div class="filter-actions mb-1">
12551278
<button type="submit"
12561279
class="btn btn-primary btn-sm">
12571280
Search CData</button>
@@ -1629,10 +1652,6 @@ class="d-inline process-form">
16291652
value="<?php
16301653
echo s($filterstate);
16311654
?>">
1632-
<input type="hidden" name="status"
1633-
value="<?php
1634-
echo s($filterstatus);
1635-
?>">
16361655
<button type="submit" name="process"
16371656
class="btn btn-sm btn-success">
16381657
<?php

0 commit comments

Comments
 (0)