Skip to content

Commit c97e1f5

Browse files
committed
doc: add documentation
- Editor - Panel (user, exercise)
1 parent 39a3afc commit c97e1f5

File tree

4 files changed

+73
-17
lines changed

4 files changed

+73
-17
lines changed

components/Editor/RichTextEditor.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,17 @@
275275
}
276276
}
277277
278+
/**
279+
* Reset the text editor
280+
* @param content
281+
*/
278282
reset(content: string = '<p></p>') {
279283
this.editor.setContent(content);
280284
}
281285
286+
/**
287+
* Check if the text editor is empty
288+
*/
282289
get isEmpty(): boolean {
283290
return this.content === '<p></p>' || this.content === '<p><br></p>' || this.content === '';
284291
}

components/Exercise/ExercisesPanel.vue

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,31 +59,51 @@
5959
threshold: ratio
6060
};
6161
62-
62+
/**
63+
* return the number of selected tags
64+
*/
6365
get numberOfFilter() {
6466
return this.$accessor.tags.selectedTags.length
6567
}
6668
69+
/**
70+
* return all the selected tags
71+
*/
6772
get confirmedTags(): SelectedTag[] {
6873
return this.$accessor.tags.selectedTags
6974
}
7075
76+
/**
77+
* Return the searched title for an exercise
78+
*/
7179
get searchModel() {
7280
return this.$accessor.exercises.search_criterion.title
7381
}
7482
83+
/**
84+
* Check if the search request is empty
85+
*/
7586
get isEmptySearchModel(): boolean {
7687
return this.$accessor.exercises.search_criterion.title === ""
7788
}
7889
90+
/**
91+
* Return the number of exercises corresponding to the search request
92+
*/
7993
get nbOfResults(): number {
8094
return this.$accessor.exercises.metadata.totalItems
8195
}
8296
97+
/**
98+
* Return all the fetched exercises
99+
*/
83100
get exercises(): Exercise[] {
84101
return this.$accessor.exercises.exercises
85102
}
86103
104+
/**
105+
* formats the selection tag according to the quotation in a human readable way
106+
*/
87107
get voteTag(): { title: string, id: number, state: TagState } | undefined {
88108
const vote = this.$accessor.exercises.search_criterion.vote;
89109
let title = '';
@@ -102,6 +122,9 @@
102122
return undefined
103123
}
104124
125+
/**
126+
* Refresh the size of the box containing all exercises if the number of selected tags change
127+
*/
105128
@Watch('numberOfFilter')
106129
onNumberOfFilterChange() {
107130
this.$nextTick(() => {
@@ -115,6 +138,9 @@
115138
})
116139
}
117140
141+
/**
142+
* Remove the rating criteria and refresh the search request
143+
*/
118144
async removeRatingCriteria() {
119145
await this.$accessor.exercises.RESET_VOTE();
120146
await this.$accessor.exercises.fetch({});
@@ -129,6 +155,11 @@
129155
})
130156
}
131157
158+
/**
159+
* Remove on tag from the search request and fetch the exercises
160+
* @param event
161+
* @param tag
162+
*/
132163
async deleteTag(event: TagLabelObjectEmitted, tag: SelectedTag) {
133164
await this.$accessor.tags.addOrRemoveTag({...tag, isSelected: false});
134165
await this.$accessor.tags.apply('default');
@@ -144,6 +175,9 @@
144175
})
145176
}
146177
178+
/**
179+
* Reset the search request
180+
*/
147181
async reset() {
148182
this.$accessor.tags.CLEAR();
149183
this.$accessor.exercises.RESET_SEARCH_CRITERION();

components/Exercise/PreviewExercise.vue

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,32 @@
2929
export default class PreviewExercise extends Vue {
3030
@Prop({type: Object, required: true}) readonly exercise!: Exercise;
3131
32-
get metaTitleLink() {
32+
/**
33+
* Return the meta title of the exercise
34+
*/
35+
get metaTitleLink() {
3336
return `${this.exercise.title} | Source Code`
3437
}
3538
36-
get metaLink() {
39+
/**
40+
* Return the link of the exercise containing its id
41+
*/
42+
get metaLink() {
3743
return `/exercices/${this.exercise.id}`
3844
}
3945
40-
get tagsFormatted(): string {
46+
/**
47+
* return a formatted list of tags
48+
* Here's the order :
49+
* 1) cours
50+
* 2) difficulté
51+
* 3) langage
52+
* 4) type d'exercice
53+
* 5) thématique
54+
*
55+
* If a category does not contain any tag, it will be not display
56+
*/
57+
get tagsFormatted(): string {
4158
const tags: ExerciseTag[] = this.exercise.tags;
4259
4360
if(!tags) return '';
@@ -52,7 +69,7 @@
5269
if (tag.category.category_text === 'cours' && orderedTextTags[0] === undefined) {
5370
orderedTextTags[0] = tag.tag_text;
5471
counter++
55-
} else if (tag.category.category_text === 'langage' && orderedTextTags[1] === undefined) {
72+
} else if (tag.category.category_text === 'difficulté' && orderedTextTags[1] === undefined) {
5673
orderedTextTags[1] = tag.tag_text;
5774
counter++
5875
} else if (tag.category.category_text === 'langage' && orderedTextTags[2] === undefined) {
@@ -86,7 +103,10 @@
86103
return formatted
87104
}
88105
89-
get rating() {
106+
/**
107+
* Return the rating of the exercise
108+
*/
109+
get rating() {
90110
91111
const metrics = this.exercise.metrics;
92112
@@ -98,14 +118,6 @@
98118
return '-'
99119
100120
}
101-
102-
gotoExercise() {
103-
if(this.$auth.loggedIn) {
104-
this.$router.push(this.metaLink)
105-
} else {
106-
this.$router.push('/login')
107-
}
108-
}
109121
}
110122
</script>
111123

components/Panel/Item/UserFilterPanel.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,19 @@
6464
6565
6666
/**
67-
* A reference to each TagSelecter components
67+
* A reference to each CheckBoxSelecter components
6868
*/
6969
@Ref() checkBoxSelecter!: CheckBoxSelecter;
7070
7171
/**
72-
* The current opened tag selecter component
72+
* The current opened CheckBoxSelecter component
7373
*/
7474
selectedCheckBoxSelecter: CheckBoxSelecter | undefined = undefined;
7575
7676
77+
/**
78+
* Filter all users in terms of role
79+
*/
7780
setUserCriteria(event: CheckboxSelecterObjectEmitted[]) {
7881
7982
const switchFunction = function (el: CheckboxSelecterObjectEmitted) {
@@ -121,7 +124,7 @@
121124
}
122125
123126
/**
124-
* Save the current tagSelecter or close a tag selecter if previously activated
127+
* Save the current CheckBoxSelecter or close a CheckBoxSelecterif previously activated
125128
* @param userSelecter
126129
*/
127130
toggleList(userSelecter: CheckBoxSelecter) {

0 commit comments

Comments
 (0)