Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
b729c09d
Commit
b729c09d
authored
Oct 01, 2018
by
Micheal Mand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract common method to mixin
parent
c7240714
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
20 deletions
+21
-20
MultipleMedia.vue
Modules/Media/Assets/js/components/MultipleMedia.vue
+3
-10
SingleMedia.vue
Modules/Media/Assets/js/components/SingleMedia.vue
+3
-10
RandomString.js
Modules/Media/Assets/js/mixins/RandomString.js
+15
-0
No files found.
Modules/Media/Assets/js/components/MultipleMedia.vue
View file @
b729c09d
...
...
@@ -33,9 +33,10 @@
import
UploadZone
from
'
./UploadZone.vue
'
;
import
MediaList
from
'
./MediaList.vue
'
;
import
StringHelpers
from
'
../../../../Core/Assets/js/mixins/StringHelpers.vue
'
;
import
RandomString
from
'
../mixins/RandomString
'
;
export
default
{
mixins
:
[
StringHelpers
],
mixins
:
[
StringHelpers
,
RandomString
],
props
:
{
zone
:
{
type
:
String
,
required
:
true
},
entity
:
{
type
:
String
,
required
:
true
},
...
...
@@ -89,20 +90,12 @@
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
.
eventName
=
`fileWasSelected
${
this
.
randomString
()}${
Math
.
floor
(
Math
.
random
()
*
999999
)}
`
;
this
.
$events
.
listen
(
this
.
eventName
,
(
mediaData
)
=>
{
if
(
_
.
find
(
this
.
selectedMedia
,
mediaData
)
===
undefined
)
{
...
...
Modules/Media/Assets/js/components/SingleMedia.vue
View file @
b729c09d
...
...
@@ -34,9 +34,10 @@
import
UploadZone
from
'
./UploadZone.vue
'
;
import
MediaList
from
'
./MediaList.vue
'
;
import
StringHelpers
from
'
../../../../Core/Assets/js/mixins/StringHelpers.vue
'
;
import
RandomString
from
'
../mixins/RandomString
'
;
export
default
{
mixins
:
[
StringHelpers
],
mixins
:
[
StringHelpers
,
RandomString
],
props
:
{
zone
:
{
type
:
String
,
required
:
true
},
entity
:
{
type
:
String
,
required
:
true
},
...
...
@@ -88,20 +89,12 @@
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
.
eventName
=
`fileWasSelected
${
this
.
randomString
()}${
Math
.
floor
(
Math
.
random
()
*
999999
)}
`
;
this
.
$events
.
listen
(
this
.
eventName
,
(
mediaData
)
=>
{
this
.
dialogVisible
=
false
;
...
...
Modules/Media/Assets/js/mixins/RandomString.js
0 → 100644
View file @
b729c09d
export
default
{
methods
:
{
randomString
(
length
)
{
const
len
=
length
||
5
;
let
text
=
''
;
const
possible
=
'
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
'
;
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
text
+=
possible
.
charAt
(
Math
.
floor
(
Math
.
random
()
*
possible
.
length
));
}
return
text
;
},
},
};
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