1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,66 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+/** |
|
4 |
+ * This file is part of contao-weinanlieferung-bundle. |
|
5 |
+ * |
|
6 |
+ * (c) vonRotenberg |
|
7 |
+ * |
|
8 |
+ * @license commercial |
|
9 |
+ */ |
|
10 |
+ |
|
11 |
+use Contao\DC_Table; |
|
12 |
+use Contao\DataContainer; |
|
13 |
+ |
|
14 |
+\Contao\System::loadLanguageFile('default'); |
|
15 |
+ |
|
16 |
+$GLOBALS['TL_DCA']['tl_vr_wa_slotassistant'] = |
|
17 |
+ [ |
|
18 |
+ |
|
19 |
+ // Config |
|
20 |
+ 'config' => |
|
21 |
+ [ |
|
22 |
+ 'dataContainer' => DC_Table::class, |
|
23 |
+ 'sql' => |
|
24 |
+ [ |
|
25 |
+ 'keys' => |
|
26 |
+ [ |
|
27 |
+ 'id' => 'primary', |
|
28 |
+ ] |
|
29 |
+ ] |
|
30 |
+ ], |
|
31 |
+ |
|
32 |
+ // Fields |
|
33 |
+ 'fields' => |
|
34 |
+ [ |
|
35 |
+ 'id' => [ |
|
36 |
+ 'sql' => "int(10) unsigned NOT NULL auto_increment" |
|
37 |
+ ], |
|
38 |
+ 'tstamp' => [ |
|
39 |
+ 'sql' => "int(10) unsigned NOT NULL default '0'" |
|
40 |
+ ], |
|
41 |
+ 'timeframe' => [ |
|
42 |
+ 'inputType' => 'multiColumnWizard', |
|
43 |
+ 'eval' => [ |
|
44 |
+ 'minCount' => 1, |
|
45 |
+ 'columnFields' => |
|
46 |
+ [ |
|
47 |
+ 'sorte' => |
|
48 |
+ [ |
|
49 |
+ 'label' => $GLOBALS['TL_LANG']['MSC']['wa_sorte'], |
|
50 |
+ 'inputType' => 'select', |
|
51 |
+ 'foreignKey' => 'tl_vr_wa_rebsorte.title', |
|
52 |
+ 'eval' => ['style' => 'width:350px', 'mandatory' => true, 'chosen' =>true, 'includeBlankOption' => true] |
|
53 |
+ ], |
|
54 |
+ 'leseart' => |
|
55 |
+ [ |
|
56 |
+ 'label' => $GLOBALS['TL_LANG']['MSC']['wa_leseart'], |
|
57 |
+ 'inputType' => 'select', |
|
58 |
+ 'foreignKey' => 'tl_vr_wa_leseart.title', |
|
59 |
+ 'eval' => ['style' => 'width:350px', 'mandatory' => true, 'chosen' =>true, 'includeBlankOption' => true] |
|
60 |
+ ] |
|
61 |
+ ] |
|
62 |
+ ], |
|
63 |
+ 'sql' => 'blob NULL' |
|
64 |
+ ] |
|
65 |
+ ] |
|
66 |
+ ]; |
0 | 67 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,19 @@ |
1 |
+<?xml version="1.0" ?> |
|
2 |
+<xliff version="1.1"> |
|
3 |
+ <file datatype="php" source-language="en" target-language="de"> |
|
4 |
+ <body> |
|
5 |
+ <trans-unit id="wa_slotassistant.base_legend"> |
|
6 |
+ <source>Base settings</source> |
|
7 |
+ <target>Grundeinstellungen</target> |
|
8 |
+ </trans-unit> |
|
9 |
+ <trans-unit id="wa_slotassistant.time_legend"> |
|
10 |
+ <source>Timeframe</source> |
|
11 |
+ <target>Zeitraum</target> |
|
12 |
+ </trans-unit> |
|
13 |
+ <trans-unit id="wa_slotassistant.slot_legend"> |
|
14 |
+ <source>Slot settings</source> |
|
15 |
+ <target>Slot-Einstellungen</target> |
|
16 |
+ </trans-unit> |
|
17 |
+ </body> |
|
18 |
+ </file> |
|
19 |
+</xliff> |
... | ... |
@@ -24,6 +24,9 @@ |
24 | 24 |
{% if not field.widget.hasErrors() and field.help is defined and field.help|length %} |
25 | 25 |
<p class="tl_help tl_tip">{{ field.help }}</p> |
26 | 26 |
{% endif %} |
27 |
+ {% if field.widget.updateMode is defined %} |
|
28 |
+ {{ field.widget.updateMode|raw }} |
|
29 |
+ {% endif %} |
|
27 | 30 |
</div> |
28 | 31 |
{% endfor %} |
29 | 32 |
</fieldset> |
... | ... |
@@ -12,20 +12,29 @@ declare(strict_types=1); |
12 | 12 |
|
13 | 13 |
namespace vonRotenberg\WeinanlieferungBundle\Controller\Backend; |
14 | 14 |
|
15 |
+use Contao\Ajax; |
|
16 |
+use Contao\Backend; |
|
17 |
+use Contao\BackendTemplate; |
|
15 | 18 |
use Contao\Config; |
19 |
+use Contao\Controller; |
|
16 | 20 |
use Contao\CoreBundle\Controller\AbstractController; |
17 | 21 |
use Contao\CoreBundle\Csrf\ContaoCsrfTokenManager; |
18 | 22 |
use Contao\Date; |
23 |
+use Contao\DC_File; |
|
19 | 24 |
use Contao\Environment; |
25 |
+use Contao\FileTree; |
|
20 | 26 |
use Contao\FrontendUser; |
21 | 27 |
use Contao\Image; |
22 | 28 |
use Contao\Input; |
23 | 29 |
use Contao\SelectMenu; |
24 | 30 |
use Contao\StringUtil; |
25 | 31 |
use Contao\System; |
32 |
+use Contao\TextArea; |
|
26 | 33 |
use Contao\TextField; |
34 |
+use Contao\Upload; |
|
27 | 35 |
use Contao\Widget; |
28 | 36 |
use Doctrine\DBAL\Connection; |
37 |
+use MenAtWork\MultiColumnWizardBundle\Contao\Widgets\MultiColumnWizard; |
|
29 | 38 |
use Symfony\Component\HttpFoundation\RequestStack; |
30 | 39 |
use Symfony\Component\HttpFoundation\Response; |
31 | 40 |
use Symfony\Component\Routing\Annotation\Route; |
... | ... |
@@ -68,17 +77,34 @@ class WeinanlieferungSlotAssistantController extends AbstractController |
68 | 77 |
|
69 | 78 |
public function __invoke(): Response |
70 | 79 |
{ |
80 |
+ // Handle ajax request |
|
81 |
+ if ($_POST && Environment::get('isAjaxRequest')) |
|
82 |
+ { |
|
83 |
+ $this->objAjax = new Ajax(Input::post('action')); |
|
84 |
+ $this->objAjax->executePreActions(); |
|
85 |
+ } |
|
86 |
+ |
|
71 | 87 |
$GLOBALS['TL_CSS']['cirrus'] = 'bundles/vonrotenbergweinanlieferung/css/backend.css|static'; |
72 | 88 |
$arrData = [ |
73 | 89 |
'request_token' => $this->tokenManager->getDefaultTokenValue(), |
74 | 90 |
'ref' => $this->request->attributes->get('_contao_referer_id') |
75 | 91 |
]; |
76 | 92 |
System::loadLanguageFile('default'); |
93 |
+ System::loadLanguageFile('wa_slotassistant'); |
|
94 |
+ Controller::loadDataContainer('tl_vr_wa_slot'); |
|
95 |
+ Controller::loadDataContainer('tl_vr_wa_slotassistant'); |
|
77 | 96 |
|
78 | 97 |
// dump($this->getWidgets()); |
79 | 98 |
|
80 | 99 |
$arrData['fields'] = $this->getWidgets(); |
81 | 100 |
|
101 |
+ // AJAX request |
|
102 |
+ if ($_POST && Environment::get('isAjaxRequest')) |
|
103 |
+ { |
|
104 |
+ $dc = new DC_File('tl_vr_wa_slotassistant'); |
|
105 |
+ $this->objAjax->executePostActions($dc); |
|
106 |
+ } |
|
107 |
+ |
|
82 | 108 |
return new Response( |
83 | 109 |
$this->twig->render( |
84 | 110 |
'@Contao_VonrotenbergWeinanlieferungBundle/be_wa_slotassistant.html.twig', |
... | ... |
@@ -123,14 +149,95 @@ class WeinanlieferungSlotAssistantController extends AbstractController |
123 | 149 |
'time_legend' => [ |
124 | 150 |
[ |
125 | 151 |
'class' => 'w50 wizard', |
126 |
- 'help' => 'Zeitslot-Typ/Annahmestelle fest.', |
|
152 |
+ 'help' => 'Der Zeitpunkt ab wann der erste Zeitslot angelegt werden soll.', |
|
127 | 153 |
'widget' => new TextField([ |
128 | 154 |
'name' => 'date_start[1]', |
129 | 155 |
'mandatory' => true, |
130 |
- 'label' => 'Pufferzeit in min.', |
|
156 |
+ 'label' => 'Zeitraum Beginn', |
|
131 | 157 |
'rgxp' => 'datim', |
132 | 158 |
'datepicker' => true, |
133 | 159 |
]) |
160 |
+ ], |
|
161 |
+ [ |
|
162 |
+ 'class' => 'w50 wizard', |
|
163 |
+ 'help' => 'Der Zeitpunkt bis wann der letzte Zeitslot abgeschlossen sein muss.', |
|
164 |
+ 'widget' => new TextField([ |
|
165 |
+ 'name' => 'date_end[1]', |
|
166 |
+ 'mandatory' => true, |
|
167 |
+ 'label' => 'Zeitraum Ende', |
|
168 |
+ 'rgxp' => 'datim', |
|
169 |
+ 'datepicker' => true, |
|
170 |
+ ]) |
|
171 |
+ ], |
|
172 |
+ [ |
|
173 |
+ 'class' => 'clr', |
|
174 |
+ 'help' => 'blah', |
|
175 |
+ 'widget' => new MultiColumnWizard([ |
|
176 |
+ 'name' => 'timeframe', |
|
177 |
+ 'minCount' => 1, |
|
178 |
+ 'columnFields' => |
|
179 |
+ [ |
|
180 |
+ 'sorte' => |
|
181 |
+ [ |
|
182 |
+ 'label' => $GLOBALS['TL_LANG']['MSC']['wa_sorte'], |
|
183 |
+ 'inputType' => 'select', |
|
184 |
+ 'foreignKey' => 'tl_vr_wa_rebsorte.title', |
|
185 |
+ 'eval' => ['style' => 'width:350px', 'mandatory' => true, 'chosen' =>true, 'includeBlankOption' => true] |
|
186 |
+ ], |
|
187 |
+ 'leseart' => |
|
188 |
+ [ |
|
189 |
+ 'label' => $GLOBALS['TL_LANG']['MSC']['wa_leseart'], |
|
190 |
+ 'inputType' => 'select', |
|
191 |
+ 'foreignKey' => 'tl_vr_wa_leseart.title', |
|
192 |
+ 'eval' => ['style' => 'width:350px', 'mandatory' => true, 'chosen' =>true, 'includeBlankOption' => true] |
|
193 |
+ ] |
|
194 |
+ ] |
|
195 |
+ ]) |
|
196 |
+ ] |
|
197 |
+ ], |
|
198 |
+ 'slot_legend' => [ |
|
199 |
+ [ |
|
200 |
+ 'class' => 'w50', |
|
201 |
+ 'help' => 'Der Beginn des Zeitraums, ab wann der Slot im Vorfeld gebucht werden kann.', |
|
202 |
+ 'widget' => new TextField([ |
|
203 |
+ 'name' => 'bookableFrom', |
|
204 |
+ 'mandatory' => true, |
|
205 |
+ 'label' => 'Buchbar ab in h', |
|
206 |
+ 'rgxp' => 'natural' |
|
207 |
+ ]) |
|
208 |
+ ], |
|
209 |
+ [ |
|
210 |
+ 'class' => 'w50', |
|
211 |
+ 'help' => 'Das Ende des Zeitraums, bis wann der Slot im Vorfeld gebucht werden kann.', |
|
212 |
+ 'widget' => new TextField([ |
|
213 |
+ 'name' => 'bookableTill', |
|
214 |
+ 'mandatory' => true, |
|
215 |
+ 'label' => 'Buchbar bis in h', |
|
216 |
+ 'rgxp' => 'natural' |
|
217 |
+ ]) |
|
218 |
+ ], |
|
219 |
+ [ |
|
220 |
+ 'class' => 'clr', |
|
221 |
+ 'help' => 'Anmerkungen zum Zeitslot. Diese werden bei der Buchung angezeigt.', |
|
222 |
+ 'widget' => new TextArea([ |
|
223 |
+ 'name' => 'annotation', |
|
224 |
+ 'mandatory' => true, |
|
225 |
+ 'label' => 'Anmerkungen', |
|
226 |
+ 'rte' => 'tinyMCE' |
|
227 |
+ ]) |
|
228 |
+ ], |
|
229 |
+ [ |
|
230 |
+ 'class' => 'clr', |
|
231 |
+ 'help' => 'Anmerkungen zum Zeitslot. Diese werden bei der Buchung angezeigt.', |
|
232 |
+ 'widget' => new FileTree([ |
|
233 |
+ 'name' => 'enclosure', |
|
234 |
+ 'mandatory' => true, |
|
235 |
+ 'label' => 'Anmerkungen', |
|
236 |
+ 'multiple' => true, |
|
237 |
+ 'fieldType' => 'checkbox', |
|
238 |
+ 'filesOnly' => true, |
|
239 |
+ 'isDownloads' => true |
|
240 |
+ ]) |
|
134 | 241 |
] |
135 | 242 |
] |
136 | 243 |
]; |
... | ... |
@@ -194,6 +301,37 @@ class WeinanlieferungSlotAssistantController extends AbstractController |
194 | 301 |
$field['widget']->wizard = $wizard; |
195 | 302 |
} |
196 | 303 |
|
304 |
+ // Replace the textarea with an RTE instance |
|
305 |
+ if (!empty($field['widget']->rte)) |
|
306 |
+ { |
|
307 |
+ list($file, $type) = explode('|', $field['widget']->rte, 2) + [null, null]; |
|
308 |
+ |
|
309 |
+ $fileBrowserTypes = []; |
|
310 |
+ $pickerBuilder = System::getContainer()->get('contao.picker.builder'); |
|
311 |
+ |
|
312 |
+ foreach (['file' => 'image', 'link' => 'file'] as $context => $fileBrowserType) |
|
313 |
+ { |
|
314 |
+ if ($pickerBuilder->supportsContext($context)) |
|
315 |
+ { |
|
316 |
+ $fileBrowserTypes[] = $fileBrowserType; |
|
317 |
+ } |
|
318 |
+ } |
|
319 |
+ |
|
320 |
+ $objTemplate = new BackendTemplate('be_' . $file); |
|
321 |
+ $objTemplate->selector = 'ctrl_' . $field['widget']->id; |
|
322 |
+ $objTemplate->type = $type; |
|
323 |
+ $objTemplate->fileBrowserTypes = $fileBrowserTypes; |
|
324 |
+ $objTemplate->source = 'wa_slotassistant.' . $field['widget']->id; |
|
325 |
+ $objTemplate->readonly = (bool)($field['widget']->readonly ?? false); |
|
326 |
+ |
|
327 |
+ // Deprecated since Contao 4.0, to be removed in Contao 5.0 |
|
328 |
+ $objTemplate->language = Backend::getTinyMceLanguage(); |
|
329 |
+ |
|
330 |
+ $field['widget']->updateMode = $objTemplate->parse(); |
|
331 |
+ |
|
332 |
+ unset($file, $type, $pickerBuilder, $fileBrowserTypes, $fileBrowserType); |
|
333 |
+ } |
|
334 |
+ |
|
197 | 335 |
if (Input::post('FORM_SUBMIT') == 'wa_slotassistant') |
198 | 336 |
{ |
199 | 337 |
dump($field['widget']->validate()); |