Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-webui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-webui
Commits
c01b4719
Verified
Commit
c01b4719
authored
4 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
STY: js-beautify
parent
4146e4b9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!37
prepare release v0.3.1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/js/form_elements.js
+31
-19
31 additions, 19 deletions
src/core/js/form_elements.js
with
31 additions
and
19 deletions
src/core/js/form_elements.js
+
31
−
19
View file @
c01b4719
...
...
@@ -207,7 +207,7 @@ var form_elements = new function () {
this
.
make_alert
=
function
(
config
)
{
caosdb_utils
.
assert_string
(
config
.
message
,
"
config param `message`
"
);
caosdb_utils
.
assert_type
(
config
.
proceed_callback
,
"
function
"
,
"
config param `proceed_callback`
"
);
"
config param `proceed_callback`
"
);
// define some defaults.
const
title
=
config
.
title
?
`<h4>
${
config
.
title
}
</h4>`
:
""
;
...
...
@@ -218,12 +218,14 @@ var form_elements = new function () {
// check if alert should be created at all
if
(
remember
)
{
var
result
=
this
.
_get_alert_decision
(
config
.
remember_my_decision_id
);
if
(
result
==
"
proceed
"
)
{
// call callback asyncronously and return
(
async
function
(){
config
.
proceed_callback
();
})();
return
undefined
;
}
var
result
=
this
.
_get_alert_decision
(
config
.
remember_my_decision_id
);
if
(
result
==
"
proceed
"
)
{
// call callback asyncronously and return
(
async
function
()
{
config
.
proceed_callback
();
})();
return
undefined
;
}
}
// create the alert
...
...
@@ -235,8 +237,8 @@ var form_elements = new function () {
// create the "Don't ask me again" checkbox
var
checkbox
=
undefined
;
if
(
remember
)
{
const
remember_my_decision_text
=
config
.
remember_my_decision_text
||
"
Don't ask me again.
"
;
const
remember_my_decision_text
=
config
.
remember_my_decision_text
||
"
Don't ask me again.
"
;
checkbox
=
$
(
`<p class="checkbox"><label>
<input type="checkbox"/>
${
remember_my_decision_text
}
</label></p>`
);
_alert
.
append
(
checkbox
);
...
...
@@ -295,7 +297,7 @@ var form_elements = new function () {
return
form_elements
.
_make_option
(
entity_id
,
desc
);
}
this
.
_make_option
=
function
(
value
,
label
)
{
this
.
_make_option
=
function
(
value
,
label
)
{
const
opt_str
=
'
<option value="
'
+
value
+
'
">
'
+
label
+
"
</option>
"
;
return
$
(
opt_str
)[
0
];
...
...
@@ -325,7 +327,7 @@ var form_elements = new function () {
* @returns {HTMLElement} SELECT element with entity options.
*/
this
.
make_reference_select
=
async
function
(
entities
,
make_desc
,
make_value
,
name
,
multiple
)
{
make_value
,
name
,
multiple
)
{
caosdb_utils
.
assert_array
(
entities
,
"
param `entities`
"
,
false
);
if
(
typeof
make_desc
!==
"
undefined
"
)
{
caosdb_utils
.
assert_type
(
make_desc
,
"
function
"
,
...
...
@@ -631,7 +633,7 @@ var form_elements = new function () {
const
is_file
=
$
(
child
).
is
(
"
input:file
"
);
if
(
is_file
)
{
var
fileList
=
child
.
files
;
if
(
fileList
.
length
>
0
)
{
if
(
fileList
.
length
>
0
)
{
for
(
let
i
=
0
;
i
<
fileList
.
length
;
i
++
)
{
value
=
name
+
"
_
"
+
fileList
[
i
].
name
;
if
(
typeof
data
[
name
]
===
"
undefined
"
)
{
...
...
@@ -668,7 +670,7 @@ var form_elements = new function () {
}
this
.
logger
.
trace
(
"
leave element_to_json
"
,
element
,
data
,
files
);
return
[
data
,
files
];
return
[
data
,
files
];
};
const
ret
=
_to_json
(
form
,
{},
[]);
...
...
@@ -1210,7 +1212,9 @@ var form_elements = new function () {
this
.
_make_field_wrapper
=
function
(
name
)
{
caosdb_utils
.
assert_string
(
name
,
"
param `name`
"
);
return
$
(
'
<div class="form-group caosdb-f-field" data-field-name="
'
+
name
+
'
" />
'
)
.
css
({
"
padding
"
:
"
0
"
})[
0
];
.
css
({
"
padding
"
:
"
0
"
})[
0
];
}
/**
...
...
@@ -1274,7 +1278,9 @@ var form_elements = new function () {
$
(
ret
)
.
find
(
"
input:file
"
)
.
prop
(
"
multiple
"
,
!!
config
.
multiple
)
.
css
({
"
display
"
:
"
block
"
});
.
css
({
"
display
"
:
"
block
"
});
if
(
config
.
accept
)
{
$
(
ret
)
.
find
(
"
input:file
"
)
...
...
@@ -1298,7 +1304,13 @@ var form_elements = new function () {
select
.
append
(
form_elements
.
_make_option
(
option
.
value
,
option
.
label
));
}
const
ret
=
form_elements
.
_make_input
(
config
,
select
[
0
]);
form_elements
.
init_select_picker
(
select
[
0
],
config
.
value
);
// Here, the bootstrap-select features should be activated for the new
// select element. However, up until now, this only works when the
// select element is already a part of the dom tree - which is not the
// case when this method is called and is controlled by the client. So
// there is currently no other work-around than to call
// init_select_picker after the form creation explicitely :(
//form_elements.init_select_picker(select[0], config.value);
return
ret
;
}
...
...
@@ -1431,8 +1443,8 @@ var form_elements = new function () {
let
type
=
config
.
type
||
"
text
"
;
let
value
=
config
.
value
;
const
_input
=
$
(
input
||
'
<input class="form-control caosdb-f-property-single-raw-value" type="
'
+
type
+
'
" name="
'
+
name
+
'
" />
'
);
'
<input class="form-control caosdb-f-property-single-raw-value" type="
'
+
type
+
'
" name="
'
+
name
+
'
" />
'
);
_input
.
change
(
function
()
{
ret
[
0
].
dispatchEvent
(
form_elements
.
field_changed_event
);
});
...
...
@@ -1469,4 +1481,4 @@ var form_elements = new function () {
$
(
document
).
ready
(
function
()
{
caosdb_modules
.
register
(
form_elements
);
});
});
\ No newline at end of file
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