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
c79b75a2
Commit
c79b75a2
authored
Jun 19, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GUI: sort actions by priority
parent
0ba9af7d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
6 deletions
+28
-6
dream/platform/src/dream/index.js
dream/platform/src/dream/index.js
+28
-6
No files found.
dream/platform/src/dream/index.js
View file @
c79b75a2
...
...
@@ -33,7 +33,6 @@
/////////////////////////////////////////////////////////////////
// Minimalistic ERP5's like portal type configuration
/////////////////////////////////////////////////////////////////
// XXX we should use lists instead to keep ordering
var
portal_types
=
{
"
Input Module
"
:
{
"
view
"
:
{
...
...
@@ -154,22 +153,45 @@
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
var
url_list
=
[],
action_item_list
=
[],
i
,
key2
;
for
(
key2
in
portal_types
[
portal_type
])
{
if
(
portal_types
[
portal_type
].
hasOwnProperty
(
key2
))
{
action
=
portal_types
[
portal_type
][
key2
];
if
(
action
.
type
===
"
object_view
"
)
{
if
((
action
.
condition
===
undefined
)
||
(
action
.
condition
(
gadget
)))
{
url_list
.
push
(
calculateTabHTML
(
gadget
,
options
,
key2
,
action
.
title
,
(
key2
===
options
.
action
))
);
action_item_list
.
push
([
key2
,
action
]);
}
}
}
}
/*
* Sort actions so that higher priorities are displayed first.
* If no priority is defined, sort by action id to have stable order.
*/
action_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
<
action_item_list
.
length
;
i
+=
1
)
{
url_list
.
push
(
calculateTabHTML
(
gadget
,
options
,
action_item_list
[
i
][
0
],
action_item_list
[
i
][
1
].
title
,
(
action_item_list
[
i
][
0
]
===
options
.
action
))
);
}
return
RSVP
.
all
(
url_list
);
})
.
push
(
function
(
entry_list
)
{
...
...
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