]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-417
authormarina <m.zozirova@gmail.com>
Mon, 26 May 2025 08:10:54 +0000 (11:10 +0300)
committermarina <m.zozirova@gmail.com>
Mon, 26 May 2025 08:10:54 +0000 (11:10 +0300)
erp24/views/write_offs_erp/_form.php

index c74a9970e02b6ac13abf88d0ce3d7300685808c0..51a6038902e38b5c28d07bc8ce1d475817f72a7b 100644 (file)
@@ -268,10 +268,24 @@ JS
                             'entity_id' => $data['id']
                         ]);
 
-                        return $file ? [
+                        if (!$file) return null;
+
+                        // Prepare initial preview data
+                        $initialPreview = [$file->url];
+                        $initialPreviewConfig = [[
+                            'type' => 'video',
+                            'filetype' => mime_content_type($file->path),
+                            'caption' => basename($file->url),
+                            'size' => filesize($file->path),
+                            'url' => Url::to(['delete-video', 'id' => $data['id']])
+                        ]];
+
+                        return [
                             'caption' => basename($file->url),
-                            'url' => $file->url // URL для удаления или скачивания
-                        ] : null;
+                            'url' => $file->url,
+                            'initialPreview' => $initialPreview,
+                            'initialPreviewConfig' => $initialPreviewConfig
+                        ];
                     },
                     'options' => [
                         'options' => [
@@ -284,36 +298,12 @@ JS
                             'showCaption' => true,
                             'showRemove' => true,
                             'showUpload' => true,
-                            'initialPreview' => function ($data) {
-                                $file = Files::findOne([
-                                    'entity' => self::WRITE_OFFS_VIDEO,
-                                    'entity_id' => $data['id']
-                                ]);
-                                return $file ? [$file->url] : [];
-                            },
-                            'initialPreviewConfig' => function ($data) {
-                                $file = Files::findOne([
-                                    'entity' => self::WRITE_OFFS_VIDEO,
-                                    'entity_id' => $data['id']
-                                ]);
-
-                                return $file ? [[
-                                    'type' => 'video',
-                                    'filetype' => mime_content_type($file->path),
-                                    'caption' => basename($file->url),
-                                    'size' => filesize($file->path),
-                                    'url' => Url::to(['delete-video', 'id' => $data['id']])
-                                ]] : [];
-                            },
                             'previewFileType' => 'video',
                             'allowedFileTypes' => ['video'],
                             'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
                             'maxFileSize' => 10240, // 10MB
                         ],
                     ],
-                    'columnOptions' => [
-                        'style' => 'min-width: 240px; overflow: visible;',
-                    ],
                 ],
                 [
                     'name' => 'comment',