added translate for form name

This commit is contained in:
decoder 2024-03-06 23:11:10 +05:00
parent c18c2d0f32
commit fd9dc5d545
8 changed files with 1809 additions and 1398 deletions

View File

@ -191,7 +191,7 @@ class FormController extends Controller
public function update($id) public function update($id)
{ {
try { try {
$input = request()->only('name', 'description', 'slug'); $input = request()->only('name', 'name_ru', 'name_est', 'description', 'slug');
$form_data = [ $form_data = [
'form' => request()->input('form'), 'form' => request()->input('form'),
'emailConfig' => request()->input('email_config'), 'emailConfig' => request()->input('email_config'),
@ -210,6 +210,8 @@ class FormController extends Controller
$form = Form::find($id); $form = Form::find($id);
$form->name = $input['name']; $form->name = $input['name'];
$form->name_ru = $input['name_ru'];
$form->name_est = $input['name_est'];
$form->slug = $input['slug']; $form->slug = $input['slug'];
$form->description = $input['description']; $form->description = $input['description'];
$form->schema = $input['schema']; $form->schema = $input['schema'];

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\UserSetting;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Session;
@ -17,6 +18,14 @@ class LocaleController extends Controller
app()->setLocale($locale); app()->setLocale($locale);
$userSetting = UserSetting::where('user_id', auth()->user()->id)->first();
if (!empty($userSetting)) {
$userSetting->update([
'language' => $locale
]);
}
return redirect()->back(); return redirect()->back();
} }
} }

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\UserSetting; use App\UserSetting;
use DateTimeZone; use DateTimeZone;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session;
class ManageSettingsController extends Controller class ManageSettingsController extends Controller
{ {
@ -57,6 +58,14 @@ class ManageSettingsController extends Controller
$setting = UserSetting::where('user_id', $input['user_id'])->first(); $setting = UserSetting::where('user_id', $input['user_id'])->first();
if (! in_array($request->language, ['en', 'ru', 'est'])) {
abort(400);
}
Session::put('locale', $request->language);
app()->setLocale($request->language);
if (empty($setting)) { if (empty($setting)) {
UserSetting::create($input); UserSetting::create($input);
} else { } else {

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('forms', function (Blueprint $table) {
$table->string('name_ru')->after('name')->nullable();
$table->string('name_est')->after('name_ru')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('forms', function (Blueprint $table) {
//
});
}
};

View File

@ -685,4 +685,6 @@ return [
'placeholder_ru' => 'Placeholder in Ru', 'placeholder_ru' => 'Placeholder in Ru',
'options_est' => 'Options in est', 'options_est' => 'Options in est',
'options_ru' => 'Options in Ru', 'options_ru' => 'Options in Ru',
'form_name_est' => 'Form Name est',
'form_name_ru' => 'Form Name ru',
]; ];

View File

@ -3,114 +3,244 @@
<form id="create_form"> <form id="create_form">
<ul class="nav nav-tabs" id="myTab" role="tablist"> <ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation"> <li class="nav-item" role="presentation">
<a class="nav-link active" id="form-tab" data-toggle="tab" href="#form_builder_tab" role="tab" aria-controls="form" aria-selected="true"> <a
<i class="fas fa-align-justify"></i> {{ trans('messages.form') }} class="nav-link active"
id="form-tab"
data-toggle="tab"
href="#form_builder_tab"
role="tab"
aria-controls="form"
aria-selected="true"
>
<i class="fas fa-align-justify"></i> {{ trans("messages.form") }}
</a> </a>
</li> </li>
<li class="nav-item" role="presentation" id="tour_step_4"> <li class="nav-item" role="presentation" id="tour_step_4">
<a class="nav-link" id="field_conditions-tab" data-toggle="tab" href="#field_conditions_tab" role="tab" aria-controls="field_conditions" aria-selected="false"> <a
<i class="fas fa-wrench"></i> {{trans('messages.field_conditions')}} class="nav-link"
id="field_conditions-tab"
data-toggle="tab"
href="#field_conditions_tab"
role="tab"
aria-controls="field_conditions"
aria-selected="false"
>
<i class="fas fa-wrench"></i>
{{ trans("messages.field_conditions") }}
</a> </a>
</li> </li>
<li class="nav-item" role="presentation" id="tour_step_5"> <li class="nav-item" role="presentation" id="tour_step_5">
<a class="nav-link" id="email-tab" data-toggle="tab" href="#email_settings_tab" role="tab" aria-controls="email" aria-selected="false"> <a
<i class="fas fa-envelope"></i> {{trans('messages.email')}} class="nav-link"
id="email-tab"
data-toggle="tab"
href="#email_settings_tab"
role="tab"
aria-controls="email"
aria-selected="false"
>
<i class="fas fa-envelope"></i> {{ trans("messages.email") }}
</a> </a>
</li> </li>
<li class="nav-item" role="presentation" id="tour_step_6"> <li class="nav-item" role="presentation" id="tour_step_6">
<a class="nav-link" id="form-settings-tab" data-toggle="tab" href="#form_settings_tab" role="tab" aria-controls="form-settings" aria-selected="false"> <a
<i class="fas fa-cogs"></i> {{trans('messages.settings')}} class="nav-link"
id="form-settings-tab"
data-toggle="tab"
href="#form_settings_tab"
role="tab"
aria-controls="form-settings"
aria-selected="false"
>
<i class="fas fa-cogs"></i> {{ trans("messages.settings") }}
</a> </a>
</li> </li>
<li class="nav-item" role="presentation" id="tour_step_7"> <li class="nav-item" role="presentation" id="tour_step_7">
<a class="nav-link" id="mailchimp-tab" data-toggle="tab" href="#mailchimp_tab" role="tab" aria-controls="mailchimp" aria-selected="false"> <a
<i class="fab fa-mailchimp fa-lg"></i> {{trans('messages.mailchimp')}} class="nav-link"
id="mailchimp-tab"
data-toggle="tab"
href="#mailchimp_tab"
role="tab"
aria-controls="mailchimp"
aria-selected="false"
>
<i class="fab fa-mailchimp fa-lg"></i>
{{ trans("messages.mailchimp") }}
</a> </a>
</li> </li>
<li class="nav-item" role="presentation" id="acelle_mail_tour" <li
v-if="is_acelle_mail_enabled"> class="nav-item"
<a class="nav-link" id="acelle-mail-tab" data-toggle="tab" href="#acelle_mail_tab" role="tab"> role="presentation"
id="acelle_mail_tour"
v-if="is_acelle_mail_enabled"
>
<a
class="nav-link"
id="acelle-mail-tab"
data-toggle="tab"
href="#acelle_mail_tab"
role="tab"
>
<i class="fas fa-mail-bulk"></i> <i class="fas fa-mail-bulk"></i>
{{ acelle_mail_name }} {{ acelle_mail_name }}
</a> </a>
</li> </li>
<li class="nav-item" role="presentation" id="webhook_tour"> <li class="nav-item" role="presentation" id="webhook_tour">
<a class="nav-link" id="webhook-tab" data-toggle="tab" href="#webhook_tab" role="tab"> <a
class="nav-link"
id="webhook-tab"
data-toggle="tab"
href="#webhook_tab"
role="tab"
>
<i class="far fa-paper-plane"></i> <i class="far fa-paper-plane"></i>
{{trans('messages.webhook')}} {{ trans("messages.webhook") }}
</a> </a>
</li> </li>
<li class="nav-item" role="presentation" id="tour_step_8"> <li class="nav-item" role="presentation" id="tour_step_8">
<a class="nav-link" id="js-css-tab" data-toggle="tab" href="#custom_js_css_tab" role="tab" aria-controls="js-css" aria-selected="false"> <a
<i class="fas fa-file-code"></i> {{trans('messages.additional_js_css')}} class="nav-link"
id="js-css-tab"
data-toggle="tab"
href="#custom_js_css_tab"
role="tab"
aria-controls="js-css"
aria-selected="false"
>
<i class="fas fa-file-code"></i>
{{ trans("messages.additional_js_css") }}
</a> </a>
</li> </li>
<li class="nav-item" role="presentation"> <li class="nav-item" role="presentation">
<button type="button" class="btn btn-xs bg-gradient-danger app_tour_play_btn" @click="getAppTour"> <button
type="button"
class="btn btn-xs bg-gradient-danger app_tour_play_btn"
@click="getAppTour"
>
<i class="far fa-play-circle"></i> <i class="far fa-play-circle"></i>
{{trans('messages.app_tour')}} {{ trans("messages.app_tour") }}
</button> </button>
</li> </li>
</ul> </ul>
<div class="tab-content" id="myTabContent"> <div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="form_builder_tab" role="tabpanel" aria-labelledby="form-tab"> <div
<form-tab :selected_elements="selected_elements" :settings="settings" :form="form" :placeholder_img="placeholderImg" :form_custom_attributes="form_custom_attributes"></form-tab> class="tab-pane fade show active"
id="form_builder_tab"
role="tabpanel"
aria-labelledby="form-tab"
>
<form-tab
:selected_elements="selected_elements"
:settings="settings"
:form="form"
:placeholder_img="placeholderImg"
:form_custom_attributes="form_custom_attributes"
></form-tab>
</div> </div>
<div class="tab-pane fade" id="field_conditions_tab" role="tabpanel" aria-labelledby="field_conditions-tab"> <div
class="tab-pane fade"
id="field_conditions_tab"
role="tabpanel"
aria-labelledby="field_conditions-tab"
>
<condtionalFields <condtionalFields
:conditional-fields="conditional_fields" :conditional-fields="conditional_fields"
:selected-elements="selected_elements" :selected-elements="selected_elements"
></condtionalFields> ></condtionalFields>
</div> </div>
<div class="tab-pane fade" id="email_settings_tab" role="tabpanel" aria-labelledby="email-tab"> <div
class="tab-pane fade"
id="email_settings_tab"
role="tabpanel"
aria-labelledby="email-tab"
>
<email-tab <email-tab
:emailConfig="emailConfig" :emailConfig="emailConfig"
:selected_elements="selected_elements" :selected_elements="selected_elements"
:settings="settings"> :settings="settings"
>
</email-tab> </email-tab>
</div> </div>
<div class="tab-pane fade" id="form_settings_tab" role="tabpanel" aria-labelledby="form-settings-tab"> <div
class="tab-pane fade"
id="form_settings_tab"
role="tabpanel"
aria-labelledby="form-settings-tab"
>
<settings-tab <settings-tab
:settings="settings" :settings="settings"
:selected_elements="selected_elements"> :selected_elements="selected_elements"
>
</settings-tab> </settings-tab>
</div> </div>
<div class="tab-pane fade" id="mailchimp_tab" role="tabpanel" aria-labelledby="mailchimp-tab"> <div
class="tab-pane fade"
id="mailchimp_tab"
role="tabpanel"
aria-labelledby="mailchimp-tab"
>
<mailchimp <mailchimp
:details="mailchimp_details" :details="mailchimp_details"
:selected_elements="selected_elements"> :selected_elements="selected_elements"
>
</mailchimp> </mailchimp>
</div> </div>
<div class="tab-pane fade" id="acelle_mail_tab" role="tabpanel" aria-labelledby="acelle-mail-tab" <div
v-if="is_acelle_mail_enabled"> class="tab-pane fade"
id="acelle_mail_tab"
role="tabpanel"
aria-labelledby="acelle-mail-tab"
v-if="is_acelle_mail_enabled"
>
<acelle-mail <acelle-mail
:acelle-mail="acelle_mail_info" :acelle-mail="acelle_mail_info"
:selected_elements="selected_elements"> :selected_elements="selected_elements"
>
</acelle-mail> </acelle-mail>
</div> </div>
<div class="tab-pane fade" id="webhook_tab" role="tabpanel" aria-labelledby="webhook-tab"> <div
<webhook class="tab-pane fade"
:webhook-info="webhook_info"/> id="webhook_tab"
role="tabpanel"
aria-labelledby="webhook-tab"
>
<webhook :webhook-info="webhook_info" />
</div> </div>
<div class="tab-pane fade" id="custom_js_css_tab" role="tabpanel" aria-labelledby="js-css-tab"> <div
class="tab-pane fade"
id="custom_js_css_tab"
role="tabpanel"
aria-labelledby="js-css-tab"
>
<additional-js-css :additional-data="additionalData"> <additional-js-css :additional-data="additionalData">
</additional-js-css> </additional-js-css>
</div> </div>
</div> </div>
<!-- submit button --> <!-- submit button -->
<div v-if="selected_elements.length"> <div v-if="selected_elements.length">
<hr class="mt-5"> <hr class="mt-5" />
<div id="tour_step_9"> <div id="tour_step_9">
<button type="submit" class="btn btn-success btn-lg float-right ladda-form-save-btn mb-2" name="submit_type" value="0"> <button
{{trans('messages.save_as_form')}} type="submit"
class="btn btn-success btn-lg float-right ladda-form-save-btn mb-2"
name="submit_type"
value="0"
>
{{ trans("messages.save_as_form") }}
</button> </button>
<button type="submit" class="btn btn-secondary btn-lg float-right ladda-template-save-btn mb-2 mr-1" name="submit_type" value="1" v-if="disabled_save_temp_btn"> <button
{{trans('messages.save_as_template')}} type="submit"
class="btn btn-secondary btn-lg float-right ladda-template-save-btn mb-2 mr-1"
name="submit_type"
value="1"
v-if="disabled_save_temp_btn"
>
{{ trans("messages.save_as_template") }}
</button> </button>
</div> </div>
</div> </div>
<AskUserChoice id="userChoiceModal"> <AskUserChoice id="userChoiceModal"> </AskUserChoice>
</AskUserChoice>
</form> </form>
</div> </div>
</template> </template>
@ -126,7 +256,7 @@
import AcelleMail from "./AcelleMail"; import AcelleMail from "./AcelleMail";
import Webhook from "./Webhook/Webhook"; import Webhook from "./Webhook/Webhook";
export default { export default {
props: ['formData', 'placeholderImg', 'saveTemplate'], props: ["formData", "placeholderImg", "saveTemplate"],
components: { components: {
formTab, formTab,
emailTab, emailTab,
@ -136,7 +266,7 @@
condtionalFields, condtionalFields,
AskUserChoice, AskUserChoice,
AcelleMail, AcelleMail,
Webhook Webhook,
}, },
data() { data() {
return { return {
@ -145,38 +275,38 @@
form: [], form: [],
emailConfig: {}, emailConfig: {},
settings: {}, settings: {},
dashboard:'', dashboard: "",
additionalData: {}, additionalData: {},
mailchimp_details: {}, mailchimp_details: {},
conditional_fields: [], conditional_fields: [],
form_scheduling: { form_scheduling: {
closed_msg:'The form has been closed now!', closed_msg: "The form has been closed now!",
start_date_time:'', start_date_time: "",
end_date_time:'', end_date_time: "",
is_enabled: false is_enabled: false,
}, },
form_submision_ref: { form_submision_ref: {
is_enabled: false, is_enabled: false,
prefix: '', prefix: "",
suffix: '', suffix: "",
start_no: '1', start_no: "1",
min_digit: '4' min_digit: "4",
}, },
form_theme: 'default', form_theme: "default",
responseData: [], responseData: [],
is_enabled_draft_submit: 0, is_enabled_draft_submit: 0,
form_custom_attributes: [], form_custom_attributes: [],
disabled_save_temp_btn: null, disabled_save_temp_btn: null,
password_protection: { password_protection: {
is_enabled: false, is_enabled: false,
password: '' password: "",
}, },
pdf_design: { pdf_design: {
header: `<h1 style="margin-top: 0px; margin-bottom: 0.5rem; font-family: &quot;Source Sans Pro&quot;, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; line-height: 1.2; color: rgb(0, 0, 0); font-size: 2.5rem; text-align: center;"><span style="color: rgb(33, 37, 41); font-size: 12.8px; text-align: left; background-color: rgb(244, 246, 249);"><span style="font-size: 24px;"><span style="font-weight: bolder;">{form_name}</span></span><sub style="font-size: 9.6px;"><span style="font-size: 12px;">{submission_date}</span></sub></span></h1>` header: `<h1 style="margin-top: 0px; margin-bottom: 0.5rem; font-family: &quot;Source Sans Pro&quot;, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; line-height: 1.2; color: rgb(0, 0, 0); font-size: 2.5rem; text-align: center;"><span style="color: rgb(33, 37, 41); font-size: 12.8px; text-align: left; background-color: rgb(244, 246, 249);"><span style="font-size: 24px;"><span style="font-weight: bolder;">{form_name}</span></span><sub style="font-size: 9.6px;"><span style="font-size: 12px;">{submission_date}</span></sub></span></h1>`,
}, },
spread_to_col: { spread_to_col: {
enable: false, enable: false,
column: 2 column: 2,
}, },
acelle_mail_info: {}, acelle_mail_info: {},
is_acelle_mail_enabled: APP.ACELLE_MAIL_ENABLED, is_acelle_mail_enabled: APP.ACELLE_MAIL_ENABLED,
@ -184,40 +314,57 @@
webhook_info: {}, webhook_info: {},
popover_help_text: { popover_help_text: {
enable: false, enable: false,
content: '' content: "",
} },
}; };
}, },
created() { created() {
this.form_parsed = JSON.parse(this.formData); this.form_parsed = JSON.parse(this.formData);
this.form.name = this.form_parsed.name; this.form.name = this.form_parsed.name;
this.form.name_ru = this.form_parsed.name_ru;
this.form.name_est = this.form_parsed.name_est;
this.form.slug = this.form_parsed.slug; this.form.slug = this.form_parsed.slug;
this.form.description = this.form_parsed.description; this.form.description = this.form_parsed.description;
this.form.is_template = this.form_parsed.is_template; this.form.is_template = this.form_parsed.is_template;
this.disabled_save_temp_btn = JSON.parse(this.saveTemplate); this.disabled_save_temp_btn = JSON.parse(this.saveTemplate);
if (this.form_parsed.schema === null) { if (this.form_parsed.schema === null) {
this.emailConfig = this.getData('email_config'); this.emailConfig = this.getData("email_config");
this.settings = this.getData('settings'); this.settings = this.getData("settings");
this.additionalData = {js:'', css:''}; this.additionalData = { js: "", css: "" };
this.conditional_fields = this.getData('conditional_fields'); this.conditional_fields = this.getData("conditional_fields");
} else { } else {
this.selected_elements = this.form_parsed.schema.form; this.selected_elements = this.form_parsed.schema.form;
this.emailConfig = this.form_parsed.schema.emailConfig; this.emailConfig = this.form_parsed.schema.emailConfig;
this.settings = this.form_parsed.schema.settings; this.settings = this.form_parsed.schema.settings;
this.additionalData = _.isNull(this.form_parsed.schema.additional_js_css) ? {js:'', css:''} : this.form_parsed.schema.additional_js_css; this.additionalData = _.isNull(this.form_parsed.schema.additional_js_css)
? { js: "", css: "" }
: this.form_parsed.schema.additional_js_css;
this.mailchimp_details = _.isNull(this.form_parsed.mailchimp_details) ? this.getData('mailchimp') : this.form_parsed.mailchimp_details; this.mailchimp_details = _.isNull(this.form_parsed.mailchimp_details)
? this.getData("mailchimp")
: this.form_parsed.mailchimp_details;
this.acelle_mail_info = _.isEmpty(this.form_parsed.acelle_mail_info) ? this.getData('acelle_mail') : this.form_parsed.acelle_mail_info; this.acelle_mail_info = _.isEmpty(this.form_parsed.acelle_mail_info)
? this.getData("acelle_mail")
: this.form_parsed.acelle_mail_info;
this.conditional_fields = _.isUndefined(this.form_parsed.schema.conditional_fields) ? this.getData('conditional_fields') : this.form_parsed.schema.conditional_fields; this.conditional_fields = _.isUndefined(
this.form_custom_attributes = _.isUndefined(this.form_parsed.schema.form_attributes) ? this.form_custom_attributes : this.form_parsed.schema.form_attributes; this.form_parsed.schema.conditional_fields
)
? this.getData("conditional_fields")
: this.form_parsed.schema.conditional_fields;
this.form_custom_attributes = _.isUndefined(
this.form_parsed.schema.form_attributes
)
? this.form_custom_attributes
: this.form_parsed.schema.form_attributes;
} }
this.webhook_info = this.form_parsed?.webhook_info || this.getData('webhook_info'); this.webhook_info =
this.form_parsed?.webhook_info || this.getData("webhook_info");
this.getNewlyAddedPropertyForExistingForm(); this.getNewlyAddedPropertyForExistingForm();
this.$eventBus.$on('callRedirectUser', (data) => { this.$eventBus.$on("callRedirectUser", (data) => {
$("#userChoiceModal").modal("hide"); $("#userChoiceModal").modal("hide");
setTimeout(() => { setTimeout(() => {
this.redirectUsersAccordingToResponse(data); this.redirectUsersAccordingToResponse(data);
@ -225,12 +372,12 @@
}); });
}, },
beforeDestroy() { beforeDestroy() {
this.$eventBus.$off('callRedirectUser'); this.$eventBus.$off("callRedirectUser");
}, },
mounted() { mounted() {
const self = this; const self = this;
$('form#create_form').validate({ $("form#create_form").validate({
ignore: ".note-editor *", ignore: ".note-editor *",
submitHandler: function (form, e) { submitHandler: function (form, e) {
var field_names = []; var field_names = [];
@ -238,28 +385,45 @@
for (let index = 0; index < self.selected_elements.length; index++) { for (let index = 0; index < self.selected_elements.length; index++) {
self.selected_elements[index].extras.showConfigurator = false; self.selected_elements[index].extras.showConfigurator = false;
if (_.isEmpty(self.selected_elements[index].name)) { if (_.isEmpty(self.selected_elements[index].name)) {
toastr.error(self.trans('messages.field_dont_have_name_property', { toastr.error(
self.trans("messages.field_dont_have_name_property", {
input: self.selected_elements[index].label, input: self.selected_elements[index].label,
})); })
);
return false; return false;
} else if (/\s/.test(self.selected_elements[index].name)) { } else if (/\s/.test(self.selected_elements[index].name)) {
toastr.error(self.trans('messages.field_contain_space', { toastr.error(
self.trans("messages.field_contain_space", {
input: self.selected_elements[index].label, input: self.selected_elements[index].label,
})); })
);
return false; return false;
} else if (_.includes(field_names, self.selected_elements[index].name)) { } else if (
toastr.error(self.trans('messages.field_contain_duplicate_field_name', { _.includes(field_names, self.selected_elements[index].name)
) {
toastr.error(
self.trans("messages.field_contain_duplicate_field_name", {
input: self.selected_elements[index].label, input: self.selected_elements[index].label,
})); })
);
field_names = []; field_names = [];
return false; return false;
}else if (!_.includes(field_names, self.selected_elements[index].name)) { } else if (
!_.includes(field_names, self.selected_elements[index].name)
) {
field_names.push(self.selected_elements[index].name); field_names.push(self.selected_elements[index].name);
} }
} }
} }
let data = _.pick(self.form, ['name', 'description', 'slug']); let data = _.pick(self.form, [
"name",
"name_ru",
"name_est",
"description",
"slug",
]);
console.log(data);
data.form = self.selected_elements; data.form = self.selected_elements;
data.email_config = self.emailConfig; data.email_config = self.emailConfig;
data.settings = self.settings; data.settings = self.settings;
@ -269,26 +433,36 @@
data.conditional_fields = self.conditional_fields; data.conditional_fields = self.conditional_fields;
data.is_template = $("input[name='submit_type']").val(); data.is_template = $("input[name='submit_type']").val();
data.form_attributes = self.form_custom_attributes; data.form_attributes = self.form_custom_attributes;
data.contains_page_break = _.some(self.selected_elements, {type: "page_break"}); data.contains_page_break = _.some(self.selected_elements, {
type: "page_break",
});
data.webhook_info = self.webhook_info; data.webhook_info = self.webhook_info;
//get ladda btn based on submit type //get ladda btn based on submit type
if (data.is_template === '1') { if (data.is_template === "1") {
var ladda = Ladda.create(document.querySelector('.ladda-template-save-btn')); var ladda = Ladda.create(
document.querySelector(".ladda-template-save-btn")
);
} else { } else {
var ladda = Ladda.create(document.querySelector('.ladda-form-save-btn')); var ladda = Ladda.create(
document.querySelector(".ladda-form-save-btn")
);
} }
if ($('form#create_form').valid()) { if ($("form#create_form").valid()) {
//disable both btn and start ladda //disable both btn and start ladda
$("button.ladda-form-save-btn, button.ladda-template-save-btn").attr('disabled', 'disabled'); $("button.ladda-form-save-btn, button.ladda-template-save-btn").attr(
"disabled",
"disabled"
);
ladda.start(); ladda.start();
axios axios
.put('/forms/'+self.form_parsed.id, data) .put("/forms/" + self.form_parsed.id, data)
.then(function (response) { .then(function (response) {
//remove disable from both btn and stop ladda //remove disable from both btn and stop ladda
$("button.ladda-form-save-btn, button.ladda-template-save-btn").removeAttr("disabled"); $(
"button.ladda-form-save-btn, button.ladda-template-save-btn"
).removeAttr("disabled");
ladda.stop(); ladda.stop();
if (response.data.success == true) { if (response.data.success == true) {
@ -302,146 +476,143 @@
console.log(error); console.log(error);
}); });
} }
} },
}); });
//if mpfg_tour not finished call getAppTour //if mpfg_tour not finished call getAppTour
if (_.isNull(localStorage.getItem("mpfg_tour"))) { if (_.isNull(localStorage.getItem("mpfg_tour"))) {
localStorage.setItem("mpfg_tour", 'finished'); localStorage.setItem("mpfg_tour", "finished");
this.getAppTour(); this.getAppTour();
} }
}, },
methods: { methods: {
getData(type) { getData(type) {
if (type == 'email_config') { if (type == "email_config") {
var email = { var email = {
email: { email: {
enable: '', enable: "",
from: '', from: "",
to: '', to: "",
reply_to_email: '', reply_to_email: "",
cc:'', cc: "",
bcc:'', bcc: "",
subject: '', subject: "",
body:'', body: "",
attach_pdf: false attach_pdf: false,
}, },
auto_response: { auto_response: {
from:'', from: "",
to:'', to: "",
subject: '', subject: "",
body: '', body: "",
is_enable: false, is_enable: false,
attach_pdf: false attach_pdf: false,
}, },
smtp: { smtp: {
host:'', host: "",
port:'', port: "",
from_address:'', from_address: "",
from_name:'', from_name: "",
encryption:'', encryption: "",
username:'', username: "",
password:'', password: "",
use_system_smtp:1 use_system_smtp: 1,
} },
}; };
return email; return email;
} else if (type == 'settings') { } else if (type == "settings") {
var setting = { var setting = {
recaptcha: { recaptcha: {
is_enable: 0, is_enable: 0,
site_key:'', site_key: "",
secret_key:'' secret_key: "",
}, },
color: { color: {
label:'#000000', label: "#000000",
error_msg:'#a94442', error_msg: "#a94442",
required_asterisk_color:'#a94442', required_asterisk_color: "#a94442",
background:'#ffffff', background: "#ffffff",
image_path:'', image_path: "",
page_color:'#f4f6f9' page_color: "#f4f6f9",
}, },
notification: { notification: {
post_submit_action:'same_page', post_submit_action: "same_page",
failed_msg:'Something went wrong, please try again.', failed_msg: "Something went wrong, please try again.",
success_msg:'Your submission has been received.', success_msg: "Your submission has been received.",
redirect_url:'', redirect_url: "",
position: 'toast-top-right' position: "toast-top-right",
}, },
submit: { submit: {
text:'Submit', text: "Submit",
loading_text:'Submitting...', loading_text: "Submitting...",
btn_alignment:'float-right', btn_alignment: "float-right",
btn_size:'', btn_size: "",
btn_color:'btn-primary', btn_color: "btn-primary",
btn_style: 'default', btn_style: "default",
btn_icon: 'none', btn_icon: "none",
icon_position:'left' icon_position: "left",
}, },
form_data: { form_data: {
col_visible: [], col_visible: [],
btn_enabled:[ btn_enabled: ["view", "delete"],
'view', 'delete'
]
}, },
background: { background: {
bg_type:'bg_color' bg_type: "bg_color",
}, },
form_scheduling: this.form_scheduling, form_scheduling: this.form_scheduling,
form_submision_ref: this.form_submision_ref, form_submision_ref: this.form_submision_ref,
theme: this.form_theme, theme: this.form_theme,
is_enabled_draft_submit: this.is_enabled_draft_submit, is_enabled_draft_submit: this.is_enabled_draft_submit,
layout: 'classic', layout: "classic",
password_protection: this.password_protection, password_protection: this.password_protection,
pdf_design: this.pdf_design, pdf_design: this.pdf_design,
is_qr_code_enabled: false, is_qr_code_enabled: false,
qr_code_data_format: 'string', qr_code_data_format: "string",
is_ref_num_bar_code_enabled: false, is_ref_num_bar_code_enabled: false,
is_ref_num_qr_code_enabled: false is_ref_num_qr_code_enabled: false,
}; };
return setting; return setting;
} else if(type == 'mailchimp'){ } else if (type == "mailchimp") {
return { return {
is_enable: false, is_enable: false,
api_key: '', api_key: "",
list_id: '', list_id: "",
email_field: '', email_field: "",
name_field: '' name_field: "",
}; };
} else if(type == 'acelle_mail'){ } else if (type == "acelle_mail") {
return { return {
is_enable: false, is_enable: false,
api_token: '', api_token: "",
list_id: '', list_id: "",
campaign_fields: [] campaign_fields: [],
}; };
} else if (type == 'conditional_fields') { } else if (type == "conditional_fields") {
var conditional_fields = [ var conditional_fields = [
{ {
'action':'', action: "",
'element':'', element: "",
'conditions': [ conditions: [
{ {
'condition':'', condition: "",
'value':"", value: "",
'element_type' : 'text', element_type: "text",
'element_index' : '', element_index: "",
'operator' : '==', operator: "==",
'logical_operator' : 'AND' logical_operator: "AND",
} },
] ],
} },
]; ];
return conditional_fields; return conditional_fields;
} else if (type == 'webhook_info') { } else if (type == "webhook_info") {
return { return {
is_enable: false, is_enable: false,
url: '', url: "",
secret_key: '' secret_key: "",
}; };
} }
}, },
@ -449,32 +620,32 @@
const self = this; const self = this;
_.forEach(self.selected_elements, function (element) { _.forEach(self.selected_elements, function (element) {
if (_.isUndefined(element.conditional_class)) { if (_.isUndefined(element.conditional_class)) {
element.conditional_class = ''; element.conditional_class = "";
} }
if (_.isUndefined(element.col)) { if (_.isUndefined(element.col)) {
element.col = 'col-md-12'; element.col = "col-md-12";
} }
if (_.isUndefined(element.popover_help_text)) { if (_.isUndefined(element.popover_help_text)) {
element['popover_help_text'] = _.clone(self.popover_help_text); element["popover_help_text"] = _.clone(self.popover_help_text);
} }
//if spread to col option is undefined for element set to default //if spread to col option is undefined for element set to default
if ( if (
_.includes(['radio', 'checkbox'], element.type) && _.includes(["radio", "checkbox"], element.type) &&
_.isUndefined(element.spread_to_col) _.isUndefined(element.spread_to_col)
) { ) {
element.spread_to_col = self.spread_to_col; element.spread_to_col = self.spread_to_col;
} }
if ( if (
_.includes(['text'], element.type) && _.includes(["text"], element.type) &&
_.includes(['text', 'email', 'number'], element.subtype) && _.includes(["text", "email", "number"], element.subtype) &&
_.isUndefined(element.allowed_input) _.isUndefined(element.allowed_input)
) { ) {
element.allowed_input = { element.allowed_input = {
values:'', values: "",
error_msg: 'This value is not allowed.' error_msg: "This value is not allowed.",
}; };
} }
}); });
@ -492,19 +663,19 @@
} }
if (_.isUndefined(self.settings.is_qr_code_enabled)) { if (_.isUndefined(self.settings.is_qr_code_enabled)) {
Vue.set(self.settings, 'is_qr_code_enabled', false); Vue.set(self.settings, "is_qr_code_enabled", false);
} }
if ( if (
_.isUndefined(self.settings.is_ref_num_bar_code_enabled) || _.isUndefined(self.settings.is_ref_num_bar_code_enabled) ||
_.isUndefined(self.settings.is_ref_num_qr_code_enabled) _.isUndefined(self.settings.is_ref_num_qr_code_enabled)
) { ) {
Vue.set(self.settings, 'is_ref_num_bar_code_enabled', false); Vue.set(self.settings, "is_ref_num_bar_code_enabled", false);
Vue.set(self.settings, 'is_ref_num_qr_code_enabled', false); Vue.set(self.settings, "is_ref_num_qr_code_enabled", false);
} }
if (_.isUndefined(self.settings.qr_code_data_format)) { if (_.isUndefined(self.settings.qr_code_data_format)) {
Vue.set(self.settings, 'qr_code_data_format', 'string'); Vue.set(self.settings, "qr_code_data_format", "string");
} }
if (_.isUndefined(self.settings.is_enabled_draft_submit)) { if (_.isUndefined(self.settings.is_enabled_draft_submit)) {
@ -512,23 +683,23 @@
} }
if (_.isUndefined(self.settings.notification.position)) { if (_.isUndefined(self.settings.notification.position)) {
self.settings.notification.position = 'toast-top-right'; self.settings.notification.position = "toast-top-right";
} }
if (_.isUndefined(self.settings.submit.btn_style)) { if (_.isUndefined(self.settings.submit.btn_style)) {
Vue.set(self.settings.submit, 'btn_style', 'default'); Vue.set(self.settings.submit, "btn_style", "default");
} }
if (_.isUndefined(self.settings.submit.btn_icon)) { if (_.isUndefined(self.settings.submit.btn_icon)) {
Vue.set(self.settings.submit, 'btn_icon', 'none'); Vue.set(self.settings.submit, "btn_icon", "none");
} }
if (_.isUndefined(self.settings.submit.icon_position)) { if (_.isUndefined(self.settings.submit.icon_position)) {
Vue.set(self.settings.submit, 'icon_position', 'left'); Vue.set(self.settings.submit, "icon_position", "left");
} }
if (_.isUndefined(self.settings.color.page_color)) { if (_.isUndefined(self.settings.color.page_color)) {
Vue.set(self.settings.color, 'page_color', '#f4f6f9'); Vue.set(self.settings.color, "page_color", "#f4f6f9");
} }
if (_.isUndefined(self.settings.password_protection)) { if (_.isUndefined(self.settings.password_protection)) {
@ -540,16 +711,15 @@
} }
}, },
redirectUsersAccordingToResponse(choice) { redirectUsersAccordingToResponse(choice) {
if (choice == 'home') { if (choice == "home") {
window.location = this.responseData.redirect; window.location = this.responseData.redirect;
} else if (choice == 'preview') { } else if (choice == "preview") {
window.open(this.responseData.preview, this.responseData.form_name); window.open(this.responseData.preview, this.responseData.form_name);
} }
}, },
getAppTour() { getAppTour() {
if (!$('#appTab a[href="#form-generator"]').hasClass("active")) {
if (!$('#appTab a[href="#form-generator"]').hasClass('active')) { $('#appTab a[href="#form-generator"]').tab("show");
$('#appTab a[href="#form-generator"]').tab('show');
} }
const self = this; const self = this;
@ -557,61 +727,61 @@
intro.setOptions({ intro.setOptions({
steps: [ steps: [
{ {
intro : self.trans('messages.welcome_tour_msg') intro: self.trans("messages.welcome_tour_msg"),
}, },
{ {
element: document.querySelectorAll('#tour_step_1')[0], element: document.querySelectorAll("#tour_step_1")[0],
intro: self.trans('messages.tour_step_1_intro'), intro: self.trans("messages.tour_step_1_intro"),
position: 'right', position: "right",
scrollTo: 'tooltip' scrollTo: "tooltip",
}, },
{ {
element: '#tour_step_2', element: "#tour_step_2",
intro: self.trans('messages.tour_step_2_intro'), intro: self.trans("messages.tour_step_2_intro"),
position: 'right', position: "right",
scrollTo: 'tooltip' scrollTo: "tooltip",
}, },
{ {
element: '#tour_step_3', element: "#tour_step_3",
intro: self.trans('messages.tour_step_3_intro'), intro: self.trans("messages.tour_step_3_intro"),
position: 'bottom', position: "bottom",
scrollTo: 'tooltip' scrollTo: "tooltip",
}, },
{ {
element: '#tour_step_4', element: "#tour_step_4",
intro: self.trans('messages.tour_step_4_intro'), intro: self.trans("messages.tour_step_4_intro"),
scrollTo: 'tooltip' scrollTo: "tooltip",
}, },
{ {
element: '#tour_step_5', element: "#tour_step_5",
intro: self.trans('messages.tour_step_5_intro'), intro: self.trans("messages.tour_step_5_intro"),
scrollTo: 'tooltip' scrollTo: "tooltip",
}, },
{ {
element: '#tour_step_6', element: "#tour_step_6",
intro: self.trans('messages.tour_step_6_intro'), intro: self.trans("messages.tour_step_6_intro"),
scrollTo: 'tooltip' scrollTo: "tooltip",
}, },
{ {
element: '#tour_step_7', element: "#tour_step_7",
intro: self.trans('messages.tour_step_7_intro'), intro: self.trans("messages.tour_step_7_intro"),
scrollTo: 'tooltip' scrollTo: "tooltip",
}, },
{ {
element: '#tour_step_8', element: "#tour_step_8",
intro: self.trans('messages.tour_step_8_intro'), intro: self.trans("messages.tour_step_8_intro"),
scrollTo: 'tooltip' scrollTo: "tooltip",
}, },
{ {
element: '#tour_step_9', element: "#tour_step_9",
intro: self.trans('messages.tour_step_9_intro'), intro: self.trans("messages.tour_step_9_intro"),
scrollTo: 'tooltip' scrollTo: "tooltip",
} },
] ],
}); });
intro.start(); intro.start();
} },
} },
} };
</script> </script>

File diff suppressed because it is too large Load Diff

View File

@ -178,6 +178,15 @@
@section('footer') @section('footer')
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
var lang = `{{session()->get('locale')}}`
var titleColName = 'name';
console.log(lang);
if (lang === 'est') {
titleColName = 'name_est'
} else if (lang === 'ru') {
titleColName = 'name_ru'
}
// form dataTable // form dataTable
var form_table = $('#form_table').DataTable({ var form_table = $('#form_table').DataTable({
@ -196,7 +205,15 @@
{"width": "20%", "targets": 4} {"width": "20%", "targets": 4}
], ],
columns: [ columns: [
{data: 'name', name: 'name'}, {
data: titleColName,
name: titleColName,
createdCell: function (td, cellData, rowData, row, col) {
if (td.innerHTML.length === 0) {
td.innerHTML = rowData.name
}
},
},
{data: 'description', name: 'description'}, {data: 'description', name: 'description'},
{data: 'created_at', name: 'created_at'}, {data: 'created_at', name: 'created_at'},
{data: 'data_count', name: 'data_count', searchable: false}, {data: 'data_count', name: 'data_count', searchable: false},