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

index 4f21d6637419f66349a03618bd223298323e64ea..1aa13999a0dc26d90b399b0f7fc5e542e7b37458 100644 (file)
@@ -186,22 +186,24 @@ JS
                             'capture' => '',
                             'class' => 'file',
                             'required' => true,
-                        ],
+                               ],
                         'pluginOptions' => [
-//                        'previewFileType' => ['jpg','png'],
-//                        'allowedFileExtensions'=>['jpg','png'],
-                            'showPreview' => false,
-                            'showCaption' => true,
-                            'showRemove' => true,
-                            'showUpload' => false,
-                            //'uploadClass' => 'hide',
-//                        'initialPreview'=> $initalImages,
-                            'overwriteInitial' => true,
-
-//                        'initialPreviewAsData'=>true,
-                            //initialPreviewAsData: false,
-//                        'bsColCssPrefixes'=>3,
-                            // 'uploadUrl' => Url::to(['/site/image-manager-upload']),
+                            'showPreview' => true,
+                            'showCaption' => true, // ✅ Должно быть true
+                            'initialCaption' => '55656',
+                            'initialPreview' => '809',
+//                            'initialPreviewConfig' => function($data) {
+//                                if (!$data || !isset($data['id'])) return [];
+//                                $file = Files::findOne([
+//                                    'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
+//                                    'entity_id' => $data['id']
+//                                ]);
+//                                return $file ? [[
+//                                    'caption' => basename($file->url), // ✅ Обязательно!
+//                                    'type' => 'video',
+//                                    'size' => @filesize(Yii::getAlias('@webroot') . $file->url),
+//                                ]] : [];
+//                            },
                             'browseIcon' => '+',
                             'cancelIcon' => 'x',
                             'removeIcon' => '-',
@@ -257,25 +259,50 @@ JS
                     ]
                 ],
                 [
-                    'name' => 'video',
-                    'title' => 'Видео',
-                    'type' => 'fileInput',
-                    'options' => [
-                        'options' => [
-                            'accept' => 'video/*',
-                            'multiple' => false,
-                        ],
-                    ],
+                    'name' => 'videoFiles',
+                    'title' => 'Видео: mp4, mov, avi',
+                    'type' => FileInput::className(),
                     'value' => function ($data) {
-                        if (empty($data['id'])) return null;
+                        if (!$data || !isset($data['id'])) return null;
 
                         $file = Files::findOne([
                             'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
                             'entity_id' => $data['id']
                         ]);
 
-                        return $file ? basename($file->url) : null;
-                    }
+                        if (!$file) return null;
+
+                        $initialPreview = [$file->url];
+                        $initialPreviewConfig = [[
+                            'type' => 'video',
+                            'caption' => basename($file->url),
+                            'url' => Url::to(['delete-video', 'id' => $data['id']])
+                        ]];
+
+                        return [
+                            'caption' => basename($file->url),
+                            'url' => $file->url,
+                            'initialPreview' => $initialPreview,
+                            'initialPreviewConfig' => $initialPreviewConfig
+                        ];
+                    },
+                    'options' => [
+                        'options' => [
+                            'multiple' => false,
+                            'accept' => 'video/*',
+                            'name' => 'video_name'
+                        ],
+                        'pluginOptions' => [
+                            'showPreview' => true,
+                            'showCaption' => true,
+                            'showRemove' => true,
+                            'showUpload' => true,
+                            'previewFileType' => 'video',
+                            'allowedFileTypes' => ['video'],
+                            'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
+                            'maxFileSize' => 10240,
+                        ],
+                    ],
                 ],
                 [
                     'name' => 'comment',
@@ -283,7 +310,6 @@ JS
                     'title' => 'Комментарий',
 
                 ],
-
             ],
             'addButtonPosition' => MultipleInput::POS_FOOTER, // show add button in the header
         ])->label(false); ?>