Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
uphrh-smf-web
Commits
458fd2ec
Commit
458fd2ec
authored
2 years ago
by
devendra
Browse files
Options
Download
Patches
Plain Diff
Feat: Delete form feature
parent
2aa78683
master
delete-form
1 merge request
!12
Delete form
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/form/ListForms.js
+47
-0
src/components/form/ListForms.js
src/helpers/auth.js
+9
-0
src/helpers/auth.js
with
56 additions
and
0 deletions
+56
-0
src/components/form/ListForms.js
+
47
−
0
View file @
458fd2ec
...
...
@@ -4,12 +4,16 @@ import { FormService } from "../../services/form.service";
import
{
APP
,
LANG
}
from
"
../../constants
"
;
import
Notify
from
"
../../helpers/notify
"
;
import
{
BtnTwo
}
from
"
../buttons
"
;
import
{
ConfirmModal
}
from
"
../../components/modal
"
;
import
Helper
from
"
../../helpers/auth
"
;
class
ListForms
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
forms
:
[],
isAdmin
:
Helper
.
isAdmin
(),
formToDelete
:
{},
};
this
.
getFormShortCode
=
this
.
getFormShortCode
.
bind
(
this
);
}
...
...
@@ -105,7 +109,30 @@ class ListForms extends Component {
// history: PropTypes.object.isRequired,
// };
deleteForm
=
()
=>
{
this
.
setState
({
showConfirmModal
:
false
});
// FormService.deleteForm(formToDelete?.id).then(
// (response) => {
// if (response.statusInfo && response.statusInfo.statusCode === APP.CODE.SUCCESS) {
// console.log(response.responseData);
// Notify.success('Form deleted successfully!');
// getAllForms();
// } else {
// Notify.error(response.statusInfo.errorMessage);
// }
// this.setState({showConfirmModal: false});
// },
// (error) => {
// error.statusInfo
// ? Notify.error(error.statusInfo.errorMessage)
// : Notify.error(error.message);
// this.setState({showConfirmModal: false});
// }
// );
}
render
()
{
const
{
isAdmin
,
showConfirmModal
,
formToDelete
}
=
this
.
state
;
return
(
<
Fragment
>
<
div
className
=
"
row pt-2
"
>
...
...
@@ -194,7 +221,18 @@ class ListForms extends Component {
<
/td
>
<
td
className
=
"
td-preview
"
>
{
form
.
status
===
LANG
.
FORM_STATUS
.
DRAFT
&&
(
<>
<
Link
to
=
{
`/forms/
${
form
.
id
}
/edit`
}
>
Edit
<
/Link
>
{
isAdmin
&&
(
<
span
className
=
"
ml-3 text-danger pointer
"
onClick
=
{
()
=>
{
this
.
setState
({
formToDelete
:
form
,
showConfirmModal
:
true
})
}
}
>
Delete
<
/span
>
)}
<
/
>
)}
{
form
.
status
!==
LANG
.
FORM_STATUS
.
DRAFT
&&
(
<
span
className
=
"
font-weight-bold black-16
"
>
Edit
<
/span
>
...
...
@@ -206,6 +244,15 @@ class ListForms extends Component {
<
/table
>
<
/div
>
<
/div
>
{
showConfirmModal
&&
(
<
ConfirmModal
title
=
"
Delete Form
"
onConfirm
=
{
this
.
deleteForm
}
onCancel
=
{()
=>
{
this
.
setState
({
showConfirmModal
:
false
,
formToDelete
:
{}});
}}
>
Do
you
want
to
delete
{
formToDelete
?.
title
}
?
<
/ConfirmModal
>
)}
<
/Fragment
>
);
}
...
...
This diff is collapsed.
Click to expand it.
src/helpers/auth.js
+
9
−
0
View file @
458fd2ec
...
...
@@ -31,6 +31,15 @@ const Auth = {
}
else
{
return
false
;
}
},
isAdmin
()
{
const
userRole
=
this
.
getUserRole
();
if
(
userRole
===
APP
.
ROLE
.
SUPER_ADMIN
||
userRole
===
APP
.
ROLE
.
REGULATOR
)
{
return
true
;
}
else
{
return
false
;
}
}
};
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets