Skip to content
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

Edit modal - add additional fields to "Basic info" section #3370

Merged
merged 18 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,45 +32,80 @@
box
@focus="trackClick('Title')"
/>
<!-- Description -->
<VTextarea
v-if="oneSelected"
ref="description"
v-model="description"
:label="$tr('descriptionLabel')"
maxlength="400"
counter
autoGrow
box
@focus="trackClick('Description')"
/>
<!-- Tags -->
<VCombobox
ref="tags"
v-model="contentTags"
class="tagbox"
:items="tags"
:searchInput.sync="tagText"
chips
box
:label="$tr('tagsLabel')"
multiple
deletableChips
hideSelected
maxlength="30"
autoSelectFirst
@focus="trackClick('Tags')"
>
<template v-slot:no-data>
<VListTile v-if="tagText && tagText.trim()">
<VListTileContent>
<VListTileTitle>
{{ $tr('noTagsFoundText', { text: tagText.trim() }) }}
</VListTileTitle>
</VListTileContent>
</VListTile>
</template>
</VCombobox>
<VLayout row wrap>
<VFlex
xs12
md6
class="basicInfoColumn"
:class="{ 'pr-2': $vuetify.breakpoint.mdAndUp }"
>
<!-- Description -->
<VTextarea
v-if="oneSelected"
ref="description"
v-model="description"
:label="$tr('descriptionLabel')"
maxlength="400"
counter
autoGrow
box
height="100%"
class="descriptionTextArea"
@focus="trackClick('Description')"
/>
</VFlex>
<VFlex
xs12
md6
:class="{ 'pl-2': $vuetify.breakpoint.mdAndUp }"
>
<!-- Learning activity -->
<LearningActivityOptions
ref="learning_activities"
v-model="contentLearningActivities"
@focus="trackClick('Learning activities')"
/>
<!-- Level -->
<LevelsOptions
ref="contentLevel"
v-model="contentLevel"
@focus="trackClick('Levels dropdown')"
/>
<!-- What you will need -->
<ResourcesNeededOptions
ref="resourcesNeeded"
v-model="resourcesNeeded"
@focus="trackClick('What you will need')"
/>
<!-- Tags -->
<VCombobox
ref="tags"
v-model="contentTags"
class="tagbox"
:items="tags"
:searchInput.sync="tagText"
chips
box
:label="$tr('tagsLabel')"
multiple
deletableChips
hideSelected
maxlength="30"
autoSelectFirst
@focus="trackClick('Tags')"
>
<template v-slot:no-data>
<VListTile v-if="tagText && tagText.trim()">
<VListTileContent>
<VListTileTitle>
{{ $tr('noTagsFoundText', { text: tagText.trim() }) }}
</VListTileTitle>
</VListTileContent>
</VListTile>
</template>
</VCombobox>
</VFlex>
</VLayout>
</VFlex>
</VLayout>

Expand Down Expand Up @@ -328,6 +363,10 @@
import SubtitlesList from '../../views/files/supplementaryLists/SubtitlesList';
import { isImportedContent, importedChannelLink } from '../../utils';
import AccessibilityOptions from './AccessibilityOptions.vue';
import LevelsOptions from './LevelsOptions.vue';
import ResourcesNeededOptions from './ResourcesNeededOptions.vue';
import LearningActivityOptions from './LearningActivityOptions.vue';

import {
getTitleValidators,
getCopyrightHolderValidators,
Expand Down Expand Up @@ -386,6 +425,7 @@
* - `grade_levels` (sometimes referred to as `content_levels`)
* - `learner_needs` (resources needed)
* - `accessibility_labels` (accessibility options)
* - `learning_activities` (learning activities)
*/
function generateNestedNodesGetterSetter(key) {
return {
Expand Down Expand Up @@ -416,6 +456,9 @@
ContentNodeThumbnail,
Checkbox,
AccessibilityOptions,
LevelsOptions,
ResourcesNeededOptions,
LearningActivityOptions,
},
mixins: [constantsTranslationMixin, metadataTranslationMixin],
props: {
Expand Down Expand Up @@ -495,6 +538,10 @@
role: generateGetterSetter('role_visibility'),
language: generateGetterSetter('language'),
accessibility: generateNestedNodesGetterSetter('accessibility_labels'),
contentLevel: generateNestedNodesGetterSetter('grade_levels'),
resourcesNeeded: generateNestedNodesGetterSetter('learner_needs'),
contentLearningActivities: generateNestedNodesGetterSetter('learning_activities'),

mastery_model() {
return this.getExtraFieldsValueFromNodes('mastery_model');
},
Expand Down Expand Up @@ -825,6 +872,18 @@
}
}
}

