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
aa84cca4
Commit
aa84cca4
authored
2 years ago
by
devendra
Browse files
Options
Download
Patches
Plain Diff
Feat: Duplicate form feature
parent
458fd2ec
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/AddForm.js
+58
-18
src/components/form/AddForm.js
src/components/form/ListForms.js
+1
-0
src/components/form/ListForms.js
with
59 additions
and
18 deletions
+59
-18
src/components/form/AddForm.js
+
58
−
18
View file @
aa84cca4
...
...
@@ -16,6 +16,7 @@ import Header from "./../common/Header";
import
Sortable
from
"
sortablejs
"
;
import
{
BtnTwo
}
from
"
../buttons/BtnTwo
"
;
import
{
BtnOne
}
from
"
../buttons/BtnOne
"
;
import
{
ConfirmModal
}
from
"
../../components/modal
"
;
let
strings
=
new
LocalizedStrings
(
translations
);
...
...
@@ -27,6 +28,7 @@ class AddForm extends Component {
this
.
resetElements
=
this
.
resetElements
.
bind
(
this
);
this
.
handleChange
=
this
.
handleChange
.
bind
(
this
);
this
.
submit
=
this
.
submit
.
bind
(
this
);
this
.
saveFormDetails
=
this
.
saveFormDetails
.
bind
(
this
);
this
.
state
=
{
language
:
"
en
"
,
formElements
:
[],
...
...
@@ -39,6 +41,7 @@ class AddForm extends Component {
fields
:
[],
},
breadcrumbData
:
[],
showDuplicateConfirmModal
:
false
,
};
}
...
...
@@ -276,30 +279,46 @@ class AddForm extends Component {
}
if
(
allowSubmission
)
{
FormService
.
add
(
formData
).
then
(
(
response
)
=>
{
if
(
response
.
statusInfo
.
statusCode
===
APP
.
CODE
.
SUCCESS
)
{
Notify
.
success
(
response
.
statusInfo
.
statusMessage
);
// this.props.updateParent(response.responseData.id);
setTimeout
(()
=>
{
this
.
props
.
history
.
push
(
"
/manage?tab=1
"
);
},
500
);
}
else
{
Notify
.
error
(
response
.
statusInfo
.
errorMessage
);
}
},
(
error
)
=>
{
error
.
statusInfo
?
Notify
.
error
(
error
.
statusInfo
.
errorMessage
)
:
Notify
.
error
(
error
.
message
);
}
);
this
.
saveFormDetails
(
formData
,
false
);
}
else
{
Notify
.
error
(
"
Kindly fill all the fields
"
);
}
};
saveFormDetails
=
(
formData
,
isDuplicate
)
=>
{
FormService
.
add
(
formData
).
then
(
(
response
)
=>
{
if
(
response
.
statusInfo
.
statusCode
===
APP
.
CODE
.
SUCCESS
)
{
if
(
isDuplicate
)
{
Notify
.
success
(
"
Duplicate form is added successfully
"
);
this
.
setState
({
showDuplicateConfirmModal
:
false
});
}
else
{
Notify
.
success
(
response
.
statusInfo
.
statusMessage
);
}
// this.props.updateParent(response.responseData.id);
setTimeout
(()
=>
{
this
.
props
.
history
.
push
(
"
/manage?tab=1
"
);
},
500
);
}
else
{
Notify
.
error
(
response
.
statusInfo
.
errorMessage
);
}
},
(
error
)
=>
{
error
.
statusInfo
?
Notify
.
error
(
error
.
statusInfo
.
errorMessage
)
:
Notify
.
error
(
error
.
message
);
}
);
}
duplicateForm
=
()
=>
{
let
formData
=
{...
this
.
state
.
formDetails
,
id
:
""
,
title
:
'
Copy of
'
+
this
.
state
.
formDetails
.
title
};
this
.
saveFormDetails
(
formData
,
true
);
}
render
()
{
const
{
formDetails
,
showDuplicateConfirmModal
}
=
this
.
state
;
strings
.
setLanguage
(
localStorage
.
getItem
(
"
language
"
)
||
this
.
state
.
language
);
...
...
@@ -339,6 +358,18 @@ class AddForm extends Component {
/
>
<
/div
>
)}
{
this
.
state
.
formDetails
.
status
===
LANG
.
FORM_STATUS
.
DRAFT
&&
(
<
div
className
=
"
mr-3
"
>
<
BtnOne
label
=
"
Duplicate
"
btnType
=
"
button
"
isLink
=
{
false
}
link
=
""
clickHandler
=
{(
e
)
=>
this
.
setState
({
showDuplicateConfirmModal
:
true
})}
/
>
<
/div
>
)}
<
div
className
=
"
mr-0
"
>
<
BtnTwo
label
=
"
Submit
"
...
...
@@ -514,6 +545,15 @@ class AddForm extends Component {
<
/div
>
<
/div
>
<
/div
>
{
showDuplicateConfirmModal
&&
(
<
ConfirmModal
title
=
"
Duplicate Form
"
onConfirm
=
{
this
.
duplicateForm
}
onCancel
=
{()
=>
{
this
.
setState
({
showDuplicateConfirmModal
:
false
});
}}
>
Do
you
want
to
delete
{
formDetails
?.
title
}
?
<
/ConfirmModal
>
)}
<
/Fragment
>
);
}
...
...
This diff is collapsed.
Click to expand it.
src/components/form/ListForms.js
+
1
−
0
View file @
aa84cca4
...
...
@@ -14,6 +14,7 @@ class ListForms extends Component {
forms
:
[],
isAdmin
:
Helper
.
isAdmin
(),
formToDelete
:
{},
showConfirmModal
:
false
,
};
this
.
getFormShortCode
=
this
.
getFormShortCode
.
bind
(
this
);
}
...
...
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