Skip to content

Commit

Permalink
add show resourc component
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanOXDi committed Nov 22, 2023
1 parent 21b0b81 commit 8819943
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 27 deletions.
1 change: 1 addition & 0 deletions kolibri/plugins/coach/assets/src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const PageNames = {
QUIZ_REPLACE_QUESTIONS: 'QUIZ_REPLACE_QUESTIONS',
QUIZ_SELECT_RESOURCES: 'QUIZ_SELECT_RESOURCES',
SELECT_FROM_RESOURCE:'SELECT_FROM_RESOURCE',
BOOK_MARKED_RESOURCES:'BOOK_MARKED_RESOURCES',

/** TODO Remove unused */
EXAM_CREATION_TOPIC: 'EXAM_CREATION_TOPIC',
Expand Down
4 changes: 4 additions & 0 deletions kolibri/plugins/coach/assets/src/routes/planExamRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export default [
}
]
},
{
name: PageNames.BOOK_MARKED_RESOURCES,
path: ':section_id/book-marked-resources',
},
],
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,34 @@
<div
class="card container drop-shadow"
>
<KGrid>
<KGridItem
:layout12="{ span: 4 }"
:layout8="{ span: 2 }"
class="thumb-area"
style="{ margin:auto }"
:style="bookMarkBackgroundColor"
>
<BookmarkIcon />
</KGridItem>

<KGridItem
:layout12="{ span: 8 }"
:layout8="{ span: 6 }"
class="text-area"
>
<a :style="{ color: $themeTokens.primary }">
<p style="font-weight:600;">{{ bookmarksLabel$() }}</p>
<span> {{ numberOfSelectedBookmarks$({ count: bookMarkedResoures }) }}</span>
</a>
</KGridItem>
</KGrid>

<KRouterLink
:to="to"
style="width:100%"
>
<KGrid>
<KGridItem
:layout12="{ span: 4 }"
:layout8="{ span: 2 }"
class="thumb-area"
style="{ margin:auto }"
:style="bookMarkBackgroundColor"
>
<BookmarkIcon />
</KGridItem>

<KGridItem
:layout12="{ span: 8 }"
:layout8="{ span: 6 }"
class="text-area"
>
<a :style="{ color: $themeTokens.primary }">
<p style="font-weight:600;">{{ bookmarksLabel$() }}</p>
<span> {{ numberOfSelectedBookmarks$({ count: bookMarkedResoures }) }}</span>
</a>
</KGridItem>
</KGrid>

</KRouterLink>
</div>

