adapt-authoring-ui 1.8.4 → 1.8.6

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.
@@ -1,6 +1,5 @@
1
1
  // LICENCE https://github.com/adaptlearning/adapt_authoring/blob/master/LICENSE
2
2
  define(function(require){
3
- var CourseModel = require('core/models/courseModel');
4
3
  var Origin = require('core/origin');
5
4
  var OriginView = require('core/views/originView');
6
5
  var ProjectView = require('./projectView');
@@ -90,23 +89,7 @@ define(function(require){
90
89
  },
91
90
 
92
91
  initPaging: function() {
93
- if(this.resizeTimer) {
94
- clearTimeout(this.resizeTimer);
95
- this.resizeTimer = -1;
96
- }
97
- var $item = new ProjectView({ model: new CourseModel() }).$el;
98
- $item.css({
99
- visibility: 'hidden'
100
- }).appendTo('.projects-list'); // Fixed: added missing class selector
101
-
102
- var containerHeight = $(window).height()-this.$el.offset().top;
103
- var itemHeight = $item.outerHeight(true);
104
- var columns = Math.floor(this.$('.projects-inner').width()/$item.outerWidth(true));
105
- var rows = Math.max(1, Math.ceil(containerHeight/itemHeight));
106
- $item.remove();
107
- // columns stack nicely, but need to add extra row if it's not a clean split
108
- if((containerHeight % itemHeight) > 0) rows++;
109
- this.collection.queryOptions.limit = columns*rows;
92
+ this.collection.queryOptions.limit = 20;
110
93
  this.resetCollection(this.setViewToReady);
111
94
  },
112
95
 
@@ -205,16 +188,16 @@ define(function(require){
205
188
  checkAndFillVisibleArea: function() {
206
189
  // Check if we need to load more items to fill the viewport
207
190
  if(this.shouldStopFetches || this.isCollectionFetching) return;
208
-
191
+
209
192
  const $last = $('.project-list-item').last();
210
193
  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
-
194
+
195
+ const $contentPane = $('.contentPane');
196
+ if($contentPane.length === 0) return;
197
+
198
+ const contentPaneBottom = $contentPane.scrollTop() + $contentPane.height();
199
+ const lastItemBottom = $last.position().top + $last.outerHeight(true);
200
+
218
201
  // If the last item is visible (within the viewport), fetch more
219
202
  if(lastItemBottom <= contentPaneBottom) {
220
203
  this.fetchCollection();
@@ -9,10 +9,11 @@ const ONE_HOUR = 60 * ONE_MINUTE
9
9
  const ONE_WEEK = 7 * 24 * ONE_HOUR
10
10
 
11
11
  export default class CacheManager {
12
- constructor (maxAge = ONE_WEEK, logger = { log: (level, ...args) => console[level](...args) }) {
12
+ constructor ({ maxAge = ONE_WEEK, logger, tempDir } = {}) {
13
13
  this.maxAge = maxAge
14
- this.logger = logger
15
- fs.ensureDirSync(this.tempPath)
14
+ this.logger = logger ?? { log: (level, ...args) => console[level](...args) }
15
+ this.tempDir = tempDir ?? path.join(os.tmpdir(), 'adapt-authoring')
16
+ fs.ensureDirSync(this.tempDir)
16
17
  }
17
18
 
18
19
  static hash (path) {
@@ -22,19 +23,14 @@ export default class CacheManager {
22
23
  .digest('hex')
23
24
  }
24
25
 
25
- get tempPath () {
26
- const tempPath = path.join(os.tmpdir(), 'adapt-authoring')
27
- return tempPath
28
- }
29
-
30
26
  cachePath (basePath, outputFilePath = process.cwd()) {
31
27
  const projectHash = CacheManager.hash(path.join(basePath, outputFilePath))
32
- const cachePath = path.join(this.tempPath, `${projectHash}.cache`)
28
+ const cachePath = path.join(this.tempDir, `${projectHash}.cache`)
33
29
  return cachePath
34
30
  }
35
31
 
36
32
  get checkFilePath () {
37
- const checkFilePath = path.join(this.tempPath, 'last.touch')
33
+ const checkFilePath = path.join(this.tempDir, 'last.touch')
38
34
  return checkFilePath
39
35
  }
40
36
 
@@ -52,7 +48,7 @@ export default class CacheManager {
52
48
  await fs.writeFile(this.checkFilePath, String(Date.now()))
53
49
  this.logger.log('debug', 'Clearing compilation cache')
54
50
  // Fetch all cache files except checkFile
55
- const files = await glob([`${this.tempPath}/**`, `!${this.checkFilePath}`], { nodir: true })
51
+ const files = await glob([`${this.tempDir}/**`, `!${this.checkFilePath}`], { nodir: true })
56
52
  // Fetch file ages
57
53
  const fileAges = []
58
54
  const now = Date.now()
@@ -12,7 +12,7 @@ import { deflate, unzip, constants } from 'zlib'
12
12
  import { globSync } from 'glob'
13
13
 
14
14
  export default class JavaScriptTask {
15
- constructor (buildDir, logFunc, uiPlugins) {
15
+ constructor (buildDir, logFunc, uiPlugins, tempDir) {
16
16
  this.log = logFunc ?? ((level, ...args) => console.log(level.toUpperCase(), ...args))
17
17
  this.convertSlashes = /\\/g
18
18
  this.cwd = process.cwd().replace(this.convertSlashes, '/') + '/'
@@ -20,7 +20,7 @@ export default class JavaScriptTask {
20
20
  this.isFirstRun = true
21
21
  this.cache = null
22
22
  this.extensions = ['.js', '.jsx']
23
- this.cacheManager = new CacheManager({ logger: { log: this.log } })
23
+ this.cacheManager = new CacheManager({ logger: { log: this.log }, tempDir })
24
24
  this.resolvedNodeModules = {}
25
25
  this.resolvedNodeModulesPaths = []
26
26
 
package/lib/UiBuild.js CHANGED
@@ -60,7 +60,7 @@ class UiBuild {
60
60
  this.preBuildHook = new Hook()
61
61
  this.postBuildHook = new Hook()
62
62
 
63
- this.jsTask = new JavaScriptTask(this.Paths.Output, this.log, this.uiPlugins)
63
+ this.jsTask = new JavaScriptTask(this.Paths.Output, this.log, this.uiPlugins, this.app.getConfig('tempDir'))
64
64
  }
65
65
 
66
66
  collate (collateAtFolderName, destFolder, srcFileName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-ui",
3
- "version": "1.8.4",
3
+ "version": "1.8.6",
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",