Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
daa-custom-stack
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Felipe Vieira de Moraes Tavares
daa-custom-stack
Commits
0601e276
Commit
0601e276
authored
Mar 04, 2017
by
fvieira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preliminar validation done
parent
de45cff6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
15 deletions
+31
-15
inquisitor-validator.js
backend/app/people/inquisitor-validator.js
+2
-1
people.js
backend/app/people/people.js
+4
-4
people.js
frontend/app/core/people.js
+8
-2
peopleService.js
frontend/app/core/peopleService.js
+8
-8
error-partial.html
frontend/app/error-partial.html
+9
-0
No files found.
backend/app/people/inquisitor-validator.js
View file @
0601e276
...
...
@@ -6,7 +6,7 @@ var areBadPetsHere = function (pets) {
return
false
}
var
m
=
pets
.
map
(
function
(
pet
)
{
return
pet
==
''
return
pet
==
''
||
pet
==
undefined
})
return
m
.
reduce
(
function
(
i
,
j
)
{
return
i
||
j
...
...
@@ -14,6 +14,7 @@ var areBadPetsHere = function (pets) {
}
var
inquisitor
=
function
(
next
)
{
console
.
log
(
this
)
if
(
this
.
name
==
''
){
next
(
erroneous_name
)
}
...
...
backend/app/people/people.js
View file @
0601e276
...
...
@@ -54,10 +54,10 @@ db.once('open',function () {
}
people
.
modifyPet
=
function
(
id
,
old_pet_name
,
new_pet_name
,
callback
)
{
people
.
removePet
(
id
,
old_pet_name
,
function
(
)
{
pe
ople
.
addPet
(
id
,
new_pet_name
,
function
()
{
callback
(
)
}
)
people
.
model
.
findById
(
id
).
then
(
function
(
person
)
{
pe
rson
.
pets
.
splice
(
person
.
pets
.
indexOf
(
old_pet_name
),
1
)
person
.
pets
.
push
(
new_pet_name
)
person
.
save
(
callback
)
})
}
...
...
frontend/app/core/people.js
View file @
0601e276
...
...
@@ -8,6 +8,12 @@ app.controller('peopleCtrl',function ($scope,ngDialog,people) {
})
}
$scope
.
badData
=
function
()
{
ngDialog
.
open
({
template
:
'../error-partial.html'
})
}
this
.
load
()
$scope
.
remove
=
function
(
item
)
{
...
...
@@ -16,7 +22,7 @@ app.controller('peopleCtrl',function ($scope,ngDialog,people) {
$scope
.
add
=
function
()
{
console
.
log
(
"adding"
)
people
.
add
(
$scope
.
name
,
self
.
load
)
people
.
add
(
$scope
.
name
,
self
.
load
,
$scope
.
badData
)
$scope
.
name
=
''
}
...
...
@@ -34,7 +40,7 @@ app.controller('peopleCtrl',function ($scope,ngDialog,people) {
people
.
addPet
(
person
,
pet
,
function
()
{
self
.
load
()
$scope
.
pet
=
''
})
}
,
$scope
.
badData
)
}
$scope
.
do
=
function
(
person
,
pet
)
{
...
...
frontend/app/core/peopleService.js
View file @
0601e276
...
...
@@ -7,18 +7,18 @@ app.service('people', function ($http) {
$http
.
delete
(
'http://127.0.0.1:8000/people/'
+
item
.
_id
).
then
(
callback
)
}
this
.
add
=
function
(
n
,
callback
)
{
$http
.
post
(
'http://127.0.0.1:8000/people'
,{
name
:
n
}).
then
(
callback
)
this
.
add
=
function
(
n
,
callback
,
reject
)
{
$http
.
post
(
'http://127.0.0.1:8000/people'
,{
name
:
n
}).
then
(
callback
)
.
catch
(
reject
)
}
this
.
modify
=
function
(
item
,
callback
)
{
this
.
modify
=
function
(
item
,
callback
,
reject
)
{
$http
.
put
(
'http://127.0.0.1:8000/people'
,{
person_id
:
item
.
_id
,
name
:
item
.
name
})
.
then
(
callback
)
.
then
(
callback
)
.
catch
(
reject
)
}
this
.
addPet
=
function
(
item
,
pet_name
,
callback
)
{
this
.
addPet
=
function
(
item
,
pet_name
,
callback
,
reject
)
{
$http
.
post
(
'http://127.0.0.1:8000/people/pets'
,{
person_id
:
item
.
_id
,
petname
:
pet_name
})
.
then
(
callback
)
.
then
(
callback
)
.
catch
(
reject
)
}
this
.
removePet
=
function
(
item
,
pet_name
,
callback
)
{
...
...
@@ -26,12 +26,12 @@ app.service('people', function ($http) {
.
then
(
callback
)
}
this
.
modifyPet
=
function
(
item
,
old_pet_name
,
new_petname
,
callback
)
{
this
.
modifyPet
=
function
(
item
,
old_pet_name
,
new_petname
,
callback
,
reject
)
{
$http
.
put
(
'http://127.0.0.1:8000/people/pets'
,
{
person_id
:
item
.
_id
,
old_petname
:
old_pet_name
,
new_petname
:
new_petname
}).
then
(
callback
)
}).
then
(
callback
)
.
catch
(
reject
)
}
})
frontend/app/error-partial.html
0 → 100644
View file @
0601e276
<div>
<h1>
Error
</h1>
Erroneous data.
<div
class=
"row"
>
<div
class=
"6u align-center"
>
<button
ng-click=
'closeThisDialog()'
>
Oops
</button>
</div>
</div>
</div>
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