.basicInfoColumn {
display: flex;
/deep/ .v-input {
// Stretches the "Description" text area to fill the column vertically
align-items: stretch;
}
/deep/ .v-input__control {
// Makes sure that the character count does not get pushed to second column
flex-wrap: nowrap;
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>

<VSelect
v-model="learningActivity"
:items="learningActivities"
box
chips
clearable
:label="translateMetadataString('learningActivity')"
multiple
deletableChips
:rules="learningActivityRules"
/>

</template>

<script>

import { camelCase } from 'lodash';
import { LearningActivities } from 'shared/constants';
import { constantsTranslationMixin, metadataTranslationMixin } from 'shared/mixins';
import { getLearningActivityValidators, translateValidator } from 'shared/utils/validation';

export default {
name: 'LearningActivityOptions',
mixins: [constantsTranslationMixin, metadataTranslationMixin],
props: {
value: {
type: Array,
default: () => [],
},
},
computed: {
learningActivity: {
get() {
return this.value;
},
set(value) {
this.$emit('input', value);
},
},
learningActivities() {
return Object.entries(LearningActivities).map(activity => ({
text: this.translateMetadataString(camelCase(activity[0])),
value: activity[1],
}));
},
learningActivityRules() {
return getLearningActivityValidators().map(translateValidator);
},
},
};

</script>
<style lang="scss">
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<template>

<VSelect
ref="level"
v-model="level"
:items="levels"
box
chips
clearable
:label="translateMetadataString('level')"
multiple
deletableChips
/>

</template>

<script>

import { camelCase } from 'lodash';
import { ContentLevels } from 'shared/constants';
import { constantsTranslationMixin, metadataTranslationMixin } from 'shared/mixins';

export default {
name: 'LevelsOptions',
mixins: [constantsTranslationMixin, metadataTranslationMixin],
props: {
value: {
type: Array,
default: () => [],
},
},
computed: {
level: {
get() {
return this.value;
},
set(value) {
this.$emit('input', value);
},
},
/**
* List of levels to show in the dropdown, taking into account mapping
* to levels in the constants that do not have an exact matching corresponding string
* @returns {Array}
*/
levels() {
return Object.entries(ContentLevels).map(level => {
let translationKey;
if (level[0] === 'PROFESSIONAL') {
translationKey = 'specializedProfessionalTraining';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @marcellamaki we might want to consolidate this logic somewhere like I think we did on Kolibri?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else if (level[0] === 'WORK_SKILLS') {
translationKey = 'allLevelsWorkSkills';
} else if (level[0] === 'BASIC_SKILLS') {
translationKey = 'allLevelsBasicSkills';
} else {
translationKey = camelCase(level[0]);
}
return {
text: this.translateMetadataString(translationKey),
value: level[1],
};
});
},
},
};

</script>
<style lang="scss">

</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<template>

<VSelect
ref="need"
v-model="need"
:items="resources"
box
chips
:label="$tr('resourcesNeededLabel')"
multiple
deletableChips
clearable
/>

</template>

<script>

import { ResourcesNeededTypes } from 'shared/constants';
import { constantsTranslationMixin, metadataTranslationMixin } from 'shared/mixins';

/**
* @param {array} listOfKeys
* @returns {Object}
*
* Determines resources to show in the dropdown, to remove resources
* that do not currently need to be displayed in Kolibri
*/
export function updateResourcesDropdown(listOfKeys) {
if (listOfKeys) {
return Object.keys(ResourcesNeededTypes).reduce((acc, key) => {
if (listOfKeys.indexOf(key) === -1) {
acc[key] = ResourcesNeededTypes[key];
}
return acc;
}, {});
}
}

//the variable below can be changed or removed when metadata/Kolibri is updated
const keysToBeTemporarilyRemoved = ['PEERS', 'TEACHER', 'PRIOR_KNOWLEDGE', 'MATERIALS'];
const dropdown = updateResourcesDropdown(keysToBeTemporarilyRemoved) || ResourcesNeededTypes;

export default {
name: 'ResourcesNeededOptions',
mixins: [constantsTranslationMixin, metadataTranslationMixin],
props: {
value: {
type: Array,
default: () => [],
},
},
computed: {
need: {
get() {
return this.value;
},
set(value) {
this.$emit('input', value);
},
},
resources() {
return Object.entries(dropdown).map(resource => ({
text: this.translateMetadataString(resource[0]),
value: resource[1],
}));
},
},
$trs: {
resourcesNeededLabel: 'What you will need',
},
};

</script>
<style lang="scss">
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ describe.skip('detailsTabView', () => {
});
describe('on render', () => {
// TODO: add defaults for 'accessibility' field
// TODO: add defaults for 'grade_levels' field
// TODO: add defaults for 'learner_needs' field
it('all fields should match node field values', () => {
let keys = [
'language',
Expand Down
Loading