Files
edx-platform/lms/static/js/edxnotes/collections/notes.js
Syed Ali Abbas Zaidi f1fb38ed83 fix: multi lines and spaces issues (#31885)
* fix: multi lines and spaces issues

* fix: eslint operator-linebreak issue

* fix: eslint quotes issue

* fix: remaining quotes issues

* fix: eslint object curly newline issue

* fix: eslint object curly spacing issue

* fix: eslint brace-style issues

* fix: react jsx indent and props issues

* fix: eslint trailing spaces issues

* fix: eslint linbreak style issue

* fix: eslint space unary operator issue

* fix: eslint line around directives issue

* fix: void and typeof space unary ops issue
2023-05-03 12:22:46 +05:00

61 lines
1.9 KiB
JavaScript

(function(define) {
'use strict';
define([
'underscore', 'edx-ui-toolkit/js/pagination/paging-collection', 'js/edxnotes/models/note'
], function(_, PagingCollection, NoteModel) {
return PagingCollection.extend({
model: NoteModel,
state: {
pageSize: 10
},
queryParams: {},
constructor: function(models, options) {
this.url = options.url;
this.state.pageSize = options.perPage;
if (options.text) {
this.queryParams.text = options.text;
}
PagingCollection.prototype.constructor.call(this, models, options);
},
/**
* Returns course structure from the list of notes.
* @return {Object}
*/
getCourseStructure: (function() {
var courseStructure = null;
return function() {
var chapters = {},
sections = {},
units = {};
this.each(function(note) {
var chapter = note.get('chapter'),
section = note.get('section'),
unit = note.get('unit');
chapters[chapter.location] = chapter;
sections[section.location] = section;
units[unit.location] = units[unit.location] || [];
units[unit.location].push(note);
});
courseStructure = {
chapters: _.sortBy(_.toArray(chapters), function(c) { return c.index; }),
sections: sections,
units: units
};
return courseStructure;
};
}())
});
});
}).call(this, define || RequireJS.define);