From 31c167ddc56e9248fafd751a1e651e5c06e2ad13 Mon Sep 17 00:00:00 2001 From: FannyVieira Date: Wed, 28 Sep 2016 21:11:20 -0300 Subject: [PATCH] =?UTF-8?q?-=20Cadastro=20e=20edi=C3=A7=C3=A3o=20de=20curs?= =?UTF-8?q?o=20e=20evento?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/controllers/cadastrarEventoCtrl.js | 45 ++++++++++++++ .../js/controllers/editarCursoCtrl.js | 59 +++++++++++++++++++ .../js/controllers/editarEventoCtrl.js | 59 +++++++++++++++++++ .../view/manager/admin/editar-curso.html | 31 ++++++++++ 4 files changed, 194 insertions(+) create mode 100644 nutrif-web-refactor/js/controllers/cadastrarEventoCtrl.js create mode 100644 nutrif-web-refactor/js/controllers/editarCursoCtrl.js create mode 100644 nutrif-web-refactor/js/controllers/editarEventoCtrl.js create mode 100644 nutrif-web-refactor/view/manager/admin/editar-curso.html diff --git a/nutrif-web-refactor/js/controllers/cadastrarEventoCtrl.js b/nutrif-web-refactor/js/controllers/cadastrarEventoCtrl.js new file mode 100644 index 00000000..12c027c5 --- /dev/null +++ b/nutrif-web-refactor/js/controllers/cadastrarEventoCtrl.js @@ -0,0 +1,45 @@ +angular.module('NutrifApp').controller('cadastrarEventoCtrl', function ($scope, $mdToast, $state,eventoService) { + + this.cadastrar = function (evento) { + + // Enviar para o serviço de cadastro de Edital. + eventoService.cadastrarEvento(evento) + .success(onSuccessCallback) + .error(onErrorCallback); + } + + function onSuccessCallback (data, status) { + + $mdToast.show( + $mdToast.simple() + .textContent('Evento cadastrado com sucesso!') + .position('top right') + .action('OK') + .hideDelay(6000) + ); + + $state.transitionTo('home.listar-eventos'); + } + + function onErrorCallback (data, status) { + var _message = ''; + + if (!data) { + _message = 'Ocorreu um erro na comunicação com o servidor, favor chamar o suporte.' + } else { + _message = data.mensagem + } + + $mdToast.show( + $mdToast.simple() + .textContent(_message) + .position('top right') + .action('OK') + .hideDelay(6000) + ); + + $state.transitionTo('home.listar-eventos'); + } + + +}); diff --git a/nutrif-web-refactor/js/controllers/editarCursoCtrl.js b/nutrif-web-refactor/js/controllers/editarCursoCtrl.js new file mode 100644 index 00000000..de45bad7 --- /dev/null +++ b/nutrif-web-refactor/js/controllers/editarCursoCtrl.js @@ -0,0 +1,59 @@ +angular.module('NutrifApp').controller('editarCursoCtrl', function ($scope, + $stateParams, $state, $mdToast, cursoService) { + + $scope.atualizar = function (curso) { + + cursoService.atualizarCurso(curso) + .success(function (data, status) { + + $state.transitionTo('home.listar-cursos', {reload: true}); + $mdToast.show( + $mdToast.simple() + .textContent('Curso atualizado com sucesso!') + .position('top right') + .action('OK') + .hideDelay(6000) + ); + }) + .error(onErrorCallback); + } + + function carregamentoInicial() { + var _id = $stateParams.id; + + if (_id == 0){ + $state.transitionTo('home.listar-cursos', {reload: true}); + } + + cursoService.getCursoById(_id) + .success(function (data, status) { + $scope.curso = data; + }) + .error(onErrorLoadCallback); + } + + function onErrorCallback(data, status) { + var _message = ''; + + if (!data) { + _message = 'Ocorreu um erro na comunicação com o servidor, favor chamar o suporte.' + } else { + _message = data.mensagem + } + + $mdToast.show( + $mdToast.simple() + .textContent(_message) + .position('top right') + .action('OK') + .hideDelay(6000) + ); + } + + function onErrorLoadCallback(data, status) { + onErrorCallback(data, status); + $state.transitionTo('home.listar-cursos', {reload: true}); + } + + carregamentoInicial(); +}); diff --git a/nutrif-web-refactor/js/controllers/editarEventoCtrl.js b/nutrif-web-refactor/js/controllers/editarEventoCtrl.js new file mode 100644 index 00000000..c35c0f49 --- /dev/null +++ b/nutrif-web-refactor/js/controllers/editarEventoCtrl.js @@ -0,0 +1,59 @@ +angular.module('NutrifApp').controller('editarEventoCtrl', function ($scope, + $stateParams, $state, $mdToast, eventoService) { + + $scope.atualizar = function (evento) { + + eventoService.atualizarEvento(evento) + .success(function (data, status) { + + $state.transitionTo('home.listar-eventos', {reload: true}); + $mdToast.show( + $mdToast.simple() + .textContent('Evento atualizado com sucesso!') + .position('top right') + .action('OK') + .hideDelay(6000) + ); + }) + .error(onErrorCallback); + } + + function carregamentoInicial() { + var _id = $stateParams.id; + + if (_id == 0){ + $state.transitionTo('home.listar-eventos', {reload: true}); + } + + eventoService.getEventoById(_id) + .success(function (data, status) { + $scope.evento = data; + }) + .error(onErrorLoadCallback); + } + + function onErrorCallback(data, status) { + var _message = ''; + + if (!data) { + _message = 'Ocorreu um erro na comunicação com o servidor, favor chamar o suporte.' + } else { + _message = data.mensagem + } + + $mdToast.show( + $mdToast.simple() + .textContent(_message) + .position('top right') + .action('OK') + .hideDelay(6000) + ); + } + + function onErrorLoadCallback(data, status) { + onErrorCallback(data, status); + $state.transitionTo('home.listar-eventos', {reload: true}); + } + + carregamentoInicial(); +}); diff --git a/nutrif-web-refactor/view/manager/admin/editar-curso.html b/nutrif-web-refactor/view/manager/admin/editar-curso.html new file mode 100644 index 00000000..0392742a --- /dev/null +++ b/nutrif-web-refactor/view/manager/admin/editar-curso.html @@ -0,0 +1,31 @@ + + + + + + + + + Editar informações do Curso + Clique em salvar para alterar as informações + + + + + + Salvar Alterações + + + + + + + + + + + + + + +