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
201a9994
Commit
201a9994
authored
Aug 11, 2014
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first step of recursive fieldsets
parent
c2b365fd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
9 deletions
+21
-9
dream/platform/src/fieldset/fieldset.js
dream/platform/src/fieldset/fieldset.js
+21
-9
No files found.
dream/platform/src/fieldset/fieldset.js
View file @
201a9994
...
...
@@ -17,17 +17,20 @@
initGadgetMixin
(
gadget_klass
);
gadget_klass
.
declareMethod
(
"
render
"
,
function
(
property_list
,
data
)
{
.
declareMethod
(
"
render
"
,
function
(
property_list
,
data
,
key
)
{
var
gadget
=
this
,
queue
,
value
,
property
;
gadget
.
key
=
key
;
// used for recursive fieldsets
gadget
.
props
.
field_gadget_list
=
[];
function
addField
(
property
,
value
)
{
var
sub_gadget
;
queue
.
push
(
function
()
{
// XXX this is incorrect for recursive fieldsets.
// we should use nested fieldset with legend
gadget
.
props
.
element
.
insertAdjacentHTML
(
'
beforeend
'
,
label_template
({
...
...
@@ -35,6 +38,10 @@
"
name
"
:
(
property
.
name
||
property
.
id
)
})
);
if
(
property
.
_class
===
"
Dream.PropertyList
"
)
{
// Create a recursive fieldset for this key.
return
gadget
.
declareGadget
(
"
../fieldset/index.html
"
);
}
if
(
property
.
type
===
"
number
"
)
{
return
gadget
.
declareGadget
(
"
../number_field/index.html
"
);
}
...
...
@@ -44,11 +51,15 @@
return
gadget
.
declareGadget
(
"
../string_field/index.html
"
);
})
.
push
(
function
(
gg
)
{
sub_gadget
=
gg
;
var
choice
=
property
.
choice
||
[],
default_opt
=
choice
[
0
]
?
[
choice
[
0
][
1
]]
:
[
""
];
sub_gadget
=
gg
;
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
,
...
...
@@ -70,10 +81,8 @@
.
push
(
function
()
{
Object
.
keys
(
property_list
).
forEach
(
function
(
i
)
{
property
=
property_list
[
i
];
if
(
property
.
_class
===
"
Dream.Property
"
)
{
value
=
property
.
_default
||
""
;
addField
(
property
,
value
);
}
});
});
...
...
@@ -82,18 +91,21 @@
// getContent of all subfields
.
declareMethod
(
"
getContent
"
,
function
()
{
var
i
,
promise_list
=
[];
var
i
,
promise_list
=
[]
,
gadget
=
this
;
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
=
{};
var
name
,
result
=
{},
content
=
result
;
if
(
gadget
.
key
)
{
content
=
result
[
gadget
.
key
]
=
{};
}
for
(
i
=
0
;
i
<
result_list
.
length
;
i
+=
1
)
{
for
(
name
in
result_list
[
i
])
{
if
(
result_list
[
i
].
hasOwnProperty
(
name
))
{
resul
t
[
name
]
=
result_list
[
i
][
name
];
conten
t
[
name
]
=
result_list
[
i
][
name
];
}
}
}
...
...
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