Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
6c84b152
Commit
6c84b152
authored
Oct 26, 2016
by
Олег Гиммельшпах
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
ee8c3b3f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
17 deletions
+80
-17
backend/uploads/.gitignore
backend/uploads/.gitignore
+1
-0
common/modules/bids/controllers/BidController.php
common/modules/bids/controllers/BidController.php
+36
-9
frontend/web/js/connect-form.js
frontend/web/js/connect-form.js
+4
-0
frontend/web/js/upload-files.js
frontend/web/js/upload-files.js
+39
-8
No files found.
backend/uploads/.gitignore
0 → 100644
View file @
6c84b152
*
\ No newline at end of file
common/modules/bids/controllers/BidController.php
View file @
6c84b152
...
...
@@ -23,6 +23,7 @@ class BidController extends \common\components\BaseController
'Add'
=>
'Добавление заявки'
,
'Blogadd'
=>
'Добавление заявки в блог'
,
'Upload-files'
=>
'Загрузка файлов'
,
'Delete-file'
=>
'Удаление файлов'
,
];
}
...
...
@@ -112,12 +113,13 @@ class BidController extends \common\components\BaseController
public
function
actionUploadFiles
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
Response
::
FORMAT_JSON
;
$model
=
new
BidFile
;
$model
->
file
=
UploadedFile
::
getInstanceByName
(
'file'
);
if
(
$model
->
file
)
{
if
(
$model
->
file
)
{
if
(
!
file_exists
(
BidFile
::
path
()))
{
mkdir
(
BidFile
::
path
(),
0777
,
true
);
}
...
...
@@ -129,5 +131,30 @@ class BidController extends \common\components\BaseController
'filename'
=>
$model
->
filename
];
}
}
else
{
throw
new
NotFoundHttpException
(
'The requested page does not exist.'
);
}
}
public
function
actionDeleteFile
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
Response
::
FORMAT_JSON
;
$filename
=
Yii
::
$app
->
request
->
post
(
'filename'
);
if
(
$filename
)
{
if
(
file_exists
(
BidFile
::
path
()
.
$filename
))
{
unlink
(
BidFile
::
path
()
.
$filename
);
}
return
[
'success'
=>
true
];
}
return
[
'success'
=>
false
];
}
else
{
throw
new
NotFoundHttpException
(
'The requested page does not exist.'
);
}
}
}
frontend/web/js/connect-form.js
View file @
6c84b152
...
...
@@ -50,6 +50,10 @@ $('form.bids-form').on('beforeSubmit', function(e) {
form
.
find
(
'
#files-zone
'
).
html
(
''
);
$
(
'
.dz-preview.dz-processing
'
).
remove
();
$
(
'
.file_drop
'
).
show
();
$
(
'
.file_drop_cs
'
).
show
();
$
(
'
.file_upload_bt_cs
'
).
show
();
$
(
'
.file_upload_bt
'
).
show
();
dataLayer
.
push
({
'
event
'
:
'
UA_event
'
,
...
...
frontend/web/js/upload-files.js
View file @
6c84b152
...
...
@@ -2,8 +2,21 @@ $(document).ready(function() {
$
(
'
.file_upload_bt .file-upload, .file_upload_bt_cs .file-upload_cs, .file_upload_bt_cs .file_drop_cs, .file_upload_bt .file_drop
'
).
click
(
function
(){
$
(
'
.dz-clickable
'
).
trigger
(
'
click
'
);
});
// Dropzone class:
// var myDropzone = new Dropzone("div#block_upload", {url: "/bids/bid/upload-files", maxFiles: 1});
var
toggleButtons
=
function
()
{
if
(
!
$
(
'
.file-upload_block.dropzone .dz-preview
'
).
length
)
{
$
(
'
.file_drop
'
).
show
();
$
(
'
.file_drop_cs
'
).
show
();
$
(
'
.file_upload_bt_cs
'
).
show
();
$
(
'
.file_upload_bt
'
).
show
();
}
else
{
$
(
'
.file_drop
'
).
hide
();
$
(
'
.file_drop_cs
'
).
hide
();
$
(
'
.file_upload_bt_cs
'
).
hide
();
$
(
'
.file_upload_bt
'
).
hide
();
}
};
Dropzone
.
options
.
blockUpload
=
{
url
:
"
/bids/bid/upload-files
"
,
maxFiles
:
4
,
...
...
@@ -14,13 +27,31 @@ $(document).ready(function() {
dictInvalidFileType
:
'
Приложенный файл не может быть загружен в целях безопасности. Пожалуйста, приложите файл в другом формате (Word, Pdf, PowerPoint, Excel).
'
,
dictFileTooBig
:
'
Максимальный размер файла составляет 15мб.
'
,
dictCancelUpload
:
'
Отменить загрузку
'
,
success
:
function
(
fi
rst
,
response
)
{
success
:
function
(
fi
le
,
response
)
{
file
.
filename
=
response
.
filename
;
$
(
'
#files-zone
'
).
append
(
'
<input type="hidden" name="Bid[file][]" value="
'
+
response
.
filename
+
'
" />
'
);
$
(
'
.file_drop
'
).
hide
();
$
(
'
.file_drop_cs
'
).
hide
();
$
(
'
.file_upload_bt_cs
'
).
hide
();
$
(
'
.file_upload_bt
'
).
hide
();
toggleButtons
();
},
removedfile
:
function
(
file
)
{
var
$block
=
$
(
file
.
previewElement
);
$
.
ajax
({
dataType
:
'
json
'
,
data
:
{
filename
:
file
.
filename
},
method
:
'
post
'
,
url
:
'
/bids/bid/delete-file
'
,
success
:
function
(
response
)
{
if
(
response
.
success
)
{
$
(
'
#files-zone input[value="
'
+
file
.
filename
+
'
"]
'
).
remove
();
$block
.
remove
();
toggleButtons
();
}
}
});
},
canceled
:
function
()
{
toggleButtons
();
}
};
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment