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
6c4fa0df
Commit
6c4fa0df
authored
Mar 25, 2020
by
Ivaylo Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
US08: Allow the user to delete an owner using the UI
parent
5c8e2c1c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletion
+23
-1
frontend/wendys-friends/src/app/component/list-owners/list-owners.component.html
.../src/app/component/list-owners/list-owners.component.html
+1
-1
frontend/wendys-friends/src/app/component/list-owners/list-owners.component.ts
...ds/src/app/component/list-owners/list-owners.component.ts
+13
-0
frontend/wendys-friends/src/app/service/owner.service.ts
frontend/wendys-friends/src/app/service/owner.service.ts
+9
-0
No files found.
frontend/wendys-friends/src/app/component/list-owners/list-owners.component.html
View file @
6c4fa0df
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
<td>
{{ owner.name }}
</td>
<td>
{{ owner.name }}
</td>
<td>
<td>
<a
class=
"btn btn-success"
href=
"owner/{{ owner.id }}/edit"
><i
class=
"fas fa-edit"
></i></a>
<a
class=
"btn btn-success"
href=
"owner/{{ owner.id }}/edit"
><i
class=
"fas fa-edit"
></i></a>
<button
class=
"btn btn-danger"
><i
class=
"fas fa-trash"
></i></button>
<button
class=
"btn btn-danger"
(click)=
"deleteOwner(owner.id, owner.name)"
><i
class=
"fas fa-trash"
></i></button>
</td>
</td>
</tr>
</tr>
</tbody>
</tbody>
...
...
frontend/wendys-friends/src/app/component/list-owners/list-owners.component.ts
View file @
6c4fa0df
...
@@ -71,6 +71,19 @@ export class ListOwnersComponent implements OnInit {
...
@@ -71,6 +71,19 @@ export class ListOwnersComponent implements OnInit {
);
);
}
}
public
deleteOwner
(
id
:
number
,
name
:
string
)
{
if
(
confirm
(
"
Are you sure you want to delete
"
+
name
+
"
. This action is irreversible.
"
))
{
this
.
ownerService
.
deleteOwner
(
id
).
subscribe
(
(
res
)
=>
{
console
.
log
(
'
Successfully deleted owner
'
);
this
.
loadAllOwners
();
},
(
error
)
=>
{
this
.
defaultServiceErrorHandling
(
error
);
}
);
}
}
private
defaultServiceErrorHandling
(
error
:
any
)
{
private
defaultServiceErrorHandling
(
error
:
any
)
{
console
.
log
(
error
);
console
.
log
(
error
);
this
.
error
=
true
;
this
.
error
=
true
;
...
...
frontend/wendys-friends/src/app/service/owner.service.ts
View file @
6c4fa0df
...
@@ -57,4 +57,13 @@ export class OwnerService {
...
@@ -57,4 +57,13 @@ export class OwnerService {
console
.
log
(
'
Update owner with id
'
+
owner
.
id
+
'
:
'
+
JSON
.
stringify
(
owner
));
console
.
log
(
'
Update owner with id
'
+
owner
.
id
+
'
:
'
+
JSON
.
stringify
(
owner
));
return
this
.
httpClient
.
put
<
Owner
>
(
this
.
messageBaseUri
+
'
/
'
+
owner
.
id
,
owner
);
return
this
.
httpClient
.
put
<
Owner
>
(
this
.
messageBaseUri
+
'
/
'
+
owner
.
id
,
owner
);
}
}
/**
* Delete an owner from the backend
* @param id
*/
deleteOwner
(
id
:
number
):
Observable
<
Object
>
{
console
.
log
(
'
Delete owner with id
'
+
id
);
return
this
.
httpClient
.
delete
(
this
.
messageBaseUri
+
'
/
'
+
id
);
}
}
}
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