adapt-authoring-ui 1.8.0 → 1.8.2

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.
@@ -50,7 +50,8 @@ define(function(require){
50
50
  'assetManagement:sidebarFilter:remove': this.removeFilter,
51
51
  'assetManagement:sidebarView:filter': this.filterBySearchInput,
52
52
  'assetManagement:assetManagementSidebarView:filterByTags': this.filterByTags,
53
- 'assetManagement:collection:refresh': this.resetCollection
53
+ 'assetManagement:collection:refresh': this.resetCollection,
54
+ 'assetManagement:assetPreviewView:delete': this.onAssetDeleted
54
55
  });
55
56
  },
56
57
 
@@ -186,6 +187,12 @@ define(function(require){
186
187
  this.fetchCollection();
187
188
  },
188
189
 
190
+ onAssetDeleted: function(assetId) {
191
+ if (!assetId) return;
192
+ this.allAssets = this.allAssets.filter(asset => asset.get('_id') !== assetId);
193
+ $('.asset-management-no-assets').toggleClass('display-none', this.allAssets.length > 0);
194
+ },
195
+
189
196
  // Event handling
190
197
 
191
198
  onResize: function() {
@@ -51,7 +51,7 @@ define(function(require){
51
51
  try {
52
52
  await $.ajax({ url: `api/assets/${this.model.get('_id')}`, type: 'DELETE' });
53
53
  this.model.trigger('destroy', this.model, this.model.collection);
54
- Origin.trigger('assetManagement:assetPreviewView:delete');
54
+ Origin.trigger('assetManagement:assetPreviewView:delete', this.model.get('_id'));
55
55
  this.remove();
56
56
  } catch(e) {
57
57
  Origin.Notify.alert({
@@ -183,6 +183,9 @@ define(function(require){
183
183
 
184
184
  this.$('.no-projects').toggleClass('display-none', this.allCourses.length > 0);
185
185
  if(typeof cb === 'function') cb(collection);
186
+
187
+ // Check if we need to load more items to fill the visible area
188
+ this.checkAndFillVisibleArea();
186
189
  },
187
190
  error: () => {
188
191
  this.isCollectionFetching = false;
@@ -195,6 +198,25 @@ define(function(require){
195
198
  });
196
199
  },
197
200
 
201
+ checkAndFillVisibleArea: function() {
202
+ // Check if we need to load more items to fill the viewport
203
+ if(this.shouldStopFetches || this.isCollectionFetching) return;
204
+
205
+ const $last = $('.project-list-item').last();
206
+ if($last.length === 0) return;
207
+
208
+ const contentPane = $('.contentPane');
209
+ if(contentPane.length === 0) return;
210
+
211
+ const contentPaneBottom = contentPane.offset().top + contentPane.height();
212
+ const lastItemBottom = $last.offset().top + $last.height();
213
+
214
+ // If the last item is visible (within the viewport), fetch more
215
+ if(lastItemBottom <= contentPaneBottom) {
216
+ this.fetchCollection();
217
+ }
218
+ },
219
+
198
220
  doLazyScroll: function(e) {
199
221
  if(this.isCollectionFetching) {
200
222
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-ui",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
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",