jpush-ui
Version:
极光大数据前端Angular组件(^6.1.0)
95 lines • 3.71 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var portal_1 = require("@angular/cdk/portal");
require("rxjs/add/operator/map");
var alert_component_1 = require("./alert/alert.component");
var confirm_component_1 = require("./confirm/confirm.component");
var prompt_component_1 = require("./prompt/prompt.component");
var dialog_model_1 = require("./dialog.model");
var portal_2 = require("../util/portal");
var DialogService = /** @class */ (function () {
// private modalVector = [] as Array<DialogData<any>>;
function DialogService(portalUtil) {
this.portalUtil = portalUtil;
}
DialogService.prototype.alert = function (content, title, opts) {
if (title === void 0) { title = '提示'; }
var data = new alert_component_1.AlertData();
data.title = title;
data.content = content;
if (opts) {
// 只允许validFields里定义的一些key
data.validFields.forEach(function (key) {
if (opts[key]) {
data[key] = opts[key];
}
});
}
var injector = this.portalUtil.resolveInputs([{
provide: alert_component_1.AlertData, useValue: data
}]);
var portal = new portal_1.ComponentPortal(alert_component_1.AlertComponent);
var host = this.portalUtil.genHost(injector);
var dialog = new dialog_model_1.DialogData(portal, host, data);
setTimeout(function () {
dialog.open();
});
// this.modalVector.push(dialog);
return dialog;
};
DialogService.prototype.confirm = function (content, opts) {
var data = new confirm_component_1.ConfirmData();
data.content = content;
if (opts) {
// 只允许validFields里定义的一些key
data.validFields.forEach(function (key) {
if (opts[key]) {
data[key] = opts[key];
}
});
}
var injector = this.portalUtil.resolveInputs([{
provide: confirm_component_1.ConfirmData, useValue: data
}]);
var portal = new portal_1.ComponentPortal(confirm_component_1.ConfirmComponent);
var host = this.portalUtil.genHost(injector);
var dialog = new dialog_model_1.DialogData(portal, host, data);
setTimeout(function () {
dialog.open();
});
return dialog;
};
DialogService.prototype.prompt = function (content, opts) {
var data = new prompt_component_1.PromptData();
data.content = content;
if (opts) {
// 只允许validFields里定义的一些key
data.validFields.forEach(function (key) {
if (opts[key]) {
data[key] = opts[key];
}
});
}
var injector = this.portalUtil.resolveInputs([{
provide: prompt_component_1.PromptData, useValue: data
}]);
var portal = new portal_1.ComponentPortal(prompt_component_1.PromptComponent);
var host = this.portalUtil.genHost(injector);
var dialog = new dialog_model_1.DialogData(portal, host, data);
setTimeout(function () {
dialog.open();
});
return dialog;
};
DialogService.decorators = [
{ type: core_1.Injectable },
];
/** @nocollapse */
DialogService.ctorParameters = function () { return [
{ type: portal_2.PortalUtil, },
]; };
return DialogService;
}());
exports.DialogService = DialogService;
//# sourceMappingURL=dialog.service.js.map