@blackbaud/sky-addin-client
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -90,3 +90,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
__export(__webpack_require__(2)); | ||
__export(__webpack_require__(7)); | ||
__export(__webpack_require__(8)); | ||
@@ -304,2 +304,31 @@ | ||
/** | ||
* Requests the host page to show a confirm dialog. | ||
* @param args Arguments for showing a confirm dialog. | ||
* @returns {Promise<string>} Returns a promise that will resolve with the | ||
* confirm action when the dialog is closed. | ||
*/ | ||
AddinClient.prototype.showConfirm = function (args) { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.confirmRequest = { | ||
reject: reject, | ||
resolve: resolve | ||
}; | ||
_this.postMessageToHostPage({ | ||
message: args, | ||
messageType: 'show-confirm' | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Informs the host to show an error dialog. | ||
* @param args Arguments for showing an error dialog. | ||
*/ | ||
AddinClient.prototype.showError = function (args) { | ||
this.postMessageToHostPage({ | ||
message: args, | ||
messageType: 'show-error' | ||
}); | ||
}; | ||
/** | ||
* Post a message to the host page informing it that the add-in is | ||
@@ -398,2 +427,8 @@ * now started and listening for messages from the host. | ||
break; | ||
case 'confirm-closed': | ||
if (this.confirmRequest) { | ||
this.confirmRequest.resolve(data.message.reason); | ||
this.confirmRequest = undefined; | ||
} | ||
break; | ||
case 'flyout-closed': | ||
@@ -558,2 +593,24 @@ if (this.flyoutRequest) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* Defines the style of a confirm dialog button. | ||
*/ | ||
var AddinConfirmButtonStyle; | ||
(function (AddinConfirmButtonStyle) { | ||
// The button represents a "secondary" action (default) | ||
AddinConfirmButtonStyle[AddinConfirmButtonStyle["Default"] = 0] = "Default"; | ||
// The button represents a "primary" action | ||
AddinConfirmButtonStyle[AddinConfirmButtonStyle["Primary"] = 1] = "Primary"; | ||
// The button represents a "link" action, often used | ||
// to trigger an action to cancel/close a confirm dialog | ||
AddinConfirmButtonStyle[AddinConfirmButtonStyle["Link"] = 2] = "Link"; | ||
})(AddinConfirmButtonStyle = exports.AddinConfirmButtonStyle || (exports.AddinConfirmButtonStyle = {})); | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* | ||
@@ -572,3 +629,3 @@ * Defines the style of the tab summary | ||
/***/ }), | ||
/* 5 */ | ||
/* 6 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -594,3 +651,3 @@ | ||
/***/ }), | ||
/* 6 */ | ||
/* 7 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -618,3 +675,3 @@ | ||
/***/ }), | ||
/* 7 */ | ||
/* 8 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -632,2 +689,3 @@ | ||
__export(__webpack_require__(6)); | ||
__export(__webpack_require__(7)); | ||
@@ -634,0 +692,0 @@ |
@@ -1,1 +0,1 @@ | ||
(function e(t,s){if(typeof exports==="object"&&typeof module==="object")module.exports=s();else if(typeof define==="function"&&define.amd)define([],s);else if(typeof exports==="object")exports["BBSkyAddinClient"]=s();else t["BBSkyAddinClient"]=s()})(this,function(){return function(e){var t={};function s(o){if(t[o]){return t[o].exports}var n=t[o]={i:o,l:false,exports:{}};e[o].call(n.exports,n,n.exports,s);n.l=true;return n.exports}s.m=e;s.c=t;s.i=function(e){return e};s.d=function(e,t,o){if(!s.o(e,t)){Object.defineProperty(e,t,{configurable:false,enumerable:true,get:o})}};s.n=function(e){var t=e&&e.__esModule?function t(){return e["default"]}:function t(){return e};s.d(t,"a",t);return t};s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};s.p="";return s(s.s=1)}([function(e,t,s){"use strict";function o(e){for(var s in e)if(!t.hasOwnProperty(s))t[s]=e[s]}Object.defineProperty(t,"__esModule",{value:true});o(s(2));o(s(7))},function(e,t,s){"use strict";function o(e){for(var s in e)if(!t.hasOwnProperty(s))t[s]=e[s]}Object.defineProperty(t,"__esModule",{value:true});o(s(0))},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:true});var o=[/^https\:\/\/[\w\-\.]+\.blackbaud\.com$/,/^https\:\/\/[\w\-\.]+\.blackbaud\-dev\.com$/,/^http\:\/\/[\w\-\.]+\.blackbaud\-dev\.com$/,/^https\:\/\/[\w\-\.]+\.blackbaudhosting\.com$/,/^https\:\/\/[\w\-\.]+\.bbcloudservices\.com$/,/^https\:\/\/localhost\:[0-9]+$/];var n=function(){function e(e){var t=this;this.args=e;this.authTokenRequests=[];this.lastAuthTokenRequestId=0;this.modalRequests=[];this.lastModalRequestId=0;this.windowMessageHandler=function(e){t.handleMessage(e)};window.addEventListener("message",this.windowMessageHandler);this.raiseAddinReadyMessage()}e.getQueryString=function(){return window.location.search};e.prototype.destroy=function(){window.removeEventListener("message",this.windowMessageHandler);if(this.heightChangeIntervalId){clearInterval(this.heightChangeIntervalId)}};e.prototype.navigate=function(e){this.postMessageToHostPage({message:{url:e.url},messageType:"navigate"})};e.prototype.getAuthToken=function(){return this.getUserIdentityToken()};e.prototype.getUserIdentityToken=function(){var e=this;return new Promise(function(t,s){var o=++e.lastAuthTokenRequestId;e.authTokenRequests[o]={reject:s,resolve:t};e.postMessageToHostPage({message:{authTokenRequestId:o},messageType:"get-auth-token"})})};e.prototype.showModal=function(e){var t=this;return{modalClosed:new Promise(function(s,o){var n=++t.lastModalRequestId;t.modalRequests[n]={reject:o,resolve:s};t.postMessageToHostPage({message:{args:e,modalRequestId:n},messageType:"show-modal"})})}};e.prototype.closeModal=function(e){this.postMessageToHostPage({message:e,messageType:"close-modal"})};e.prototype.openHelp=function(e){this.postMessageToHostPage({message:{helpKey:e.helpKey},messageType:"open-help"})};e.prototype.showToast=function(e){this.postMessageToHostPage({message:e,messageType:"show-toast"})};e.prototype.showFlyout=function(e){var t=this;return{flyoutClosed:new Promise(function(s,o){e.defaultWidth=e.defaultWidth||500;e.maxWidth=e.maxWidth||e.defaultWidth;e.minWidth=e.minWidth||320;t.flyoutRequest={reject:o,resolve:s};t.postMessageToHostPage({message:e,messageType:"show-flyout"})})}};e.prototype.closeFlyout=function(){this.postMessageToHostPage({messageType:"close-flyout"})};e.prototype.raiseAddinReadyMessage=function(){this.postMessageToHostPage({messageType:"ready"},"*")};e.prototype.handleModalClosedMessage=function(e){var t=this.modalRequests;var s=e.modalRequestId;var o=t[s];o.resolve(e.context);t[s]=undefined};e.prototype.handleAuthTokenMessage=function(e){var t=this.authTokenRequests;var s=e.message.authTokenRequestId;var o=t[s];switch(e.messageType){case"auth-token":var n=e.message.authToken;o.resolve(n);break;case"auth-token-fail":o.reject(e.message.reason);break}t[s]=undefined};e.prototype.handleMessage=function(e){var t=this;var s=e.data;if(s&&s.source==="bb-addin-host"){if(s.messageType==="host-ready"){this.setKnownAllowedHostOrigin(e.origin);this.trackHeightChangesOfAddinContent();this.args.callbacks.init({context:s.message.context,envId:s.message.envId,ready:function(e){t.checkForHeightChangesOfAddinContent();t.postMessageToHostPage({message:e,messageType:"addin-ready"})}})}else if(this.isFromValidOrigin(e)){switch(s.messageType){case"auth-token":case"auth-token-fail":this.handleAuthTokenMessage(s);break;case"modal-closed":this.handleModalClosedMessage(s.message);break;case"button-click":if(this.args.callbacks.buttonClick){this.args.callbacks.buttonClick()}break;case"flyout-closed":if(this.flyoutRequest){this.flyoutRequest.resolve();this.flyoutRequest=undefined}break;case"flyout-next-click":if(this.args.callbacks.flyoutNextClick){this.args.callbacks.flyoutNextClick()}break;case"flyout-previous-click":if(this.args.callbacks.flyoutPreviousClick){this.args.callbacks.flyoutPreviousClick()}break;case"help-click":if(this.args.callbacks.helpClick){this.args.callbacks.helpClick()}break;case"settings-click":if(this.args.callbacks.settingsClick){this.args.callbacks.settingsClick()}break}}else{this.warnInvalidOrigin()}}};e.prototype.setKnownAllowedHostOrigin=function(e){for(var t=0,s=o;t<s.length;t++){var n=s[t];if(n.test(e)){this.trustedOrigin=e;return}}};e.prototype.checkForHeightChangesOfAddinContent=function(){var e=document.documentElement.offsetHeight;if(e!==this.lastPostedIframeHeight){this.lastPostedIframeHeight=e;this.postMessageToHostPage({message:{height:e+"px"},messageType:"height-change"})}};e.prototype.trackHeightChangesOfAddinContent=function(){var e=this;this.heightChangeIntervalId=setInterval(function(){e.checkForHeightChangesOfAddinContent()},1e3)};e.prototype.postMessageToHostPage=function(e,t){e.source="bb-addin-client";e.addinId=this.getQueryVariable("addinId");t=t||this.trustedOrigin;if(t){window.parent.postMessage(e,t)}else{this.warnInvalidOrigin()}};e.prototype.isFromValidOrigin=function(e){return e.origin===this.trustedOrigin};e.prototype.warnInvalidOrigin=function(){console.warn("The origin is not trusted because the host-ready message has not been "+"sent or because the host origin is not a whitelisted origin.")};e.prototype.getQueryVariable=function(t){var s=e.getQueryString().substring(1);var o=s.split("&");for(var n=0,i=o;n<i.length;n++){var a=i[n];var r=a.split("=");if(decodeURIComponent(r[0])===t){return decodeURIComponent(r[1])}}};return e}();t.AddinClient=n},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:true});var o;(function(e){e[e["None"]=0]="None";e[e["Add"]=1]="Add";e[e["Edit"]=2]="Edit";e[e["Delete"]=3]="Delete"})(o=t.AddinButtonStyle||(t.AddinButtonStyle={}))},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:true});var o;(function(e){e[e["None"]=0]="None";e[e["Text"]=1]="Text"})(o=t.AddinTabSummaryStyle||(t.AddinTabSummaryStyle={}))},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:true});var o;(function(e){e[e["None"]=0]="None";e[e["Text"]=1]="Text";e[e["Check"]=2]="Check"})(o=t.AddinTileSummaryStyle||(t.AddinTileSummaryStyle={}))},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:true});var o;(function(e){e[e["Danger"]=0]="Danger";e[e["Info"]=1]="Info";e[e["Success"]=2]="Success";e[e["Warning"]=3]="Warning"})(o=t.AddinToastStyle||(t.AddinToastStyle={}))},function(e,t,s){"use strict";function o(e){for(var s in e)if(!t.hasOwnProperty(s))t[s]=e[s]}Object.defineProperty(t,"__esModule",{value:true});o(s(3));o(s(4));o(s(5));o(s(6))}])}); | ||
(function e(t,s){if(typeof exports==="object"&&typeof module==="object")module.exports=s();else if(typeof define==="function"&&define.amd)define([],s);else if(typeof exports==="object")exports["BBSkyAddinClient"]=s();else t["BBSkyAddinClient"]=s()})(this,function(){return function(e){var t={};function s(o){if(t[o]){return t[o].exports}var n=t[o]={i:o,l:false,exports:{}};e[o].call(n.exports,n,n.exports,s);n.l=true;return n.exports}s.m=e;s.c=t;s.i=function(e){return e};s.d=function(e,t,o){if(!s.o(e,t)){Object.defineProperty(e,t,{configurable:false,enumerable:true,get:o})}};s.n=function(e){var t=e&&e.__esModule?function t(){return e["default"]}:function t(){return e};s.d(t,"a",t);return t};s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};s.p="";return s(s.s=1)}([function(e,t,s){"use strict";function o(e){for(var s in e)if(!t.hasOwnProperty(s))t[s]=e[s]}Object.defineProperty(t,"__esModule",{value:true});o(s(2));o(s(8))},function(e,t,s){"use strict";function o(e){for(var s in e)if(!t.hasOwnProperty(s))t[s]=e[s]}Object.defineProperty(t,"__esModule",{value:true});o(s(0))},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:true});var o=[/^https\:\/\/[\w\-\.]+\.blackbaud\.com$/,/^https\:\/\/[\w\-\.]+\.blackbaud\-dev\.com$/,/^http\:\/\/[\w\-\.]+\.blackbaud\-dev\.com$/,/^https\:\/\/[\w\-\.]+\.blackbaudhosting\.com$/,/^https\:\/\/[\w\-\.]+\.bbcloudservices\.com$/,/^https\:\/\/localhost\:[0-9]+$/];var n=function(){function e(e){var t=this;this.args=e;this.authTokenRequests=[];this.lastAuthTokenRequestId=0;this.modalRequests=[];this.lastModalRequestId=0;this.windowMessageHandler=function(e){t.handleMessage(e)};window.addEventListener("message",this.windowMessageHandler);this.raiseAddinReadyMessage()}e.getQueryString=function(){return window.location.search};e.prototype.destroy=function(){window.removeEventListener("message",this.windowMessageHandler);if(this.heightChangeIntervalId){clearInterval(this.heightChangeIntervalId)}};e.prototype.navigate=function(e){this.postMessageToHostPage({message:{url:e.url},messageType:"navigate"})};e.prototype.getAuthToken=function(){return this.getUserIdentityToken()};e.prototype.getUserIdentityToken=function(){var e=this;return new Promise(function(t,s){var o=++e.lastAuthTokenRequestId;e.authTokenRequests[o]={reject:s,resolve:t};e.postMessageToHostPage({message:{authTokenRequestId:o},messageType:"get-auth-token"})})};e.prototype.showModal=function(e){var t=this;return{modalClosed:new Promise(function(s,o){var n=++t.lastModalRequestId;t.modalRequests[n]={reject:o,resolve:s};t.postMessageToHostPage({message:{args:e,modalRequestId:n},messageType:"show-modal"})})}};e.prototype.closeModal=function(e){this.postMessageToHostPage({message:e,messageType:"close-modal"})};e.prototype.openHelp=function(e){this.postMessageToHostPage({message:{helpKey:e.helpKey},messageType:"open-help"})};e.prototype.showToast=function(e){this.postMessageToHostPage({message:e,messageType:"show-toast"})};e.prototype.showFlyout=function(e){var t=this;return{flyoutClosed:new Promise(function(s,o){e.defaultWidth=e.defaultWidth||500;e.maxWidth=e.maxWidth||e.defaultWidth;e.minWidth=e.minWidth||320;t.flyoutRequest={reject:o,resolve:s};t.postMessageToHostPage({message:e,messageType:"show-flyout"})})}};e.prototype.closeFlyout=function(){this.postMessageToHostPage({messageType:"close-flyout"})};e.prototype.showConfirm=function(e){var t=this;return new Promise(function(s,o){t.confirmRequest={reject:o,resolve:s};t.postMessageToHostPage({message:e,messageType:"show-confirm"})})};e.prototype.showError=function(e){this.postMessageToHostPage({message:e,messageType:"show-error"})};e.prototype.raiseAddinReadyMessage=function(){this.postMessageToHostPage({messageType:"ready"},"*")};e.prototype.handleModalClosedMessage=function(e){var t=this.modalRequests;var s=e.modalRequestId;var o=t[s];o.resolve(e.context);t[s]=undefined};e.prototype.handleAuthTokenMessage=function(e){var t=this.authTokenRequests;var s=e.message.authTokenRequestId;var o=t[s];switch(e.messageType){case"auth-token":var n=e.message.authToken;o.resolve(n);break;case"auth-token-fail":o.reject(e.message.reason);break}t[s]=undefined};e.prototype.handleMessage=function(e){var t=this;var s=e.data;if(s&&s.source==="bb-addin-host"){if(s.messageType==="host-ready"){this.setKnownAllowedHostOrigin(e.origin);this.trackHeightChangesOfAddinContent();this.args.callbacks.init({context:s.message.context,envId:s.message.envId,ready:function(e){t.checkForHeightChangesOfAddinContent();t.postMessageToHostPage({message:e,messageType:"addin-ready"})}})}else if(this.isFromValidOrigin(e)){switch(s.messageType){case"auth-token":case"auth-token-fail":this.handleAuthTokenMessage(s);break;case"modal-closed":this.handleModalClosedMessage(s.message);break;case"button-click":if(this.args.callbacks.buttonClick){this.args.callbacks.buttonClick()}break;case"confirm-closed":if(this.confirmRequest){this.confirmRequest.resolve(s.message.reason);this.confirmRequest=undefined}break;case"flyout-closed":if(this.flyoutRequest){this.flyoutRequest.resolve();this.flyoutRequest=undefined}break;case"flyout-next-click":if(this.args.callbacks.flyoutNextClick){this.args.callbacks.flyoutNextClick()}break;case"flyout-previous-click":if(this.args.callbacks.flyoutPreviousClick){this.args.callbacks.flyoutPreviousClick()}break;case"help-click":if(this.args.callbacks.helpClick){this.args.callbacks.helpClick()}break;case"settings-click":if(this.args.callbacks.settingsClick){this.args.callbacks.settingsClick()}break}}else{this.warnInvalidOrigin()}}};e.prototype.setKnownAllowedHostOrigin=function(e){for(var t=0,s=o;t<s.length;t++){var n=s[t];if(n.test(e)){this.trustedOrigin=e;return}}};e.prototype.checkForHeightChangesOfAddinContent=function(){var e=document.documentElement.offsetHeight;if(e!==this.lastPostedIframeHeight){this.lastPostedIframeHeight=e;this.postMessageToHostPage({message:{height:e+"px"},messageType:"height-change"})}};e.prototype.trackHeightChangesOfAddinContent=function(){var e=this;this.heightChangeIntervalId=setInterval(function(){e.checkForHeightChangesOfAddinContent()},1e3)};e.prototype.postMessageToHostPage=function(e,t){e.source="bb-addin-client";e.addinId=this.getQueryVariable("addinId");t=t||this.trustedOrigin;if(t){window.parent.postMessage(e,t)}else{this.warnInvalidOrigin()}};e.prototype.isFromValidOrigin=function(e){return e.origin===this.trustedOrigin};e.prototype.warnInvalidOrigin=function(){console.warn("The origin is not trusted because the host-ready message has not been "+"sent or because the host origin is not a whitelisted origin.")};e.prototype.getQueryVariable=function(t){var s=e.getQueryString().substring(1);var o=s.split("&");for(var n=0,i=o;n<i.length;n++){var a=i[n];var r=a.split("=");if(decodeURIComponent(r[0])===t){return decodeURIComponent(r[1])}}};return e}();t.AddinClient=n},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:true});var o;(function(e){e[e["None"]=0]="None";e[e["Add"]=1]="Add";e[e["Edit"]=2]="Edit";e[e["Delete"]=3]="Delete"})(o=t.AddinButtonStyle||(t.AddinButtonStyle={}))},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:true});var o;(function(e){e[e["Default"]=0]="Default";e[e["Primary"]=1]="Primary";e[e["Link"]=2]="Link"})(o=t.AddinConfirmButtonStyle||(t.AddinConfirmButtonStyle={}))},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:true});var o;(function(e){e[e["None"]=0]="None";e[e["Text"]=1]="Text"})(o=t.AddinTabSummaryStyle||(t.AddinTabSummaryStyle={}))},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:true});var o;(function(e){e[e["None"]=0]="None";e[e["Text"]=1]="Text";e[e["Check"]=2]="Check"})(o=t.AddinTileSummaryStyle||(t.AddinTileSummaryStyle={}))},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:true});var o;(function(e){e[e["Danger"]=0]="Danger";e[e["Info"]=1]="Info";e[e["Success"]=2]="Success";e[e["Warning"]=3]="Warning"})(o=t.AddinToastStyle||(t.AddinToastStyle={}))},function(e,t,s){"use strict";function o(e){for(var s in e)if(!t.hasOwnProperty(s))t[s]=e[s]}Object.defineProperty(t,"__esModule",{value:true});o(s(3));o(s(4));o(s(5));o(s(6));o(s(7))}])}); |
@@ -0,1 +1,8 @@ | ||
# 1.0.12 (2019-05-14) | ||
- Added a `showConfirm` method to allow developers to show a confirm dialog with a title, description body, | ||
and button configuration containing custom actions to return when the dialog closes. | ||
- Added a `showError` method to allow developers to show an error dialog with a title, error description, and | ||
text for the close button. | ||
# 1.0.11 (2019-05-03) | ||
@@ -2,0 +9,0 @@ |
@@ -1,1 +0,1 @@ | ||
{"name":"@blackbaud/sky-addin-client","version":"1.0.11","description":"SKY add-in client","main":"dist/bundles/sky-addin-client.umd.js","module":"index.js","scripts":{"ci":"npm run test:ci && npm run build","test":"npm run lint && npm run test:unit","test:ci":"npm run test:unit:ci","test:unit":"npm run test:unit:base -- config/karma/local.karma.conf.js","test:unit:ci":"npm run test:unit:base -- config/karma/ci.karma.conf.js","test:unit:base":"node --max-old-space-size=4096 node_modules/karma/bin/karma start","pretest":"npm run lint","compress":"npm run uglifyjs -- dist/bundles/sky-addin-client.umd.js -m -o dist/bundles/sky-addin-client.umd.min.js","build":"npm run rimraf dist && npm run tsc && npm run webpack -- --config config/webpack/webpack.prod.config.js && npm run compress","watch":"npm run test:unit -- --auto-watch --no-single-run","lint":"tslint 'src/**/*.ts'","rimraf":"rimraf","tsc":"tsc","uglifyjs":"uglifyjs","webpack":"webpack"},"repository":{"type":"git","url":"git+https://github.com/blackbaud/sky-addin-client.git"},"author":"Blackbaud, Inc.","license":"MIT","bugs":{"url":"https://github.com/blackbaudsky-addin-client/issues"},"homepage":"https://github.com/blackbaud/sky-addin-client#readme","devDependencies":{"@types/core-js":"0.9.41","@types/jasmine":"2.5.47","@types/jasmine-ajax":"3.1.36","@types/webpack":"2.2.15","core-js":"2.4.1","fs-extra":"3.0.1","istanbul":"0.4.5","istanbul-instrumenter-loader":"0.2.0","jasmine":"2.6.0","jasmine-ajax":"3.3.1","karma":"4.0.1","karma-browserstack-launcher":"1.4.0","karma-chrome-launcher":"2.1.1","karma-coverage":"1.1.2","karma-firefox-launcher":"1.0.1","karma-jasmine":"1.1.0","karma-mocha-reporter":"2.2.3","karma-sourcemap-loader":"0.3.7","karma-webpack":"3.0.5","raw-loader":"0.5.1","remap-istanbul":"0.9.5","rimraf":"2.6.1","source-map-inline-loader":"github:blackbaud-bobbyearl/source-map-inline-loader","ts-loader":"2.0.3","tslint":"5.2.0","tslint-loader":"3.5.3","typescript":"2.3.2","uglify-js":"3.0.15","webpack":"2.5.1"}} | ||
{"name":"@blackbaud/sky-addin-client","version":"1.0.12","description":"SKY add-in client","main":"dist/bundles/sky-addin-client.umd.js","module":"index.js","scripts":{"ci":"npm run test:ci && npm run build","test":"npm run lint && npm run test:unit","test:ci":"npm run test:unit:ci","test:unit":"npm run test:unit:base -- config/karma/local.karma.conf.js","test:unit:ci":"npm run test:unit:base -- config/karma/ci.karma.conf.js","test:unit:base":"node --max-old-space-size=4096 node_modules/karma/bin/karma start","pretest":"npm run lint","compress":"npm run uglifyjs -- dist/bundles/sky-addin-client.umd.js -m -o dist/bundles/sky-addin-client.umd.min.js","build":"npm run rimraf dist && npm run tsc && npm run webpack -- --config config/webpack/webpack.prod.config.js && npm run compress","watch":"npm run test:unit -- --auto-watch --no-single-run","lint":"tslint 'src/**/*.ts'","rimraf":"rimraf","tsc":"tsc","uglifyjs":"uglifyjs","webpack":"webpack"},"repository":{"type":"git","url":"git+https://github.com/blackbaud/sky-addin-client.git"},"author":"Blackbaud, Inc.","license":"MIT","bugs":{"url":"https://github.com/blackbaudsky-addin-client/issues"},"homepage":"https://github.com/blackbaud/sky-addin-client#readme","devDependencies":{"@types/core-js":"0.9.41","@types/jasmine":"2.5.47","@types/jasmine-ajax":"3.1.36","@types/webpack":"2.2.15","core-js":"2.4.1","fs-extra":"3.0.1","istanbul":"0.4.5","istanbul-instrumenter-loader":"0.2.0","jasmine":"2.6.0","jasmine-ajax":"3.3.1","karma":"4.0.1","karma-browserstack-launcher":"1.4.0","karma-chrome-launcher":"2.1.1","karma-coverage":"1.1.2","karma-firefox-launcher":"1.0.1","karma-jasmine":"1.1.0","karma-mocha-reporter":"2.2.3","karma-sourcemap-loader":"0.3.7","karma-webpack":"3.0.5","raw-loader":"0.5.1","remap-istanbul":"0.9.5","rimraf":"2.6.1","source-map-inline-loader":"github:blackbaud-bobbyearl/source-map-inline-loader","ts-loader":"2.0.3","tslint":"5.2.0","tslint-loader":"3.5.3","typescript":"2.3.2","uglify-js":"3.0.15","webpack":"2.5.1"}} |
@@ -270,2 +270,44 @@ # sky-addin-client | ||
#### Showing a confirm dialog | ||
The add-in can instruct the parent page to show a confirm dialog. To do this, call the `showConfirm` method on the `AddinClient` object. This function takes an object argument with properties `message`, `body`, and `buttons` representing the title, body, and buttons to display on the confirm dialog. | ||
```js | ||
var client = new AddinClient({...}); | ||
client.showConfirm( | ||
{ | ||
message: 'confirm title', | ||
body: 'confirm message body', | ||
buttons: [ | ||
{ | ||
action: 'ok', | ||
text: 'OK', | ||
autofocus: true, | ||
style: AddinConfirmButtonStyle.Primary | ||
}, | ||
{ | ||
action: 'cancel', | ||
text: 'Cancel', | ||
style: AddinConfirmButtonStyle.Link | ||
} | ||
] | ||
}).then((action: string) { | ||
// Handle the action returned from the confirm dialog. | ||
}); | ||
``` | ||
#### Showing an error dialog | ||
The add-in can instruct the parent page to show an error dialog. To do this, call the `showError` method on the `AddinClient` object. This function takes an object argument with properties `closeText`, `description` and `title` representing the button text, desciption of error, and title of error to display on the error dialog. | ||
```js | ||
var client = new AddinClient({...}); | ||
client.showError( | ||
{ | ||
closeText: 'OK', | ||
description: 'An unexpected error occurred', | ||
title: 'Error' | ||
}); | ||
``` | ||
## Authentication | ||
@@ -272,0 +314,0 @@ SKY add-ins support a single-sign-on (SSO) mechanism that can be used to correlate the Blackbaud user with a user in the add-in's native system. |
@@ -5,2 +5,4 @@ import { AddinClientArgs } from './client-interfaces/addin-client-args'; | ||
import { AddinClientOpenHelpArgs } from './client-interfaces/addin-client-open-help-args'; | ||
import { AddinClientShowConfirmArgs } from './client-interfaces/addin-client-show-confirm-args'; | ||
import { AddinClientShowErrorArgs } from './client-interfaces/addin-client-show-error-args'; | ||
import { AddinClientShowFlyoutArgs } from './client-interfaces/addin-client-show-flyout-args'; | ||
@@ -37,2 +39,6 @@ import { AddinClientShowFlyoutResult } from './client-interfaces/addin-client-show-flyout-result'; | ||
/** | ||
* Tracks the current confirm dialog that has been launched from this add-in. | ||
*/ | ||
private confirmRequest; | ||
/** | ||
* The origin of the host page. | ||
@@ -112,2 +118,14 @@ */ | ||
/** | ||
* Requests the host page to show a confirm dialog. | ||
* @param args Arguments for showing a confirm dialog. | ||
* @returns {Promise<string>} Returns a promise that will resolve with the | ||
* confirm action when the dialog is closed. | ||
*/ | ||
showConfirm(args: AddinClientShowConfirmArgs): Promise<string>; | ||
/** | ||
* Informs the host to show an error dialog. | ||
* @param args Arguments for showing an error dialog. | ||
*/ | ||
showError(args: AddinClientShowErrorArgs): void; | ||
/** | ||
* Post a message to the host page informing it that the add-in is | ||
@@ -114,0 +132,0 @@ * now started and listening for messages from the host. |
@@ -193,2 +193,31 @@ "use strict"; | ||
/** | ||
* Requests the host page to show a confirm dialog. | ||
* @param args Arguments for showing a confirm dialog. | ||
* @returns {Promise<string>} Returns a promise that will resolve with the | ||
* confirm action when the dialog is closed. | ||
*/ | ||
AddinClient.prototype.showConfirm = function (args) { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.confirmRequest = { | ||
reject: reject, | ||
resolve: resolve | ||
}; | ||
_this.postMessageToHostPage({ | ||
message: args, | ||
messageType: 'show-confirm' | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Informs the host to show an error dialog. | ||
* @param args Arguments for showing an error dialog. | ||
*/ | ||
AddinClient.prototype.showError = function (args) { | ||
this.postMessageToHostPage({ | ||
message: args, | ||
messageType: 'show-error' | ||
}); | ||
}; | ||
/** | ||
* Post a message to the host page informing it that the add-in is | ||
@@ -287,2 +316,8 @@ * now started and listening for messages from the host. | ||
break; | ||
case 'confirm-closed': | ||
if (this.confirmRequest) { | ||
this.confirmRequest.resolve(data.message.reason); | ||
this.confirmRequest = undefined; | ||
} | ||
break; | ||
case 'flyout-closed': | ||
@@ -289,0 +324,0 @@ if (this.flyoutRequest) { |
@@ -12,2 +12,4 @@ export * from './addin-button-config'; | ||
export * from './addin-client-ready-button-config'; | ||
export * from './addin-client-show-confirm-args'; | ||
export * from './addin-client-show-error-args'; | ||
export * from './addin-client-show-flyout-args'; | ||
@@ -18,2 +20,4 @@ export * from './addin-client-show-flyout-result'; | ||
export * from './addin-client-show-toast-args'; | ||
export * from './addin-confirm-button'; | ||
export * from './addin-confirm-button-style'; | ||
export * from './addin-tab-summary-style'; | ||
@@ -20,0 +24,0 @@ export * from './addin-tile-config'; |
@@ -7,2 +7,3 @@ "use strict"; | ||
__export(require("./addin-button-style")); | ||
__export(require("./addin-confirm-button-style")); | ||
__export(require("./addin-tab-summary-style")); | ||
@@ -9,0 +10,0 @@ __export(require("./addin-tile-summary-style")); |
@@ -28,5 +28,5 @@ /** | ||
* Generic field for passing information about the request, such as the explanation for a | ||
* auth-token-fail message. | ||
* auth-token-fail message or action message for closing a dialog. | ||
*/ | ||
reason?: string; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
117917
98
1866
366