Skip to content

Commit

Permalink
adds resources to selected resources pool using add button
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanOXDi committed Feb 6, 2025
1 parent f95c046 commit 89a99e8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<div v-if="subpageLoading">
<KCircularLoader />
</div>

<router-view
v-else
:setTitle="setTitle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
v-if="isSelected"
:text="coreString('removeAction')"
:primary="true"
:disabled="disableSelectButton"
@click="removeResource"
@click="removeResource()"
/>
<KButton
v-else
:text="addText$()"
:primary="false"
:disabled="disableSelectButton"
@click="addResource"
@click="addResource()"
/>
</div>
</div>
Expand Down Expand Up @@ -153,7 +151,6 @@
data() {
return {
selectedQuestionIndex: 0,
disableSelectButton: false,
};
},
computed: {
Expand Down Expand Up @@ -207,11 +204,9 @@
return this.coreString('questionNumberLabel', { questionNumber });
},
addResource() {
this.disableSelectButton = true;
this.$emit('addResource', this.content);
},
removeResource() {
this.disableSelectButton = true;
this.$emit('removeResource', this.content);
},
getTime(seconds) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import commonCoreStrings from 'kolibri/uiText/commonCoreStrings';
import useFetchContentNode from '../../../../../../../composables/useFetchContentNode';
import useResourceSelection from '../../../../../../../composables/useResourceSelection';
import { coachStrings } from '../../../../../../common/commonCoachStrings';
import { PageNames } from '../../../../../../../constants/index';
import PreviewContent from './PreviewContent';
Expand All @@ -33,7 +32,6 @@
mixins: [commonCoreStrings],
setup(props) {
const { contentNode, ancestors, questions, loading } = useFetchContentNode(props.contentId);
const { selectedResources, selectResources, deselectResources } = useResourceSelection();
const { manageLessonResourcesTitle$ } = coachStrings;
props.setTitle(manageLessonResourcesTitle$());
Expand All @@ -43,9 +41,6 @@
contentNode,
ancestors,
questions,
selectedResources,
selectResources,
deselectResources,
loading,
};
},
Expand All @@ -62,46 +57,36 @@
type: Function,
default: () => {},
},
},
data() {
return {
justRemovedResource: false,
};
selectedResources: {
type: Array,
required: true,
},
},
computed: {
isSelected() {
if (this.justRemovedResource) {
return true;
}
if (this.selectedResources && this.contentNode && this.contentNode.id) {
return this.selectedResources.some(
resource => resource.contentnode_id === this.contentNode.id,
);
if (this.selectedResources) {
return this.selectedResources.find(resource => resource.id === this.contentId);
}
return false;
},
},
methods: {
handleAddResource(content) {
this.routeBack().then(() => {
this.selectResources([content]);
this.showSnackbarNotification('resourcesAddedWithCount', { count: 1 });
});
},
handleRemoveResource(content) {
this.justRemovedResource = true;
this.deselectResources([content]);
this.routeBack().then(() => {
this.showSnackbarNotification('resourcesRemovedWithCount', { count: 1 });
});
},
routeBack() {
const { params, query } = this.$route;
return this.$router.push({
return {
name: PageNames.LESSON_SELECT_RESOURCES_TOPIC_TREE,
params: params,
query: query,
});
};
},
},
methods: {
handleAddResource(content) {
this.routeBack;
this.$emit('selectResources', [content]);
this.showSnackbarNotification('resourcesAddedWithCount', { count: 1 });
},
handleRemoveResource(content) {
this.$emit('deselectResources', [content]);
this.showSnackbarNotification('resourcesRemovedWithCount', { count: 1 });
},
},
};
Expand Down

0 comments on commit 89a99e8

Please sign in to comment.