Skip to content

Commit

Permalink
chore(*): prepare release 0.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcScheib committed Apr 23, 2017
1 parent 10fbb88 commit 6fab263
Show file tree
Hide file tree
Showing 20 changed files with 452 additions and 451 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-notify",
"version": "0.7.0",
"version": "0.7.1",
"description": "A notification plugin for Aurelia.",
"keywords": [
"aurelia",
Expand Down
55 changes: 22 additions & 33 deletions dist/amd/aurelia-notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,32 @@ define(['exports', './bs-notification', './notification-level', './notification-
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.keys(_bsNotification).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _bsNotification[key];
}
});
exports.NotificationController = exports.NotificationService = exports.NotificationLevel = exports.BSNotification = undefined;
Object.defineProperty(exports, 'BSNotification', {
enumerable: true,
get: function () {
return _bsNotification.BSNotification;
}
});
Object.keys(_notificationLevel).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _notificationLevel[key];
}
});
exports.configure = configure;
Object.defineProperty(exports, 'NotificationLevel', {
enumerable: true,
get: function () {
return _notificationLevel.NotificationLevel;
}
});
Object.keys(_notificationService).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _notificationService[key];
}
});
Object.defineProperty(exports, 'NotificationService', {
enumerable: true,
get: function () {
return _notificationService.NotificationService;
}
});
Object.keys(_notificationController).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _notificationController[key];
}
});
Object.defineProperty(exports, 'NotificationController', {
enumerable: true,
get: function () {
return _notificationController.NotificationController;
}
});
exports.configure = configure;
function configure(config, callback) {
config.globalResources('./bs-notification');

Expand Down
12 changes: 7 additions & 5 deletions dist/amd/notification-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,23 @@ define(['exports', './lifecycle'], function (exports, _lifecycle) {
function NotificationController(renderer, settings) {


this._renderer = renderer;
this.renderer = renderer;
this.settings = settings;
}

NotificationController.prototype.close = function close() {
var _this = this;

if (this.closePromise) {
return this.closePromise;
}
clearTimeout(this.timer);

return (0, _lifecycle.invokeLifecycle)(this.viewModel, 'canDeactivate').then(function (canDeactivate) {
return this.closePromise = (0, _lifecycle.invokeLifecycle)(this.viewModel, 'canDeactivate').then(function (canDeactivate) {
if (canDeactivate) {
(0, _lifecycle.invokeLifecycle)(_this.viewModel, 'deactivate').then(function () {
return _this._renderer.hideNotification(_this);
return _this.renderer.hideNotification(_this);
}).then(function () {
return _this._renderer.destroyNotificationHost(_this);
return _this.renderer.destroyNotificationHost(_this);
}).then(function () {
_this.controller.unbind();
});
Expand Down
84 changes: 43 additions & 41 deletions dist/amd/notification-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,54 +25,15 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-metadata', 'aurelia-
this.notificationRenderer = notificationRenderer;
}

NotificationService.prototype._getViewModel = function _getViewModel(compositionContext) {
if (typeof compositionContext.viewModel === 'function') {
compositionContext.viewModel = _aureliaMetadata.Origin.get(compositionContext.viewModel).moduleId;
}

if (typeof compositionContext.viewModel === 'string') {
return this.compositionEngine.ensureViewModel(compositionContext);
}

return Promise.resolve(compositionContext);
};

NotificationService.prototype.notify = function notify(model, settings, level) {
var _this = this;

var notificationLevel = level || _notificationLevel.NotificationLevel.info;
var _settings = Object.assign({}, this.notificationRenderer.defaultSettings, settings);

var notification = void 0;
if (typeof model === 'string') {
notification = model;
} else if ((typeof model === 'undefined' ? 'undefined' : _typeof(model)) === 'object') {
if (model.notification === undefined) {
throw new Error('model must implement `notification` property.');
}
notification = model.notification;
} else {
throw new Error('type is not supported by `notify()`.');
}

_settings.model = {
notification: notification,
data: model,
level: notificationLevel
};

var notificationController = new _notificationController.NotificationController(this.notificationRenderer, _settings);
var notificationController = new _notificationController.NotificationController(this.notificationRenderer, _createSettings(model, _settings, level));
var childContainer = this.container.createChild();
var compositionContext = {
viewModel: _settings.viewModel,
container: this.container,
childContainer: childContainer,
model: _settings.model
};

childContainer.registerInstance(_notificationController.NotificationController, notificationController);

return this._getViewModel(compositionContext).then(function (returnedCompositionContext) {
return _getViewModel(this.container, childContainer, this.compositionEngine, notificationController).then(function (returnedCompositionContext) {
notificationController.viewModel = returnedCompositionContext.viewModel;

return (0, _lifecycle.invokeLifecycle)(returnedCompositionContext.viewModel, 'canActivate', _settings.model).then(function (canActivate) {
Expand Down Expand Up @@ -109,4 +70,45 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-metadata', 'aurelia-

return NotificationService;
}(), _class.inject = [_aureliaTemplating.CompositionEngine, _aureliaDependencyInjection.Container, _notificationRenderer.NotificationRenderer], _temp);


function _createSettings(model, settings, level) {
var notification = void 0;
if (typeof model === 'string') {
notification = model;
} else if ((typeof model === 'undefined' ? 'undefined' : _typeof(model)) === 'object') {
if (model.notification === undefined) {
throw new Error('model must implement `notification` property.');
}
notification = model.notification;
} else {
throw new Error('type is not supported by `notify()`.');
}

settings.model = {
notification: notification,
data: model,
level: level || _notificationLevel.NotificationLevel.info
};
return settings;
}

function _getViewModel(container, childContainer, compositionEngine, notificationController) {
var compositionContext = {
container: container,
childContainer: childContainer,
model: notificationController.settings.model,
viewModel: notificationController.settings.viewModel
};

if (typeof compositionContext.viewModel === 'function') {
compositionContext.viewModel = _aureliaMetadata.Origin.get(compositionContext.viewModel).moduleId;
}

if (typeof compositionContext.viewModel === 'string') {
return compositionEngine.ensureViewModel(compositionContext);
}

return Promise.resolve(compositionContext);
}
});
155 changes: 80 additions & 75 deletions dist/aurelia-notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,30 @@ export function invokeLifecycle(instance: any, name: string, model: any) {

export class NotificationController {
constructor(renderer: NotificationRenderer, settings: any) {
this._renderer = renderer;
this.renderer = renderer;
this.settings = settings;
}

close() {
if (this.closePromise) {
return this.closePromise;
}
clearTimeout(this.timer);

return invokeLifecycle(this.viewModel, 'canDeactivate').then(canDeactivate => {
if (canDeactivate) {
invokeLifecycle(this.viewModel, 'deactivate')
.then(() => {
return this._renderer.hideNotification(this);
})
.then(() => {
return this._renderer.destroyNotificationHost(this);
})
.then(() => {
this.controller.unbind();
});
}
});
return this.closePromise = invokeLifecycle(this.viewModel, 'canDeactivate')
.then(canDeactivate => {
if (canDeactivate) {
invokeLifecycle(this.viewModel, 'deactivate')
.then(() => {
return this.renderer.hideNotification(this);
})
.then(() => {
return this.renderer.destroyNotificationHost(this);
})
.then(() => {
this.controller.unbind();
});
}
});
}
}

Expand Down Expand Up @@ -212,73 +215,35 @@ export class NotificationService {
this.notificationRenderer = notificationRenderer;
}

_getViewModel(compositionContext) {
if (typeof compositionContext.viewModel === 'function') {
compositionContext.viewModel = Origin.get(compositionContext.viewModel).moduleId;
}

if (typeof compositionContext.viewModel === 'string') {
return this.compositionEngine.ensureViewModel(compositionContext);
}

return Promise.resolve(compositionContext);
}

notify(model: any, settings?: any, level?: string) {
let notificationLevel = level || NotificationLevel.info;
let _settings = Object.assign({}, this.notificationRenderer.defaultSettings, settings);

let notification;
if (typeof model === 'string') {
notification = model;
} else if (typeof model === 'object') {
if (model.notification === undefined) {
throw new Error('model must implement `notification` property.');
}
notification = model.notification;
} else {
throw new Error('type is not supported by `notify()`.');
}

_settings.model = {
notification: notification,
data: model,
level: notificationLevel
};

let notificationController = new NotificationController(this.notificationRenderer, _settings);
let notificationController = new NotificationController(this.notificationRenderer, _createSettings(model, _settings, level));
let childContainer = this.container.createChild();
let compositionContext = {
viewModel: _settings.viewModel,
container: this.container,
childContainer: childContainer,
model: _settings.model
};

childContainer.registerInstance(NotificationController, notificationController);

return this._getViewModel(compositionContext).then(returnedCompositionContext => {
notificationController.viewModel = returnedCompositionContext.viewModel;

return invokeLifecycle(returnedCompositionContext.viewModel, 'canActivate', _settings.model).then(canActivate => {
if (canActivate) {
this.compositionEngine.createController(returnedCompositionContext)
.then(controller => {
notificationController.controller = controller;
notificationController.view = controller.view;
controller.automate();

return this.notificationRenderer.createNotificationHost(notificationController);
})
.then(() => {
return this.notificationRenderer.showNotification(notificationController);
});
}
return _getViewModel(this.container, childContainer, this.compositionEngine, notificationController)
.then(returnedCompositionContext => {
notificationController.viewModel = returnedCompositionContext.viewModel;

return invokeLifecycle(returnedCompositionContext.viewModel, 'canActivate', _settings.model)
.then(canActivate => {
if (canActivate) {
this.compositionEngine.createController(returnedCompositionContext)
.then(controller => {
notificationController.controller = controller;
notificationController.view = controller.view;
controller.automate();

return this.notificationRenderer.createNotificationHost(notificationController);
})
.then(() => {
return this.notificationRenderer.showNotification(notificationController);
});
}
});
});
});
}


info(message: string, settings?: any) {
this.notify(message, settings, NotificationLevel.info);
}
Expand All @@ -295,3 +260,43 @@ export class NotificationService {
this.notify(message, settings, NotificationLevel.danger);
}
}

function _createSettings(model, settings, level) {
let notification;
if (typeof model === 'string') {
notification = model;
} else if (typeof model === 'object') {
if (model.notification === undefined) {
throw new Error('model must implement `notification` property.');
}
notification = model.notification;
} else {
throw new Error('type is not supported by `notify()`.');
}

settings.model = {
notification: notification,
data: model,
level: level || NotificationLevel.info
};
return settings;
}

function _getViewModel(container, childContainer, compositionEngine, notificationController) {
let compositionContext = {
container: container,
childContainer: childContainer,
model: notificationController.settings.model,
viewModel: notificationController.settings.viewModel
};

if (typeof compositionContext.viewModel === 'function') {
compositionContext.viewModel = Origin.get(compositionContext.viewModel).moduleId;
}

if (typeof compositionContext.viewModel === 'string') {
return compositionEngine.ensureViewModel(compositionContext);
}

return Promise.resolve(compositionContext);
}
Loading

0 comments on commit 6fab263

Please sign in to comment.