-
Notifications
You must be signed in to change notification settings - Fork 719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic layout for displaying "resources currently in lesson" #12845
Changes from 23 commits
95d5985
7291c44
4e571ab
0b1e4a0
c5a0cce
257bd3f
5264a6c
76a4fd7
adaf345
620e709
9bd9be7
a3cb994
25cafe4
2cb92ed
e925502
5ff97a3
6fef976
8bc13de
01d182e
a9eb601
26142c6
d4fe9f5
12e2a32
2218fbb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
<template> | ||
|
||
<div> | ||
<SidePanelModal | ||
alignment="right" | ||
sidePanelWidth="700px" | ||
closeButtonIconType="close" | ||
@closePanel="closeSidePanel" | ||
@shouldFocusFirstEl="() => null" | ||
> | ||
<template #header> | ||
<div :style="{ display: 'inline-flex' }"> | ||
<KIconButton | ||
v-if="true" | ||
icon="back" | ||
@click="closeSidePanel" | ||
/> | ||
<h1 | ||
:style="{ fontWeight: '600', fontSize: '18px' }" | ||
class="side-panel-title" | ||
> | ||
{{ numberOfSelectedResource$({ count: resources.length }) }} | ||
</h1> | ||
</div> | ||
</template> | ||
|
||
<SelectedResources | ||
:resourceList="resources" | ||
:currentLesson="currentLesson" | ||
:loading="resources.length === 0" | ||
@removeResource="removeResource" | ||
@navigateToParent="navigateToParent" | ||
/> | ||
|
||
<template #bottomNavigation> | ||
<div class="bottom-buttons-style"> | ||
<KButton | ||
:primary="true" | ||
:text="saveLessonResources$()" | ||
@click="closeSidePanel()" | ||
/> | ||
</div> | ||
</template> | ||
</SidePanelModal> | ||
|
||
<KModal | ||
v-if="showModal" | ||
:submitText="coreString('continueAction')" | ||
:cancelText="coreString('cancelAction')" | ||
:title="closeConfirmationTitle$()" | ||
@cancel="closeModal" | ||
@submit="$router.go(-1)" | ||
> | ||
{{ closeConfirmationMessage$() }} | ||
</KModal> | ||
</div> | ||
|
||
</template> | ||
|
||
|
||
<script> | ||
|
||
import SidePanelModal from 'kolibri-common/components/SidePanelModal'; | ||
import { mapState } from 'vuex'; | ||
import { searchAndFilterStrings } from 'kolibri-common/strings/searchAndFilterStrings'; | ||
import commonCoreStrings from 'kolibri/uiText/commonCoreStrings'; | ||
import { ref, getCurrentInstance } from 'vue'; | ||
import { enhancedQuizManagementStrings } from 'kolibri-common/strings/enhancedQuizManagementStrings'; | ||
import { PageNames } from '../../../../constants'; | ||
import commonCoach from '../../../common'; | ||
import SelectedResources from './SelectedResources'; | ||
|
||
export default { | ||
name: 'ManageSelectedLessonResources', | ||
components: { | ||
SidePanelModal, | ||
SelectedResources, | ||
}, | ||
mixins: [commonCoach, commonCoreStrings], | ||
setup() { | ||
const showModal = ref(false); | ||
const hasArrayChanged = ref(false); | ||
const router = getCurrentInstance().proxy.$router; | ||
|
||
const { saveLessonResources$, numberOfSelectedResource$ } = searchAndFilterStrings; | ||
const { closeConfirmationTitle$, closeConfirmationMessage$ } = enhancedQuizManagementStrings; | ||
|
||
function closeModal() { | ||
showModal.value = false; | ||
} | ||
|
||
function hasModifiedArray() { | ||
hasArrayChanged.value = true; | ||
} | ||
|
||
function closeSidePanel() { | ||
if (hasArrayChanged.value) { | ||
showModal.value = true; | ||
} else { | ||
router.go(-1); | ||
} | ||
} | ||
|
||
return { | ||
saveLessonResources$, | ||
numberOfSelectedResource$, | ||
closeConfirmationTitle$, | ||
closeConfirmationMessage$, | ||
showModal, | ||
closeModal, | ||
closeSidePanel, | ||
hasModifiedArray, | ||
}; | ||
}, | ||
data() { | ||
return { | ||
resources: [], | ||
}; | ||
}, | ||
computed: { | ||
...mapState('lessonSummary', ['currentLesson', 'workingResources', 'resourceCache']), | ||
}, | ||
mounted() { | ||
setTimeout(() => { | ||
this.getResources(); | ||
}, 2000); | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be taken off- was for testing |
||
methods: { | ||
removeResource(id) { | ||
this.resources = this.resources.filter(lesson => lesson.id !== id); | ||
this.hasModifiedArray(); | ||
}, | ||
navigateToParent(id) { | ||
this.$router.push({ | ||
name: PageNames.LESSONS_ROOT, | ||
params: { classId: this.$route.params.classId, lessonId: id }, | ||
}); | ||
}, | ||
getResources() { | ||
const response = this.workingResources.map(resource => { | ||
const content = this.resourceCache[resource.contentnode_id]; | ||
if (!content) { | ||
return this.missingResourceObj(resource.contentnode_id); | ||
} | ||
const tally = this.getContentStatusTally( | ||
content.content_id, | ||
this.getLearnersForLesson(this.currentLesson), | ||
); | ||
|
||
const tableRow = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will also be replaced by useResourceselection compasable. We will not need it anymore |
||
...content, | ||
node_id: content.id, | ||
hasAssignments: Object.values(tally).reduce((a, b) => a + b, 0), | ||
tally, | ||
}; | ||
|
||
const link = this.resourceLink(tableRow); | ||
if (link) { | ||
tableRow.link = link; | ||
} | ||
|
||
return tableRow; | ||
}); | ||
|
||
Promise.all(response).then(results => { | ||
this.resources = results; | ||
}); | ||
}, | ||
resourceLink(resource) { | ||
if (resource.hasAssignments) { | ||
if (resource.kind === this.ContentNodeKinds.EXERCISE) { | ||
return this.classRoute( | ||
this.group | ||
? PageNames.GROUP_LESSON_EXERCISE_LEARNER_REPORT | ||
: PageNames.LESSON_EXERCISE_LEARNERS_REPORT, | ||
{ exerciseId: resource.content_id }, | ||
); | ||
} else { | ||
return this.classRoute( | ||
this.group ? PageNames.GROUPS_ROOT : PageNames.LESSON_RESOURCE_LEARNERS_REPORT, | ||
{ resourceId: resource.content_id }, | ||
); | ||
} | ||
} | ||
}, | ||
}, | ||
$trs: {}, | ||
}; | ||
|
||
</script> | ||
|
||
|
||
<style scoped> | ||
|
||
.bottom-buttons-style { | ||
position: absolute; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
padding: 1em; | ||
margin-top: 1em; | ||
text-align: right; | ||
background-color: #ffffff; | ||
border-top: 1px solid black; | ||
} | ||
|
||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be removed in favor of a composable