diff --git a/client/src/lists/forms/CUD.js b/client/src/lists/forms/CUD.js
index 9a9fdc5f..7f1b808a 100644
--- a/client/src/lists/forms/CUD.js
+++ b/client/src/lists/forms/CUD.js
@@ -10,6 +10,7 @@ import {
AlignedRow,
Button,
ButtonRow,
+ CheckBox,
Dropdown,
Fieldset,
filterData,
@@ -45,7 +46,9 @@ export default class CUD extends Component {
this.state = {
previewContents: null,
- previewFullscreen: false
+ previewFullscreen: false,
+ fromSourceCustomForms: false,
+ sourceCustomForms: null,
};
this.serverValidatedFields = [
@@ -330,8 +333,10 @@ export default class CUD extends Component {
const data = {
name: '',
description: '',
+ fromSourceCustomForms: false,
+ sourceCustomForms: null,
selectedTemplate: 'layout',
- namespace: mailtrainConfig.user.namespace
+ namespace: mailtrainConfig.user.namespace,
};
this.supplyDefaults(data);
@@ -349,6 +354,12 @@ export default class CUD extends Component {
}
validateNamespace(t, state);
+
+ if (state.getIn(['fromSourceCustomForms', 'value']) && !state.getIn(['sourceCustomForms', 'value'])) {
+ state.setIn(['sourceCustomForms', 'error'], t('sourceCustomFormsMustNotBeEmpty'));
+ } else {
+ state.setIn(['sourceCustomForms', 'error'], null);
+ }
let formsServerValidationRunning = false;
const formsErrors = [];
@@ -380,21 +391,20 @@ export default class CUD extends Component {
}
@withFormErrorHandlers
- async submitHandler(submitAndLeave, copy) {
+ async submitHandler(submitAndLeave) {
const t = this.props.t;
-
+
let sendMethod, url;
if (this.props.entity) {
- if(copy){
- sendMethod = FormSendMethod.POST;
- url = `rest/forms/${this.props.entity.id}`
- }else{
- sendMethod = FormSendMethod.PUT;
- url = `rest/forms/${this.props.entity.id}`
- }
+ sendMethod = FormSendMethod.PUT;
+ url = `rest/forms/${this.props.entity.id}`;
} else {
sendMethod = FormSendMethod.POST;
- url = 'rest/forms'
+ if(this.getFormValue('sourceCustomForms')!=null){
+ url = `rest/forms/${this.getFormValue('sourceCustomForms')}`;
+ }else{
+ url = 'rest/forms';
+ }
}
this.disableForm();
@@ -408,22 +418,14 @@ export default class CUD extends Component {
this.navigateToWithFlashMessage('/lists/forms', 'success', t('customFormsUpdated'));
} else {
await this.getFormValuesFromURL(`rest/forms/${this.props.entity.id}`);
- this.enableForm();
- if(copy){
- this.navigateToWithFlashMessage(`/lists/forms`, 'success', t('customFormsCopied'));
- }else{
- this.setFormStatusMessage('success', t('customFormsUpdated'));
- }
+ this.enableForm()
+ this.setFormStatusMessage('success', t('customFormsUpdated'));
}
} else {
if (submitAndLeave) {
this.navigateToWithFlashMessage('/lists/forms', 'success', t('customFormsCreated'));
} else {
- if(copy){
- this.navigateToWithFlashMessage(`/lists/forms`, 'success', t('customFormsCopied'));
- }else{
- this.navigateToWithFlashMessage(`/lists/forms/${submitResult}/edit`, 'success', t('customFormsCreated'));
- }
+ this.navigateToWithFlashMessage(`/lists/forms/${submitResult}/edit`, 'success', t('customFormsCreated'));
}
}
} else {
@@ -469,6 +471,12 @@ export default class CUD extends Component {
});
}
+ const customFormsColumns = [
+ { data: 1, title: t('name') },
+ { data: 2, title: t('description') },
+ { data: 3, title: t('namespace') }
+ ];
+
const listsColumns = [
{ data: 0, title: "#" },
{ data: 1, title: t('name') },
@@ -501,62 +509,72 @@ export default class CUD extends Component {
-