Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Wendys Racing Horses
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
tu-wien
Wendys Racing Horses
Commits
361a09b0
Commit
361a09b0
authored
Mar 22, 2020
by
Ivaylo Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
US04: Make it possible to delete horses from the UI
parent
a3f6276f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
2 deletions
+28
-2
frontend/wendys-friends/src/app/component/list-horses/list-horses.component.html
.../src/app/component/list-horses/list-horses.component.html
+1
-1
frontend/wendys-friends/src/app/component/list-horses/list-horses.component.ts
...ds/src/app/component/list-horses/list-horses.component.ts
+11
-0
frontend/wendys-friends/src/app/service/horse.service.ts
frontend/wendys-friends/src/app/service/horse.service.ts
+16
-1
No files found.
frontend/wendys-friends/src/app/component/list-horses/list-horses.component.html
View file @
361a09b0
...
...
@@ -71,7 +71,7 @@
<a
class=
"btn btn-success"
href=
"horse/{{ horse.id }}/edit"
><i
class=
"fas fa-edit"
></i></a>
</td>
<td>
<button
class=
"btn btn-danger"
><i
class=
"fas fa-trash"
></i></button>
<button
class=
"btn btn-danger"
(click)=
"deleteHorse(horse.id, horse.name)"
><i
class=
"fas fa-trash"
></i></button>
</td>
</tr>
</tbody>
...
...
frontend/wendys-friends/src/app/component/list-horses/list-horses.component.ts
View file @
361a09b0
...
...
@@ -91,6 +91,17 @@ export class ListHorsesComponent implements OnInit {
);
}
public
deleteHorse
(
id
:
number
,
name
:
string
)
{
if
(
confirm
(
"
Are you sure you want to delete
"
+
name
+
"
. This action is irreversible.
"
))
{
this
.
horseService
.
deleteHorse
(
id
).
subscribe
(
(
res
)
=>
{
console
.
log
(
'
Successfully deleted horse
'
);
this
.
loadAllHorses
();
}
);
}
}
private
defaultServiceErrorHandling
(
error
:
any
)
{
console
.
log
(
error
);
this
.
error
=
true
;
...
...
frontend/wendys-friends/src/app/service/horse.service.ts
View file @
361a09b0
...
...
@@ -48,13 +48,28 @@ export class HorseService {
return
this
.
httpClient
.
post
<
Horse
>
(
this
.
messageBaseUri
,
horse
);
}
/**
* Update a specific horse with the supplied values
* @param horse
*/
updateHorse
(
horse
:
Horse
):
Observable
<
Horse
>
{
console
.
log
(
'
Update horse with id
'
+
horse
.
id
+
'
:
'
+
JSON
.
stringify
(
horse
));
return
this
.
httpClient
.
put
<
Horse
>
(
this
.
messageBaseUri
+
'
/
'
+
horse
.
id
,
horse
);
}
/**
*
* Delete a horse from the backend
* @param id
*/
deleteHorse
(
id
:
number
):
Observable
<
Object
>
{
console
.
log
(
'
Delete horse with id
'
+
id
);
return
this
.
httpClient
.
delete
(
this
.
messageBaseUri
+
'
/
'
+
id
);
}
/**
* Uploads a file to the remote server
* @param fileToUpload
* @param newFileName
*/
postFile
(
fileToUpload
:
File
,
newFileName
:
string
):
Observable
<
Object
>
{
// Prepare the form
...
...
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