From 1bf37e65a3e8c860cafafe2aa2792847030491bb Mon Sep 17 00:00:00 2001 From: root Date: Tue, 23 Jul 2019 12:35:41 +0200 Subject: [PATCH] Clone from existing custom forms Added --- client/src/lists/forms/CUD.js | 167 ++++++++++++++++------------- locales/en-US-last-run/common.json | 1 + locales/en-US/common.json | 1 + locales/es-ES/common.json | 4 +- locales/pt-BR/common.json | 5 +- server/models/forms.js | 22 ++-- server/routes/rest/forms.js | 5 +- 7 files changed, 108 insertions(+), 97 deletions(-) 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 { -
- + {!isEdit && + + } + + {this.getFormValue('fromSourceCustomForms') && + + } - { previewListId && -
- -
- - {t('noteTheseLinksAreSolelyForAQuickPreview')} - -
-

- await this.preview('web_subscribe')}>Subscribe - {' | '} - await this.preview('web_confirm_subscription_notice')}>Confirm Subscription Notice - {' | '} - await this.preview('web_confirm_unsubscription_notice')}>Confirm Unsubscription Notice - {' | '} - await this.preview('web_subscribed_notice')}>Subscribed Notice - {' | '} - await this.preview('web_updated_notice')}>Updated Notice - {' | '} - await this.preview('web_unsubscribed_notice')}>Unsubscribed Notice - {' | '} - await this.preview('web_manual_unsubscribe_notice')}>Manual Unsubscribe Notice - {' | '} - await this.preview('web_unsubscribe')}>Unsubscribe - {' | '} - await this.preview('web_manage')}>Manage - {' | '} - await this.preview('web_manage_address')}>Manage Address - {' | '} - await this.preview('web_privacy_policy_notice')}>Privacy Policy -

-
- {this.state.previewContents && -
-
-
- {this.state.fullscreen && } -
{t('formPreview') + ' ' + this.state.previewLabel}
+ {!this.getFormValue('fromSourceCustomForms') && +
+ + + { previewListId && +
+ +
+ + {t('noteTheseLinksAreSolelyForAQuickPreview')} +
-
- this.preview(this.state.previewKey)} title={t('refresh')}> - this.setState({previewFullscreen: !this.state.previewFullscreen})} title={t('maximizeEditor')}> - this.setState({previewContents: null, previewFullscreen: false})} title={t('closePreview')}> +

+ await this.preview('web_subscribe')}>Subscribe + {' | '} + await this.preview('web_confirm_subscription_notice')}>Confirm Subscription Notice + {' | '} + await this.preview('web_confirm_unsubscription_notice')}>Confirm Unsubscription Notice + {' | '} + await this.preview('web_subscribed_notice')}>Subscribed Notice + {' | '} + await this.preview('web_updated_notice')}>Updated Notice + {' | '} + await this.preview('web_unsubscribed_notice')}>Unsubscribed Notice + {' | '} + await this.preview('web_manual_unsubscribe_notice')}>Manual Unsubscribe Notice + {' | '} + await this.preview('web_unsubscribe')}>Unsubscribe + {' | '} + await this.preview('web_manage')}>Manage + {' | '} + await this.preview('web_manage_address')}>Manage Address + {' | '} + await this.preview('web_privacy_policy_notice')}>Privacy Policy +

+ + {this.state.previewContents && + - + }
- } -
- } -
+ } +
+ } - { selectedTemplate && + {!this.getFormValue('fromSourceCustomForms') && selectedTemplate &&
@@ -565,8 +583,7 @@ export default class CUD extends Component {