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
b241a3d5
Commit
b241a3d5
authored
Jul 25, 2014
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
publish static version
parent
ede9bfe3
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
338 additions
and
69 deletions
+338
-69
dream/platform/static/dream/Input_viewAvailableCapacitySpreadsheet.html
.../static/dream/Input_viewAvailableCapacitySpreadsheet.html
+23
-0
dream/platform/static/dream/Input_viewAvailableCapacitySpreadsheet.js
...rm/static/dream/Input_viewAvailableCapacitySpreadsheet.js
+57
-0
dream/platform/static/dream/Input_viewRequiredCapacitySpreadsheet.html
...m/static/dream/Input_viewRequiredCapacitySpreadsheet.html
+23
-0
dream/platform/static/dream/Input_viewRequiredCapacitySpreadsheet.js
...orm/static/dream/Input_viewRequiredCapacitySpreadsheet.js
+58
-0
dream/platform/static/dream/Input_viewSimulation.js
dream/platform/static/dream/Input_viewSimulation.js
+4
-23
dream/platform/static/dream/Output_viewCapacityUtilisationGraph.html
...orm/static/dream/Output_viewCapacityUtilisationGraph.html
+17
-0
dream/platform/static/dream/Output_viewCapacityUtilisationGraph.js
...tform/static/dream/Output_viewCapacityUtilisationGraph.js
+84
-0
dream/platform/static/dream/Output_viewExitStatistics.js
dream/platform/static/dream/Output_viewExitStatistics.js
+3
-3
dream/platform/static/dream/index.html
dream/platform/static/dream/index.html
+7
-0
dream/platform/static/dream/index.js
dream/platform/static/dream/index.js
+11
-2
dream/platform/static/fieldset/fieldset.js
dream/platform/static/fieldset/fieldset.js
+19
-3
dream/platform/static/jsplumb/jsplumb.js
dream/platform/static/jsplumb/jsplumb.js
+28
-38
dream/platform/static/list_field/listfield.js
dream/platform/static/list_field/listfield.js
+4
-0
No files found.
dream/platform/static/dream/Input_viewAvailableCapacitySpreadsheet.html
0 → 100644
View file @
b241a3d5
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<title>
Edit Available Capacity Spreadsheet
</title>
<script
src=
"../lib/rsvp.min.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/renderjs.min.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/jquery.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/jquerymobile.js"
type=
"text/javascript"
></script>
<script
src=
"mixin_gadget.js"
type=
"text/javascript"
></script>
<script
src=
"Input_viewAvailableCapacitySpreadsheet.js"
type=
"text/javascript"
></script>
</head>
<body>
<div
data-gadget-url=
"../handsontable/index.html"
data-gadget-scope=
"tableeditor"
></div>
<form
class=
"save_form"
>
<button
type=
"submit"
class=
"ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right"
>
Save
</button>
</form>
</body>
</html>
dream/platform/static/dream/Input_viewAvailableCapacitySpreadsheet.js
0 → 100644
View file @
b241a3d5
/*global rJS, RSVP, initGadgetMixin, loopEventListener */
(
function
(
window
,
rJS
,
RSVP
,
initGadgetMixin
,
loopEventListener
)
{
"
use strict
"
;
function
saveSpreadsheet
(
evt
)
{
var
gadget
=
this
,
editor_data
,
editor_gadget
;
return
new
RSVP
.
Queue
().
push
(
function
()
{
// Prevent double click
evt
.
target
.
getElementsByClassName
(
"
ui-btn
"
)[
0
].
disabled
=
true
;
return
gadget
.
getDeclaredGadget
(
"
tableeditor
"
);
}).
push
(
function
(
tablegadget
)
{
editor_gadget
=
tablegadget
;
return
editor_gadget
.
getData
();
}).
push
(
function
(
data
)
{
editor_data
=
data
;
// Always get a fresh version, to prevent deleting spreadsheet & co
return
gadget
.
aq_getAttachment
({
_id
:
gadget
.
props
.
jio_key
,
_attachment
:
"
body.json
"
});
}).
push
(
function
(
body
)
{
var
data
=
JSON
.
parse
(
body
);
data
.
capacity_by_project_spreadsheet
=
JSON
.
parse
(
editor_data
);
return
gadget
.
aq_putAttachment
({
_id
:
gadget
.
props
.
jio_key
,
_attachment
:
"
body.json
"
,
_data
:
JSON
.
stringify
(
data
,
null
,
2
),
_mimetype
:
"
application/json
"
});
}).
push
(
function
()
{
evt
.
target
.
getElementsByClassName
(
"
ui-btn
"
)[
0
].
disabled
=
false
;
});
}
function
waitForSave
(
gadget
)
{
return
loopEventListener
(
gadget
.
props
.
element
.
getElementsByClassName
(
"
save_form
"
)[
0
],
"
submit
"
,
false
,
saveSpreadsheet
.
bind
(
gadget
));
}
var
gadget_klass
=
rJS
(
window
);
initGadgetMixin
(
gadget_klass
);
gadget_klass
.
declareAcquiredMethod
(
"
aq_getAttachment
"
,
"
jio_getAttachment
"
).
declareAcquiredMethod
(
"
aq_putAttachment
"
,
"
jio_putAttachment
"
).
declareMethod
(
"
render
"
,
function
(
options
)
{
var
jio_key
=
options
.
id
,
gadget
=
this
;
gadget
.
props
.
jio_key
=
jio_key
;
return
new
RSVP
.
Queue
().
push
(
function
()
{
return
RSVP
.
all
([
gadget
.
aq_getAttachment
({
_id
:
jio_key
,
_attachment
:
"
body.json
"
}),
gadget
.
getDeclaredGadget
(
"
tableeditor
"
)
]);
}).
push
(
function
(
result_list
)
{
return
result_list
[
1
].
render
(
JSON
.
stringify
(
JSON
.
parse
(
result_list
[
0
]).
capacity_by_project_spreadsheet
),
{
minSpareRows
:
1
});
});
}).
declareMethod
(
"
startService
"
,
function
()
{
var
gadget
=
this
;
return
this
.
getDeclaredGadget
(
"
tableeditor
"
).
push
(
function
(
tableeditor
)
{
return
RSVP
.
all
([
tableeditor
.
startService
(),
waitForSave
(
gadget
)
]);
});
});
})(
window
,
rJS
,
RSVP
,
initGadgetMixin
,
loopEventListener
);
\ No newline at end of file
dream/platform/static/dream/Input_viewRequiredCapacitySpreadsheet.html
0 → 100644
View file @
b241a3d5
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<title>
Edit Required Capacity Spreadsheet
</title>
<script
src=
"../lib/rsvp.min.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/renderjs.min.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/jquery.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/jquerymobile.js"
type=
"text/javascript"
></script>
<script
src=
"mixin_gadget.js"
type=
"text/javascript"
></script>
<script
src=
"Input_viewRequiredCapacitySpreadsheet.js"
type=
"text/javascript"
></script>
</head>
<body>
<div
data-gadget-url=
"../handsontable/index.html"
data-gadget-scope=
"tableeditor"
></div>
<form
class=
"save_form"
>
<button
type=
"submit"
class=
"ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right"
>
Save
</button>
</form>
</body>
</html>
dream/platform/static/dream/Input_viewRequiredCapacitySpreadsheet.js
0 → 100644
View file @
b241a3d5
/*global rJS, RSVP, initGadgetMixin, loopEventListener */
(
function
(
window
,
rJS
,
RSVP
,
initGadgetMixin
,
loopEventListener
)
{
"
use strict
"
;
function
saveSpreadsheet
(
evt
)
{
var
gadget
=
this
,
editor_data
,
editor_gadget
;
return
new
RSVP
.
Queue
().
push
(
function
()
{
// Prevent double click
evt
.
target
.
getElementsByClassName
(
"
ui-btn
"
)[
0
].
disabled
=
true
;
return
gadget
.
getDeclaredGadget
(
"
tableeditor
"
);
}).
push
(
function
(
tablegadget
)
{
editor_gadget
=
tablegadget
;
return
editor_gadget
.
getData
();
}).
push
(
function
(
data
)
{
editor_data
=
data
;
// Always get a fresh version, to prevent deleting spreadsheet & co
return
gadget
.
aq_getAttachment
({
_id
:
gadget
.
props
.
jio_key
,
_attachment
:
"
body.json
"
});
}).
push
(
function
(
body
)
{
var
data
=
JSON
.
parse
(
body
);
data
.
capacity_by_station_spreadsheet
=
JSON
.
parse
(
editor_data
);
return
gadget
.
aq_putAttachment
({
_id
:
gadget
.
props
.
jio_key
,
_attachment
:
"
body.json
"
,
_data
:
JSON
.
stringify
(
data
,
null
,
2
),
_mimetype
:
"
application/json
"
});
}).
push
(
function
()
{
evt
.
target
.
getElementsByClassName
(
"
ui-btn
"
)[
0
].
disabled
=
false
;
});
}
function
waitForSave
(
gadget
)
{
return
loopEventListener
(
gadget
.
props
.
element
.
getElementsByClassName
(
"
save_form
"
)[
0
],
"
submit
"
,
false
,
saveSpreadsheet
.
bind
(
gadget
));
}
var
gadget_klass
=
rJS
(
window
);
initGadgetMixin
(
gadget_klass
);
gadget_klass
.
declareAcquiredMethod
(
"
aq_getAttachment
"
,
"
jio_getAttachment
"
).
declareAcquiredMethod
(
"
aq_putAttachment
"
,
"
jio_putAttachment
"
).
declareMethod
(
"
render
"
,
function
(
options
)
{
var
jio_key
=
options
.
id
,
gadget
=
this
;
gadget
.
props
.
jio_key
=
jio_key
;
return
new
RSVP
.
Queue
().
push
(
function
()
{
return
RSVP
.
all
([
gadget
.
aq_getAttachment
({
_id
:
jio_key
,
_attachment
:
"
body.json
"
}),
gadget
.
getDeclaredGadget
(
"
tableeditor
"
)
]);
}).
push
(
function
(
result_list
)
{
return
result_list
[
1
].
render
(
JSON
.
stringify
(
JSON
.
parse
(
result_list
[
0
]).
capacity_by_station_spreadsheet
),
{
minSpareCols
:
1
,
minSpareRows
:
1
});
});
}).
declareMethod
(
"
startService
"
,
function
()
{
var
gadget
=
this
;
return
this
.
getDeclaredGadget
(
"
tableeditor
"
).
push
(
function
(
tableeditor
)
{
return
RSVP
.
all
([
tableeditor
.
startService
(),
waitForSave
(
gadget
)
]);
});
});
})(
window
,
rJS
,
RSVP
,
initGadgetMixin
,
loopEventListener
);
\ No newline at end of file
dream/platform/static/dream/Input_viewSimulation.js
View file @
b241a3d5
...
...
@@ -3,30 +3,11 @@
(
function
(
window
,
rJS
,
RSVP
,
$
,
promiseEventListener
,
initGadgetMixin
)
{
"
use strict
"
;
function
saveForm
(
gadget
)
{
var
general
=
{},
field_gadget_list
;
var
general
;
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
<
field_gadget_list
.
length
;
i
+=
1
)
{
promise_list
.
push
(
field_gadget_list
[
i
].
getContent
());
}
return
RSVP
.
all
(
promise_list
);
}).
push
(
function
(
result_list
)
{
var
i
,
result
,
key
;
for
(
i
=
0
;
i
<
result_list
.
length
;
i
+=
1
)
{
result
=
result_list
[
i
];
for
(
key
in
result
)
{
if
(
result
.
hasOwnProperty
(
key
))
{
// Drop empty
if
(
result
[
key
])
{
general
[
key
]
=
result
[
key
];
}
}
}
}
return
fieldset_gadget
.
getContent
();
}).
push
(
function
(
content
)
{
general
=
content
;
// Always get a fresh version, to prevent deleting spreadsheet & co
return
gadget
.
aq_getAttachment
({
_id
:
gadget
.
props
.
jio_key
,
...
...
dream/platform/static/dream/Output_viewCapacityUtilisationGraph.html
0 → 100644
View file @
b241a3d5
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<title>
Stations Utilization
</title>
<script
src=
"../lib/rsvp.min.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/renderjs.min.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/jquery.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/jquery.flot.js"
></script>
<script
src=
"../lib/jquery.flot.stack.js"
></script>
<script
src=
"mixin_gadget.js"
type=
"text/javascript"
></script>
<script
src=
"Output_viewCapacityUtilisationGraph.js"
type=
"text/javascript"
></script>
</head>
<body>
</body>
</html>
dream/platform/static/dream/Output_viewCapacityUtilisationGraph.js
0 → 100644
View file @
b241a3d5
/*global rJS, jQuery, initGadgetMixin */
/*jslint unparam: true */
(
function
(
window
,
rJS
,
$
,
initGadgetMixin
)
{
"
use strict
"
;
function
capacity_utilisation_graph_widget
(
all_data
)
{
var
available_capacity_by_station
=
{},
station_id
,
series
,
graph_list
=
[],
options
,
capacity_usage_by_station
=
{},
input_data
=
all_data
.
input
,
output_data
=
all_data
.
result
;
// Compute availability by station
$
.
each
(
input_data
.
nodes
,
function
(
idx
,
obj
)
{
var
available_capacity
=
[];
if
(
obj
.
intervalCapacity
!==
undefined
)
{
$
.
each
(
obj
.
intervalCapacity
,
function
(
i
,
capacity
)
{
available_capacity
.
push
([
i
,
capacity
]);
});
available_capacity_by_station
[
obj
.
id
]
=
available_capacity
;
}
});
// Compute used capacity by station
$
.
each
(
output_data
.
elementList
.
sort
(
function
(
a
,
b
)
{
return
a
.
id
<
b
.
id
?
-
1
:
1
;
}),
function
(
idx
,
obj
)
{
if
(
obj
.
results
!==
undefined
&&
obj
.
results
.
capacityUsed
!==
undefined
)
{
var
capacity_usage
=
[];
$
.
each
(
obj
.
results
.
capacityUsed
,
function
(
i
,
step
)
{
var
period
=
0
,
usage
=
0
;
$
.
each
(
step
,
function
(
k
,
v
)
{
if
(
k
===
"
period
"
)
{
period
=
v
;
}
});
$
.
each
(
step
,
function
(
k
,
v
)
{
if
(
k
!==
"
utilization
"
&&
k
!==
"
period
"
)
{
usage
+=
v
;
}
});
capacity_usage
.
push
([
period
,
usage
]);
});
capacity_usage_by_station
[
obj
.
id
]
=
capacity_usage
;
}
});
for
(
station_id
in
available_capacity_by_station
)
{
if
(
available_capacity_by_station
.
hasOwnProperty
(
station_id
))
{
series
=
[
{
label
:
"
Capacity
"
,
data
:
available_capacity_by_station
[
station_id
],
color
:
"
green
"
},
{
label
:
"
Utilisation
"
,
data
:
capacity_usage_by_station
[
station_id
],
color
:
"
red
"
}
];
options
=
{
series
:
{
lines
:
{
show
:
true
,
fill
:
true
}
}
};
graph_list
.
push
([
input_data
.
nodes
[
station_id
].
name
||
station_id
,
series
,
options
]);
}
}
return
graph_list
;
}
var
gadget_klass
=
rJS
(
window
);
initGadgetMixin
(
gadget_klass
);
gadget_klass
.
declareAcquiredMethod
(
"
aq_getAttachment
"
,
"
jio_getAttachment
"
).
declareMethod
(
"
render
"
,
function
(
options
)
{
var
jio_key
=
options
.
id
,
gadget
=
this
;
gadget
.
props
.
jio_key
=
jio_key
;
gadget
.
props
.
result
=
options
.
result
;
return
gadget
.
aq_getAttachment
({
_id
:
gadget
.
props
.
jio_key
,
_attachment
:
"
simulation.json
"
}).
push
(
function
(
simulation_json
)
{
gadget
.
props
.
result_list
=
capacity_utilisation_graph_widget
(
JSON
.
parse
(
simulation_json
)[
gadget
.
props
.
result
]);
});
}).
declareMethod
(
"
startService
"
,
function
()
{
var
element
=
$
(
this
.
props
.
element
),
graph
;
$
.
each
(
this
.
props
.
result_list
,
function
(
idx
,
result
)
{
graph
=
$
(
"
<div class='capacity_graph'
"
+
"
style='width: 70%; height: 250px'></div>
"
);
element
.
append
(
$
(
"
<h2>
"
).
text
(
result
[
0
]),
graph
);
$
.
plot
(
graph
,
result
[
1
],
result
[
2
]);
});
});
})(
window
,
rJS
,
jQuery
,
initGadgetMixin
);
\ No newline at end of file
dream/platform/static/dream/Output_viewExitStatistics.js
View file @
b241a3d5
...
...
@@ -16,8 +16,8 @@
return
a
+
b
;
})
/
attainment_list
.
length
*
100
).
toFixed
(
2
);
}
function
calculate_exit_stat
(
output_
data
)
{
var
elementList
=
output_data
.
elementList
,
i
,
j
,
metric
,
metric_value
,
element
,
interval_value
,
interval_list
,
attainment_list
,
throughputTarget
=
parseFloat
(
output_data
.
general
.
throughputTarget
)
,
result
=
""
;
function
calculate_exit_stat
(
data
)
{
var
output_data
=
data
.
result
,
input_data
=
data
.
input
,
elementList
=
output_data
.
elementList
,
i
,
j
,
metric
,
metric_value
,
element
,
interval_value
,
interval_list
,
attainment_list
,
throughputTarget
=
input_data
.
general
.
throughputTarget
,
result
=
""
;
for
(
i
=
0
;
i
<
elementList
.
length
;
i
+=
1
)
{
element
=
elementList
[
i
];
if
(
element
.
_class
===
"
Dream.Exit
"
)
{
...
...
@@ -93,7 +93,7 @@
_id
:
gadget
.
props
.
jio_key
,
_attachment
:
"
simulation.json
"
}).
push
(
function
(
simulation_json
)
{
var
result
=
calculate_exit_stat
(
JSON
.
parse
(
simulation_json
)[
gadget
.
props
.
result
]
.
result
);
var
result
=
calculate_exit_stat
(
JSON
.
parse
(
simulation_json
)[
gadget
.
props
.
result
]);
gadget
.
props
.
element
.
innerHTML
=
result
;
});
});
...
...
dream/platform/static/dream/index.html
View file @
b241a3d5
...
...
@@ -34,6 +34,13 @@
<
li
><
a
href
=
"
{{link}}
"
>
{{
title
}}
<
/a></
li
>
</script>
<script
id=
"error-template"
type=
"text/x-handlebars-template"
>
<
h1
>
An
Error
Has
Occurred
<
/h1
>
<
a
href
=
"
javascript: location.reload()
"
>
Click
here
to
reload
the
page
<
/a><br/
>
The
error
detail
is
:
<
pre
>
{{
error
}}
<
/pre
>
</script>
</head>
<body>
...
...
dream/platform/static/dream/index.js
View file @
b241a3d5
/*global jQuery, rJS, RSVP, alert, Handlebars, initGadgetMixin */
/*global
console,
jQuery, rJS, RSVP, alert, Handlebars, initGadgetMixin */
/*jslint nomen: true */
(
function
(
window
,
$
,
rJS
,
RSVP
,
Handlebars
,
initGadgetMixin
)
{
"
use strict
"
;
...
...
@@ -138,7 +138,7 @@
}
}
}
},
panel_template
,
navigation_template
,
active_navigation_template
,
gadget_klass
=
rJS
(
window
);
},
panel_template
,
navigation_template
,
active_navigation_template
,
error_template
,
gadget_klass
=
rJS
(
window
);
function
calculateTabHTML
(
gadget
,
options
,
key
,
title
,
active
)
{
return
new
RSVP
.
Queue
().
push
(
function
()
{
var
kw
=
{
...
...
@@ -312,6 +312,7 @@
panel_template
=
Handlebars
.
compile
(
document
.
getElementById
(
"
panel-template
"
).
innerHTML
);
navigation_template
=
Handlebars
.
compile
(
document
.
getElementById
(
"
navigation-template
"
).
innerHTML
);
active_navigation_template
=
Handlebars
.
compile
(
document
.
getElementById
(
"
active-navigation-template
"
).
innerHTML
);
error_template
=
Handlebars
.
compile
(
document
.
getElementById
(
"
error-template
"
).
innerHTML
);
}
}).
ready
(
function
(
g
)
{
return
new
RSVP
.
Queue
().
push
(
function
()
{
...
...
@@ -404,6 +405,14 @@
if
(
page_gadget
.
startService
!==
undefined
)
{
return
page_gadget
.
startService
();
}
}).
push
(
undefined
,
function
(
error
)
{
if
(
error
instanceof
RSVP
.
CancellationError
)
{
throw
error
;
}
console
.
error
(
error
);
document
.
querySelector
(
"
article[class='gadget_container']
"
).
innerHTML
=
error_template
({
error
:
error
});
});
});
})(
window
,
jQuery
,
rJS
,
RSVP
,
Handlebars
,
initGadgetMixin
);
\ No newline at end of file
dream/platform/static/fieldset/fieldset.js
View file @
b241a3d5
...
...
@@ -29,7 +29,7 @@
}).
push
(
function
(
gg
)
{
var
choice
=
property
.
choice
||
[],
default_opt
=
choice
[
0
]
?
[
choice
[
0
][
1
]
]
:
[
""
];
sub_gadget
=
gg
;
value
=
data
[
property
.
id
]
||
value
;
value
=
data
[
property
.
id
]
===
undefined
?
value
:
data
[
property
.
id
]
;
return
sub_gadget
.
render
({
field_json
:
{
title
:
property
.
description
||
""
,
...
...
@@ -56,7 +56,23 @@
});
});
return
queue
;
}).
declareMethod
(
"
getFieldGadgetList
"
,
function
()
{
return
this
.
props
.
field_gadget_list
;
}).
declareMethod
(
"
getContent
"
,
function
()
{
var
i
,
promise_list
=
[];
for
(
i
=
0
;
i
<
this
.
props
.
field_gadget_list
.
length
;
i
+=
1
)
{
promise_list
.
push
(
this
.
props
.
field_gadget_list
[
i
].
getContent
());
}
return
RSVP
.
Queue
().
push
(
function
()
{
return
RSVP
.
all
(
promise_list
);
}).
push
(
function
(
result_list
)
{
var
name
,
result
=
{};
for
(
i
=
0
;
i
<
result_list
.
length
;
i
+=
1
)
{
for
(
name
in
result_list
[
i
])
{
if
(
result_list
[
i
].
hasOwnProperty
(
name
))
{
result
[
name
]
=
result_list
[
i
][
name
];
}
}
}
return
result
;
});
});
})(
window
,
rJS
,
RSVP
,
Handlebars
,
initGadgetMixin
);
\ No newline at end of file
dream/platform/static/jsplumb/jsplumb.js
View file @
b241a3d5
...
...
@@ -84,17 +84,12 @@
}
return
"
DreamNode_
"
+
n
;
}
function
onDataChange
()
{
//$.publish("Dream.Gui.onDataChange", g.private.getData());
return
undefined
;
}
function
updateConnectionData
(
gadget
,
connection
,
remove
,
edge_data
)
{
if
(
remove
)
{
delete
gadget
.
props
.
edge_container
[
connection
.
id
];
}
else
{
gadget
.
props
.
edge_container
[
connection
.
id
]
=
[
getNodeId
(
gadget
.
props
.
node_container
,
connection
.
sourceId
),
getNodeId
(
gadget
.
props
.
node_container
,
connection
.
targetId
),
edge_data
||
{}
];
}
onDataChange
();
}
// bind to connection/connectionDetached events,
// and update the list of connections on screen.
...
...
@@ -134,7 +129,6 @@
}
coordinates
[
node_id
]
=
coordinate
;
gadget
.
props
.
preference_container
.
coordinates
=
coordinates
;
onDataChange
();
return
coordinate
;
}
function
draggable
(
gadget
)
{
...
...
@@ -196,7 +190,6 @@
// return undefined;
// });
// split in 2 methods ? one for events one for manip
onDataChange
();
draggable
(
gadget
);
}
function
updateNodeStyle
(
gadget
,
element_id
)
{
...
...
@@ -275,7 +268,6 @@
// 1.1111;
// setZoom(gadget, zoom_level);
// gadget.props.preference_container.zoom_level = zoom_level;
// onDataChange();
// redraw(gadget);
// }
// function zoom_out(gadget) {
...
...
@@ -283,7 +275,6 @@
// 0.9;
// setZoom(gadget, zoom_level);
// gadget.props.preference_container.zoom_level = zoom_level;
// onDataChange();
// redraw(gadget);
// }
function
removeElement
(
gadget
,
node_id
)
{
...
...
@@ -297,13 +288,12 @@
delete
gadget
.
props
.
edge_container
[
k
];
}
});
onDataChange
();
}
function
updateElementData
(
gadget
,
node_id
,
data
)
{
var
element_id
=
gadget
.
props
.
node_container
[
node_id
].
element_id
,
new_id
=
data
.
id
;
if
(
data
.
name
)
{
$
(
gadget
.
props
.
element
).
find
(
"
#
"
+
element_id
).
text
(
data
.
name
).
append
(
'
<div class="ep"></div></div>
'
);
gadget
.
props
.
node_container
[
node_id
].
name
=
data
.
name
;
if
(
data
.
data
.
name
)
{
$
(
gadget
.
props
.
element
).
find
(
"
#
"
+
element_id
).
text
(
data
.
data
.
name
).
append
(
'
<div class="ep"></div></div>
'
);
gadget
.
props
.
node_container
[
node_id
].
name
=
data
.
data
.
name
;
}
delete
data
.
id
;
$
.
extend
(
gadget
.
props
.
node_container
[
node_id
],
data
.
data
);
...
...
@@ -322,7 +312,6 @@
gadget
.
props
.
preference_container
.
coordinates
[
new_id
]
=
gadget
.
props
.
preference_container
.
coordinates
[
node_id
];
delete
gadget
.
props
.
preference_container
.
coordinates
[
node_id
];
}
onDataChange
();
}
// function clearAll(gadget) {
// $.each(gadget.props.node_container, function (node_id) {
...
...
@@ -364,25 +353,12 @@
// }
// function setGeneralProperties(gadget, properties) {
// gadget.props.general_container = properties;
// onDataChange();
// }
// function updateGeneralProperties(gadget, properties) {
// $.extend(gadget.props.general_container, properties);
// onDataChange();
// }
function
saveNode
(
evt
,
gadget
,
node_id
)
{
var
i
,
data
=
{
id
:
$
(
evt
.
target
[
1
]).
val
(),
name
:
$
(
evt
.
target
[
2
]).
val
()
};
data
.
data
=
{};
for
(
i
=
3
;
i
<
evt
.
target
.
length
-
1
;
i
+=
1
)
{
data
.
data
[
evt
.
target
[
i
].
name
]
=
$
(
evt
.
target
[
i
]).
val
();
}
updateElementData
(
gadget
,
node_id
,
data
);
}
function
openNodeDialog
(
gadget
,
element
,
config_dict
)
{
var
node_id
=
getNodeId
(
gadget
.
props
.
node_container
,
element
.
id
),
node_data
=
gadget
.
props
.
node_container
[
node_id
],
element_type
=
node_data
.
_class
.
replace
(
"
.
"
,
"
-
"
),
property_list
=
config_dict
[
element_type
].
property_list
||
[],
node_edit_popup
=
$
(
gadget
.
props
.
element
).
find
(
"
#popup-edit-template
"
),
fieldset_element
,
save_promise
,
delete_promise
;
var
node_id
=
getNodeId
(
gadget
.
props
.
node_container
,
element
.
id
),
node_data
=
gadget
.
props
.
node_container
[
node_id
],
element_type
=
node_data
.
_class
.
replace
(
"
.
"
,
"
-
"
),
property_list
=
config_dict
[
element_type
].
property_list
||
[],
node_edit_popup
=
$
(
gadget
.
props
.
element
).
find
(
"
#popup-edit-template
"
),
fieldset_element
,
delete_promise
;
if
(
node_edit_popup
.
length
!==
0
)
{
node_edit_popup
.
remove
();
}
...
...
@@ -392,6 +368,7 @@
node_edit_popup
.
popup
();
node_data
.
id
=
node_id
;
if
(
property_list
.
length
===
0
||
property_list
[
0
].
id
!==
"
id
"
)
{
// XXX name & id should not be handled differently in form.
property_list
.
unshift
({
_class
:
"
Dream.Property
"
,
id
:
"
name
"
,
...
...
@@ -405,11 +382,21 @@
type
:
"
string
"
});
}
save_promise
=
new
RSVP
.
Queue
().
push
(
function
()
{
return
promiseEventListener
(
node_edit_popup
.
find
(
"
form
"
)[
0
],
"
submit
"
,
false
);
}).
push
(
function
(
evt
)
{
return
saveNode
(
evt
,
gadget
,
node_id
);
});
function
save_promise
(
fieldset_gadget
,
node_id
)
{
return
RSVP
.
Queue
().
push
(
function
()
{
return
promiseEventListener
(
node_edit_popup
.
find
(
"
form
"
)[
0
],
"
submit
"
,
false
);
}).
push
(
function
(
evt
)
{
var
data
=
{
// XXX id should not be handled differently ...
id
:
$
(
evt
.
target
[
1
]).
val
(),
data
:
{}
};
return
fieldset_gadget
.
getContent
().
then
(
function
(
r
)
{
$
.
extend
(
data
.
data
,
r
);
updateElementData
(
gadget
,
node_id
,
data
);
});
});
}
delete_promise
=
new
RSVP
.
Queue
().
push
(
function
()
{
return
promiseEventListener
(
node_edit_popup
.
find
(
"
form [type='button']
"
)[
0
],
"
click
"
,
false
);
}).
push
(
function
()
{
...
...
@@ -419,12 +406,14 @@
element
:
fieldset_element
,
scope
:
"
fieldset
"
}).
push
(
function
(
fieldset_gadget
)
{
return
fieldset_gadget
.
render
(
property_list
,
node_data
);
}).
push
(
function
()
{
// XXX those promises can probably be merged
return
RSVP
.
all
([
fieldset_gadget
,
fieldset_gadget
.
render
(
property_list
,
node_data
)
]);
}).
push
(
function
(
fieldset_gadget
)
{
node_edit_popup
.
enhanceWithin
();
node_edit_popup
.
popup
(
"
open
"
);
}).
push
(
function
()
{
return
RSVP
.
any
([
save_promise
,
delete_promise
]);
return
fieldset_gadget
[
0
];
}).
push
(
function
(
fieldset_gadget
)
{
return
RSVP
.
any
([
save_promise
(
fieldset_gadget
,
node_id
),
delete_promise
]);
}).
push
(
function
()
{
node_edit_popup
.
popup
(
"
close
"
);
});
...
...
@@ -434,6 +423,8 @@
}
function
newElement
(
gadget
,
element
,
configuration
)
{
var
element_type
=
element
.
_class
.
replace
(
"
.
"
,
"
-
"
),
option
=
configuration
[
element_type
],
render_element
=
$
(
gadget
.
props
.
element
).
find
(
"
#main
"
),
coordinate
=
element
.
coordinate
,
box
,
absolute_position
,
domElement
;
// we don't save coordinates as properties of nodes
delete
element
.
coordinate
;
element
.
element_id
=
generateElementId
(
gadget
.
props
.
element
);
if
(
!
element
.
id
)
{
element
.
id
=
generateNodeId
(
gadget
,
element_type
,
option
);
...
...
@@ -461,7 +452,6 @@
box
.
css
(
"
left
"
,
absolute_position
[
0
]);
updateNodeStyle
(
gadget
,
element
.
element_id
);
draggable
(
gadget
);
onDataChange
();
}
function
waitForDragover
(
gadget
)
{
return
loopEventListener
(
gadget
.
props
.
main
,
"
dragover
"
,
false
,
function
()
{
...
...
dream/platform/static/list_field/listfield.js
View file @
b241a3d5
...
...
@@ -26,5 +26,9 @@
});
}
select
.
innerHTML
+=
tmp
;
}).
declareMethod
(
"
getContent
"
,
function
()
{
var
select
=
this
.
element
.
getElementsByTagName
(
"
select
"
)[
0
],
result
=
{};
result
[
select
.
getAttribute
(
"
name
"
)]
=
select
.
options
[
select
.
selectedIndex
].
value
;
return
result
;
});
})(
window
,
rJS
,
Handlebars
);
\ No newline at end of file
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