</template>
Expand Down Expand Up @@ -54,6 +59,10 @@
type: Number,
required: true,
},
to:{
type:Object,
required:true,
}
},
computed: {
bookMarkBackgroundColor() {
Expand All @@ -62,6 +71,9 @@
};
},
},
mounted(){
console.log(this.$route.params);
}
};
</script>
Expand Down Expand Up @@ -91,7 +103,7 @@
.card {
position: relative;
vertical-align: top;
border-radius: 8px;
border-radius: 2px;
transition: box-shadow $core-time ease;
&:focus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
v-if="bookmarks.length > 0"
kind="bookmark"
:isMobile="true"
:to="to"
:bookMarkedResoures="bookmarks.length"
/>

Expand Down Expand Up @@ -139,6 +140,15 @@
content => !this.contentIsDirectoryKind(content) && !this.contentIsInLesson(content)
);
},
to(){
return {
name: PageNames.BOOK_MARKED_RESOURCES,
params:{
classId: this.$route.params.classId,
section_id: this.$route.params.section_id,
}
}
}
},
watch: {
Expand All @@ -157,9 +167,9 @@
},
},
beforeRouteEnter(to, from, next) {
console.log(to);
console.log(from);
console.log(to.params.topic_id);
// console.log(to);
// console.log(from);
// console.log(to.params.topic_id);
if (to.params.topic_id) {
this.showChannelQuizCreationTopicPage(this.$store, to.params).then(() => {
next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
import SectionEditor from './SectionEditor';
import ReplaceQuestions from './ReplaceQuestions';
import ResourceSelection from './ResourceSelection';
import ShowBookMarkedResources from './ShowBookMarkedResources.vue';
const pageNameComponentMap = {
[PageNames.QUIZ_SECTION_EDITOR]: SectionEditor,
[PageNames.QUIZ_REPLACE_QUESTIONS]: ReplaceQuestions,
[PageNames.QUIZ_SELECT_RESOURCES]: ResourceSelection,
[PageNames.BOOK_MARKED_RESOURCES]:ShowBookMarkedResources,
};
export default {
Expand All @@ -38,6 +40,7 @@
ReplaceQuestions,
ResourceSelection,
ResourceSelectionBreadcrumbs,
ShowBookMarkedResources,
},
inject: ['quizForge'],
data() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<template>
<div class="">

<ContentCardList
:contentList="bookmarks"
:showSelectAll="selectAllIsVisible"
:viewMoreButtonState="viewMoreButtonState"
:selectAllChecked="bookmarks.length === 0"
:contentIsChecked="contentIsInLesson"
:contentHasCheckbox="c => !contentIsDirectoryKind(c)"
:contentCardMessage="() =>selectionMetadata"
:contentCardLink="contentLink"
@changeselectall="toggleTopicInWorkingResources"
@change_content_card="toggleSelected"
@moreresults="handleMoreResults"
/>
</div>
</template>

<script>
import { useResources } from '../../../composables/useResources';
import ContentCardList from './../LessonResourceSelectionPage/ContentCardList.vue';
import { PageNames } from '../../../constants';
export default {
name:"ShowBookMarkedResources",
components:{
ContentCardList,
},
setup(){
const {
bookmarks
} = useResources();
return {
bookmarks,
}
},
computed:{
selectAllIsVisible(){
return true;
},
addableContent() {
// Content in the topic that can be added if 'Select All' is clicked
const list = bookmarksList;
return list.filter(
content => !this.contentIsDirectoryKind(content) && !this.contentIsInLesson(content)
);
},
contentIsInLesson() {
return ({ id }) =>

Check failure on line 50 in kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ShowBookMarkedResources.vue

View workflow job for this annotation

GitHub Actions / All file linting

'bookmarksList' is not defined
Boolean(this.workingResources.find(resource => resource.contentnode_id === id));
},
selectionMetadata(){
return '';
},
},
data(){
return {
viewMoreButtonState: 'no_more_results',
}
},
methods:{
contentLink(){
if (!content.is_leaf) {
return {

Check failure on line 65 in kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ShowBookMarkedResources.vue

View workflow job for this annotation

GitHub Actions / All file linting

'content' is not defined
name: PageNames.SELECT_FROM_RESOURCE,
params: {
topic_id: content.id,
},

Check failure on line 69 in kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ShowBookMarkedResources.vue

View workflow job for this annotation

GitHub Actions / All file linting

'content' is not defined
};
}
},
toggleTopicInWorkingResources(){
if (isChecked) {
this.addableContent.forEach(resource => {

Check failure on line 75 in kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ShowBookMarkedResources.vue

View workflow job for this annotation

GitHub Actions / All file linting

'isChecked' is not defined
this.addToResourceCache({
node: { ...resource },
});
});
this.addToWorkingResources(this.addableContent);
} else {
this.removeFromSelectedResources(this.quizForge.channels.value);
}
},
toggleSelected(){
if (checked) {
this.addToSelectedResources(content);

Check failure on line 87 in kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ShowBookMarkedResources.vue

View workflow job for this annotation

GitHub Actions / All file linting

'checked' is not defined
} else {

Check failure on line 88 in kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ShowBookMarkedResources.vue

View workflow job for this annotation

GitHub Actions / All file linting

'content' is not defined
this.removeFromSelectedResources([content]);
}

Check failure on line 90 in kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ShowBookMarkedResources.vue

View workflow job for this annotation

GitHub Actions / All file linting

'content' is not defined
},
handleMoreResults(){
},
contentIsDirectoryKind({ is_leaf }) {
return !is_leaf;
},
}
}
</script>

0 comments on commit 8819943

Please sign in to comment.