Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vuejs component: Multiple file selector #523

Closed
wants to merge 90 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
52d278a
Set tags only if passed any.
Fisiu Apr 16, 2018
d28fbf1
Vuejs component: Multiple file selector
Apr 20, 2018
4c30c45
Merge pull request #518 from Fisiu/allow_empty_tags
nWidart Apr 20, 2018
e6e689f
CkEditor file browser: data table loads the files via ajax
Apr 20, 2018
d5aff74
Add origin media
Apr 25, 2018
20657b3
Preparing 3.5.3
nWidart May 3, 2018
c59bf4c
Adding changelog item
nWidart May 3, 2018
5bc09f2
Merge pull request #1 from AsgardCms/3.0
kamekun May 3, 2018
523f664
Create auth.php
kamekun May 3, 2018
26d5f66
Create pagination.php
kamekun May 3, 2018
b5a47a9
Create passwords.php
kamekun May 3, 2018
cc6b19e
Create validation.php for ES Languague.
kamekun May 3, 2018
cf56e1d
Update Core.php 3.5.3
kamekun May 3, 2018
c216dff
Updated core.php
kamekun May 3, 2018
ae7b78f
Don't show draft pages.
Fisiu May 4, 2018
b3f4a31
Updated a typo for core.php
kamekun May 4, 2018
3caa50b
Tweaked dutch core translations
RSpeekenbrink May 4, 2018
69d13b5
Replaced dutch translation with english in english files
RSpeekenbrink May 4, 2018
ed1b150
Tweaked dutch dashboard translations
RSpeekenbrink May 4, 2018
c43aef8
Tweaked dutch media translations
RSpeekenbrink May 4, 2018
2a95224
Tweaked dutch menu translations
RSpeekenbrink May 4, 2018
b023620
Tweaked dutch notification translations
RSpeekenbrink May 4, 2018
6aadf7f
Tweaked dutch page translations
RSpeekenbrink May 4, 2018
4866cd5
Tweaked dutch setting translations
RSpeekenbrink May 4, 2018
4533486
Tweaked dutch tag translations
RSpeekenbrink May 4, 2018
bda4441
Tweaked dutch translation translations
RSpeekenbrink May 4, 2018
ed8f5fb
Tweaked dutch user translations
RSpeekenbrink May 4, 2018
6e5e1e1
Tweaked dutch workshop translations
RSpeekenbrink May 4, 2018
7db1088
Merge pull request #527 from RSpeekenbrink/feature/dutch-translations
nWidart May 4, 2018
332b39a
Merge pull request #526 from Fisiu/draft-pages
nWidart May 4, 2018
5ae06f6
Merge pull request #525 from kamekun/3.0
nWidart May 4, 2018
96c4152
Adding a test the user token is correctly generated for the createWit…
nWidart May 6, 2018
7a91d62
Adding changelog items
nWidart May 6, 2018
abaf326
Set Carbon locale
kamekun May 8, 2018
070eb0b
Update AppServiceProvider.php
kamekun May 8, 2018
6aaf5e6
Merge pull request #2 from AsgardCms/3.0
kamekun May 9, 2018
6a97c12
Update changelog.yml to the lasted changes.
kamekun May 9, 2018
fe5094b
Update changelog.yml
kamekun May 9, 2018
f3b2ce5
Update changelog.yml
kamekun May 9, 2018
905b9d5
Update changelog.yml
kamekun May 9, 2018
b8cae94
body not required to create a page.
kamekun May 9, 2018
fb845a4
body not required to edit a page.
kamekun May 9, 2018
2eb6b0d
hide dropdown language if you only have one.
kamekun May 9, 2018
ba4ca8c
Update changelog.yml
kamekun May 9, 2018
692eb02
Update core.php
kamekun May 10, 2018
2739d62
Update core.php
kamekun May 10, 2018
aac061a
Update core.php
kamekun May 10, 2018
6988ae7
Update core.php
kamekun May 10, 2018
f45a0d9
Tweaked dutch translations
RSpeekenbrink May 17, 2018
f7c72d1
Merge pull request #539 from RSpeekenbrink/feature/dutch-trans-perfec…
nWidart May 18, 2018
705d04d
Merge pull request #531 from kamekun/3.0
nWidart May 18, 2018
b8d8486
Merge pull request #3 from AsgardCms/3.0
kamekun May 23, 2018
d872a58
2018_05_23_145242_edit_body_column_nullable.php
kamekun May 23, 2018
6226140
Update 2018_05_23_145242_edit_body_column_nullable.php
kamekun May 23, 2018
e1cff91
Update 2018_05_23_145242_edit_body_column_nullable.php
kamekun May 23, 2018
bd05494
Update 2018_05_23_145242_edit_body_column_nullable.php
kamekun May 23, 2018
18e0817
Merge pull request #542 from kamekun/3.0
nWidart May 23, 2018
7b9eed2
Check page status if page exists.
Fisiu May 13, 2018
dab7089
Fix creation of an activated user.
Fisiu May 6, 2018
d9261e4
add hungarian translation for core
davidporos92 Jun 20, 2018
5c15e15
add hungarian translation for dashboard
davidporos92 Jun 20, 2018
fa192ca
add hungarian translation for media
davidporos92 Jun 20, 2018
c3c5c7a
add hungarian translation for menu
davidporos92 Jun 20, 2018
66bfccb
add hungarian translation for notification
davidporos92 Jun 20, 2018
f6c9429
add hungarian translation for page
davidporos92 Jun 20, 2018
2a6217b
add hungarian translation for setting
davidporos92 Jun 20, 2018
50b2b2e
add hungarian translation for tag
davidporos92 Jun 20, 2018
a9d59b3
add hungarian translation for translation
davidporos92 Jun 20, 2018
080b0f7
add hungarian translation for user
davidporos92 Jun 20, 2018
6c610d8
add hungarian translation for workshop
davidporos92 Jun 20, 2018
4cd9e64
add hungarian translation for base laravel
davidporos92 Jun 20, 2018
12b5083
fix native in available locales conf
davidporos92 Jun 20, 2018
b49c130
only watch the request path for the backend route param, not the whol…
davidporos92 Jun 20, 2018
6d58072
Merge pull request #552 from davidporos92/hotfix/backend-subdomain
nWidart Jun 21, 2018
6ce3f86
Merge pull request #551 from davidporos92/feature/add-hungarian-language
nWidart Jun 21, 2018
efa7c32
Merge pull request #535 from Fisiu/draft-pages
nWidart Jun 21, 2018
5163979
Adding changelog items
nWidart Jun 21, 2018
5465031
Using strict type check
nWidart Jun 21, 2018
ab8797c
Adding changelog item
nWidart Jun 21, 2018
10757e4
Merge pull request #529 from Fisiu/create-user-fixes
nWidart Jun 21, 2018
e22a39d
Adding changelog item & compiling
nWidart Jun 21, 2018
a86e268
fix route:cache and config:cache issue
huydang284 Jul 2, 2018
a13deea
In case of accepts json then instead of redirecting sending unauthori…
naval-mantra Jul 3, 2018
53e8692
Merge pull request #554 from huydang284/3.0
nWidart Jul 9, 2018
6d1bdc2
Merge pull request #555 from navalkishore30/3.0
nWidart Jul 9, 2018
79878ee
Merge branch '3.0' of https://github.com/AsgardCms/Platform into 3.0
Jul 14, 2018
e387ce7
Vuejs component: Multiple file selector
Apr 20, 2018
6af839e
CkEditor file browser: data table loads the files via ajax
Apr 20, 2018
d46f629
Add origin media
Apr 25, 2018
03f4aeb
Merge branch '3.0' of github.com:daothanh/Platform into 3.0
Jul 14, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Modules/Core/Config/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,11 @@
| useViewNamespaces.backend-theme needs to be enabled at module level
*/
'enable-theme-overrides' => false,

