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
b7cd320d
Commit
b7cd320d
authored
Nov 20, 2014
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lots of cleanups
parent
2272f3e9
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
134 additions
and
155 deletions
+134
-155
dream/platform/src/dream/Input_viewProductionLine.js
dream/platform/src/dream/Input_viewProductionLine.js
+4
-4
dream/platform/src/fieldset/fieldset.js
dream/platform/src/fieldset/fieldset.js
+30
-30
dream/platform/src/jsplumb/jsplumb.js
dream/platform/src/jsplumb/jsplumb.js
+84
-102
dream/platform/src/list_field/listfield.js
dream/platform/src/list_field/listfield.js
+6
-6
dream/platform/src/number_field/numberfield.js
dream/platform/src/number_field/numberfield.js
+4
-5
dream/platform/src/string_field/stringfield.js
dream/platform/src/string_field/stringfield.js
+4
-5
dream/platform/src/toolbox/toolbox.js
dream/platform/src/toolbox/toolbox.js
+2
-3
No files found.
dream/platform/src/dream/Input_viewProductionLine.js
View file @
b7cd320d
...
...
@@ -3,9 +3,9 @@
"
use strict
"
;
var
gadget_klass
=
rJS
(
window
);
// TODO: save on parent gadget
function
saveGraph
(
evt
)
{
var
gadget
=
this
,
graph_data
;
var
gadget
=
this
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
// Prevent double click
...
...
@@ -18,11 +18,10 @@
return
graph_gadget
.
getContent
();
})
.
push
(
function
(
body
)
{
console
.
log
(
"
saving
"
,
JSON
.
parse
(
body
));
return
gadget
.
aq_putAttachment
({
"
_id
"
:
gadget
.
props
.
jio_key
,
"
_attachment
"
:
"
body.json
"
,
"
_data
"
:
body
,
//JSON.stringify(data
, null, 2),
"
_data
"
:
JSON
.
stringify
(
JSON
.
parse
(
body
)
,
null
,
2
),
"
_mimetype
"
:
"
application/json
"
});
})
...
...
@@ -44,6 +43,7 @@
gadget_klass
// TODO Mixin
.
ready
(
function
(
g
)
{
g
.
props
=
{};
})
...
...
dream/platform/src/fieldset/fieldset.js
View file @
b7cd320d
...
...
@@ -17,15 +17,17 @@
initGadgetMixin
(
gadget_klass
);
gadget_klass
.
declareMethod
(
"
render
"
,
function
(
property_list
,
data
,
key
)
{
.
declareMethod
(
"
render
"
,
function
(
options
,
node_id
)
{
// XXX node_id is added like a property so that one can change the node
// id
var
gadget
=
this
,
queue
,
value
,
property
;
gadget
.
key
=
key
;
// used for recursive fieldsets
gadget
.
props
.
key
=
options
.
key
;
// used for recursive fieldsets
gadget
.
props
.
field_gadget_list
=
[];
function
addField
(
property
,
value
)
{
function
addField
(
property_id
,
property_definition
,
value
)
{
var
sub_gadget
;
queue
.
push
(
function
()
{
...
...
@@ -34,39 +36,29 @@
gadget
.
props
.
element
.
insertAdjacentHTML
(
'
beforeend
'
,
label_template
({
"
for
"
:
property
.
id
,
"
name
"
:
(
property
.
name
||
property
.
id
)
"
for
"
:
property
_
id
,
"
name
"
:
(
property
_definition
.
name
||
property_
id
)
})
);
if
(
property
.
_class
===
"
Dream.PropertyLis
t
"
)
{
if
(
property
_definition
.
type
===
"
objec
t
"
)
{
// Create a recursive fieldset for this key.
return
gadget
.
declareGadget
(
"
../fieldset/index.html
"
);
}
if
(
property
.
type
===
"
number
"
)
{
if
(
property
_definition
.
type
===
"
number
"
)
{
return
gadget
.
declareGadget
(
"
../number_field/index.html
"
);
}
if
(
property
.
choice
)
{
if
(
property
_definition
.
enum
)
{
return
gadget
.
declareGadget
(
"
../list_field/index.html
"
);
}
return
gadget
.
declareGadget
(
"
../string_field/index.html
"
);
})
.
push
(
function
(
gg
)
{
sub_gadget
=
gg
;
var
choice
=
property
.
choice
||
[],
default_opt
=
choice
[
0
]
?
[
choice
[
0
][
1
]]
:
[
""
];
value
=
(
data
[
property
.
id
]
===
undefined
?
value
:
data
[
property
.
id
]);
if
(
gg
.
__title
===
'
Fieldset
'
)
{
// XXX there must be a better way instead of using __title ?
return
gg
.
render
(
property
.
property_list
,
value
,
property
.
id
);
}
return
sub_gadget
.
render
({
field_json
:
{
title
:
(
property
.
description
||
''
),
key
:
property
.
id
,
return
sub_gadget
.
render
({
key
:
property_id
,
value
:
value
,
items
:
choice
,
default
:
default_opt
}});
property_definition
:
property_definition
});
})
.
push
(
function
()
{
return
sub_gadget
.
getElement
();
...
...
@@ -79,13 +71,21 @@
queue
=
new
RSVP
.
Queue
()
.
push
(
function
()
{
Object
.
keys
(
property_list
).
forEach
(
function
(
i
)
{
property
=
property_list
[
i
];
value
=
property
.
_default
===
undefined
?
""
:
property
.
_default
;
addField
(
property
,
value
);
if
(
node_id
)
{
addField
(
'
id
'
,
{
'
type
'
:
'
string
'
},
node_id
);
}
Object
.
keys
(
options
.
property_definition
.
properties
).
forEach
(
function
(
property_name
)
{
var
property_definition
=
options
.
property_definition
.
properties
[
property_name
],
value
=
(
options
.
value
||
{})[
property_name
]
===
undefined
?
property_definition
.
_default
:
options
.
value
[
property_name
];
// XXX some properties are not editable
if
(
property_name
!==
'
coordinate
'
&&
property_name
!==
'
_class
'
)
{
addField
(
property_name
,
property_definition
,
value
);
}
});
});
return
queue
;
})
...
...
@@ -99,8 +99,8 @@
.
push
(
function
()
{
return
RSVP
.
all
(
promise_list
);
})
.
push
(
function
(
result_list
)
{
var
name
,
result
=
{},
content
=
result
;
if
(
gadget
.
key
)
{
content
=
result
[
gadget
.
key
]
=
{};
if
(
gadget
.
props
.
key
)
{
content
=
result
[
gadget
.
props
.
key
]
=
{};
}
for
(
i
=
0
;
i
<
result_list
.
length
;
i
+=
1
)
{
for
(
name
in
result_list
[
i
])
{
...
...
dream/platform/src/jsplumb/jsplumb.js
View file @
b7cd320d
This diff is collapsed.
Click to expand it.
dream/platform/src/list_field/listfield.js
View file @
b7cd320d
...
...
@@ -28,18 +28,18 @@
var
select
=
this
.
element
.
getElementsByTagName
(
'
select
'
)[
0
],
i
,
template
,
field_json
=
options
.
field_json
,
tmp
=
''
;
select
.
setAttribute
(
'
name
'
,
field_json
.
key
);
for
(
i
=
0
;
i
<
field_json
.
items
.
length
;
i
+=
1
)
{
if
(
field_json
.
items
[
i
][
1
]
===
field_json
.
value
)
{
select
.
setAttribute
(
'
name
'
,
options
.
key
);
for
(
i
=
0
;
i
<
options
.
property_definition
.
enum
.
length
;
i
+=
1
)
{
if
(
options
.
property_definition
.
enum
[
i
]
===
options
.
value
)
{
template
=
selected_option_template
;
}
else
{
template
=
option_template
;
}
// XXX value and text are always same in json schema
tmp
+=
template
({
value
:
field_json
.
items
[
i
][
1
],
text
:
field_json
.
items
[
i
][
0
]
value
:
options
.
property_definition
.
enum
[
i
],
text
:
options
.
property_definition
.
enum
[
i
]
});
}
select
.
innerHTML
+=
tmp
;
...
...
dream/platform/src/number_field/numberfield.js
View file @
b7cd320d
...
...
@@ -10,11 +10,10 @@
});
})
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
input
=
this
.
element
.
querySelector
(
'
input
'
),
field_json
=
options
.
field_json
||
{};
input
.
setAttribute
(
'
value
'
,
field_json
.
value
);
input
.
setAttribute
(
'
name
'
,
field_json
.
key
);
input
.
setAttribute
(
'
title
'
,
field_json
.
title
);
var
input
=
this
.
element
.
querySelector
(
'
input
'
);
input
.
setAttribute
(
'
value
'
,
options
.
value
);
input
.
setAttribute
(
'
name
'
,
options
.
key
);
input
.
setAttribute
(
'
title
'
,
options
.
title
||
options
.
key
);
})
.
declareMethod
(
'
getContent
'
,
function
()
{
...
...
dream/platform/src/string_field/stringfield.js
View file @
b7cd320d
...
...
@@ -10,11 +10,10 @@
});
})
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
input
=
this
.
element
.
querySelector
(
'
input
'
),
field_json
=
options
.
field_json
||
{};
input
.
setAttribute
(
'
value
'
,
field_json
.
value
||
""
);
input
.
setAttribute
(
'
name
'
,
field_json
.
key
);
input
.
setAttribute
(
'
title
'
,
field_json
.
title
);
var
input
=
this
.
element
.
querySelector
(
'
input
'
);
input
.
setAttribute
(
'
value
'
,
options
.
value
||
""
);
input
.
setAttribute
(
'
name
'
,
options
.
key
);
input
.
setAttribute
(
'
title
'
,
options
.
title
||
options
.
key
);
})
.
declareMethod
(
'
getContent
'
,
function
()
{
...
...
dream/platform/src/toolbox/toolbox.js
View file @
b7cd320d
...
...
@@ -2,7 +2,6 @@
(
function
(
window
,
document
,
RSVP
,
rJS
,
initGadgetMixin
)
{
"
use strict
"
;
// XXX use a renderjs utility function for that
/*jslint nomen: true*/
var
gadget_klass
=
rJS
(
window
);
function
waitForDragstart
(
tool
)
{
...
...
@@ -19,7 +18,7 @@
callback
=
function
(
evt
)
{
try
{
evt
.
dataTransfer
.
setData
(
'
application/json
'
,
tool
.
dataset
.
class_
definition
);
tool
.
dataset
.
class_
name
);
}
catch
(
e
)
{
reject
(
e
);
}
...
...
@@ -49,7 +48,7 @@
tool
.
className
=
"
tool
"
+
key
;
tool
.
textContent
=
_class
.
name
||
key
;
tool
.
draggable
=
true
;
tool
.
dataset
.
class_
definition
=
JSON
.
stringify
([
key
,
_class
]
);
tool
.
dataset
.
class_
name
=
JSON
.
stringify
(
key
);
Object
.
keys
(
_class
.
css
||
{}).
forEach
(
function
(
k
)
{
tool
.
style
[
k
]
=
_class
.
css
[
k
];
});
...
...
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