Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
8a8ce265
Commit
8a8ce265
authored
Jul 07, 2014
by
Thibaut Frain
Committed by
Jérome Perrin
Aug 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created fieldset gadget to manage list of field
parent
4caad75d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
136 additions
and
68 deletions
+136
-68
dream/platform/src2/dream/Input_viewSimulation.html
dream/platform/src2/dream/Input_viewSimulation.html
+4
-2
dream/platform/src2/dream/Input_viewSimulation.js
dream/platform/src2/dream/Input_viewSimulation.js
+23
-66
dream/platform/src2/fieldset/fieldset.js
dream/platform/src2/fieldset/fieldset.js
+87
-0
dream/platform/src2/fieldset/index.html
dream/platform/src2/fieldset/index.html
+22
-0
No files found.
dream/platform/src2/dream/Input_viewSimulation.html
View file @
8a8ce265
...
...
@@ -20,7 +20,9 @@
</head>
<body>
<form
class=
"save_form"
>
<fieldset
class=
"simulation_parameters"
>
<fieldset>
<div
data-gadget-url=
"../fieldset/index.html"
data-gadget-scope=
"fieldset"
></div>
</fieldset>
<button
type=
"submit"
class=
"ui-btn ui-btn-b ui-btn-inline
ui-icon-refresh ui-btn-icon-right"
>
Run Simulation
</button>
...
...
dream/platform/src2/dream/Input_viewSimulation.js
View file @
8a8ce265
/*global rJS, RSVP, jQuery, Handlebars,
promiseEventListener, initGadgetMixin */
/*global rJS, RSVP, jQuery, promiseEventListener, initGadgetMixin */
/*jslint nomen: true */
(
function
(
window
,
rJS
,
RSVP
,
$
,
Handlebars
,
promiseEventListener
,
initGadgetMixin
)
{
(
function
(
window
,
rJS
,
RSVP
,
$
,
promiseEventListener
,
initGadgetMixin
)
{
"
use strict
"
;
function
saveForm
(
gadget
)
{
var
general
=
{};
return
new
RSVP
.
Queue
()
var
general
=
{},
field_gadget_list
;
return
gadget
.
getDeclaredGadget
(
'
fieldset
'
)
.
push
(
function
(
fieldset_gadget
)
{
return
fieldset_gadget
.
getFieldGadgetList
();
})
.
push
(
function
(
field_gadgets
)
{
field_gadget_list
=
field_gadgets
;
})
.
push
(
function
()
{
var
i
,
promise_list
=
[];
for
(
i
=
0
;
i
<
gadget
.
props
.
gadget_list
.
length
;
i
+=
1
)
{
promise_list
.
push
(
gadget
.
props
.
gadget_list
[
i
].
getContent
());
for
(
i
=
0
;
i
<
field_
gadget_list
.
length
;
i
+=
1
)
{
promise_list
.
push
(
field_
gadget_list
[
i
].
getContent
());
}
return
RSVP
.
all
(
promise_list
);
})
...
...
@@ -127,12 +132,7 @@
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
var
gadget_klass
=
rJS
(
window
),
source
=
gadget_klass
.
__template_element
.
getElementById
(
"
label-template
"
)
.
innerHTML
,
label_template
=
Handlebars
.
compile
(
source
);
var
gadget_klass
=
rJS
(
window
);
initGadgetMixin
(
gadget_klass
);
gadget_klass
/////////////////////////////////////////////////////////////////
...
...
@@ -150,49 +150,13 @@
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
render
"
,
function
(
options
)
{
var
i
,
gadget
=
this
,
property
,
parent_element
=
gadget
.
props
.
element
.
querySelector
(
"
.simulation_parameters
"
),
value
,
queue
,
var
gadget
=
this
,
property_list
,
data
;
this
.
props
.
jio_key
=
options
.
id
;
function
addField
(
property
,
value
)
{
var
sub_gadget
;
queue
.
push
(
function
()
{
parent_element
.
insertAdjacentHTML
(
'
beforeend
'
,
label_template
({
label
:
(
property
.
name
||
property
.
id
)})
);
if
(
property
.
type
===
"
number
"
)
{
return
gadget
.
declareGadget
(
"
../number_field/index.html
"
);
}
return
gadget
.
declareGadget
(
"
../string_field/index.html
"
);
})
.
push
(
function
(
gg
)
{
sub_gadget
=
gg
;
value
=
data
[
property
.
id
]
||
value
;
return
sub_gadget
.
render
({
field_json
:
{
title
:
(
property
.
description
||
''
),
key
:
property
.
id
,
value
:
value
}});
})
.
push
(
function
()
{
return
sub_gadget
.
getElement
();
})
.
push
(
function
(
sub_element
)
{
parent_element
.
appendChild
(
sub_element
);
gadget
.
props
.
gadget_list
.
push
(
sub_gadget
);
});
}
queue
=
gadget
.
aq_getAttachment
({
return
gadget
.
aq_getAttachment
({
"
_id
"
:
gadget
.
props
.
jio_key
,
"
_attachment
"
:
"
body.json
"
})
...
...
@@ -201,23 +165,16 @@
return
gadget
.
aq_getConfigurationDict
();
})
.
push
(
function
(
configuration_dict
)
{
var
property_list
=
property_list
=
configuration_dict
[
'
Dream-Configuration
'
].
property_list
;
gadget
.
props
.
gadget_list
=
[];
for
(
i
=
0
;
i
<
property_list
.
length
;
i
+=
1
)
{
property
=
property_list
[
i
];
if
(
property
.
_class
===
"
Dream.Property
"
)
{
value
=
property
.
_default
||
""
;
addField
(
property
,
value
);
}
}
return
gadget
.
getDeclaredGadget
(
'
fieldset
'
);
})
.
push
(
function
(
fieldset_gadget
)
{
return
fieldset_gadget
.
render
(
property_list
,
data
);
});
return
queue
;
})
.
declareMethod
(
"
startService
"
,
function
()
{
return
waitForRunSimulation
(
this
);
});
}(
window
,
rJS
,
RSVP
,
jQuery
,
Handlebars
,
promiseEventListener
,
initGadgetMixin
));
}(
window
,
rJS
,
RSVP
,
jQuery
,
promiseEventListener
,
initGadgetMixin
));
dream/platform/src2/fieldset/fieldset.js
0 → 100644
View file @
8a8ce265
/*global rJS, RSVP, jQuery, Handlebars,
promiseEventListener, initGadgetMixin*/
/*jslint nomen: true */
(
function
(
window
,
rJS
,
RSVP
,
Handlebars
,
initGadgetMixin
)
{
"
use strict
"
;
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
var
gadget_klass
=
rJS
(
window
),
source
=
gadget_klass
.
__template_element
.
getElementById
(
"
label-template
"
)
.
innerHTML
,
label_template
=
Handlebars
.
compile
(
source
);
initGadgetMixin
(
gadget_klass
);
gadget_klass
.
declareMethod
(
"
render
"
,
function
(
property_list
,
data
)
{
var
gadget
=
this
,
queue
,
value
,
property
;
gadget
.
props
.
field_gadget_list
=
[];
function
addField
(
property
,
value
)
{
var
sub_gadget
;
queue
.
push
(
function
()
{
gadget
.
props
.
element
.
insertAdjacentHTML
(
'
beforeend
'
,
label_template
({
"
for
"
:
property
.
id
,
"
name
"
:
(
property
.
name
||
property
.
id
)
})
);
if
(
property
.
type
===
"
number
"
)
{
return
gadget
.
declareGadget
(
"
../number_field/index.html
"
);
}
if
(
property
.
choice
)
{
return
gadget
.
declareGadget
(
"
../list_field/index.html
"
);
}
return
gadget
.
declareGadget
(
"
../string_field/index.html
"
);
})
.
push
(
function
(
gg
)
{
var
choice
=
property
.
choice
||
[],
default_opt
=
choice
[
0
]
?
[
choice
[
0
][
1
]]
:
[
""
];
sub_gadget
=
gg
;
value
=
data
[
property
.
id
]
||
value
;
return
sub_gadget
.
render
({
field_json
:
{
title
:
(
property
.
description
||
''
),
key
:
property
.
id
,
value
:
value
,
items
:
choice
,
default
:
default_opt
}});
})
.
push
(
function
()
{
return
sub_gadget
.
getElement
();
})
.
push
(
function
(
sub_element
)
{
gadget
.
props
.
element
.
appendChild
(
sub_element
);
gadget
.
props
.
field_gadget_list
.
push
(
sub_gadget
);
});
}
queue
=
new
RSVP
.
Queue
()
.
push
(
function
()
{
Object
.
keys
(
property_list
).
forEach
(
function
(
i
)
{
property
=
property_list
[
i
];
if
(
property
.
_class
===
"
Dream.Property
"
)
{
value
=
property
.
_default
||
""
;
addField
(
property
,
value
);
}
});
});
return
queue
;
})
.
declareMethod
(
"
getFieldGadgetList
"
,
function
()
{
return
this
.
props
.
field_gadget_list
;
});
}(
window
,
rJS
,
RSVP
,
Handlebars
,
initGadgetMixin
));
dream/platform/src2/fieldset/index.html
0 → 100644
View file @
8a8ce265
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<title>
Fieldset
</title>
<script
src=
"../<%= copy.rsvp.relative_dest %>"
type=
"text/javascript"
></script>
<script
src=
"../<%= copy.renderjs.relative_dest %>"
type=
"text/javascript"
></script>
<script
src=
"../<%= copy.handlebars.relative_dest %>"
type=
"text/javascript"
></script>
<script
src=
"../<%= curl.jquery.relative_dest %>"
type=
"text/javascript"
></script>
<script
src=
"../<%= curl.jquerymobilejs.relative_dest %>"
type=
"text/javascript"
></script>
<script
id=
"label-template"
type=
"text/x-handlebars-template"
>
<
label
for
=
"
{{for}}
"
>
{{
name
}}
<
/label
>
</script>
<script
src=
"../dream/mixin_gadget.js"
type=
"text/javascript"
></script>
<script
src=
"fieldset.js"
type=
"text/javascript"
></script>
</head>
<body>
</body>
</html>
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