/*
|--------------------------------------------------------------------------
| Check if asgard was installed
|--------------------------------------------------------------------------
*/
'is_installed' => env('INSTALLED', false)
];
2 changes: 1 addition & 1 deletion Modules/Core/Foundation/AsgardCms.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ class AsgardCms
* The AsgardCms version.
* @var string
*/
const VERSION = '3.5.2';
const VERSION = '3.5.3';
}
2 changes: 1 addition & 1 deletion Modules/Core/Http/Middleware/Authorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function handle($request, \Closure $next, $permission)
*/
private function handleUnauthorizedRequest(Request $request, $permission)
{
if ($request->ajax()) {
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', Response::HTTP_FORBIDDEN);
}
if ($request->user() === null) {
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Providers/CoreServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function boot()
public function register()
{
$this->app->singleton('asgard.isInstalled', function () {
return true === env('INSTALLED', false);
return true === config('asgard.core.core.is_installed');
});
$this->app->singleton('asgard.onBackend', function () {
return $this->onBackend();
Expand Down Expand Up @@ -349,7 +349,7 @@ public function bladeDirectives()
*/
private function onBackend()
{
$url = app(Request::class)->url();
$url = app(Request::class)->path();
if (str_contains($url, config('asgard.core.core.admin-prefix'))) {
return true;
}
Expand Down
32 changes: 24 additions & 8 deletions Modules/Core/Providers/RoutingServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,30 @@ public function map(Router $router)
$this->loadApiRoutes($router);
});

$router->group([
'namespace' => $this->namespace,
'prefix' => LaravelLocalization::setLocale(),
'middleware' => ['localizationRedirect', 'web'],
], function (Router $router) {
$this->loadBackendRoutes($router);
$this->loadFrontendRoutes($router);
});
$prefixes = $this->getPrefixes();
foreach ($prefixes as $prefix) {
$router->group([
'namespace' => $this->namespace,
'prefix' => $prefix,
'middleware' => ['localizationRedirect', 'web'],
], function (Router $router) {
$this->loadBackendRoutes($router);
$this->loadFrontendRoutes($router);
});
}
}

/**
* Get locale prefixes
* @return array
*/
private function getPrefixes()
{
if (app('asgard.isInstalled')) {
return array_merge(json_decode(setting('core::locales')), ['']);
}

return [LaravelLocalization::setLocale()];
}

/**
Expand Down
11 changes: 11 additions & 0 deletions Modules/Core/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
url: https://github.com/AsgardCms/Platform
versions:
"@unreleased":
added:
- New Hungarian translations
changed:
- Updating Dutch translations
- Fix Carbon locale
- Fixed how the admin url is parsed by reading the <code>path</code> instead of <code>url</code>
"3.5.3":
changed:
- Updating Polish translations
- Updating Spanish translations
"3.5.2":
changed:
- Correctly returning the Query object from <code>allWithBuilder</code> method in base repository
Expand Down
123 changes: 123 additions & 0 deletions Modules/Media/Assets/js/components/MultipleMedia.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<template>
<div>
<label class="el-form-item__label">{{ getFieldLabel() }}</label>
<div class="jsThumbnailImageWrapper jsSingleThumbnailWrapper" v-if="hasSelectedMedia" >
<figure v-for="media in this.selectedMedia" :key="media.id">
<img :src="media.small_thumb" alt="" v-if="media.is_image"/>
<i :class="`fa ${media.fa_icon}`" style="font-size: 60px;" v-if="! media.is_image"></i>
<span v-if="! media.is_image" style="display:block;">{{ media.filename }}</span>
<span class="el-icon-error remove-media" @click="unSelectMedia(media.id)"></span>
</figure>
<div class="clearfix"></div>
</div>
<div>
<el-button type="button" @click="dialogVisible = true">{{ trans('media.Browse') }}</el-button>
</div>
<el-dialog
:visible.sync="dialogVisible"
fullscreen
:before-close="handleClose">

<media-list single-modal :event-name="this.eventName"></media-list>

<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">{{ trans('core.button.cancel') }}</el-button>
</span>
</el-dialog>
</div>
</template>

<script>
import axios from 'axios';
import UploadZone from '../../../../Media/Assets/js/components/UploadZone.vue';
import MediaList from '../../../../Media/Assets/js/components/MediaList.vue';
import StringHelpers from '../../../../Core/Assets/js/mixins/StringHelpers.vue';

export default {
mixins: [StringHelpers],
props: {
zone: { type: String, required: true },
entity: { type: String, required: true },
entityId: { default: null },
label: { type: String },
},
components: {
'upload-zone': UploadZone,
'media-list': MediaList,
},
watch: {
entityId() {
if (this.entityId) {
this.fetchMedia();
}
},
},
data() {
return {
dialogVisible: false,
selectedMedia: [],
eventName: '',
};
},
computed: {
hasSelectedMedia() {
return this.selectedMedia !== undefined && !_.isEmpty(this.selectedMedia);
},
},
methods: {
handleClose(done) {
done();
},
unSelectMedia(id) {
this.selectedMedia = _.reject(this.selectedMedia, media => media.id === id);
this.$emit('fileUnselected', { id, zone: this.zone });
},
fetchMedia() {
axios.get(route('api.media.get-by-zone-and-entity', {
zone: this.zone,
entity: this.entity,
entity_id: this.entityId,
}))
.then((response) => {
this.selectedMedia = response.data.data;
_.forEach(this.selectedMedia, (file) => {
this.$emit('multipleFileSelected', { id: file.id, zone: this.zone });
});
});
},
getFieldLabel() {
return this.label || this.ucwords(this.zone.replace('_', ' '));
},
makeId() {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

for (let i = 0; i < 5; i++) { text += possible.charAt(Math.floor(Math.random() * possible.length)); }

return text;
},
},
mounted() {
if (this.entityId) {
this.fetchMedia();
}
this.eventName = `fileWasSelected${this.makeId()}${Math.floor(Math.random() * 999999)}`;

this.$events.listen(this.eventName, (mediaData) => {
if (_.find(this.selectedMedia, mediaData) === undefined) {
if (!this.selectedMedia) this.selectedMedia = [];
this.selectedMedia.push(mediaData);
this.$emit('multipleFileSelected', _.merge(mediaData, { zone: this.zone }));
}
});
},
};
</script>
<style>
.remove-media{
position: absolute;
top: 5px;
left: 5px;
color: #FA5555;
}
</style>
27 changes: 27 additions & 0 deletions Modules/Media/Assets/js/mixins/MultipleFileSelector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export default {
methods: {
selectMultipleFile(event, model) {
if (!this[model].medias_multi) {
this[model].medias_multi = {};
}
if (!this[model].medias_multi[event.zone]) {
this[model].medias_multi[event.zone] = { files: [] };
}
this[model].medias_multi[event.zone].files.push(event.id);
},
unselectFile(event, model) {
if (!this[model].medias_multi) {
this[model].medias_multi = {};
}
if (!this[model].medias_multi[event.zone]) {
this[model].medias_multi[event.zone] = { files: [] };
if (this.$refs['multiple-media'] !== undefined && this.$refs['multiple-media'].selectedMedia !== undefined && !_.isEmpty(this.$refs['multiple-media'].selectedMedia)) {
_.forEach(this.$refs['multiple-media'].selectedMedia, (file, key) => {
this[model].medias_multi[event.zone].files.push(file.id);
});
}
}
this[model].medias_multi[event.zone].files = _.reject(this[model].medias_multi[event.zone].files, media => media === event.id);
},
},
};
31 changes: 27 additions & 4 deletions Modules/Media/Http/Controllers/Admin/MediaGridController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace Modules\Media\Http\Controllers\Admin;

use Illuminate\Http\Request;
use Modules\Core\Http\Controllers\Admin\AdminBaseController;
use Modules\Media\Image\ThumbnailManager;
use Modules\Media\Repositories\FileRepository;
use Modules\Media\Transformers\MediaTransformer;

class MediaGridController extends AdminBaseController
{
Expand Down Expand Up @@ -39,13 +41,34 @@ public function index()

/**
* A grid view of uploaded files used for the wysiwyg editor
* @param Request $request
* @return \Illuminate\View\View
*/
public function ckIndex()
public function ckIndex(Request $request)
{
$files = $this->file->allForGrid();
$thumbnails = $this->thumbnailsManager->all();
if ($request->isXmlHttpRequest()) {
$cols = $request->get('columns');
$start = $request->get('start', 0);
$length = $request->get('length', 25);
$page = ($start/$length) + 1;
$requestData = ['per_page' => $length, 'page' => $page];
foreach ($cols as $col) {
if ($col['searchable'] && isset($col['search']['value'])) {
$requestData[$col['data']] = $col['search']['value'];
}
}
$request->merge($requestData);
$files = $this->file->pagingForGrid($request);

$output = [
"draw" => $request->get('draw'),
"recordsTotal" => $files->total(),
"recordsFiltered" => $files->total(),
'data' => MediaTransformer::collection($files)
];
return response()->json($output);

return view('media::admin.grid.ckeditor', compact('files', 'thumbnails'));
}
return view('media::admin.grid.ckeditor');
}
}
17 changes: 17 additions & 0 deletions Modules/Media/Http/Controllers/Api/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,23 @@ public function findFirstByZoneEntity(Request $request)
return new MediaTransformer($file);
}

/**
* Get a media collection by zone and entity object. Require some params that were passed to request: entity (Full class name of entity), entity_id and zone
*
* @param Request $request
* @return JsonResponse|\Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function getByZoneEntity(Request $request)
{
$entityName = (string)$request->get('entity');
$entityModel = new $entityName;
$entity = $entityModel::find($request->get('entity_id'));
if ($entity && in_array('Modules\Media\Support\Traits\MediaRelation', class_uses($entity)) && $entity->files()->count()) {
$files = $this->file->findMultipleFilesByZoneForEntity($request->get('zone'), $entity);
return MediaTransformer::collection($files);
}
return response()->json(['data' => null]);
}
/**
* Store a newly created resource in storage.
*
Expand Down
5 changes: 5 additions & 0 deletions Modules/Media/Http/apiRoutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
'as' => 'api.media.find-first-by-zone-and-entity',
]);

$router->get('media/get-by-zone-and-entity', [
'uses' => 'MediaController@getByZoneEntity',
'as' => 'api.media.get-by-zone-and-entity',
]);

$router->get('media/{media}', [
'uses' => 'MediaController@find',
'as' => 'api.media.media.find',
Expand Down
4 changes: 0 additions & 4 deletions Modules/Media/Http/backendRoutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
use Illuminate\Routing\Router;

/** @var Router $router */
$router->bind('media', function ($id) {
return app(\Modules\Media\Repositories\FileRepository::class)->find($id);
});

$router->group(['prefix' => '/media'], function (Router $router) {
$router->get('media', [
'as' => 'admin.media.media.index',
Expand Down
4 changes: 4 additions & 0 deletions Modules/Media/Providers/MediaServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public function register()
$event->load('media', array_dot(trans('media::media')));
$event->load('folders', array_dot(trans('media::folders')));
});

app('router')->bind('media', function ($id) {
return app(FileRepository::class)->find($id);
});
}

public function boot(DispatcherContract $events)
Expand Down
28 changes: 28 additions & 0 deletions Modules/Media/Repositories/Eloquent/EloquentFileRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,34 @@ public function allForGrid(): Collection
return $this->model->where('is_folder', 0)->get();
}

/**
* @param Request $request
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function pagingForGrid(Request $request)
{

$media = $this->allWithBuilder();
$media->where('is_folder', 0);
if ($request->get('search') !== null) {
$term = $request->get('search');
if (is_array($term)) {
$term = $term['value'];
}
$media->where('filename', 'LIKE', "%{$term}%");
}

if ($request->get('order_by') !== null && $request->get('order') !== 'null') {
$order = $request->get('order') === 'ascending' ? 'asc' : 'desc';

$media->orderBy($request->get('order_by'), $order);
} else {
$media->orderBy('created_at', 'desc');
}

return $media->paginate($request->get('per_page', 10));
}

public function move(File $file, File $destination) : File
{
$previousData = [
Expand Down
Loading