Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PET Computação
Farol_antigo
Commits
0aa2e358
Commit
0aa2e358
authored
Oct 16, 2015
by
Vytor Calixto
👾
Browse files
Sweetalert na página dos professores
parent
49e9ab68
Changes
2
Hide whitespace changes
Inline
Side-by-side
client/views/admin/professores.ejs
View file @
0aa2e358
...
...
@@ -5,7 +5,29 @@
<
%
include
../
partials
/
admin-header
%
>
<section
class=
"page-wrap"
>
<
%
if
(
message.length
>
0) { %>
<div
class=
"card margin"
><
%=
message
%
></div>
<
%
if
(
message.length
>
0) { %>
<div
class=
"card margin"
><
%=
message
%
></div>
<
%
}
%
>
<
%
if
(message =
=
"
successDelete
")
{
%
>
<script>
swal
(
"
Deletado!
"
,
"
O professor foi deletado com sucesso.
"
,
"
success
"
);
</script>
<
%
}
%
>
<
%
if
(message =
=
"
successSave
")
{
%
>
<script>
swal
(
"
Salvo!
"
,
"
O professor foi criado com sucesso.
"
,
"
success
"
);
</script>
<
%
}
%
>
<
%
if
(message =
=
"
errorSave
")
{
%
>
<script>
swal
(
"
Erro :(
"
,
"
Não foi possível salvar o professor. Tente novamente.
"
,
"
error
"
);
</script>
<
%
}
%
>
<
%
if
(message =
=
"
successEdit
")
{
%
>
<script>
swal
(
"
Salvo!
"
,
"
O professor foi editado com sucesso.
"
,
"
success
"
);
</script>
<
%
}
%
>
<
%
}
%
>
<div
class=
"card card-list margin"
>
<ul
class=
"list"
>
...
...
@@ -24,22 +46,38 @@
<li
class=
"list-item text-left"
>
<
%=
professores
[
i
].
nome
%
>
<div
class=
"float-right"
>
<
a
href=
"
/admin/professores/<%= professores[i]._id %>"
class=
"button normal hover-shadow"
>
<
button
onclick=
"location.
href=
'
/admin/professores/<%= professores[i]._id %>
'
"
class=
"button normal hover-shadow"
>
<i
class=
"fa fa-edit fa-fw"
></i>
</
a
>
</
button
>
<
a
href=
"/admin/professores/delete/
<%= professores[i]._id %>"
class=
"button red hover-shadow"
>
<
button
onclick=
"deleteModal('
<%= professores[i]._id %>
')
"
class=
"button red hover-shadow"
>
<i
class=
"fa fa-close fa-fw"
></i>
</
a
>
</
button
>
</div>
</li>
<
%
}
%
>
<
%
if
(professores.length =
=
0)
{
%
>
<li
class=
"list-item"
>
Não há
matéria
s cadastrad
a
s.
</li>
<li
class=
"list-item"
>
Não há
professore
s cadastrad
o
s.
</li>
<
%
}
%
>
</ul>
</div>
</section>
<
%
include
../
partials
/
footer
%
>
<script>
function
deleteModal
(
id
)
{
swal
({
title
:
"
Você tem certeza?
"
,
text
:
"
Não será possível recuperar o professor!
"
,
type
:
"
warning
"
,
showCancelButton
:
true
,
confirmButtonColor
:
"
#DD6B55
"
,
confirmButtonText
:
"
Sim, deletar professor!
"
,
closeOnConfirm
:
true
,
html
:
false
},
function
(){
location
.
href
=
'
/admin/professores/delete/
'
+
id
;
});
}
</script>
</body>
</html>
libs/routes/admin/professores.js
View file @
0aa2e358
...
...
@@ -26,9 +26,10 @@ router.post('/', function(req, res) {
professor
.
save
(
function
(
err
)
{
if
(
!
err
)
{
req
.
flash
(
'
professoresMessage
'
,
'
successSave
'
)
res
.
redirect
(
'
/admin/professores
'
)
}
else
{
req
.
flash
(
'
professoresMessage
'
,
'
E
rro
ao salvar a matéria
'
)
req
.
flash
(
'
professoresMessage
'
,
'
e
rro
rSave
'
)
res
.
redirect
(
'
/admin/professores
'
)
}
})
...
...
@@ -62,7 +63,7 @@ router.post('/:id', function(req, res) {
professor
.
save
(
function
(
err
)
{
if
(
!
err
)
{
req
.
flash
(
'
professoresMessage
'
,
'
Professor salvo com sucesso
'
)
req
.
flash
(
'
professoresMessage
'
,
'
successEdit
'
)
res
.
redirect
(
'
/admin/professores
'
)
}
else
{
// TODO: redirecionar para 500
...
...
@@ -78,7 +79,7 @@ router.get('/delete/:id', function(req, res) {
// TODO: redirecionar para 500
res
.
redirect
(
'
/
'
)
}
req
.
flash
(
'
professoresMessage
'
,
'
Professor removido com sucesso
'
)
req
.
flash
(
'
professoresMessage
'
,
'
successDelete
'
)
res
.
redirect
(
'
/admin/professores
'
)
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment