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
c5c40a40
Commit
c5c40a40
authored
Jun 26, 2013
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gui prototype: store property values
parent
4c0010e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
29 deletions
+70
-29
dream/platform/static/src/dream.js
dream/platform/static/src/dream.js
+59
-29
dream/platform/static/src/dream_launcher.js
dream/platform/static/src/dream_launcher.js
+1
-0
dream/platform/static/src/jsonPlumb.js
dream/platform/static/src/jsonPlumb.js
+10
-0
No files found.
dream/platform/static/src/dream.js
View file @
c5c40a40
...
...
@@ -52,8 +52,8 @@
priv
.
prepareDialogForElement
=
function
(
title
,
element_id
)
{
// code to allow changing values on connections. For now we assume
// that it is throughput. But we will need more generic code
var
throughput
=
$
(
"
#throughput
"
),
allFields
=
$
(
[]
).
add
(
throughput
);
//
var throughput = $( "#throughput" ),
//
allFields = $( [] ).add( throughput );
$
(
function
()
{
$
(
"
input[type=submit]
"
)
.
button
()
...
...
@@ -65,25 +65,42 @@
// Render fields for that particular element
var
fieldset
=
$
(
"
#dialog-fieldset
"
);
$
(
"
#dialog-fieldset
"
).
children
().
remove
()
var
render_field
=
function
(
property_list
,
prefix
)
{
var
element_id_prefix
=
element_id
.
split
(
"
_
"
)[
0
];
var
property_list
=
configuration
[
element_id_prefix
].
property_list
||
[];
console
.
log
(
"
getData on element_id
"
,
element_id
);
var
previous_data
=
priv
.
plumb
.
getData
()[
"
element
"
];
previous_data
=
previous_data
[
element_id
]
||
{};
previous_data
=
previous_data
.
data
||
{};
console
.
log
(
"
previous_data
"
,
previous_data
);
var
previous_value
;
var
renderField
=
function
(
property_list
,
previous_data
,
prefix
)
{
if
(
prefix
===
undefined
)
{
prefix
=
""
;
}
_
.
each
(
property_list
,
function
(
property
,
key
,
list
)
{
if
(
property
.
_class
===
"
Dream.Property
"
)
{
console
.
log
(
"
property.id, previous_data
"
,
property
.
id
,
previous_data
);
previous_value
=
previous_data
[
property
.
id
]
||
""
;
if
(
previous_value
.
length
>
0
)
{
previous_value
=
'
value="
'
+
previous_value
+
'
"
'
;
}
//previous_value = ' value="bar"';
console
.
log
(
"
previous_value
"
);
fieldset
.
append
(
"
<label>
"
+
prefix
+
property
.
id
+
"
</label>
"
+
'
<input type="text" name="
'
+
property
.
id
+
'
" id="
'
+
property
.
id
+
'
" class="text ui-widget-content ui-corner-all"/>
'
)
'
<input type="text" name="
'
+
prefix
+
property
.
id
+
'
"
'
+
previous_value
+
'
id="
'
+
prefix
+
property
.
id
+
'
"
'
+
'
class="text ui-widget-content ui-corner-all"/>
'
)
}
else
if
(
property
.
_class
===
"
Dream.PropertyList
"
)
{
var
next_prefix
=
prefix
+
property
.
id
+
"
.
"
;
render_field
(
property
.
property_list
,
next_prefix
);
var
next_prefix
=
prefix
+
property
.
id
+
"
-
"
;
var
next_previous_data
=
previous_data
[
property
.
id
]
||
{};
console
.
log
(
"
next_previous_data
"
,
next_previous_data
);
renderField
(
property
.
property_list
,
next_previous_data
,
next_prefix
);
}
});
};
var
element_id_prefix
=
element_id
.
split
(
"
_
"
)[
0
];
var
property_list
=
configuration
[
element_id_prefix
].
property_list
||
[];
console
.
log
(
"
property_list to be rendered
"
,
property_list
);
render
_field
(
property_list
);
render
Field
(
property_list
,
previous_data
);
$
(
"
#dialog-form
"
).
dialog
({
autoOpen
:
false
,
...
...
@@ -100,28 +117,33 @@
priv
.
removeElement
(
element_id
);
$
(
this
).
dialog
(
"
close
"
);
},
"
Validate
"
:
function
()
{
var
bValid
=
true
,
i
,
i_length
,
box
;
allFields
.
removeClass
(
"
ui-state-error
"
);
bValid
=
bValid
&&
checkRegexp
(
throughput
,
/^
([
0-9
])
+$/
,
"
Througput must be integer.
"
);
if
(
bValid
)
{
// Update the model with new value
i_length
=
model
.
box_list
.
length
;
for
(
i
=
0
;
i
<
i_length
;
i
++
)
{
box
=
model
.
box_list
[
i
];
if
(
box
.
id
===
priv
.
box_id
)
{
box
.
throughput
=
parseInt
(
throughput
.
val
(),
10
);
}
Validate
:
function
()
{
var
data
=
{},
prefixed_property_id
,
property_element
;
var
updateDataPropertyList
=
function
(
property_list
,
data
,
prefix
)
{
console
.
log
(
"
updateDataPropertyList, property_list
"
,
property_list
);
if
(
prefix
===
undefined
)
{
prefix
=
""
;
}
priv
.
updateModel
();
$
(
this
).
dialog
(
"
close
"
);
}
_
.
each
(
property_list
,
function
(
property
,
key
,
list
)
{
if
(
property
.
_class
===
"
Dream.Property
"
)
{
prefixed_property_id
=
prefix
+
property
.
id
;
console
.
log
(
"
prefixed_property_id
"
,
prefixed_property_id
);
property_element
=
$
(
"
#
"
+
prefixed_property_id
);
data
[
property
.
id
]
=
property_element
.
val
();
}
else
if
(
property
.
_class
===
"
Dream.PropertyList
"
)
{
var
next_prefix
=
prefix
+
property
.
id
+
"
-
"
;
data
[
property
.
id
]
=
{};
updateDataPropertyList
(
property
.
property_list
,
data
[
property
.
id
],
next_prefix
);
}
});
};
updateDataPropertyList
(
property_list
,
data
);
priv
.
plumb
.
updateElementData
(
element_id
,
{
data
:
data
});
$
(
this
).
dialog
(
"
close
"
);
},
},
close
:
function
()
{
allFields
.
val
(
""
).
removeClass
(
"
ui-state-error
"
);
//
allFields.val( "" ).removeClass( "ui-state-error" );
}
});
};
...
...
@@ -135,7 +157,6 @@
priv
.
plumb
.
newElement
(
element
,
configuration
[
element_id
]);
$
(
"
#
"
+
element
.
id
).
bind
(
'
click
'
,
function
()
{
console
.
log
(
"
bind click on window
"
,
$
(
this
));
//$("#dialog-form").attr("title", "bar");
$
(
"
#dialog-form
"
).
dialog
(
"
destroy
"
)
;
priv
.
prepareDialogForElement
(
element
.
id
,
element
.
id
);
$
(
"
#dialog-form
"
).
dialog
(
"
open
"
);
...
...
@@ -164,6 +185,15 @@
}
});
Object
.
defineProperty
(
that
,
"
updateElementData
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
element_id
,
data
)
{
priv
.
plumb
.
updateElementData
(
element_id
,
data
);
}
});
return
that
;
};
var
DreamNamespace
=
(
function
()
{
...
...
dream/platform/static/src/dream_launcher.js
View file @
c5c40a40
...
...
@@ -80,6 +80,7 @@
});
console
.
log
(
"
going to add newElement
"
,
value
);
dream_instance
.
newElement
(
value
);
dream_instance
.
updateElementData
(
element_id
,
{
data
:
value
.
data
||
{}});
});
// Now link elements between them and update id_container
_
.
each
(
response
.
data
.
element
,
function
(
value
,
key
,
list
)
{
...
...
dream/platform/static/src/jsonPlumb.js
View file @
c5c40a40
...
...
@@ -133,6 +133,16 @@
priv
.
onDataChange
();
};
Object
.
defineProperty
(
that
,
"
updateElementData
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
element_id
,
data
)
{
_
.
extend
(
priv
.
element_container
[
element_id
],
data
);
priv
.
onDataChange
();
}
});
Object
.
defineProperty
(
that
,
"
start
"
,
{
configurable
:
false
,
enumerable
:
false
,
...
...
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