Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Toolkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Web Component Framework
Toolkit
Commits
a4a64997
Commit
a4a64997
authored
5 years ago
by
Neuber, Eugen Ramon
Committed by
Reiter, Christoph
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Make vpu-button disable work
parent
5fee7c49
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/common/utils.js
+22
-12
22 additions, 12 deletions
packages/common/utils.js
packages/common/vpu-button.js
+6
-3
6 additions, 3 deletions
packages/common/vpu-button.js
with
28 additions
and
15 deletions
packages/common/utils.js
+
22
−
12
View file @
a4a64997
import
env
from
'
./env.js
'
;
export
const
getAssetURL
=
(
path
)
=>
{
const
elm
=
document
.
getElementById
(
'
vpu-library-app-src
'
);
if
(
!
elm
)
return
path
;
const
url
=
elm
.
src
;
// newer browsers only
//var url = import.meta.url;
return
new
URL
(
path
,
url
).
href
;
};
/**
* Parses a link header
*
...
...
@@ -28,7 +38,7 @@ export const parseLinkHeader = (header) => {
}
return
links
;
}
}
;
/**
* Reads a setting
...
...
@@ -38,11 +48,11 @@ export const parseLinkHeader = (header) => {
*/
export
const
setting
=
(
key
)
=>
{
return
env
[
key
];
}
}
;
export
const
getAPiUrl
=
(
path
=
""
,
withPrefix
=
true
)
=>
{
return
env
.
apiBaseUrl
+
(
withPrefix
?
env
.
apiUrlPrefix
:
""
)
+
path
;
}
}
;
/**
* Parses the base url from an url
...
...
@@ -55,7 +65,7 @@ export const parseBaseUrl = (url) => {
const
protocol
=
pathArray
[
0
];
const
host
=
pathArray
[
2
];
return
protocol
+
'
//
'
+
host
;
}
}
;
/**
* Converts a string list to a data array for Select2
...
...
@@ -67,7 +77,7 @@ export const stringListToSelect2DataArray = (list) => {
let
data
=
[];
list
.
forEach
((
item
)
=>
{
data
.
push
({
id
:
item
,
text
:
item
})});
return
data
;
}
}
;
/**
* Does generic Base64 Encoding with support for 16-bit encoded strings
...
...
@@ -84,7 +94,7 @@ export const base64EncodeUnicode = (str) => {
});
return
btoa
(
utf8Bytes
);
}
}
;
/**
* Like customElements.define() but tries to display an error in case the browser doesn't
...
...
@@ -106,7 +116,7 @@ export const defineCustomElement = (name, constructor, options) => {
}
customElements
.
define
(
name
,
constructor
,
options
);
return
true
;
}
}
;
/**
* Creates a random id
...
...
@@ -117,15 +127,15 @@ export const defineCustomElement = (name, constructor, options) => {
* @returns {string}
*/
export
const
makeId
=
(
length
)
=>
{
var
result
=
''
;
var
characters
=
'
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
'
;
var
charactersLength
=
characters
.
length
;
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
let
result
=
''
;
const
characters
=
'
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
'
;
const
charactersLength
=
characters
.
length
;
for
(
let
i
=
0
;
i
<
length
;
i
++
)
{
result
+=
characters
.
charAt
(
Math
.
floor
(
Math
.
random
()
*
charactersLength
));
}
return
result
;
}
}
;
/**
* Pads a number with a 0 so it has two digits
...
...
This diff is collapsed.
Click to expand it.
packages/common/vpu-button.js
+
6
−
3
View file @
a4a64997
import
{
html
,
LitElement
,
css
}
from
'
lit-element
'
;
import
*
as
commonUtils
from
'
./utils.js
'
;
import
bulmaCSSPath
from
'
bulma/css/bulma.min.css
'
;
import
*
as
utils
from
"
../../src/utils
"
;
class
Button
extends
LitElement
{
...
...
@@ -12,6 +11,7 @@ class Button extends LitElement {
this
.
type
=
"
primary
"
;
this
.
spinner
=
false
;
this
.
spinnerOnClick
=
true
;
this
.
disabled
=
false
;
}
static
get
properties
()
{
...
...
@@ -20,6 +20,7 @@ class Button extends LitElement {
type
:
{
type
:
String
},
spinner
:
{
type
:
Boolean
},
spinnerOnClick
:
{
type
:
Boolean
,
attribute
:
'
spinner-on-click
'
},
disabled
:
{
type
:
Boolean
},
};
}
...
...
@@ -38,11 +39,13 @@ class Button extends LitElement {
}
render
()
{
const
bulmaCSS
=
u
tils
.
getAssetURL
(
bulmaCSSPath
);
const
bulmaCSS
=
commonU
tils
.
getAssetURL
(
bulmaCSSPath
);
return
html
`
<link rel="stylesheet" href="
${
bulmaCSS
}
">
<button @click="
${
this
.
clickHandler
}
" class="button
${
this
.
type
}
">
${
this
.
value
}
<vpu-mini-spinner style="display:
${
this
.
spinner
?
"
inline
"
:
"
none
"
}
"></vpu-mini-spinner></button>
<button @click="
${
this
.
clickHandler
}
" class="button
${
this
.
type
}
" ?disabled="
${
this
.
disabled
}
">
${
this
.
value
}
<vpu-mini-spinner style="display:
${
this
.
spinner
?
"
inline
"
:
"
none
"
}
"></vpu-mini-spinner>
</button>
`
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment