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
2aa28a74
Commit
2aa28a74
authored
Jun 19, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
graph editor: sort properties by "priority" property, then by property id
parent
c79b75a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
7 deletions
+30
-7
dream/platform/src/fieldset/fieldset.js
dream/platform/src/fieldset/fieldset.js
+30
-7
No files found.
dream/platform/src/fieldset/fieldset.js
View file @
2aa28a74
...
...
@@ -83,6 +83,7 @@
queue
=
new
RSVP
.
Queue
()
.
push
(
function
()
{
var
property_item_list
=
[],
i
,
property_name
,
property_definition
,
value
;
//gadget.props.fieldset_element = document.createElement("fieldset");
//gadget.props.element.appendChild(gadget.props.fieldset_element);
gadget
.
props
.
fieldset_element
=
gadget
.
props
.
element
;
...
...
@@ -93,12 +94,34 @@
if
(
node_id
)
{
addField
(
'
id
'
,
options
.
property_definition
.
properties
.
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
];
Object
.
keys
(
options
.
property_definition
.
properties
).
forEach
(
function
(
property_name
)
{
property_item_list
.
push
([
property_name
,
options
.
property_definition
.
properties
[
property_name
]]);
});
/*
* Sort properties so that higher priorities are displayed first.
* If no priority is defined, sort by property id to have stable order.
*/
property_item_list
.
sort
(
function
(
a
,
b
)
{
var
key_a
=
a
[
0
],
value_a
=
a
[
1
],
key_b
=
b
[
0
],
value_b
=
b
[
1
];
if
(
!
isNaN
(
value_a
.
priority
))
{
if
(
!
isNaN
(
value_b
.
priority
))
{
return
value_b
.
priority
-
value_a
.
priority
;
}
return
-
1
;
}
if
(
!
isNaN
(
value_b
.
priority
))
{
return
1
;
}
return
key_a
<
key_b
?
-
1
:
(
key_a
>
key_b
?
1
:
0
);
});
for
(
i
=
0
;
i
<
property_item_list
.
length
;
i
+=
1
)
{
property_name
=
property_item_list
[
i
][
0
];
property_definition
=
property_item_list
[
i
][
1
];
value
=
(
options
.
value
||
{})[
property_name
]
===
undefined
?
property_definition
.
default
:
options
.
value
[
property_name
];
// XXX some properties are not editable
// XXX should not be defined here
if
(
property_name
!==
'
coordinate
'
&&
...
...
@@ -106,7 +129,7 @@
property_name
!==
'
id
'
)
{
addField
(
property_name
,
property_definition
,
value
);
}
}
);
}
});
return
queue
;
})
...
...
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