Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cicer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Quique
cicer
Commits
66b1136c
Commit
66b1136c
authored
4 years ago
by
meskio
Browse files
Options
Downloads
Patches
Plain Diff
Add confirmation modal to product deletion
parent
d0be5a30
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ProductList.js
+32
-3
32 additions, 3 deletions
src/ProductList.js
src/member/MemberEditer.js
+1
-1
1 addition, 1 deletion
src/member/MemberEditer.js
with
33 additions
and
4 deletions
src/ProductList.js
+
32
−
3
View file @
66b1136c
import
React
from
"
react
"
;
import
{
Table
,
Button
,
Alert
}
from
"
react-bootstrap
"
;
import
{
Table
,
Button
,
Alert
,
Modal
}
from
"
react-bootstrap
"
;
import
Fetcher
from
"
./Fetcher
"
;
import
EditableCell
from
"
./EditableCell
"
;
import
ProductAdder
from
"
./ProductAdder
"
;
...
...
@@ -12,9 +12,15 @@ class ProductList extends React.Component {
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
delete
:
{
name
:
null
,
},
products
:
[],
error
:
null
,
};
this
.
modalClose
=
this
.
modalClose
.
bind
(
this
);
this
.
delProduct
=
this
.
delProduct
.
bind
(
this
);
}
update
(
row
,
key
,
value
)
{
...
...
@@ -52,11 +58,13 @@ class ProductList extends React.Component {
});
}
delProduct
(
code
)
{
delProduct
()
{
const
code
=
this
.
state
.
delete
.
code
;
let
products
=
this
.
state
.
products
;
const
index
=
products
.
findIndex
((
p
)
=>
p
.
code
===
code
);
products
.
splice
(
index
,
1
);
this
.
setState
({
products
});
this
.
modalClose
();
fetch
(
url
(
"
/api/product/
"
+
code
),
{
headers
:
{
"
x-authentication
"
:
this
.
context
.
token
},
...
...
@@ -89,6 +97,10 @@ class ProductList extends React.Component {
});
}
modalClose
()
{
this
.
setState
({
delete
:
{
name
:
null
}
});
}
render
()
{
let
alert
=
null
;
if
(
this
.
state
.
error
!==
null
)
{
...
...
@@ -127,7 +139,7 @@ class ProductList extends React.Component {
<
td
sm
=
{
1
}
>
<
Button
variant
=
"
danger
"
onClick
=
{()
=>
this
.
delProduct
(
product
.
code
)}
onClick
=
{()
=>
this
.
setState
({
delete
:
product
}
)}
>
-
<
/Button
>
...
...
@@ -161,6 +173,23 @@ class ProductList extends React.Component {
<
ProductAdder
addProduct
=
{(
p
)
=>
this
.
addProduct
(
p
)}
/
>
<
/div
>
)}
<
Modal
show
=
{
this
.
state
.
delete
.
name
!=
null
}
onHide
=
{
this
.
modalClose
}
>
<
Modal
.
Header
closeButton
>
<
Modal
.
Title
>
Confirmar
la
elminicacion
<
/Modal.Title
>
<
/Modal.Header
>
<
Modal
.
Body
>
¿
Borrar
permanentemente
el
producto
{
this
.
state
.
delete
.
name
}?
<
/Modal.Body
>
<
Modal
.
Footer
>
<
Button
variant
=
"
secondary
"
onClick
=
{
this
.
modalClose
}
>
Cancelar
<
/Button
>
<
Button
variant
=
"
danger
"
onClick
=
{
this
.
delProduct
}
>
Eliminar
<
/Button
>
<
/Modal.Footer
>
<
/Modal
>
<
/Fetcher
>
);
}
...
...
This diff is collapsed.
Click to expand it.
src/member/MemberEditer.js
+
1
−
1
View file @
66b1136c
...
...
@@ -102,7 +102,7 @@ function MemberEditer() {
<
Modal
.
Title
>
Confirmar
la
elminicacion
<
/Modal.Title
>
<
/Modal.Header
>
<
Modal
.
Body
>
¿
Borrar
la
cuenta
permanentemente
la
cuenta
de
{
member
.
name
}?
¿
Borrar
permanentemente
la
cuenta
de
{
member
.
name
}?
<
/Modal.Body
>
<
Modal
.
Footer
>
<
Button
variant
=
"
secondary
"
onClick
=
{
handleClose
}
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment