diff --git a/modules/ContactForm/Providers/ContactFormServiceProvider.php b/modules/ContactForm/Providers/ContactFormServiceProvider.php
index 9f0c298a..6bb4e7c4 100644
--- a/modules/ContactForm/Providers/ContactFormServiceProvider.php
+++ b/modules/ContactForm/Providers/ContactFormServiceProvider.php
@@ -1,8 +1,12 @@
registerTranslations();
$this->registerConfig();
$this->registerViews();
+ $this->registerWidgets();
}
/**
@@ -83,4 +88,11 @@ class ContactFormServiceProvider extends ServiceProvider
{
return array ();
}
+
+ private function registerWidgets()
+ {
+ $registrator = $this->app->make('registerWidget');
+
+ $registrator->register(Address::class, null, ContactForm::getModuleId());
+ }
}
diff --git a/modules/ContactForm/Resources/lang/en/admin/widgets.php b/modules/ContactForm/Resources/lang/en/admin/widgets.php
new file mode 100644
index 00000000..3e09aa89
--- /dev/null
+++ b/modules/ContactForm/Resources/lang/en/admin/widgets.php
@@ -0,0 +1,16 @@
+ [
+ 'name' => 'Address block',
+ 'description' => 'Small widget for displaying address saved in selected contact form.',
+ 'new' => 'New address block',
+ 'edit' => 'Editing address block'
+ ],
+ 'form' => [
+ 'name' => 'Contact form',
+ 'description' => 'Display small contact form anywhere on website.',
+ 'new' => 'New contact block widget'
+ ],
+ 'noContactForms' => 'You have not created any contact form. Try to create one before creating this widget.',
+ 'selectContactForm' => 'Select contact form'
+];
\ No newline at end of file
diff --git a/modules/ContactForm/Resources/views/admin/widgets/address/edit.blade.php b/modules/ContactForm/Resources/views/admin/widgets/address/edit.blade.php
new file mode 100644
index 00000000..00692dd9
--- /dev/null
+++ b/modules/ContactForm/Resources/views/admin/widgets/address/edit.blade.php
@@ -0,0 +1,19 @@
+@extends('admin.layoutWithNavigation')
+
+@section('pageHeading', @trans('contactform::admin/widgets.address.edit'))
+@section('pageDescription', $widget->description)
+
+@section('content')
+
+ @if(!count($forms))
+
@lang('contactform::admin/widgets.noContactForms')
+ @else
+
+ @include('contactform::admin.widgets.address.form', ['action' => route('widgets.postEdit', ['id' => $widget->id])])
+
+
+ @widgetPreview($widget)
+
+ @endif
+@endsection
+
diff --git a/modules/ContactForm/Resources/views/admin/widgets/address/form.blade.php b/modules/ContactForm/Resources/views/admin/widgets/address/form.blade.php
new file mode 100644
index 00000000..e6cda721
--- /dev/null
+++ b/modules/ContactForm/Resources/views/admin/widgets/address/form.blade.php
@@ -0,0 +1,19 @@
+
\ No newline at end of file
diff --git a/modules/ContactForm/Resources/views/admin/widgets/address/new.blade.php b/modules/ContactForm/Resources/views/admin/widgets/address/new.blade.php
new file mode 100644
index 00000000..3a5eef53
--- /dev/null
+++ b/modules/ContactForm/Resources/views/admin/widgets/address/new.blade.php
@@ -0,0 +1,14 @@
+@extends('admin.layoutWithNavigation')
+
+@section('pageHeading', @trans('contactform::admin/widgets.address.new'))
+@section('pageDescription', @trans($type->description))
+
+@section('content')
+
+ @if(!count($forms))
+ @lang('contactform::admin/widgets.noContactForms')
+ @else
+ @include('contactform::admin.widgets.address.form', ['action' => route('widgets.postNew', ['type' => $type])])
+ @endif
+@endsection
+
diff --git a/modules/ContactForm/Widgets/Address/Address.php b/modules/ContactForm/Widgets/Address/Address.php
new file mode 100644
index 00000000..77139c8f
--- /dev/null
+++ b/modules/ContactForm/Widgets/Address/Address.php
@@ -0,0 +1,52 @@
+settings = json_encode(['contactFormId' => $data->contactFormId,]);
+
+ return $widget;
+ }
+}
\ No newline at end of file
diff --git a/modules/ContactForm/Widgets/Address/Presenter.php b/modules/ContactForm/Widgets/Address/Presenter.php
new file mode 100644
index 00000000..1901cfff
--- /dev/null
+++ b/modules/ContactForm/Widgets/Address/Presenter.php
@@ -0,0 +1,76 @@
+settings->contactFormId);
+
+ if (!$form)
+ return null;
+
+ $formData = json_decode($form->module_settings);
+
+ $code = '";
+
+ return $code;
+ }
+
+ /**
+ * Display form for creating new instance of widget
+ *
+ * @param WidgetType $type
+ *
+ * @return mixed
+ */
+ public static function renderAddForm(WidgetType $type)
+ {
+ $contactForms = Content::where('module_handler', config('contactform.handler'))
+ ->get();
+
+ return view('contactform::admin.widgets.address.new', [
+ 'type' => $type,
+ 'widget' => new Widget(),
+ 'forms' => $contactForms
+ ]);
+ }
+
+ /**
+ * Display form for editing already existing widget
+ *
+ * @param Widget $widget
+ *
+ * @return mixed
+ */
+ public static function renderEditForm(Widget $widget)
+ {
+ $contactForms = Content::where('module_handler', config('contactform.handler'))
+ ->get();
+ return view('contactform::admin.widgets.address.edit', [
+ 'widget' => $widget,
+ 'forms' => $contactForms
+ ]);
+ }
+}
\ No newline at end of file