@qtoggle/qui 1.16.1 → 1.16.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.
@@ -96,6 +96,10 @@ class PageForm extends mix(Form).with(PageMixin) {
96
96
  }
97
97
 
98
98
  let context = currentSection.getPagesContext()
99
+ if (!context) {
100
+ return
101
+ }
102
+
99
103
  let pages = context.getPages()
100
104
  let pageForms = pages.filter(p => p instanceof PageForm)
101
105
 
package/js/pages/page.js CHANGED
@@ -9,6 +9,7 @@ import * as Navigation from '$qui/navigation.js'
9
9
  import * as Theme from '$qui/theme.js'
10
10
  import {asap} from '$qui/utils/misc.js'
11
11
  import ViewMixin from '$qui/views/view.js'
12
+ import * as Sections from '$qui/sections/sections.js'
12
13
  import * as Window from '$qui/window.js'
13
14
 
14
15
  import {getPagesContainer} from './pages.js'
@@ -182,7 +183,7 @@ const PageMixin = Mixin((superclass = Object, rootclass) => {
182
183
  /**
183
184
  * Override this to implement how the page is loaded.
184
185
  *
185
- * By default does nothing, returning a resolved promise.
186
+ * Does nothing by default, returning a resolved promise.
186
187
  *
187
188
  * @returns {Promise}
188
189
  */
@@ -727,6 +728,14 @@ const PageMixin = Mixin((superclass = Object, rootclass) => {
727
728
  this.onSectionHide()
728
729
  }
729
730
 
731
+ /**
732
+ * Returns the section to which the page currently belongs (may be `null`).
733
+ * @returns {?qui.sections.Section}
734
+ */
735
+ getSection() {
736
+ return Sections.all().find(s => s.getPagesContext() === this.getContext()) || null
737
+ }
738
+
730
739
  /**
731
740
  * Override this method to enable the options bar for this page.
732
741
  * @returns {?jQuery|qui.views.ViewMixin}
package/js/pages/pages.js CHANGED
@@ -48,7 +48,7 @@ export function getCurrentContext() {
48
48
  /**
49
49
  * Replace the current pages context.
50
50
  * @alias qui.pages.setCurrentContext
51
- * @param {?qui.pages.PagesContext} context new context, or `null` to replace with a brand new context
51
+ * @param {?qui.pages.PagesContext} context new context, or `null` to replace with a brand-new context
52
52
  */
53
53
  export function setCurrentContext(context) {
54
54
  let pagesToDetach = currentContext.getPages()
@@ -3,6 +3,7 @@ import $ from '$qui/lib/jquery.module.js'
3
3
  import Logger from '$qui/lib/logger.module.js'
4
4
 
5
5
  import {NotImplementedError} from '$qui/base/errors.js'
6
+ import {AssertionError} from '$qui/base/errors.js'
6
7
  import {mix} from '$qui/base/mixwith.js'
7
8
  import SingletonMixin from '$qui/base/singleton.js'
8
9
  import StockIcon from '$qui/icons/stock-icon.js'
@@ -358,18 +359,24 @@ class Section extends mix().with(SingletonMixin) {
358
359
  * @returns {?qui.pages.PageMixin}
359
360
  */
360
361
  getCurrentPage() {
361
- return this.getPagesContext().getCurrentPage()
362
+ let context = this.getPagesContext()
363
+ return context ? context.getCurrentPage() : null
362
364
  }
363
365
 
364
366
  /**
365
367
  * Return the pages context of this section.
366
- * @returns {qui.pages.PagesContext}
368
+ * @returns {?qui.pages.PagesContext}
367
369
  */
368
370
  getPagesContext() {
369
371
  /* A hidden section has its pages context stored in _savedPagesContext. A visible (current) section owns the
370
372
  * current pages context. */
371
373
 
372
- return this._savedPagesContext || getCurrentContext()
374
+ if (this.isCurrent()) {
375
+ return getCurrentContext()
376
+ }
377
+ else {
378
+ return this._savedPagesContext
379
+ }
373
380
  }
374
381
 
375
382
 
@@ -525,6 +532,10 @@ class Section extends mix().with(SingletonMixin) {
525
532
  }
526
533
 
527
534
  let context = this.getPagesContext()
535
+ if (!context) {
536
+ throw new AssertionError('Attempt to push page to uninitialized section')
537
+ }
538
+
528
539
  if (!context.isCurrent()) {
529
540
  historyEntry = false
530
541
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qtoggle/qui",
3
3
  "description": "A JavaScript UI library with batteries included.",
4
- "version": "1.16.1",
4
+ "version": "1.16.2",
5
5
  "author": {
6
6
  "name": "Calin Crisan",
7
7
  "email": "ccrisan@gmail.com"
package/setup.py CHANGED
@@ -8,7 +8,7 @@ except ImportError:
8
8
 
9
9
  setup(
10
10
  name='qui-server',
11
- version='1.16.1',
11
+ version='1.16.2',
12
12
  description='QUI server-side',
13
13
  author='Calin Crisan',
14
14
  author_email='ccrisan@gmail.com',