@qtoggle/qui 0.0.0
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.
- package/.eslintignore +2 -0
- package/.eslintrc.json +492 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- package/.github/ISSUE_TEMPLATE/improvement_proposal.md +20 -0
- package/.github/workflows/main.yml +74 -0
- package/.pre-commit-config.yaml +8 -0
- package/LICENSE.txt +177 -0
- package/README.md +4 -0
- package/font/dejavusans-bold.woff +0 -0
- package/font/dejavusans-bolditalic.woff +0 -0
- package/font/dejavusans-italic.woff +0 -0
- package/font/dejavusans-regular.woff +0 -0
- package/img/qui-icons.svg +1937 -0
- package/js/base/base.js +47 -0
- package/js/base/condition-variable.js +92 -0
- package/js/base/errors.js +36 -0
- package/js/base/i18n.js +20 -0
- package/js/base/mixwith.js +135 -0
- package/js/base/require-js-compat.js +78 -0
- package/js/base/signal.js +91 -0
- package/js/base/singleton.js +66 -0
- package/js/base/timer.js +126 -0
- package/js/config.js +184 -0
- package/js/forms/common-fields/check-field.js +42 -0
- package/js/forms/common-fields/choice-buttons-field.js +30 -0
- package/js/forms/common-fields/color-combo-field.js +37 -0
- package/js/forms/common-fields/combo-field.js +108 -0
- package/js/forms/common-fields/common-fields.js +23 -0
- package/js/forms/common-fields/composite-field.js +132 -0
- package/js/forms/common-fields/custom-html-field.js +51 -0
- package/js/forms/common-fields/email-field.js +30 -0
- package/js/forms/common-fields/file-picker-field.js +46 -0
- package/js/forms/common-fields/jquery-ui-field.js +111 -0
- package/js/forms/common-fields/labels-field.js +69 -0
- package/js/forms/common-fields/numeric-field.js +39 -0
- package/js/forms/common-fields/password-field.js +28 -0
- package/js/forms/common-fields/phone-field.js +26 -0
- package/js/forms/common-fields/progress-disk-field.js +69 -0
- package/js/forms/common-fields/push-button-field.js +138 -0
- package/js/forms/common-fields/slider-field.js +51 -0
- package/js/forms/common-fields/text-area-field.js +34 -0
- package/js/forms/common-fields/text-field.js +89 -0
- package/js/forms/common-fields/up-down-field.js +85 -0
- package/js/forms/common-forms/common-forms.js +16 -0
- package/js/forms/common-forms/options-form.js +77 -0
- package/js/forms/common-forms/page-form.js +115 -0
- package/js/forms/form-button.js +202 -0
- package/js/forms/form-field.js +1183 -0
- package/js/forms/form.js +1181 -0
- package/js/forms/forms.js +68 -0
- package/js/global-glass.js +100 -0
- package/js/icons/default-stock.js +173 -0
- package/js/icons/icon.js +64 -0
- package/js/icons/icons.js +16 -0
- package/js/icons/multi-state-sprites-icon.js +362 -0
- package/js/icons/stock-icon.js +219 -0
- package/js/icons/stock.js +98 -0
- package/js/icons/stocks.js +57 -0
- package/js/index.js +232 -0
- package/js/lib/jquery.longpress.js +79 -0
- package/js/lib/jquery.module.js +4 -0
- package/js/lib/logger.module.js +4 -0
- package/js/lib/pep.module.js +4 -0
- package/js/lists/common-items/common-items.js +5 -0
- package/js/lists/common-items/icon-label-list-item.js +86 -0
- package/js/lists/common-lists/common-lists.js +5 -0
- package/js/lists/common-lists/page-list.js +53 -0
- package/js/lists/list-item.js +147 -0
- package/js/lists/list.js +636 -0
- package/js/lists/lists.js +26 -0
- package/js/main-ui/main-ui.js +64 -0
- package/js/main-ui/menu-bar.js +144 -0
- package/js/main-ui/options-bar.js +181 -0
- package/js/main-ui/status.js +185 -0
- package/js/main-ui/top-bar.js +59 -0
- package/js/messages/common-message-forms/common-message-forms.js +7 -0
- package/js/messages/common-message-forms/confirm-message-form.js +81 -0
- package/js/messages/common-message-forms/simple-message-form.js +67 -0
- package/js/messages/common-message-forms/sticky-simple-message-form.js +27 -0
- package/js/messages/message-form.js +107 -0
- package/js/messages/messages.js +21 -0
- package/js/messages/sticky-modal-page.js +98 -0
- package/js/messages/sticky-modal-progress-message.js +27 -0
- package/js/messages/toast.js +164 -0
- package/js/navigation.js +654 -0
- package/js/pages/breadcrumbs.js +124 -0
- package/js/pages/common-pages/common-pages.js +6 -0
- package/js/pages/common-pages/modal-progress-page.js +83 -0
- package/js/pages/common-pages/structured-page.js +46 -0
- package/js/pages/page.js +1018 -0
- package/js/pages/pages-context.js +154 -0
- package/js/pages/pages.js +252 -0
- package/js/pwa.js +337 -0
- package/js/sections/section.js +612 -0
- package/js/sections/sections.js +300 -0
- package/js/tables/common-cells/common-cells.js +7 -0
- package/js/tables/common-cells/icon-label-table-cell.js +68 -0
- package/js/tables/common-cells/push-button-table-cell.js +133 -0
- package/js/tables/common-cells/simple-table-cell.js +37 -0
- package/js/tables/common-tables/common-tables.js +5 -0
- package/js/tables/common-tables/page-table.js +55 -0
- package/js/tables/table-cell.js +198 -0
- package/js/tables/table-row.js +126 -0
- package/js/tables/table.js +492 -0
- package/js/tables/tables.js +36 -0
- package/js/theme.js +304 -0
- package/js/utils/ajax.js +126 -0
- package/js/utils/array.js +194 -0
- package/js/utils/colors.js +445 -0
- package/js/utils/cookies.js +65 -0
- package/js/utils/crypto.js +439 -0
- package/js/utils/css.js +234 -0
- package/js/utils/date.js +300 -0
- package/js/utils/files.js +27 -0
- package/js/utils/gestures.js +165 -0
- package/js/utils/html.js +76 -0
- package/js/utils/misc.js +81 -0
- package/js/utils/object.js +324 -0
- package/js/utils/promise.js +49 -0
- package/js/utils/string.js +192 -0
- package/js/utils/url.js +187 -0
- package/js/utils/utils.js +3 -0
- package/js/utils/visibility-manager.js +211 -0
- package/js/views/common-views/common-views.js +7 -0
- package/js/views/common-views/icon-label-view.js +210 -0
- package/js/views/common-views/progress-view.js +89 -0
- package/js/views/common-views/structured-view.js +368 -0
- package/js/views/view.js +467 -0
- package/js/views/views.js +3 -0
- package/js/widgets/base-widget.js +23 -0
- package/js/widgets/common-widgets/check-button.js +109 -0
- package/js/widgets/common-widgets/choice-buttons.js +322 -0
- package/js/widgets/common-widgets/color-combo.js +104 -0
- package/js/widgets/common-widgets/combo.js +645 -0
- package/js/widgets/common-widgets/common-widgets.js +17 -0
- package/js/widgets/common-widgets/email-input.js +7 -0
- package/js/widgets/common-widgets/file-picker.js +133 -0
- package/js/widgets/common-widgets/labels.js +132 -0
- package/js/widgets/common-widgets/numeric-input.js +49 -0
- package/js/widgets/common-widgets/password-input.js +91 -0
- package/js/widgets/common-widgets/phone-input.js +7 -0
- package/js/widgets/common-widgets/progress-disk.js +174 -0
- package/js/widgets/common-widgets/push-button.js +155 -0
- package/js/widgets/common-widgets/slider.js +455 -0
- package/js/widgets/common-widgets/text-area.js +52 -0
- package/js/widgets/common-widgets/text-input.js +174 -0
- package/js/widgets/common-widgets/up-down.js +351 -0
- package/js/widgets/widgets.js +57 -0
- package/js/window.js +557 -0
- package/jsdoc.conf.json +20 -0
- package/less/base.less +123 -0
- package/less/forms/common-fields.less +101 -0
- package/less/forms/common-forms.less +5 -0
- package/less/forms/form-button.less +21 -0
- package/less/forms/form-field.less +266 -0
- package/less/forms/form.less +131 -0
- package/less/global-glass.less +64 -0
- package/less/icon-label-view.less +82 -0
- package/less/icons.less +144 -0
- package/less/lists.less +105 -0
- package/less/main-ui.less +328 -0
- package/less/messages.less +189 -0
- package/less/no-effects.less +24 -0
- package/less/pages/breadcrumbs.less +98 -0
- package/less/pages/common-pages.less +36 -0
- package/less/pages/page.less +70 -0
- package/less/progress-view.less +51 -0
- package/less/stock-icons.less +43 -0
- package/less/structured-view.less +245 -0
- package/less/tables.less +84 -0
- package/less/theme-dark.less +133 -0
- package/less/theme-light.less +132 -0
- package/less/theme.less +419 -0
- package/less/visibility-manager.less +11 -0
- package/less/widgets/check-button.less +96 -0
- package/less/widgets/choice-buttons.less +160 -0
- package/less/widgets/color-combo.less +33 -0
- package/less/widgets/combo.less +230 -0
- package/less/widgets/common-buttons.less +120 -0
- package/less/widgets/common.less +24 -0
- package/less/widgets/input.less +258 -0
- package/less/widgets/labels.less +81 -0
- package/less/widgets/progress-disk.less +70 -0
- package/less/widgets/slider.less +199 -0
- package/less/widgets/updown.less +115 -0
- package/less/widgets/various.less +36 -0
- package/package.json +47 -0
- package/pyproject.toml +45 -0
- package/qui/__init__.py +110 -0
- package/qui/constants.py +1 -0
- package/qui/exceptions.py +2 -0
- package/qui/j2template.py +71 -0
- package/qui/settings.py +60 -0
- package/qui/templates/manifest.json +25 -0
- package/qui/templates/qui.html +126 -0
- package/qui/templates/service-worker.js +188 -0
- package/qui/web/__init__.py +0 -0
- package/qui/web/tornado.py +220 -0
- package/scripts/postinstall.sh +10 -0
- package/webpack/webpack-adjust-css-urls-loader.js +36 -0
- package/webpack/webpack-common.js +384 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @namespace qui.sections
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import $ from '$qui/lib/jquery.module.js'
|
|
6
|
+
import Logger from '$qui/lib/logger.module.js'
|
|
7
|
+
|
|
8
|
+
import {AssertionError} from '$qui/base/errors.js'
|
|
9
|
+
import {CancelledError} from '$qui/base/errors.js'
|
|
10
|
+
import StockIcon from '$qui/icons/stock-icon.js'
|
|
11
|
+
import * as OptionsBar from '$qui/main-ui/options-bar.js'
|
|
12
|
+
import * as Navigation from '$qui/navigation.js'
|
|
13
|
+
import * as Theme from '$qui/theme.js'
|
|
14
|
+
import * as Window from '$qui/window.js'
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @alias qui.sections.BUTTON_TYPE_MENU_BAR
|
|
19
|
+
*/
|
|
20
|
+
export const BUTTON_TYPE_MENU_BAR = 'menu_bar'
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @alias qui.sections.BUTTON_TYPE_TOP_BAR
|
|
24
|
+
*/
|
|
25
|
+
export const BUTTON_TYPE_TOP_BAR = 'top_bar'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @alias qui.sections.BUTTON_TYPE_NONE
|
|
29
|
+
*/
|
|
30
|
+
export const BUTTON_TYPE_NONE = 'none'
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
const logger = Logger.get('qui.sections')
|
|
34
|
+
|
|
35
|
+
let sectionClasses = []
|
|
36
|
+
let sectionsList = []
|
|
37
|
+
let currentSection = null
|
|
38
|
+
let homeSection = null
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* An error class used to prevent hiding sections.
|
|
43
|
+
* @alias qui.sections.HideCancelled
|
|
44
|
+
* @extends qui.base.errors.CancelledError
|
|
45
|
+
*/
|
|
46
|
+
export class HideCancelled extends CancelledError {
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
function attachSectionEventRelays() {
|
|
51
|
+
Window.screenLayoutChangeSignal.connect(function (smallScreen, landscape) {
|
|
52
|
+
sectionsList.forEach(function (s) {
|
|
53
|
+
s.onScreenLayoutChange(smallScreen, landscape)
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
Window.resizeSignal.connect(function (width, height) {
|
|
58
|
+
sectionsList.forEach(function (s) {
|
|
59
|
+
s.onWindowResize(width, height)
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
Window.activeChangeSignal.connect(function (active) {
|
|
64
|
+
sectionsList.forEach(function (s) {
|
|
65
|
+
s.onWindowActiveChange(active)
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
Window.focusChangeSignal.connect(function (focused) {
|
|
70
|
+
sectionsList.forEach(function (s) {
|
|
71
|
+
s.onWindowFocusedChange(focused)
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
OptionsBar.openCloseSignal.connect(function (opened) {
|
|
76
|
+
if (!currentSection) {
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
currentSection.onOptionsBarOpenClose(opened)
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @private
|
|
86
|
+
* @returns {Promise}
|
|
87
|
+
*/
|
|
88
|
+
function softReload() {
|
|
89
|
+
logger.debug('soft reloading')
|
|
90
|
+
|
|
91
|
+
/* Reset sections */
|
|
92
|
+
if (currentSection) {
|
|
93
|
+
let currentPath = Navigation.getCurrentPath()
|
|
94
|
+
|
|
95
|
+
return reset().then(function () {
|
|
96
|
+
return Navigation.navigate({path: currentPath, historyEntry: false})
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return Promise.resolve()
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Register a section class.
|
|
106
|
+
* @alias qui.sections.register
|
|
107
|
+
* @param {typeof qui.sections.Section} sectionClass the section class (see {@link qui.sections.Section})
|
|
108
|
+
*/
|
|
109
|
+
export function register(sectionClass) {
|
|
110
|
+
let index = sectionClasses.indexOf(sectionClass)
|
|
111
|
+
if (index >= 0) {
|
|
112
|
+
throw new AssertionError('Attempt to register a section class that has already been registered')
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
sectionClasses.push(sectionClass)
|
|
116
|
+
|
|
117
|
+
let section = sectionClass.getInstance()
|
|
118
|
+
section.handleRegister()
|
|
119
|
+
sectionsList.push(section)
|
|
120
|
+
|
|
121
|
+
logger.debug(`registered section "${section.getId()}"`)
|
|
122
|
+
|
|
123
|
+
if (!homeSection) {
|
|
124
|
+
/* Home section is, by default, the first section */
|
|
125
|
+
logger.debug(`home section set to "${section.getId()}"`)
|
|
126
|
+
homeSection = section
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Unregister a section class.
|
|
132
|
+
* @alias qui.sections.unregister
|
|
133
|
+
* @param {typeof qui.sections.Section} sectionClass the section class (see {@link qui.sections.Section})
|
|
134
|
+
*/
|
|
135
|
+
export function unregister(sectionClass) {
|
|
136
|
+
let index = sectionClasses.indexOf(sectionClass)
|
|
137
|
+
if (index < 0) {
|
|
138
|
+
throw new AssertionError('Attempt to unregister a section class that has not been registered')
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
sectionClasses.splice(index, 1)
|
|
142
|
+
|
|
143
|
+
let section = sectionsList[index]
|
|
144
|
+
section.handleUnregister()
|
|
145
|
+
|
|
146
|
+
sectionsList.splice(index, 1)
|
|
147
|
+
logger.debug(`unregistered section "${section.getId()}"`)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Lookup a section by its identifier.
|
|
152
|
+
* @alias qui.sections.get
|
|
153
|
+
* @param {String} id the section identifier
|
|
154
|
+
* @returns {?qui.sections.Section} the section if found, otherwise `null`
|
|
155
|
+
*/
|
|
156
|
+
export function get(id) {
|
|
157
|
+
return sectionsList.find(section => section.getId() === id) || null
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Return the current section.
|
|
162
|
+
* @alias qui.sections.getCurrent
|
|
163
|
+
* @returns {?qui.sections.Section}
|
|
164
|
+
*/
|
|
165
|
+
export function getCurrent() {
|
|
166
|
+
return currentSection
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Return all registered sections, in order.
|
|
171
|
+
* @alias qui.sections.all
|
|
172
|
+
* @returns {qui.sections.Section[]}
|
|
173
|
+
*/
|
|
174
|
+
export function all() {
|
|
175
|
+
return sectionsList.slice()
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Switch to the given section, making it current.
|
|
180
|
+
* @alias qui.sections.switchTo
|
|
181
|
+
* @param {qui.sections.Section} section the section
|
|
182
|
+
* @param {String} [source] optional source to pass to {@link qui.sections.Section#onShow} (defaults to `program`)
|
|
183
|
+
* @param {Boolean} [historyEntry] whether to create a new history entry for current context before switching to the
|
|
184
|
+
* new section, or not (defaults to `false`)
|
|
185
|
+
* @returns {Promise} a promise that resolves as soon as the section is loaded.
|
|
186
|
+
*/
|
|
187
|
+
export function switchTo(section, source, historyEntry = false) {
|
|
188
|
+
/* If requested section is already the current section, do nothing more */
|
|
189
|
+
if ((currentSection === section)) {
|
|
190
|
+
Navigation.updateHistoryEntry()
|
|
191
|
+
return currentSection.whenLoaded()
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return section.whenPreloaded().then(function () {
|
|
195
|
+
let oldSection = currentSection
|
|
196
|
+
let hidePromise = Promise.resolve()
|
|
197
|
+
if (oldSection) {
|
|
198
|
+
hidePromise = oldSection._hide(historyEntry)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return hidePromise.then(function () {
|
|
202
|
+
|
|
203
|
+
let s = section.navigate([])
|
|
204
|
+
if (s !== section) {
|
|
205
|
+
logger.debug(`section "${section.getId()}" redirected to section "${s.getId()}"`)
|
|
206
|
+
return switchTo(s, source)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
currentSection = section
|
|
210
|
+
|
|
211
|
+
if (source === undefined) {
|
|
212
|
+
source = 'program'
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
logger.debug(`switching to section "${section.getId()}" (source: ${source})`)
|
|
216
|
+
|
|
217
|
+
}).then(function () {
|
|
218
|
+
return section._show(source, oldSection)
|
|
219
|
+
}).then(function () {
|
|
220
|
+
Navigation.updateHistoryEntry()
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
})
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Switch to the home section.
|
|
228
|
+
* @alias qui.sections.showHome
|
|
229
|
+
* @param {?Boolean} [reset] if `true` will reset the home section to its initial state, recreating its main page
|
|
230
|
+
* @returns {Promise} a promise that resolves as soon as the home section is loaded.
|
|
231
|
+
*/
|
|
232
|
+
export function showHome(reset) {
|
|
233
|
+
if (!homeSection) {
|
|
234
|
+
throw new AssertionError('No home section')
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
let promise = Promise.resolve()
|
|
238
|
+
if (reset) {
|
|
239
|
+
promise = homeSection.reset()
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return promise.then(function () {
|
|
243
|
+
return switchTo(homeSection, /* source = */ 'home')
|
|
244
|
+
})
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Set the home section.
|
|
249
|
+
* @alias qui.sections.setHome
|
|
250
|
+
* @param {qui.sections.Section} section the new home section
|
|
251
|
+
*/
|
|
252
|
+
export function setHome(section) {
|
|
253
|
+
homeSection = section
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Return the home section.
|
|
258
|
+
* @alias qui.sections.getHome
|
|
259
|
+
* @returns {?qui.sections.Section}
|
|
260
|
+
*/
|
|
261
|
+
export function getHome() {
|
|
262
|
+
return homeSection
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Reset all sections.
|
|
267
|
+
* @returns {Promise} a promise that is settled as soon as all sections have been reset
|
|
268
|
+
*/
|
|
269
|
+
export function reset() {
|
|
270
|
+
return Promise.all(sectionsList.map(s => s.reset()))
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
export function init() {
|
|
275
|
+
attachSectionEventRelays()
|
|
276
|
+
|
|
277
|
+
/* Prevent unwanted section closing when window is closed */
|
|
278
|
+
Window.closeSignal.connect(function () {
|
|
279
|
+
return !sectionsList.some(s => !s.canClose())
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
Window.screenLayoutChangeSignal.connect(function (smallScreen, landscape) {
|
|
283
|
+
/* Automatically update top icon buttons according to small screen state */
|
|
284
|
+
$('div.qui-top-bar > div.qui-top-button.qui-section-button > div.qui-icon').each(function () {
|
|
285
|
+
StockIcon.alterElement($(this), {variant: smallScreen ? 'white' : 'interactive'})
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
logger.debug('soft reloading due to screen layout change')
|
|
289
|
+
softReload()
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
Theme.changeSignal.connect(function (theme) {
|
|
293
|
+
logger.debug('soft reloading due to theme change')
|
|
294
|
+
softReload()
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
/* Export some stuff to global scope */
|
|
298
|
+
let qui = (window.qui = window.qui || {})
|
|
299
|
+
qui.getCurrentSection = getCurrent
|
|
300
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @namespace qui.tables.commoncells
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export {default as IconLabelTableCell} from './icon-label-table-cell.js'
|
|
6
|
+
export {default as PushButtonTableCell} from './push-button-table-cell.js'
|
|
7
|
+
export {default as SimpleTableCell} from './simple-table-cell.js'
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
|
|
2
|
+
import {mix} from '$qui/base/mixwith.js'
|
|
3
|
+
import StockIcon from '$qui/icons/stock-icon.js'
|
|
4
|
+
import * as Lists from '$qui/lists/lists.js'
|
|
5
|
+
import {IconLabelViewMixin} from '$qui/views/common-views/common-views.js'
|
|
6
|
+
|
|
7
|
+
import TableCell from '../table-cell.js'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A table cell made of an icon and a label.
|
|
12
|
+
* @alias qui.tables.commoncells.IconLabelTableCell
|
|
13
|
+
* @extends qui.tables.TableCell
|
|
14
|
+
* @mixes qui.views.commonviews.IconLabelViewMixin
|
|
15
|
+
*/
|
|
16
|
+
class IconLabelTableCell extends mix(TableCell).with(IconLabelViewMixin) {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @constructs
|
|
20
|
+
* @param {...*} args parent class parameters
|
|
21
|
+
*/
|
|
22
|
+
constructor({...args} = {}) {
|
|
23
|
+
super(args)
|
|
24
|
+
|
|
25
|
+
this._selectMode = null
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
makeContent() {
|
|
29
|
+
return this.getIconLabelContainer()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
showValue(value) {
|
|
33
|
+
this.setIcon(value.icon)
|
|
34
|
+
this.setLabel(value.label)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
prepareIcon(icon) {
|
|
38
|
+
if (!(icon instanceof StockIcon)) {
|
|
39
|
+
return icon
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let clickable = (this._selectMode !== Lists.LIST_SELECT_MODE_DISABLED)
|
|
43
|
+
if (clickable) {
|
|
44
|
+
return icon.alterDefault({
|
|
45
|
+
variant: 'interactive',
|
|
46
|
+
activeVariant: 'interactive',
|
|
47
|
+
selectedVariant: 'background'
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return super.prepareIcon(icon)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
setSelectMode(selectMode) {
|
|
56
|
+
/* Override setSelectMode to simply know what select mode the list has and to adjust the icon accordingly */
|
|
57
|
+
this._selectMode = selectMode
|
|
58
|
+
this.updateIcon()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
setSelected(selected) {
|
|
62
|
+
this.getIconLabelContainer().toggleClass('selected', selected)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
export default IconLabelTableCell
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
|
|
2
|
+
import $ from '$qui/lib/jquery.module.js'
|
|
3
|
+
|
|
4
|
+
import TableCell from '../table-cell.js'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A table cell with a push button.
|
|
9
|
+
* @alias qui.tables.commoncells.PushButtonTableCell
|
|
10
|
+
* @extends qui.tables.TableCell
|
|
11
|
+
*/
|
|
12
|
+
class PushButtonTableCell extends TableCell {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @constructs
|
|
16
|
+
* @param {String} caption the button caption
|
|
17
|
+
* @param {Function} [onClick] function to be executed when the button is pushed (see
|
|
18
|
+
* {@link qui.tables.commoncells.PushButtonTableCell#onClick})
|
|
19
|
+
* @param {String} caption button caption
|
|
20
|
+
* @param {String} [style] button style:
|
|
21
|
+
* * `"foreground"`
|
|
22
|
+
* * `"interactive"` (default)
|
|
23
|
+
* * `"highlight"`
|
|
24
|
+
* * `"danger"`,
|
|
25
|
+
* * `"colored"`
|
|
26
|
+
* @param {String} [backgroundColor] custom background color (ignored unless `style` is `"colored"`)
|
|
27
|
+
* @param {String} [backgroundActiveColor] custom background active color (ignored unless `style` is `"colored"`)
|
|
28
|
+
* @param {String} [foregroundColor] custom foreground color (ignored unless `style` is `"colored"`)
|
|
29
|
+
* @param {qui.icons.Icon} [icon] an optional button icon
|
|
30
|
+
* @param {...*} args parent class parameters
|
|
31
|
+
*/
|
|
32
|
+
constructor({
|
|
33
|
+
caption,
|
|
34
|
+
onClick = null,
|
|
35
|
+
style = 'interactive',
|
|
36
|
+
backgroundColor = '@interactive-color',
|
|
37
|
+
backgroundActiveColor = '@interactive-active-color',
|
|
38
|
+
foregroundColor = '@foreground-interactive-color',
|
|
39
|
+
icon = null,
|
|
40
|
+
...args
|
|
41
|
+
}) {
|
|
42
|
+
super({...args})
|
|
43
|
+
|
|
44
|
+
this._pushButtonParams = {
|
|
45
|
+
caption,
|
|
46
|
+
style,
|
|
47
|
+
backgroundColor,
|
|
48
|
+
backgroundActiveColor,
|
|
49
|
+
foregroundColor,
|
|
50
|
+
icon
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (onClick) {
|
|
54
|
+
this.onClick = onClick
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this._buttonDiv = null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
makeContent() {
|
|
61
|
+
this._buttonDiv = $('<div></div>', {class: 'qui-push-button-table-cell'}).pushbutton(this._pushButtonParams)
|
|
62
|
+
this._buttonDiv.on('click', () => this.onClick())
|
|
63
|
+
|
|
64
|
+
return this._buttonDiv
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
showValue(value) {
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Update button style.
|
|
72
|
+
* @param {String} style
|
|
73
|
+
*/
|
|
74
|
+
setStyle(style) {
|
|
75
|
+
this._widgetCall({style: style})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Update button caption.
|
|
80
|
+
* @param {String} caption
|
|
81
|
+
*/
|
|
82
|
+
setCaption(caption) {
|
|
83
|
+
this._widgetCall({caption: caption})
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Update background color.
|
|
88
|
+
* @param {String} color
|
|
89
|
+
*/
|
|
90
|
+
setBackgroundColor(color) {
|
|
91
|
+
this._widgetCall({backgroundColor: color})
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Update background active color.
|
|
96
|
+
* @param {String} color
|
|
97
|
+
*/
|
|
98
|
+
setBackgroundActiveColor(color) {
|
|
99
|
+
this._widgetCall({backgroundActiveColor: color})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Update foreground color.
|
|
104
|
+
* @param {String} color
|
|
105
|
+
*/
|
|
106
|
+
setForegroundColor(color) {
|
|
107
|
+
this._widgetCall({foregroundColor: color})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Update button icon.
|
|
112
|
+
* @param {?qui.icons.Icon} icon
|
|
113
|
+
*/
|
|
114
|
+
setIcon(icon) {
|
|
115
|
+
this._widgetCall({icon: icon})
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Set button enabled state.
|
|
120
|
+
* @param {Boolean} enabled
|
|
121
|
+
*/
|
|
122
|
+
setEnabled(enabled) {
|
|
123
|
+
this._widgetCall({disabled: !enabled})
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
_widgetCall(params) {
|
|
127
|
+
return this._buttonDiv.pushbutton(params)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
export default PushButtonTableCell
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import $ from '$qui/lib/jquery.module.js'
|
|
3
|
+
|
|
4
|
+
import TableCell from '../table-cell.js'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A simple, textual table cell.
|
|
9
|
+
* @alias qui.tables.commoncells.SimpleTableCell
|
|
10
|
+
* @extends qui.tables.TableCell
|
|
11
|
+
*/
|
|
12
|
+
class SimpleTableCell extends TableCell {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @constructs
|
|
16
|
+
* @param {...*} args parent class parameters
|
|
17
|
+
*/
|
|
18
|
+
constructor({...args} = {}) {
|
|
19
|
+
super(args)
|
|
20
|
+
|
|
21
|
+
this._element = null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
makeContent() {
|
|
25
|
+
this._element = $('<span></span>', {class: 'qui-simple-table-cell-element'})
|
|
26
|
+
|
|
27
|
+
return this._element
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
showValue(value) {
|
|
31
|
+
this._element.html(value)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
export default SimpleTableCell
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
import {mix} from '$qui/base/mixwith.js'
|
|
3
|
+
import StockIcon from '$qui/icons/stock-icon.js'
|
|
4
|
+
import PageMixin from '$qui/pages/page.js'
|
|
5
|
+
import * as ObjectUtils from '$qui/utils/object.js'
|
|
6
|
+
|
|
7
|
+
import Table from '../table.js'
|
|
8
|
+
|
|
9
|
+
// TODO: PageTable shares a lot of code with PageList; common code could be generalized into a mixin;
|
|
10
|
+
// Maybe it could also be applied to PageForm.
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A table that can be used as a page.
|
|
14
|
+
* @alias qui.tables.commontables.PageTable
|
|
15
|
+
* @extends qui.tables.Table
|
|
16
|
+
* @mixes qui.pages.PageMixin
|
|
17
|
+
*/
|
|
18
|
+
class PageTable extends mix(Table).with(PageMixin) {
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @constructs
|
|
22
|
+
* @param {...*} args parent class parameters
|
|
23
|
+
*/
|
|
24
|
+
constructor({...args} = {}) {
|
|
25
|
+
ObjectUtils.setDefault(args, 'transparent', false)
|
|
26
|
+
ObjectUtils.setDefault(args, 'topless', true)
|
|
27
|
+
|
|
28
|
+
super(args)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
prepareIcon(icon) {
|
|
32
|
+
/* Popup page views should normally have the default foreground icon color, even on small screens */
|
|
33
|
+
if (this.isPopup() && (icon instanceof StockIcon)) {
|
|
34
|
+
icon = icon.alterDefault({variant: 'foreground'})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return super.prepareIcon(icon)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
handleVertScroll() {
|
|
41
|
+
super.handleVertScroll()
|
|
42
|
+
this._updateVertScroll()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
_updateVertScroll() {
|
|
46
|
+
let params = this.getVertScrollParams()
|
|
47
|
+
|
|
48
|
+
/* Place progress widget in the viewport by pushing it down a bit */
|
|
49
|
+
this.getProgressWidget().css('margin-top', `${params.offset}px`)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
export default PageTable
|