Skip to content

Instantly share code, notes, and snippets.

@warrenbuckley
Last active August 29, 2015 14:10
Show Gist options
  • Save warrenbuckley/07d21b682c8e076cb5e2 to your computer and use it in GitHub Desktop.
Save warrenbuckley/07d21b682c8e076cb5e2 to your computer and use it in GitHub Desktop.
This is a POC idea to hook into when content node is Saved or Saved & Published do a $http Get/Post to perform some action such as auto create media folder. Then once successful show a notification with notificationService. This is a POC way to try and get around the current lack of firing a notification from an eventHandler like V6 style.
//Get the same base module that Umbraco uses
var app = angular.module("umbraco");
//When the module runs/excutes...
app.run(["$rootScope", "notificationsService", "eventsService", function ($rootScope, notificationsService, eventsService) {
//Let's listen for any time formSubmitting
eventsService.on("formSubmitting", function (e, args) {
console.log("e", e);
console.log("args", args);
//Sad panda :(
//This event 'formSubmitting' from formHelper.service.js only fires on the relative scope
//And not the rootScope so have no easy way to listen in for this
//Need another smart way?!
//Psudeo code
//Check for the type of docType that is being saved
//If type == "magic"
//Then do $http post or own service/resource with promise
//Do some funky event stuff - create an auto media folder
//If success promise
//Show notificationwith notificationService.add() using JSON response from API $http
});
//Let's listen for any time formSubmitted
eventsService.on("formSubmitted", function (e, args) {
console.log("e", e);
console.log("args", args);
});
//Let's listen for any time app.ready this is an event on the rootScope that is emitted
//So this works just lovely
eventsService.on("app.ready", function (e, args) {
console.log("e", e);
console.log("args", args);
notificationsService.success("Warren", "says hello");
});
}]);
@warrenbuckley
Copy link
Author

If anyone reads or follows this thread.
Recommend you vote up the issue here on the Umbraco Core Team Issue Tracker please
http://issues.umbraco.org/issue/U4-5927

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment