-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Cadastro e edição de curso e evento
- Loading branch information
FannyVieira
authored and
FannyVieira
committed
Sep 29, 2016
1 parent
33a562f
commit 31c167d
Showing
4 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
} | ||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<md-card> | ||
<md-card-header> | ||
|
||
<md-card-avatar> | ||
<md-icon class="md-avatar-icon" md-svg-icon="img/icon/create-new-pencil-button.svg"></md-icon> | ||
</md-card-avatar> | ||
|
||
<md-card-header-text> | ||
<span class="md-title">Editar informações do Curso</span> | ||
<span class="md-subhead">Clique em salvar para alterar as informações</span> | ||
</md-card-header-text> | ||
|
||
<!-- Salvar alterações --> | ||
<md-card-icon-actions> | ||
<md-button class="md-icon-button" aria-label="Salvar alterações" ng-click="atualizar(curso)"> | ||
<md-tooltip md-direction="bottom">Salvar Alterações</md-tooltip> | ||
<md-icon md-svg-icon="img/icon/save-button.svg"></md-icon> | ||
</md-button> | ||
</md-card-icon-actions> | ||
|
||
</md-card-header> | ||
<md-card-content layout="column"> | ||
|
||
<!-- Nome --> | ||
<md-input-container class="md-icon-float md-block"> | ||
<label>Nome</label> | ||
<input ng-model="curso.nome" type="text"> | ||
</md-input-container> | ||
|
||
</md-card-content> | ||
</md-card> |