@iebh/tera-fy 1.13.0 → 1.13.1
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/CHANGELOG.md +2 -0
- package/api.md +10 -5
- package/lib/terafy.client.js +11 -5
- package/lib/terafy.server.js +46 -17
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/api.md
CHANGED
|
@@ -997,11 +997,13 @@ Display simple text within TERA
|
|
|
997
997
|
|
|
998
998
|
### Parameters
|
|
999
999
|
|
|
1000
|
-
* `text` **[String][150]
|
|
1000
|
+
* `text` **[String][150]?** Text to display, if specified this populates `options.body`
|
|
1001
1001
|
* `options` **[Object][151]?** Additional options to mutate behaviour
|
|
1002
1002
|
|
|
1003
|
-
* `options.
|
|
1003
|
+
* `options.body` **[String][150]** The body text to display (optional, default `"Alert!"`)
|
|
1004
1004
|
* `options.isHtml` **[Boolean][159]** If falsy the text is rendered as plain-text otherwise it will be assumed as HTML content (optional, default `false`)
|
|
1005
|
+
* `options.title` **[String][150]** The title of the alert box (optional, default `'TERA'`)
|
|
1006
|
+
* `options.buttons` **(`"ok"` | `false`)** Button set to use or falsy to disable (optional, default `'ok'`)
|
|
1005
1007
|
|
|
1006
1008
|
Returns **[Promise][157]** A promise which resolves when the alert has been dismissed
|
|
1007
1009
|
|
|
@@ -1011,11 +1013,12 @@ Present a simple ok/cancel dialog to the user
|
|
|
1011
1013
|
|
|
1012
1014
|
### Parameters
|
|
1013
1015
|
|
|
1014
|
-
* `text` **[String][150]
|
|
1016
|
+
* `text` **[String][150]?** Text to display, if specified this populates `options.body`
|
|
1015
1017
|
* `options` **[Object][151]?** Additional options to mutate behaviour
|
|
1016
1018
|
|
|
1017
|
-
* `options.
|
|
1019
|
+
* `options.body` **[String][150]** The body text to display (optional, default `"Confirm?"`)
|
|
1018
1020
|
* `options.isHtml` **[Boolean][159]** If falsy the text is rendered as plain-text otherwise it will be assumed as HTML content (optional, default `false`)
|
|
1021
|
+
* `options.title` **[String][150]** The title of the confirmation box (optional, default `'TERA'`)
|
|
1019
1022
|
|
|
1020
1023
|
Returns **[Promise][157]** A promise which resolves with `Promise.resolve('OK')` or rejects with `Promise.reject('CANCEL')`
|
|
1021
1024
|
|
|
@@ -1044,13 +1047,15 @@ Prompt the user for an input, responding with a Promisable value
|
|
|
1044
1047
|
|
|
1045
1048
|
### Parameters
|
|
1046
1049
|
|
|
1050
|
+
* `text` **[String][150]?** Text to display, if specified this populates `options.body`
|
|
1047
1051
|
* `options` **[Object][151]?** Additional options to mutate behaviour
|
|
1048
1052
|
|
|
1053
|
+
* `options.body` **[String][150]?** Optional additional body text
|
|
1049
1054
|
* `options.value` **[String][150]?** Current or default value to display pre-filled
|
|
1050
1055
|
* `options.title` **[String][150]** The dialog title to display (optional, default `'Input required'`)
|
|
1051
|
-
* `options.body` **[String][150]?** Optional additional body text
|
|
1052
1056
|
* `options.bodyHtml` **[Boolean][159]** If truthy, treat the body as HTML (optional, default `false`)
|
|
1053
1057
|
* `options.placeholder` **[String][150]?** Optional placeholder text
|
|
1058
|
+
* `options.required` **[Boolean][159]** Treat nullish or empty inputs as a cancel operation (optional, default `true`)
|
|
1054
1059
|
|
|
1055
1060
|
Returns **[Promise][157]\<any>** Either the eventual user value or a throw with `Promise.reject('CANCEL')`
|
|
1056
1061
|
|
package/lib/terafy.client.js
CHANGED
|
@@ -1297,11 +1297,13 @@ export default class TeraFy {
|
|
|
1297
1297
|
* Display simple text within TERA
|
|
1298
1298
|
*
|
|
1299
1299
|
* @function uiAlert
|
|
1300
|
-
* @param {String} text
|
|
1300
|
+
* @param {String} [text] Text to display, if specified this populates `options.body`
|
|
1301
1301
|
*
|
|
1302
1302
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
1303
|
-
* @param {String} [options.
|
|
1303
|
+
* @param {String} [options.body="Alert!"] The body text to display
|
|
1304
1304
|
* @param {Boolean} [options.isHtml=false] If falsy the text is rendered as plain-text otherwise it will be assumed as HTML content
|
|
1305
|
+
* @param {String} [options.title='TERA'] The title of the alert box
|
|
1306
|
+
* @param {'ok'|false} [options.buttons='ok'] Button set to use or falsy to disable
|
|
1305
1307
|
*
|
|
1306
1308
|
* @returns {Promise} A promise which resolves when the alert has been dismissed
|
|
1307
1309
|
*/
|
|
@@ -1311,11 +1313,12 @@ export default class TeraFy {
|
|
|
1311
1313
|
* Present a simple ok/cancel dialog to the user
|
|
1312
1314
|
*
|
|
1313
1315
|
* @function uiConfirm
|
|
1314
|
-
* @param {String} text
|
|
1316
|
+
* @param {String} [text] Text to display, if specified this populates `options.body`
|
|
1315
1317
|
*
|
|
1316
1318
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
1317
|
-
* @param {String} [options.
|
|
1319
|
+
* @param {String} [options.body="Confirm?"] The body text to display
|
|
1318
1320
|
* @param {Boolean} [options.isHtml=false] If falsy the text is rendered as plain-text otherwise it will be assumed as HTML content
|
|
1321
|
+
* @param {String} [options.title='TERA'] The title of the confirmation box
|
|
1319
1322
|
*
|
|
1320
1323
|
* @returns {Promise} A promise which resolves with `Promise.resolve('OK')` or rejects with `Promise.reject('CANCEL')`
|
|
1321
1324
|
*/
|
|
@@ -1343,12 +1346,15 @@ export default class TeraFy {
|
|
|
1343
1346
|
* Prompt the user for an input, responding with a Promisable value
|
|
1344
1347
|
*
|
|
1345
1348
|
* @function uiPrompt
|
|
1349
|
+
* @param {String} [text] Text to display, if specified this populates `options.body`
|
|
1350
|
+
*
|
|
1346
1351
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
1352
|
+
* @param {String} [options.body] Optional additional body text
|
|
1347
1353
|
* @param {String} [options.value] Current or default value to display pre-filled
|
|
1348
1354
|
* @param {String} [options.title='Input required'] The dialog title to display
|
|
1349
|
-
* @param {String} [options.body] Optional additional body text
|
|
1350
1355
|
* @param {Boolean} [options.bodyHtml=false] If truthy, treat the body as HTML
|
|
1351
1356
|
* @param {String} [options.placeholder] Optional placeholder text
|
|
1357
|
+
* @param {Boolean} [options.required=true] Treat nullish or empty inputs as a cancel operation
|
|
1352
1358
|
*
|
|
1353
1359
|
* @returns {Promise<*>} Either the eventual user value or a throw with `Promise.reject('CANCEL')`
|
|
1354
1360
|
*/
|
package/lib/terafy.server.js
CHANGED
|
@@ -1431,27 +1431,33 @@ export default class TeraFyServer {
|
|
|
1431
1431
|
/**
|
|
1432
1432
|
* Display simple text within TERA
|
|
1433
1433
|
*
|
|
1434
|
-
* @param {String} text
|
|
1434
|
+
* @param {String} [text] Text to display, if specified this populates `options.body`
|
|
1435
1435
|
*
|
|
1436
1436
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
1437
|
-
* @param {String} [options.
|
|
1437
|
+
* @param {String} [options.body="Alert!"] The body text to display
|
|
1438
1438
|
* @param {Boolean} [options.isHtml=false] If falsy the text is rendered as plain-text otherwise it will be assumed as HTML content
|
|
1439
|
+
* @param {String} [options.title='TERA'] The title of the alert box
|
|
1439
1440
|
* @param {'ok'|false} [options.buttons='ok'] Button set to use or falsy to disable
|
|
1440
1441
|
*
|
|
1441
1442
|
* @returns {Promise} A promise which resolves when the alert has been dismissed
|
|
1442
1443
|
*/
|
|
1443
1444
|
uiAlert(text, options) {
|
|
1444
1445
|
let settings = {
|
|
1445
|
-
|
|
1446
|
+
body: 'Alert!',
|
|
1446
1447
|
isHtml: false,
|
|
1448
|
+
title: 'TERA',
|
|
1447
1449
|
buttons: 'ok',
|
|
1448
|
-
...
|
|
1450
|
+
...(
|
|
1451
|
+
typeof text == 'string' ? {body: text, ...options}
|
|
1452
|
+
: typeof text == 'object' ? text
|
|
1453
|
+
: options
|
|
1454
|
+
),
|
|
1449
1455
|
};
|
|
1450
1456
|
|
|
1451
1457
|
return this.requestFocus(()=>
|
|
1452
1458
|
app.service('$prompt').dialog({
|
|
1453
1459
|
title: settings.title,
|
|
1454
|
-
body:
|
|
1460
|
+
body: settings.body,
|
|
1455
1461
|
buttons:
|
|
1456
1462
|
settings.buttons == 'ok' ? ['ok']
|
|
1457
1463
|
: false,
|
|
@@ -1465,19 +1471,25 @@ export default class TeraFyServer {
|
|
|
1465
1471
|
/**
|
|
1466
1472
|
* Present a simple ok/cancel dialog to the user
|
|
1467
1473
|
*
|
|
1468
|
-
* @param {String} text
|
|
1474
|
+
* @param {String} [text] Text to display, if specified this populates `options.body`
|
|
1469
1475
|
*
|
|
1470
1476
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
1471
|
-
* @param {String} [options.
|
|
1477
|
+
* @param {String} [options.body="Confirm?"] The body text to display
|
|
1472
1478
|
* @param {Boolean} [options.isHtml=false] If falsy the text is rendered as plain-text otherwise it will be assumed as HTML content
|
|
1479
|
+
* @param {String} [options.title='TERA'] The title of the confirmation box
|
|
1473
1480
|
*
|
|
1474
1481
|
* @returns {Promise} A promise which resolves with `Promise.resolve('OK')` or rejects with `Promise.reject('CANCEL')`
|
|
1475
1482
|
*/
|
|
1476
1483
|
uiConfirm(text, options) {
|
|
1477
1484
|
let settings = {
|
|
1478
|
-
|
|
1485
|
+
body: 'Confirm?',
|
|
1479
1486
|
isHtml: false,
|
|
1480
|
-
|
|
1487
|
+
title: 'TERA',
|
|
1488
|
+
...(
|
|
1489
|
+
typeof text == 'string' ? {body: text, ...options}
|
|
1490
|
+
: typeof text == 'object' ? text
|
|
1491
|
+
: options
|
|
1492
|
+
),
|
|
1481
1493
|
};
|
|
1482
1494
|
|
|
1483
1495
|
return this.requestFocus(()=>
|
|
@@ -1509,9 +1521,9 @@ export default class TeraFyServer {
|
|
|
1509
1521
|
* All options are cumulative - i.e. they are merged with other options previously provided
|
|
1510
1522
|
*
|
|
1511
1523
|
* @param {Object|Boolean} [options] Additional options to mutate behaviour, if boolean false `{close: true}` is assumed
|
|
1512
|
-
* @param {String} [options.title='TERA'] Window title, can only be set on the initial call
|
|
1513
1524
|
* @param {String} [options.body=''] Window body text
|
|
1514
1525
|
* @param {Boolean} [options.bodyHtml=false] If truthy, treat the body as HTML
|
|
1526
|
+
* @param {String} [options.title='TERA'] Window title, can only be set on the initial call
|
|
1515
1527
|
* @param {Boolean} [options.close=false] Close the existing dialog, if true the dialog is disposed and options reset
|
|
1516
1528
|
* @param {Number} [options.progress] The current progress of the task being conducted, this is assumed to be a value less than `progressMax`
|
|
1517
1529
|
* @param {Number} [options.progressMax] The maximum value that the progress can be
|
|
@@ -1523,9 +1535,9 @@ export default class TeraFyServer {
|
|
|
1523
1535
|
|
|
1524
1536
|
if (this.uiProgressOptions === null) { // New uiProgress window
|
|
1525
1537
|
this.uiProgressOptions = reactive({
|
|
1526
|
-
title: 'TERA',
|
|
1527
1538
|
body: '',
|
|
1528
1539
|
bodyHtml: false,
|
|
1540
|
+
title: 'TERA',
|
|
1529
1541
|
close: false,
|
|
1530
1542
|
progress: 0,
|
|
1531
1543
|
progressMax: 0,
|
|
@@ -1562,23 +1574,31 @@ export default class TeraFyServer {
|
|
|
1562
1574
|
/**
|
|
1563
1575
|
* Prompt the user for an input, responding with a Promisable value
|
|
1564
1576
|
*
|
|
1577
|
+
* @param {String} [text] Text to display, if specified this populates `options.body`
|
|
1578
|
+
*
|
|
1565
1579
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
1580
|
+
* @param {String} [options.body] Optional additional body text
|
|
1566
1581
|
* @param {String} [options.value] Current or default value to display pre-filled
|
|
1567
1582
|
* @param {String} [options.title='Input required'] The dialog title to display
|
|
1568
|
-
* @param {String} [options.body] Optional additional body text
|
|
1569
1583
|
* @param {Boolean} [options.bodyHtml=false] If truthy, treat the body as HTML
|
|
1570
1584
|
* @param {String} [options.placeholder] Optional placeholder text
|
|
1585
|
+
* @param {Boolean} [options.required=true] Treat nullish or empty inputs as a cancel operation
|
|
1571
1586
|
*
|
|
1572
1587
|
* @returns {Promise<*>} Either the eventual user value or a throw with `Promise.reject('CANCEL')`
|
|
1573
1588
|
*/
|
|
1574
|
-
uiPrompt(options) {
|
|
1589
|
+
uiPrompt(text, options) {
|
|
1575
1590
|
let settings = {
|
|
1576
|
-
title: 'Input required',
|
|
1577
|
-
value: '',
|
|
1578
1591
|
body: '',
|
|
1579
1592
|
bodyHtml: false,
|
|
1593
|
+
title: 'Input required',
|
|
1594
|
+
value: '',
|
|
1580
1595
|
placeholder: '',
|
|
1581
|
-
|
|
1596
|
+
required: true,
|
|
1597
|
+
...(
|
|
1598
|
+
typeof text == 'string' ? {body: text, ...options}
|
|
1599
|
+
: typeof text == 'object' ? text
|
|
1600
|
+
: options
|
|
1601
|
+
),
|
|
1582
1602
|
};
|
|
1583
1603
|
|
|
1584
1604
|
return this.requestFocus(()=>
|
|
@@ -1595,7 +1615,16 @@ export default class TeraFyServer {
|
|
|
1595
1615
|
buttons: ['ok', 'cancel'],
|
|
1596
1616
|
})
|
|
1597
1617
|
)
|
|
1598
|
-
.then(answer =>
|
|
1618
|
+
.then(answer => {
|
|
1619
|
+
if (answer) {
|
|
1620
|
+
return answer;
|
|
1621
|
+
} else if (settings.required) {
|
|
1622
|
+
return Promise.reject('CANCEL');
|
|
1623
|
+
} else {
|
|
1624
|
+
return answer;
|
|
1625
|
+
}
|
|
1626
|
+
})
|
|
1627
|
+
.catch(()=> Promise.reject('CANCEL'))
|
|
1599
1628
|
}
|
|
1600
1629
|
|
|
1601
1630
|
|
package/package.json
CHANGED