Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Bloco de código
languagejs
firstline1
titleExemplo
linenumberstrue
collapsetrue
sampleController.$inject = ['$rootScope', '$scope', 'totvs.app-notification.Service'];
function sampleController($rootScope, $scope, appNotificationService) {

	// Exemplo de chamada direta ao sistema de notificação:
	appNotificationService.message({
    	title: 'l-attention',
        text: 'Vamos lhe fazer uma pergunta.',
        help: 'Se precisar de ajuda, chame os universitários.',
        size: 'lg',  //opicional
        callback: function() {
        	appNotificationService.question({
            	title: 'l-question',
                text: 'Hoje é sexta-feira?',
                cancelLabel: 'l-no', // Padrão é 'cancel'
                confirmLabel: 'l-yes', // Padrão é 'ok'
                callback: function(isPositiveResult) {
                	var alert = {
                    	type: 'error',
                        title: 'Atenção',
				        size: 'md',  //opicional
                        detail: 'Hoje não é sexta-feira :('
                    };
                    if (isPositiveResult) {
                    	alert.type = 'success';
                        alert.detail = 'Hoje é sexta-feira :)'
                    } 
                    appNotificationService.notify(alert);
				}
			});
		}
	});
}

...

Bloco de código
languagejs
firstline1
titleExemplo
linenumberstruecollapsetrue
sampleController.$inject = ['$rootScope', '$scope'];
function sampleController($rootScope, $scope) {
	// Exemplo de chamada por evento ao sistema de notificação:
	$rootScope.$broadcast(TOTVSEvent.showNotification, {
    	type: 'info',
        title: 'Evento',
        detail: 'Esta notificação foi disparada através de um evento.'
	});
}

...

Bloco de código
languagexml
firstline1
titleExemplo
linenumberstruecollapsetrue
<html>
	<head>Exemplo</head>
	<body>
		<!--
        Diretiva definida para utilização do sistema de notificação via toaster.
        Caso não seja necessária a utilização basta remover a tag abaixo.
	    -->
	    <toaster-container toaster-options="{'time-out': 5000}"></toaster-container>
	</body>
</html>

...

Bloco de código
languagejs
firstline1
titleExemplo
linenumberstruecollapsetrue
// Controller principal para resolução das interações da aplicação que não 
// dizem respeito ao programa aberto (content). 
// Em resumo, é responsável pela barra de navegação e 'menus', entre outros.
appMainController.$inject = ['$rootScope', '$scope', 'totvs.app-notification.Service'];
function appMainController($rootScope, $scope, appNotificationService) {

	...

	// appNotificationService
	// Para evitar que todos os demais AngularJS Controllers e Services precisem
    // injetar o serviço de notificação, o serviço pode ficar disponível através
    // de eventos. Para isto basta injetar o appNotificationService no 
    // appMainController para dar suporte as notificações.
    $scope.$on(TOTVSEvent.showNotification, function (event, alerts) {
    	appNotificationService.notify(alerts);
	});
        
    $scope.$on(TOTVSEvent.showMessage, function (event, message) {
        appNotificationService.message(message);
    });
        
    $scope.$on(TOTVSEvent.showQuestion, function (event, question) {
        appNotificationService.question(question);
    }); 
}