Skip to content
Snippets Groups Projects
Commit 872a1a95 authored by Ron Lucke's avatar Ron Lucke Committed by Jan-Hendrik Willms
Browse files

fix #954

Closes #954

Merge request studip/studip!597
parent 61865bdb
No related branches found
No related tags found
No related merge requests found
...@@ -4237,6 +4237,19 @@ cw tiles ...@@ -4237,6 +4237,19 @@ cw tiles
&.default-image { &.default-image {
@include background-icon(courseware, clickable, 128); @include background-icon(courseware, clickable, 128);
} }
.overlay-text {
padding: 0.25em;
margin: 0.25em;
background-color: rgba(255,255,255,0.8);
width: fit-content;
max-width: 100%;
height: 1.25em;
overflow: hidden;
text-overflow: ellipsis;
float: right;
text-align: right;
}
} }
.description { .description {
height: 220px; height: 220px;
......
...@@ -14,33 +14,40 @@ ...@@ -14,33 +14,40 @@
v-if="currentStyle === 'list-details' || currentStyle === 'list'" v-if="currentStyle === 'list-details' || currentStyle === 'list'"
:class="['cw-block-table-of-contents-' + currentStyle]" :class="['cw-block-table-of-contents-' + currentStyle]"
> >
<li v-for="child in childElements" :key="child.id"> <li v-for="child in childElementsWithTasks" :key="child.id">
<router-link :to="'/structural_element/' + child.id"> <router-link :to="'/structural_element/' + child.id">
<div class="cw-block-table-of-contents-title-box" :class="[child.attributes.payload.color]"> <div class="cw-block-table-of-contents-title-box" :class="[child.attributes.payload.color]">
{{ child.attributes.title }} {{ child.attributes.title }}
<span v-if="child.attributes.purpose === 'task'"> | {{ child.solverName }}</span>
<p v-if="currentStyle === 'list-details'">{{ child.attributes.payload.description }}</p> <p v-if="currentStyle === 'list-details'">{{ child.attributes.payload.description }}</p>
</div> </div>
</router-link> </router-link>
</li> </li>
</ul> </ul>
<ul <ul
v-if="currentStyle === 'tiles'" v-if="currentStyle === 'tiles'"
class="cw-block-table-of-contents-tiles cw-tiles" class="cw-block-table-of-contents-tiles cw-tiles"
> >
<li <li
v-for="child in childElements" v-for="child in childElementsWithTasks"
:key="child.id" :key="child.id"
class="tile" class="tile"
:class="[child.attributes.payload.color]" :class="[child.attributes.payload.color]"
> >
<router-link :to="'/structural_element/' + child.id" :title="child.attributes.title"> <router-link :to="'/structural_element/' + child.id" :title="child.attributes.purpose === 'task' ? child.attributes.title + ' | ' + child.solverName : child.attributes.title">
<div <div
class="preview-image" class="preview-image"
:class="[hasImage(child) ? '' : 'default-image']" :class="[hasImage(child) ? '' : 'default-image']"
:style="getChildStyle(child)" :style="getChildStyle(child)"
></div> >
<div v-if="child.attributes.purpose === 'task'" class="overlay-text">{{ child.solverName }}</div>
</div>
<div class="description"> <div class="description">
<header>{{ child.attributes.title }}</header> <header
:class="[child.attributes.purpose !== '' ? 'description-icon-' + child.attributes.purpose : '']"
>
{{ child.attributes.title || ""}}
</header>
<div class="description-text-wrapper"> <div class="description-text-wrapper">
<p>{{ child.attributes.payload.description }}</p> <p>{{ child.attributes.payload.description }}</p>
</div> </div>
...@@ -103,6 +110,10 @@ export default { ...@@ -103,6 +110,10 @@ export default {
...mapGetters({ ...mapGetters({
childrenById: 'courseware-structure/children', childrenById: 'courseware-structure/children',
structuralElementById: 'courseware-structural-elements/byId', structuralElementById: 'courseware-structural-elements/byId',
context: 'context',
taskById: 'courseware-tasks/byId',
userById: 'users/byId',
groupById: 'status-groups/byId',
}), }),
structuralElement() { structuralElement() {
return this.structuralElementById({ id: this.$route.params.id }); return this.structuralElementById({ id: this.$route.params.id });
...@@ -116,29 +127,42 @@ export default { ...@@ -116,29 +127,42 @@ export default {
style() { style() {
return this.block?.attributes?.payload?.style; return this.block?.attributes?.payload?.style;
}, },
childSets() { childElementsWithTasks() {
let childSets = []; let children = [];
let childElements = this.childElements; this.childElements.forEach(element => {
while (childElements.length > 0) { if (element.relationships.task.data) {
let set = []; let solverName = this.getSolverName(element.relationships.task.data.id);
for (let i = 0; i < 4; i++) { if (solverName) {
let elem = childElements.shift(); element.solverName = solverName;
if (elem !== undefined) { children.push(element);
set.push(elem);
} }
} else {
children.push(element);
} }
childSets.push(set); });
}
return childSets; return children;
} }
}, },
mounted() { mounted() {
this.initCurrentData(); this.initCurrentData();
this.childElements.forEach(element => {
if (element.relationships.task.data) {
const taskId = element.relationships.task.data.id;
try {
this.loadTask({
taskId: taskId,
});
} catch(error) {
console.debug(error);
}
}
});
}, },
methods: { methods: {
...mapActions({ ...mapActions({
updateBlock: 'updateBlockInContainer', updateBlock: 'updateBlockInContainer',
loadTask: 'loadTask',
}), }),
initCurrentData() { initCurrentData() {
this.currentTitle = this.title; this.currentTitle = this.title;
...@@ -169,11 +193,31 @@ export default { ...@@ -169,11 +193,31 @@ export default {
} }
}, },
countChildChildren(child) { countChildChildren(child) {
return this.childrenById(child.id).length; return this.childrenById(child.id).length + 1;
}, },
hasImage(child) { hasImage(child) {
return child.relationships?.image?.data !== null; return child.relationships?.image?.data !== null;
}, },
getSolverName(taskId) {
const task = this.taskById({ id: taskId});
if (task === undefined) {
return false;
}
const solver = task.relationships.solver.data;
if (solver.type === 'users') {
const user = this.userById({ id: solver.id });
return user.attributes['formatted-name'];
}
if (solver.type === 'status-groups') {
const group = this.groupById({ id: solver.id });
return group.attributes.name;
}
return false;
}
}, },
}; };
</script> </script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment