113 lines
3.6 KiB
Plaintext
113 lines
3.6 KiB
Plaintext
@using BeWoPlanerMobil.Util
|
|
@model BeWoPlanerMobil.Models.MainModel
|
|
|
|
@{
|
|
if(TempData[TempDataConstants.DoLogoutKey] is bool doLogout && doLogout)
|
|
{
|
|
<text>
|
|
<script type="text/javascript">
|
|
$("#second-logout-form").submit();
|
|
</script>
|
|
</text>
|
|
}
|
|
}
|
|
|
|
<script type="text/javascript">
|
|
function textCategoryOnClick(categoryId) {
|
|
const childrenContainer = $(`#${categoryId}-children-container`);
|
|
const iconSpan = $(`#${categoryId}-icon-span`);
|
|
|
|
const displayValue = childrenContainer.css("display");
|
|
|
|
const classToRemove = displayValue === "block" ? "fa-angle-up" : "fa-angle-down";
|
|
const classToAdd = displayValue === "block" ? "fa-angle-down" : "fa-angle-up";
|
|
|
|
iconSpan.removeClass(classToRemove);
|
|
iconSpan.addClass(classToAdd);
|
|
|
|
childrenContainer.toggle();
|
|
}
|
|
|
|
function textModuleOnClick(textModuleOid) {
|
|
var focusedDokuFeld;
|
|
|
|
var dokufeldId = "#dokufeld";
|
|
var dokuTextareaId = "#doku-textarea-";
|
|
var textareaContainerId = "#doku_";
|
|
|
|
if("@Model.IsInMultiBookingMode".toLocaleLowerCase() === "true") {
|
|
dokufeldId = "#mb-dokufeld";
|
|
dokuTextareaId = "#mb-doku-textarea-";
|
|
textareaContainerId = "#mb-doku_";
|
|
}
|
|
|
|
$.get("@Url.Action("LoadCompleteTextbausteinByOid")", { pTextbausteinOid: textModuleOid }).done(function(textModuleText) {
|
|
if($(dokufeldId).length > 0) {
|
|
focusedDokuFeld = $(dokufeldId);
|
|
} else {
|
|
const numberOfDokutypes = getNumberOfDokutypes();
|
|
|
|
for(let i = 0; i < numberOfDokutypes; i++) {
|
|
const currentElement = $(`#doku_${i}`);
|
|
|
|
if(currentElement.css("display") !== "none") {
|
|
focusedDokuFeld = $(dokuTextareaId + i);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
const cursorPosition = focusedDokuFeld.prop("selectionStart");
|
|
const v = focusedDokuFeld.val();
|
|
const textBefore = v.substring(0, cursorPosition);
|
|
const textAfter = v.substring(cursorPosition, v.length);
|
|
|
|
focusedDokuFeld.val(textBefore + textModuleText + textAfter);
|
|
|
|
$("#textbausteine-popup").modal("hide");
|
|
});
|
|
}
|
|
</script>
|
|
|
|
@helper BuildTextModuleTree(TextbausteinDisplayItem textModule)
|
|
{
|
|
if(textModule.IsParent)
|
|
{
|
|
<a href="#" class="list-group-item list-group-item-action mx-0 px-1" onclick="textCategoryOnClick('@textModule.Oid')">
|
|
<span id="@textModule.Oid-icon-span" class="fas fa-angle-down mr-1"></span>
|
|
@textModule.Name
|
|
</a>
|
|
<div id="@textModule.Oid-children-container" style="display: none;" class="list-group list-group-item mx-0 px-1">
|
|
@foreach(var childTextModule in textModule.Children)
|
|
{
|
|
@BuildTextModuleTree(childTextModule)
|
|
}
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<a href="#" id="@textModule.Oid" class="list-group-item list-group-item-action mx-0 px-1" onclick="textModuleOnClick('@textModule.Oid')">
|
|
@textModule.Name
|
|
</a>
|
|
}
|
|
}
|
|
|
|
@if(Model?.TextModules?.Any() ?? false)
|
|
{
|
|
<script type="text/javascript">
|
|
$("#textmodule-container").show();
|
|
</script>
|
|
|
|
<div class="list-group">
|
|
@foreach(var textModule in Model.TextModules)
|
|
{
|
|
@BuildTextModuleTree(textModule)
|
|
}
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<script type="text/javascript">
|
|
$("#textmodule-container").hide();
|
|
</script>
|
|
} |