Files
BeWoPlaner/BeWoPlanerMobil/Views/Main/RestoreServiceRecordInputsPartial.cshtml
Christian 25267634df Release 3.27
Neue Felder für MA Schwerbehindertenausweis.
Todos fürs Release
2025-08-15 03:03:24 +02:00

391 lines
12 KiB
Plaintext

@using BeWoPlanerMobil.Service
@using BeWoPlanerMobil.Util
@model BeWoPlanerMobil.Models.MainModel
@*
ToDo: Bei Hilfeplan schauen, ob die Ziele/Maßnahmen, Kategorie/Leistung, Textbausteines korrekt sind.
*@
@if(TempData[TempDataConstants.AfterRestoreKey] is bool and true)
{
<text>
<script type="text/javascript">
</script>
</text>
}
<script type="text/javascript">
class LocalBeWoStorage {
id;
inputList;
groupBookingCb2ScRelOids;
multiBookingCb2ScRelOids;
groupBookingGroupOids;
multiBookingGroupOids;
groupBookingEmployeeOids;
multiBookingEmployeeOids;
constructor(id, inputList) {
this.id = id;
this.inputList = inputList;
this.groupBookingCb2ScRelOids = [];
this.groupBookingGroupOids = [];
this.groupBookingEmployeeOids = [];
this.multiBookingCb2ScRelOids = [];
this.multiBookingGroupOids = [];
this.multiBookingEmployeeOids = [];
}
clearInputList() {
if (this.inputList === null || this.inputList === undefined) {
this.inputList = [];
}
this.inputList.length = 0;
localStorage.setItem(this.id, JSON.stringify(this));
}
removeItemById(id) {
const newInputList = [];
for (let i = 0; i < this.inputList.length; i++) {
const input = this.inputList[i];
if (input.inputId !== id) {
newInputList.push(input);
}
}
this.inputList = newInputList;
localStorage.setItem(this.id, JSON.stringify(this));
}
removeItemByName(name) {
const newInputList = [];
for (let i = 0; i < this.inputList.length; i++) {
const input = this.inputList[i];
if (input.inputName !== name) {
newInputList.push(input);
}
}
this.inputList = newInputList;
localStorage.setItem(this.id, JSON.stringify(this));
}
addInputValue(inputId, inputName, inputType, inputValue, timeStamp) {
if (inputType === "radio") {
this.removeItemByName(inputName);
}
const obj = {
inputId: inputId,
inputName: inputName,
inputType: inputType,
inputValue: inputValue,
timeStamp: timeStamp
};
this.removeItemById(inputId);
this.inputList.push(obj);
localStorage.setItem(this.id, JSON.stringify(this));
}
getItemById(id) {
const item = this.inputList.find((element) => element.inputId === id);
return item;
}
getItemsByName(name) {
const result = [];
this.inputList.map((item) => {
if (item.inputName === name) {
result.push(item);
}
});
return result;
}
updateGroupBookingSelectedCb2ScRelOids(commaSeparatedOidString) {
if(commaSeparatedOidString === null || commaSeparatedOidString === undefined) {
commaSeparatedOidString = "";
}
const strArr = commaSeparatedOidString.split(",");
for(let i = 0; i < strArr.length; i++) {
if($.isNumeric(strArr[i])) {
this.groupBookingCb2ScRelOids.push(parseInt(strArr[i]));
}
}
localStorage.setItem(this.id, JSON.stringify(this));
}
updateGroupBookingSelectedGroupOids(commaSeparatedOidString) {
if(commaSeparatedOidString === null || commaSeparatedOidString === undefined) {
commaSeparatedOidString = "";
}
const strArr = commaSeparatedOidString.split(",");
for(let i = 0; i < strArr.length; i++) {
if($.isNumeric(strArr[i])) {
this.groupBookingGroupOids.push(parseInt(strArr[i]));
}
}
localStorage.setItem(this.id, JSON.stringify(this));
}
getGroupBookingSelectedCb2ScRelOids() {
return this.groupBookingCb2ScRelOids;
}
getGroupBookingSelectedGroupOids() {
return this.groupBookingGroupOids;
}
updateGroupBookingSelectedEmployeeOids(commaSeparatedOidString) {
if(commaSeparatedOidString === null || commaSeparatedOidString === undefined) {
commaSeparatedOidString = "";
}
const strArr = commaSeparatedOidString.split(",");
for(let i = 0; i < strArr.length; i++) {
if($.isNumeric(strArr[i])) {
this.groupBookingEmployeeOids.push(parseInt(strArr[i]));
}
}
localStorage.setItem(this.id, JSON.stringify(this));
}
getMultiBookingSelectedCb2ScRelOids() {
return this.multiBookingCb2ScRelOids;
}
getMultiBookingSelectedGroupOids() {
return this.multiBookingGroupOids;
}
updateMultiBookingSelectedCb2ScRelOids(commaSeparatedOidString) {
if(commaSeparatedOidString === null || commaSeparatedOidString === undefined) {
commaSeparatedOidString = "";
}
const strArr = commaSeparatedOidString.split(",");
for(let i = 0; i < strArr.length; i++) {
if($.isNumeric(strArr[i])) {
this.multiBookingCb2ScRelOids.push(parseInt(strArr[i]));
}
}
localStorage.setItem(this.id, JSON.stringify(this));
}
updateMultiBookingSelectedGroupOids(commaSeparatedOidString) {
if(commaSeparatedOidString === null || commaSeparatedOidString === undefined) {
commaSeparatedOidString = "";
}
const strArr = commaSeparatedOidString.split(",");
for(let i = 0; i < strArr.length; i++) {
if($.isNumeric(strArr[i])) {
this.multiBookingGroupOids.push(parseInt(strArr[i]));
}
}
localStorage.setItem(this.id, JSON.stringify(this));
}
updateMultiBookingSelectedEmployeeOids(commaSeparatedOidString) {
if(commaSeparatedOidString === null || commaSeparatedOidString === undefined) {
commaSeparatedOidString = "";
}
const strArr = commaSeparatedOidString.split(",");
for(let i = 0; i < strArr.length; i++) {
if($.isNumeric(strArr[i])) {
this.multiBookingEmployeeOids.push(parseInt(strArr[i]));
}
}
localStorage.setItem(this.id, JSON.stringify(this));
}
}
function getLocalStorageKey() {
return "@MobileSessionFacade.LocalStorageKey";
}
function getBeWoStorage() {
const localStorageKey = getLocalStorageKey();
const unparsedLocalStorageJson = localStorage.getItem(localStorageKey);
let beWoStorage = new LocalBeWoStorage(localStorageKey, []);
if(unparsedLocalStorageJson === null || unparsedLocalStorageJson === undefined || unparsedLocalStorageJson.length === 0) {
localStorage.setItem(localStorageKey, JSON.stringify(beWoStorage));
} else {
const parsedJson = JSON.parse(unparsedLocalStorageJson);
beWoStorage = new LocalBeWoStorage(localStorageKey, parsedJson.inputList);
}
return beWoStorage;
}
function clearLocalBeWoStorage() {
const beWoStorage = getBeWoStorage();
beWoStorage.clearInputList();
}
function getRestoreButtonState() {
const beWoStorage = getBeWoStorage();
return beWoStorage.inputList.length > 0;
}
window.addEventListener("load", function() {
$(".booking-form-container, #goals-tree").find("textarea, select, input").on("change", function() { saveItemValueLocally(this); });
$("#IsInGroupBookingMode, #IsInMultiBookingMode").on("change", function() { saveItemValueLocally(this); });
});
function restoreField(id) {
const beWoStorage = getBeWoStorage();
const inputObj = beWoStorage.getItemById(id);
if(inputObj === undefined || inputObj === null) {
return;
}
$(`#${id}`).val(inputObj.inputValue);
$(`#${id}`).trigger("change");
}
function saveItemValueLocally(htmlElement) {
const item = $(htmlElement);
const id = item.attr("id");
const type = item.prop("type");
const value = type === "checkbox" ? item.is(":checked").toString() : item.val();
if((value === null || value === undefined) || value.length === 0) {
return;
}
const name = item.prop("name");
const beWoStorage = getBeWoStorage();
beWoStorage.addInputValue(id, name, type, value, new Date());
toggleRestoreButton();
}
function restoreAllFields() {
const beWoStorage = getBeWoStorage();
$.each(beWoStorage.inputList, (index, item) => {
logInfo3(`Id: ${item.inputId}; Wert: ${item.inputValue};`);
});
// ToDo: die versteckten Felder ausfüllen und das Formular an den Server schicken, wo ein neues ServiceRecord-Objekt mithilfe des versteckten Formulars erzeugt wird.
$("#srr-gb-cb2sc-oids").val(beWoStorage.groupBookingCb2ScRelOids);
$("#srr-gb-group-oids").val(beWoStorage.groupBookingGroupOids);
$("#srr-gb-emp-oids").val(beWoStorage.groupBookingEmployeeOids);
$("#srr-mb-cb2sc-oids").val(beWoStorage.multiBookingCb2ScRelOids);
$("#srr-mb-group-oids").val(beWoStorage.multiBookingGroupOids);
$("#srr-mb-emp-oids").val(beWoStorage.multiBookingEmployeeOids);
$.each(beWoStorage.inputList, (index, item) => {
if (item.inputType === "checkbox") {
$(`#${item.inputId}`).prop("checked", item.inputValue);
} else {
$(`#${item.inputId}`).val(item.inputValue);
}
let inputId = item.inputId;
if(item.inputId.startsWith("sb-") || item.inputId.startsWith("gb-") || item.inputId.startsWith("mb-")) {
inputId = item.inputId.slice(3);
}
if(inputId === "doku-textarea") {
inputId += "-6";
}
logInfo(`Id: ${inputId}; Wert: ${item.inputValue};`);
//$(`#srr-${inputId}`).val(item.inputValue);
//$(`#${item.inputId}`).trigger("change");
});
$("#restore-service-record-form").submit();
}
$(window).ready(function() {
const sbDate = $("#sb-start-date-input").val();
const gbDate = $("#gb-start-date-input").val();
const mbDate = $("#mb-start-date-input").val();
logInfo(`Einzelbuchung: ${sbDate}\r\nGruppenbuchung: ${gbDate}\r\nMehrfachbuchung: ${mbDate}`);
});
</script>
@using(Html.BeginForm("RestoreServiceRecordForm", "Main", FormMethod.Post, new {id="restore-service-record-form"}))
{
<input type="hidden" id="srr-start-time-input" name="@FormCollectionConstants.DateKey" />
<input type="hidden" id="srr-end-time-input" name="@FormCollectionConstants.EndKey" />
<input type="hidden" id="srr-start-date-input" name="@FormCollectionConstants.StartKey" />
<input type="hidden" id="srr-end-date-input" name="@FormCollectionConstants.EndDateKey" />
<input type="hidden" id="srr-doku-textarea-1" name="@FormCollectionConstants.Dokumentation1Key" />
<input type="hidden" id="srr-doku-textarea-2" name="@FormCollectionConstants.Dokumentation2Key" />
<input type="hidden" id="srr-doku-textarea-3" name="@FormCollectionConstants.Dokumentation3Key" />
<input type="hidden" id="srr-doku-textarea-4" name="@FormCollectionConstants.Dokumentation4Key" />
<input type="hidden" id="srr-doku-textarea-5" name="@FormCollectionConstants.Dokumentation5Key" />
<input type="hidden" id="srr-doku-textarea-6" name="@FormCollectionConstants.Dokumentation6Key" />
<input type="hidden" id="srr-distance-input" name="@FormCollectionConstants.DistanceKey" />
<input type="hidden" id="srr-form-id" name="@FormCollectionConstants.FormIdKey" />
<input type="hidden" id="srr-marker-cb" name="@FormCollectionConstants.MarkerKey" />
<input type="hidden" id="srr-leistung-select" name="@FormCollectionConstants.ServiceDescriptionKey" />
<input type="hidden" id="srr-duration-input" name="@FormCollectionConstants.DurationKey" />
<input type="hidden" id="srr-betrag" name="@FormCollectionConstants.BetragKey" />
<input type="hidden" id="srr-sb-emp-oid" name="@FormCollectionConstants.SingleBookingEmployeeOidKey" />
<input type="hidden" id="srr-gb-cb2sc-oids" name="@FormCollectionConstants.GroupBookingSelectedCb2ScOidsKey" />
<input type="hidden" id="srr-gb-emp-oids" name="@FormCollectionConstants.GroupBookingSelectedEmployeeOidsKey" />
<input type="hidden" id="srr-gb-group-oids" name="@FormCollectionConstants.GroupBookingSelectedGroupOidsKey" />
<input type="hidden" id="srr-mb-cb2sc-oids" name="@FormCollectionConstants.MultiBookingSelectedCb2ScOidsKey" />
<input type="hidden" id="srr-mb-emp-oids" name="@FormCollectionConstants.MultiBookingSelectedEmployeeOidsKey" />
<input type="hidden" id="srr-mb-group-oids" name="@FormCollectionConstants.MultiBookingSelectedGroupOidsKey" />
@*<button type="button" class="btn btn-bewo-dev bewo-restore-btn" onclick="window.restoreAllFields()">
<i class="fas fa-recycle"></i>
</button>*@
}