164 lines
6.5 KiB
Plaintext
164 lines
6.5 KiB
Plaintext
@using BeWoPlanerMobil.Models
|
|
@using BeWoPlanerMobil.Util
|
|
@using BS.Shared.DataContracts
|
|
@model MainModel
|
|
|
|
<script>
|
|
function toggleGoalHeader(branchId) {
|
|
try {
|
|
$(branchId).collapse("toggle");
|
|
} catch(error) {
|
|
showErrorPopup(error);
|
|
}
|
|
}
|
|
|
|
function stopToggle(e) {
|
|
try {
|
|
e.stopPropagation();
|
|
} catch(error) {
|
|
showErrorPopup(error);;
|
|
}
|
|
}
|
|
|
|
function goalTreeSearchOnChangeV2() {
|
|
try {
|
|
var text = $("#goal-search-input").val().toLowerCase();
|
|
|
|
if (text.length === 0 || !text.replace(/\s\g/, '').length) {
|
|
resetGoalTreeSearch();
|
|
return;
|
|
}
|
|
|
|
$(".goal-card").hide();
|
|
|
|
var goalLabels = $(".goal-name-label");
|
|
|
|
$.each(goalLabels, function(index, item) {
|
|
var goalText = $.trim($(item).text());
|
|
|
|
var isLeaf = $(item).parent().prop("class").includes("goal-text");
|
|
|
|
// ToDo: Auch die Ziele beachten!
|
|
|
|
if(goalText.toLowerCase().includes(text)) {
|
|
$.each($($(item).parents(".goal-card")), function(cardIndex, card) {
|
|
$(card).show();
|
|
$(card).find(".collapse").collapse("show");
|
|
});
|
|
} else if(isLeaf) {
|
|
var parent1 = $($(item).parent());
|
|
|
|
if(parent1 !== undefined && parent1 !== null) {
|
|
var parent2 = $(parent1.parent());
|
|
|
|
if(parent2 !== undefined && parent2 !== null) {
|
|
var parent3 = $(parent2.parent());
|
|
|
|
if (parent3 !== undefined && parent3 !== null && parent3.siblings().length > 0) {
|
|
var cardHeader = $(parent3.siblings()[0]);
|
|
|
|
if (cardHeader !== undefined && cardHeader !== null && cardHeader.children().length > 0) {
|
|
var clearFix = $(cardHeader.children()[0]);
|
|
|
|
if (clearFix !== undefined && clearFix !== null && clearFix.children().length > 0) {
|
|
var goalCardHeader = $(clearFix.children()[0]);
|
|
|
|
if(goalCardHeader !== undefined && goalCardHeader === null){
|
|
$(item).parent().hide();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
} catch(error) {
|
|
showErrorPopup(error);
|
|
}
|
|
}
|
|
|
|
function resetGoalTreeSearch() {
|
|
try {
|
|
$("#goal-search-input").val("");
|
|
|
|
var entries = $(".goal-text");
|
|
var treeCard = $(".goal-card");
|
|
var collapsable = treeCard.find(".collapse");
|
|
|
|
entries.show();
|
|
treeCard.show();
|
|
|
|
hideCollapsable(collapsable);
|
|
} catch (error) {
|
|
showErrorPopup(error);
|
|
}
|
|
}
|
|
</script>
|
|
|
|
@helper BuildGoalTreeBranch(GoalTreeItem goalTreeItem)
|
|
{
|
|
var isChecked = Model.SelectedGoals.Any(a => a.ValueListEntryOid.HasValue && a.ValueListEntryOid.Value == goalTreeItem.ValueListEntryOid);
|
|
var isCheckedValue = isChecked ? "checked" : string.Empty;
|
|
|
|
RatingTypeDC ratingType = null;
|
|
|
|
if(isChecked)
|
|
{
|
|
var selectedGoal = Model.SelectedGoals.FirstOrDefault(f => f.ValueListEntryOid.HasValue && f.ValueListEntryOid.Value == goalTreeItem.ValueListEntryOid);
|
|
|
|
if(!(selectedGoal is null))
|
|
{
|
|
ratingType = Model.GoalRatingTypes.FirstOrDefault(f => f.RatingTypeOid.HasValue && f.RatingTypeOid.Value == selectedGoal.RatingTypeOid);
|
|
}
|
|
}
|
|
|
|
if(!goalTreeItem.IsLeaf) // Ziel
|
|
{
|
|
<div class="card w-100 mb-3 goal-card" id="c-@goalTreeItem.ValueListEntryOid">
|
|
<div class="card-header px-2" onclick="cardHeaderClick('#goal-chevron-@goalTreeItem.ValueListEntryOid', '#collapsable-goal-tree-branch-@goalTreeItem.ValueListEntryOid')">
|
|
<div class="clearfix">
|
|
<div class="custom-control custom-checkbox goal-card-header float-left" onclick="stopToggle(event)" >
|
|
<input type="checkbox" class="custom-control-input" value="@goalTreeItem.ValueListEntryOid" @isCheckedValue id="@goalTreeItem.ValueListEntryOid" onchange="updateSelectedGoals()" />
|
|
<label class="custom-control-label" for="@goalTreeItem.ValueListEntryOid">@goalTreeItem.Header</label>
|
|
@if(AbstractModel.HasRightToRateGoals)
|
|
{
|
|
<span id="goal-rating-@goalTreeItem.ValueListEntryOid" class="badge badge-bewo-goal-rating goal-rating-badge ml-1" onclick="showGoalRatingPopup(@goalTreeItem.ValueListEntryOid)">
|
|
@(ratingType?.DisplayName ?? goalTreeItem.RatingName)
|
|
</span>
|
|
}
|
|
</div>
|
|
<div class="btn-group float-right" role="group">
|
|
<span class="fas fa-chevron-down text-primary align-middle" id="goal-chevron-@goalTreeItem.ValueListEntryOid"></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="collapse" id="collapsable-goal-tree-branch-@goalTreeItem.ValueListEntryOid">
|
|
<div class="card-body p-1 goal-list">
|
|
@foreach(var child in goalTreeItem.Children)
|
|
{
|
|
@BuildGoalTreeBranch(child)
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
else // Maßnahme
|
|
{
|
|
<div class="custom-control custom-checkbox goal-text">
|
|
<input type="checkbox" class="custom-control-input" id="@goalTreeItem.ValueListEntryOid" @isCheckedValue onchange="updateSelectedGoals()">
|
|
<label for="@goalTreeItem.ValueListEntryOid" class="custom-control-label goal-name-label">@goalTreeItem.Header</label>
|
|
@if(AbstractModel.HasRightToRateGoals)
|
|
{
|
|
<span id="goal-rating-@goalTreeItem.ValueListEntryOid" class="badge badge-bewo-goal-rating goal-rating-badge ml-1" onclick="showGoalRatingPopup(@goalTreeItem.ValueListEntryOid)">
|
|
@(ratingType?.DisplayName ?? goalTreeItem.RatingName)
|
|
</span>
|
|
}
|
|
</div>
|
|
}
|
|
}
|
|
|
|
@foreach(var branch in Model.GoalTree)
|
|
{
|
|
@BuildGoalTreeBranch(branch)
|
|
} |