diff --git a/backend/modules/card/models/UserCard.php b/backend/modules/card/models/UserCard.php index 9f6719e..d23b70e 100755 --- a/backend/modules/card/models/UserCard.php +++ b/backend/modules/card/models/UserCard.php @@ -3,6 +3,7 @@ namespace backend\modules\card\models; use backend\modules\settings\models\Skill; +use common\classes\Debug; use common\models\CardSkill; use common\models\FieldsValue; use common\models\FieldsValueNew; @@ -61,11 +62,14 @@ class UserCard extends \common\models\UserCard if($post['fields']){ FieldsValueNew::deleteAll(['item_id' => $this->id, 'item_type' => FieldsValueNew::TYPE_PROFILE]); - foreach ( $post['fields'] as $item) { $fildsValue = new FieldsValueNew(); $fildsValue->field_id = $item['field_id']; $fildsValue->value = $item['value']; + $fildsValue->type_file = 'text'; + if(substr($item['value'],0,1) == '/'){ + $fildsValue->type_file = 'file'; + } $fildsValue->order = $item['order']; $fildsValue->item_id = $this->id; $fildsValue->item_type = FieldsValueNew::TYPE_PROFILE; diff --git a/backend/modules/card/views/user-card/_form.php b/backend/modules/card/views/user-card/_form.php index c710dc8..c1592a6 100755 --- a/backend/modules/card/views/user-card/_form.php +++ b/backend/modules/card/views/user-card/_form.php @@ -130,7 +130,7 @@ use yii\widgets\ActiveForm;
field($model, 'fields')->widget(MultipleInput::class, [ - + 'cloneButton' => true, 'columns' => [ [ 'name' => 'field_id', @@ -145,12 +145,21 @@ use yii\widgets\ActiveForm; 'options' => ['prompt' => 'Выберите'] ], [ - 'name' => 'value', + 'name' => 'value', 'title' => 'Значение', - 'enableError' => true, + 'type' => InputFile::className(), 'options' => [ - 'class' => 'input-priority' - ] + 'language' => 'ru', + 'controller' => 'elfinder', + // вставляем название контроллера, по умолчанию равен elfinder + // фильтр файлов, можно задать массив фильтров https://github.com/Studio-42/elFinder/wiki/Client-con.. + 'name' => 'fields[value]', + 'id' => 'fields-value', + 'options' => ['class' => 'form-control itemImg', 'maxlength' => '255'], + 'buttonOptions' => ['class' => 'btn btn-primary'], + 'value' => $model->fields[0]['value'], + 'buttonName' => 'Выбрать файл', + ], ], [ 'name' => 'order', @@ -159,8 +168,8 @@ use yii\widgets\ActiveForm; 'options' => [ 'class' => 'input-priority' ] - ] - ] + ], + ], ])->label('Дополнительно'); ?>
diff --git a/backend/web/css/site.css b/backend/web/css/site.css index 2d0533f..6425487 100755 --- a/backend/web/css/site.css +++ b/backend/web/css/site.css @@ -27,3 +27,12 @@ max-height: 100px; flex-direction: column; } + +.field-usercard-fields-0-value{ + display: flex; + width: auto; +} + +.field-usercard-fields-0-value .itemImg { + width: 100% !important; +} \ No newline at end of file diff --git a/common/models/FieldsValueNew.php b/common/models/FieldsValueNew.php index e382edd..439faf1 100644 --- a/common/models/FieldsValueNew.php +++ b/common/models/FieldsValueNew.php @@ -13,6 +13,8 @@ use Yii; * @property int $item_type * @property int $order * @property string $value + * @property string $option + * @property string $type_file */ class FieldsValueNew extends \yii\db\ActiveRecord { @@ -36,7 +38,7 @@ class FieldsValueNew extends \yii\db\ActiveRecord return [ [['field_id', 'item_id', 'item_type'], 'required'], [['field_id', 'item_id', 'item_type', 'order'], 'integer'], - [['value'], 'string'], + [['value', 'type_file'], 'string'], ]; } @@ -52,6 +54,7 @@ class FieldsValueNew extends \yii\db\ActiveRecord 'item_type' => 'Item Type', 'order' => 'Order', 'value' => 'Value', + 'type_file' => 'Приложение' ]; } diff --git a/composer.json b/composer.json index 5909483..be9888b 100755 --- a/composer.json +++ b/composer.json @@ -24,7 +24,10 @@ "kartik-v/yii2-widget-select2": "@dev", "kavalar/hhapi": "@dev", "kartik-v/yii2-widget-datepicker": "@dev", - "nkovacs/yii2-datetimepicker": "*" + "nkovacs/yii2-datetimepicker": "*", + "mirocow/yii2-eav": "*", + "kartik-v/yii2-widget-fileinput": "^1.0", + "2amigos/yii2-file-upload-widget": "~1.0" }, "require-dev": { "yiisoft/yii2-debug": "~2.0.0", diff --git a/composer.lock b/composer.lock index 24c0151..1a22504 100755 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,127 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7578e68130787df83321118c46ab02e6", + "content-hash": "cd1fbf237e9c2dd5e5075f26ed71b815", "packages": [ + { + "name": "2amigos/yii2-file-upload-widget", + "version": "1.0.9", + "source": { + "type": "git", + "url": "https://github.com/2amigos/yii2-file-upload-widget.git", + "reference": "2da8054d5eb598820b9e070fcfeaa5b2b2c0cd46" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/2amigos/yii2-file-upload-widget/zipball/2da8054d5eb598820b9e070fcfeaa5b2b2c0cd46", + "reference": "2da8054d5eb598820b9e070fcfeaa5b2b2c0cd46", + "shasum": "" + }, + "require": { + "2amigos/yii2-gallery-widget": "^1.0", + "bower-asset/blueimp-file-upload": "^9.9", + "yiisoft/yii2": "^2.0.0", + "yiisoft/yii2-bootstrap": "^2.0.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "dosamigos\\fileupload\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "2amigOS! Consulting Group", + "email": "hola@2amigos.us", + "homepage": "http://2amigos.us", + "role": "Developer" + } + ], + "description": "Blueimp file upload widget for the Yii framework", + "homepage": "https://github.com/2amigos/yii2-file-upload-widget", + "keywords": [ + "2amigos", + "upload", + "widget", + "yii", + "yii 2", + "yii2" + ], + "time": "2018-09-06T19:15:49+00:00" + }, + { + "name": "2amigos/yii2-gallery-widget", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/2amigos/yii2-gallery-widget.git", + "reference": "0ce7de28d05a4662da7698773993b5a0245a6136" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/2amigos/yii2-gallery-widget/zipball/0ce7de28d05a4662da7698773993b5a0245a6136", + "reference": "0ce7de28d05a4662da7698773993b5a0245a6136", + "shasum": "" + }, + "require": { + "bower-asset/blueimp-gallery": "~2.17.0", + "yiisoft/yii2": "~2.0.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0", + "scrutinizer/ocular": "~1.1" + }, + "type": "yii2-extension", + "extra": { + "asset-installer-paths": { + "npm-asset-library": "vendor/npm", + "bower-asset-library": "vendor/bower" + }, + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "dosamigos\\gallery\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "2amigOS! Consulting Group", + "email": "hola@2amigos.us", + "homepage": "http://2amigos.us", + "role": "Developer" + } + ], + "description": "Blueimp gallery widget for the Yii framework", + "homepage": "https://github.com/2amigos/yii2-gallery-widget", + "keywords": [ + "2amigos", + "gallery", + "widget", + "yii", + "yii 2", + "yii2" + ], + "time": "2017-09-09T16:01:44+00:00" + }, { "name": "almasaeed2010/adminlte", "version": "v2.4.8", @@ -50,6 +169,90 @@ ], "time": "2018-07-15T18:48:11+00:00" }, + { + "name": "bower-asset/blueimp-canvas-to-blob", + "version": "v3.15.0", + "source": { + "type": "git", + "url": "https://github.com/blueimp/JavaScript-Canvas-to-Blob.git", + "reference": "f47d01f2827f69dde571c0fe06159e8e99a1de96" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/blueimp/JavaScript-Canvas-to-Blob/zipball/f47d01f2827f69dde571c0fe06159e8e99a1de96", + "reference": "f47d01f2827f69dde571c0fe06159e8e99a1de96" + }, + "type": "bower-asset" + }, + { + "name": "bower-asset/blueimp-file-upload", + "version": "v9.34.0", + "source": { + "type": "git", + "url": "https://github.com/blueimp/jQuery-File-Upload.git", + "reference": "bb52d3493d725175fcf5554da034a317aaaea0e2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/blueimp/jQuery-File-Upload/zipball/bb52d3493d725175fcf5554da034a317aaaea0e2", + "reference": "bb52d3493d725175fcf5554da034a317aaaea0e2" + }, + "require": { + "bower-asset/blueimp-canvas-to-blob": ">=2.1.1", + "bower-asset/blueimp-load-image": ">=1.13.0", + "bower-asset/blueimp-tmpl": ">=2.5.4", + "bower-asset/jquery": ">=1.6" + }, + "type": "bower-asset", + "license": [ + "MIT" + ] + }, + { + "name": "bower-asset/blueimp-gallery", + "version": "v2.17.0", + "source": { + "type": "git", + "url": "https://github.com/blueimp/Gallery.git", + "reference": "8336bb5934cb623608808601129db3fbf9201a09" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/blueimp/Gallery/zipball/8336bb5934cb623608808601129db3fbf9201a09", + "reference": "8336bb5934cb623608808601129db3fbf9201a09" + }, + "type": "bower-asset" + }, + { + "name": "bower-asset/blueimp-load-image", + "version": "v2.23.0", + "source": { + "type": "git", + "url": "https://github.com/blueimp/JavaScript-Load-Image.git", + "reference": "455a28c68dc1cd1046e8c458cc0f5027ed7ac03f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/blueimp/JavaScript-Load-Image/zipball/455a28c68dc1cd1046e8c458cc0f5027ed7ac03f", + "reference": "455a28c68dc1cd1046e8c458cc0f5027ed7ac03f" + }, + "type": "bower-asset" + }, + { + "name": "bower-asset/blueimp-tmpl", + "version": "v3.12.0", + "source": { + "type": "git", + "url": "https://github.com/blueimp/JavaScript-Templates.git", + "reference": "f8fe3d34c662fb3315e3af8dc5bae8bdf5a619b2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/blueimp/JavaScript-Templates/zipball/f8fe3d34c662fb3315e3af8dc5bae8bdf5a619b2", + "reference": "f8fe3d34c662fb3315e3af8dc5bae8bdf5a619b2" + }, + "type": "bower-asset" + }, { "name": "bower-asset/bootstrap", "version": "v3.3.7", @@ -136,7 +339,7 @@ "version": "2.24.0", "source": { "type": "git", - "url": "https://github.com/moment/moment.git", + "url": "git@github.com:moment/moment.git", "reference": "96d0d6791ab495859d09a868803d31a55c917de1" }, "dist": { @@ -696,6 +899,59 @@ ], "time": "2016-10-24T15:52:54+00:00" }, + { + "name": "kartik-v/bootstrap-fileinput", + "version": "v4.5.3", + "source": { + "type": "git", + "url": "https://github.com/kartik-v/bootstrap-fileinput.git", + "reference": "64e083b0414d294d99329fa94194f24345fc334a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kartik-v/bootstrap-fileinput/zipball/64e083b0414d294d99329fa94194f24345fc334a", + "reference": "64e083b0414d294d99329fa94194f24345fc334a", + "shasum": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.5.x-dev" + } + }, + "autoload": { + "psr-4": { + "kartik\\plugins\\fileinput\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kartik Visweswaran", + "email": "kartikv2@gmail.com", + "homepage": "http://www.krajee.com/" + } + ], + "description": "An enhanced HTML 5 file input for Bootstrap 3.x with features for file preview for many file types, multiple selection, ajax uploads, and more.", + "homepage": "https://github.com/kartik-v/bootstrap-fileinput", + "keywords": [ + "ajax", + "bootstrap", + "delete", + "file", + "image", + "input", + "jquery", + "multiple", + "preview", + "progress", + "upload" + ], + "time": "2019-03-21T11:44:25+00:00" + }, { "name": "kartik-v/yii2-krajee-base", "version": "v1.9.9", @@ -801,6 +1057,61 @@ ], "time": "2018-08-29T12:10:45+00:00" }, + { + "name": "kartik-v/yii2-widget-fileinput", + "version": "v1.0.8", + "source": { + "type": "git", + "url": "https://github.com/kartik-v/yii2-widget-fileinput.git", + "reference": "7f76d784cc48733746ff90b53b8474dcf48ea6c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kartik-v/yii2-widget-fileinput/zipball/7f76d784cc48733746ff90b53b8474dcf48ea6c4", + "reference": "7f76d784cc48733746ff90b53b8474dcf48ea6c4", + "shasum": "" + }, + "require": { + "kartik-v/bootstrap-fileinput": "~4.4", + "kartik-v/yii2-krajee-base": ">=1.9" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "kartik\\file\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kartik Visweswaran", + "email": "kartikv2@gmail.com", + "homepage": "http://www.krajee.com/" + } + ], + "description": "An enhanced FileInput widget for Bootstrap 3.x & 4.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)", + "homepage": "https://github.com/kartik-v/yii2-widget-fileinput", + "keywords": [ + "extension", + "file", + "form", + "input", + "jquery", + "plugin", + "upload", + "widget", + "yii2" + ], + "time": "2018-09-19T13:09:42+00:00" + }, { "name": "kartik-v/yii2-widget-select2", "version": "dev-master", @@ -936,6 +1247,63 @@ ], "time": "2018-10-01T17:00:54+00:00" }, + { + "name": "mirocow/yii2-eav", + "version": "v0.7.2", + "source": { + "type": "git", + "url": "https://github.com/Mirocow/yii2-eav.git", + "reference": "e4c231cdf7afa5ef21e5fbfececd88ba83b072b9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Mirocow/yii2-eav/zipball/e4c231cdf7afa5ef21e5fbfececd88ba83b072b9", + "reference": "e4c231cdf7afa5ef21e5fbfececd88ba83b072b9", + "shasum": "" + }, + "require": { + "php": ">=5.5.0", + "yiisoft/yii2": ">=2.0.5" + }, + "type": "yii2-extension", + "autoload": { + "psr-4": { + "mirocow\\eav\\": "./src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alexey Samoylov", + "email": "alexey.samoylov@gmail.com", + "homepage": "http://yiiblog.ru", + "role": "Developer" + }, + { + "name": "Mirocow", + "email": "mr.mirocow@gmail.com", + "homepage": "http://mirocow.com", + "role": "Developer" + }, + { + "name": "Alien-art", + "email": "alien@alien-art.ru", + "role": "Developer" + } + ], + "description": "EAV for Yii2", + "keywords": [ + "attribute", + "cck", + "eav", + "fields", + "yii2" + ], + "time": "2017-01-07T19:07:59+00:00" + }, { "name": "nkovacs/yii2-datetimepicker", "version": "3.1.0", diff --git a/console/migrations/m190726_064708_add_option_column.php b/console/migrations/m190726_064708_add_option_column.php new file mode 100644 index 0000000..ff8a4ce --- /dev/null +++ b/console/migrations/m190726_064708_add_option_column.php @@ -0,0 +1,25 @@ +addColumn('fields_value_new', 'type_file', $this->string(255)->defaultValue(null)); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropColumn('fields_value_new', 'type_file'); + } +}