Skip to content

Commit 86fb719

Browse files
committed
allow users to re-arrange field options
1 parent 9695ffb commit 86fb719

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

Views/Vehicle/Inspection/_InspectionRecordFieldOption.cshtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@
1212
<input class="form-check-input" data-type="fieldOptionIsFail" type="checkbox" role="switch" @(Model.IsFail ? "checked" : "")>
1313
<label class="form-check-label" onclick="stretchedLinkClick(this)">@translator.Translate(userLanguage, "Fail")</label>
1414
</div>
15-
<button type="button" class="btn btn-outline-danger btn-sm" onclick="deleteInspectionRecordFieldOption(this)"><i class="bi bi-trash"></i></button>
15+
<button type="button" class="btn btn-outline-secondary btn-sm" onclick="moveInspectionRecordFieldOption(this)"><i class="bi bi-arrow-up"></i></button>
16+
<button type="button" class="btn btn-outline-secondary btn-sm ms-2" onclick="moveInspectionRecordFieldOption(this, true)"><i class="bi bi-arrow-down"></i></button>
17+
<button type="button" class="btn btn-outline-danger btn-sm ms-2" onclick="deleteInspectionRecordFieldOption(this)"><i class="bi bi-trash"></i></button>
1618
</div>

wwwroot/js/inspectionrecord.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,20 @@ function moveInspectionRecordField(e, isDown) {
449449
}
450450
}
451451
}
452+
function moveInspectionRecordFieldOption(e, isDown) {
453+
let currentField = $(e).closest('[data-type="fieldOption"]');
454+
if (isDown) {
455+
let nextField = currentField.next('[data-type="fieldOption"]');
456+
if (nextField.length != 0) {
457+
currentField.insertAfter(nextField);
458+
}
459+
} else {
460+
let prevField = currentField.prev('[data-type="fieldOption"]');
461+
if (prevField.length != 0) {
462+
currentField.insertBefore(prevField);
463+
}
464+
}
465+
}
452466
function duplicateInspectionRecordTemplateToVehicle() {
453467
let inspectionRecordsIds = [];
454468
inspectionRecordsIds.push(getInspectionRecordModelData().id);

0 commit comments

Comments
 (0)