Skip to content

Commit

Permalink
Merge tag 'v0.14.4-weekly4' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	kolibri/plugins/coach/assets/src/views/plan/LessonCreationPage/index.vue
  • Loading branch information
jonboiser committed Oct 16, 2020
2 parents bf91a09 + f287108 commit deb8fb3
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 18 deletions.
4 changes: 3 additions & 1 deletion kolibri/core/content/utils/import_export_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ def get_files_to_transfer(


def calculate_files_to_transfer(nodes_to_include, available):
nodes_to_include_and_ancestors = nodes_to_include.get_ancestors(include_self=True)

files_to_transfer = LocalFile.objects.filter(
available=available, files__contentnode__in=nodes_to_include
available=available, files__contentnode__in=nodes_to_include_and_ancestors
)

# Make sure the files are unique, to avoid duplicating downloads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

<script>
import { ERROR_CONSTANTS } from 'kolibri.coreVue.vuex.constants';
import CatchErrors from 'kolibri.utils.CatchErrors';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import AssignmentDetailsModal from '../assignments/AssignmentDetailsModal';
import commonCoach from '../../common';
Expand All @@ -60,6 +62,14 @@
})
.then(() => {
this.showSnackbarNotification('lessonCreated');
})
.catch(error => {
const errors = CatchErrors(error, [ERROR_CONSTANTS.UNIQUE]);
if (errors) {
this.$refs.detailsModal.handleSubmitTitleFailure();
} else {
this.$refs.detailsModal.handleSubmitFailure();
}
});
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
this.$refs.searchinput.focus();
},
search() {
if (this.searchTerm !== '') {
if (this.searchTerm !== '' && this.searchTermHasChanged) {
this.$emit('searchterm', this.searchTerm);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
return this.pageName === LessonsPageNames.SELECTION_SEARCH;
},
searchTerm() {
return this.$route.params.searchTerm;
return this.$route.params.searchTerm || '';
},
routerParams() {
return { classId: this.classId, lessonId: this.lessonId };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@
:text="coreString('cancelAction')"
appearance="flat-button"
:primary="false"
:disabled="disabled"
:disabled="disabled || formIsSubmitted"
@click="$emit('cancel')"
/>
<KButton
:text="coreString('saveChangesAction')"
:primary="true"
:disabled="disabled"
:disabled="disabled || formIsSubmitted"
@click="submitData"
/>
</KButtonGroup>
Expand Down Expand Up @@ -156,7 +156,7 @@
computed: {
titleIsInvalidText() {
// submission is handled because "blur" event happens on submit
if (!this.disabled && this.titleIsVisited) {
if (!this.disabled && !this.formIsSubmitted && this.titleIsVisited) {
if (this.title === '') {
return this.coreString('requiredFieldError');
}
Expand Down Expand Up @@ -220,6 +220,7 @@
}
if (this.formIsValid) {
this.formIsSubmitted = true;
this.$emit('submit', {
title: this.title,
description: this.description,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<p>{{ $tr('renameFacilityExplanation') }}</p>
<KTextbox
ref="name"
v-model.trim="name"
v-model="name"
type="text"
:label="coreString('facilityName')"
:autofocus="true"
Expand All @@ -36,6 +36,10 @@
name: 'EditFacilityNameModal',
mixins: [commonCoreStrings],
props: {
facilityId: {
type: String,
required: true,
},
facilityName: {
type: String,
required: true,
Expand All @@ -52,7 +56,7 @@
computed: {
...mapState('facilityConfig', ['facilities']),
nameIsInvalidText() {
if (this.name === '') {
if (this.name.trim() === '') {
return this.coreString('requiredFieldError');
}
if (this.isDuplicated) return this.coreString('facilityDuplicated');
Expand All @@ -68,7 +72,8 @@
},
facilityNameIsUnique(value) {
this.isDuplicated = !!this.facilities.find(
({ name }) => name.toLowerCase() === value.toLowerCase()
facility =>
facility.id != this.facilityId && facility.name.toLowerCase() === value.toLowerCase()
);
},
handleSubmit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
<EditFacilityNameModal
v-if="showEditFacilityModal"
id="edit-facility"
:facilityId="facilityId"
:facilityName="facilityName"
@submit="sendFacilityName"
@cancel="showEditFacilityModal = false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
size="small"
:submitText="coreString('saveAction')"
:cancelText="coreString('cancelAction')"
:submitDisabled="submitting"
:disabled="submitting"
@submit="createNewClass"
@cancel="$emit('cancel')"
>
Expand All @@ -15,6 +15,7 @@
type="text"
:label="coreString('classNameLabel')"
:autofocus="true"
:disabled="submitting"
:invalid="nameIsInvalid"
:invalidText="nameIsInvalidText"
:maxlength="50"
Expand Down Expand Up @@ -48,16 +49,12 @@
},
computed: {
duplicateName() {
const index = this.classes.findIndex(
return !!this.classes.find(
classroom => classroom.name.toUpperCase() === this.name.toUpperCase()
);
if (index === -1) {
return false;
}
return true;
},
nameIsInvalidText() {
if (this.nameBlurred || this.formSubmitted) {
if (!this.formSubmitted) {
if (this.name === '') {
return this.coreString('requiredFieldError');
}
Expand All @@ -76,14 +73,15 @@
},
methods: {
createNewClass() {
this.formSubmitted = true;
this.submitting = true;
if (this.formIsValid) {
this.submitting = true;
this.formSubmitted = true;
this.$store.dispatch('classManagement/createClass', this.name).then(() => {
this.$emit('success');
this.showSnackbarNotification('classCreated');
});
} else {
this.submitting = false;
this.$refs.name.focus();
}
},
Expand Down

0 comments on commit deb8fb3

Please sign in to comment.