adapt-authoring-ui 1.8.1 → 1.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -123,7 +123,11 @@ define(function(require){
123
123
  creatorName = Origin.l10n.t('app.unknownuser');
124
124
  }
125
125
  if(this._isShared && creatorName) model.set('creatorName', creatorName);
126
- model.set('tagTitles', model.get('tags').map(tId => this.allTags.find(t => t.get('_id') === tId).get('title')));
126
+ model.set('tagTitles', (model.get('tags') || []).reduce((titles, tId) => {
127
+ const tag = this.allTags.find(t => t.get('_id') === tId);
128
+ tag ? titles.push(tag.get('title')) : console.error(`Missing tag '${tId}' on course ${model.get('_id')}`);
129
+ return titles;
130
+ }, []));
127
131
  const view = new ProjectView({ model });
128
132
  this.childViews.push(view);
129
133
  this.getProjectsContainer().append(view.$el);
@@ -183,6 +187,9 @@ define(function(require){
183
187
 
184
188
  this.$('.no-projects').toggleClass('display-none', this.allCourses.length > 0);
185
189
  if(typeof cb === 'function') cb(collection);
190
+
191
+ // Check if we need to load more items to fill the visible area
192
+ this.checkAndFillVisibleArea();
186
193
  },
187
194
  error: () => {
188
195
  this.isCollectionFetching = false;
@@ -195,6 +202,25 @@ define(function(require){
195
202
  });
196
203
  },
197
204
 
205
+ checkAndFillVisibleArea: function() {
206
+ // Check if we need to load more items to fill the viewport
207
+ if(this.shouldStopFetches || this.isCollectionFetching) return;
208
+
209
+ const $last = $('.project-list-item').last();
210
+ if($last.length === 0) return;
211
+
212
+ const contentPane = $('.contentPane');
213
+ if(contentPane.length === 0) return;
214
+
215
+ const contentPaneBottom = contentPane.offset().top + contentPane.height();
216
+ const lastItemBottom = $last.offset().top + $last.height();
217
+
218
+ // If the last item is visible (within the viewport), fetch more
219
+ if(lastItemBottom <= contentPaneBottom) {
220
+ this.fetchCollection();
221
+ }
222
+ },
223
+
198
224
  doLazyScroll: function(e) {
199
225
  if(this.isCollectionFetching) {
200
226
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-ui",
3
- "version": "1.8.1",
3
+ "version": "1.8.3",
4
4
  "description": "Front-end application for the Adapt authoring tool",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-ui",
6
6
  "license": "GPL-3.0",