Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ecommerce-ui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
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
ecommerce-ui
Commits
556f8af9
Commit
556f8af9
authored
Oct 15, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generic pagination working
parent
a2ded3ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
18 deletions
+68
-18
js/erp5_loader.js
js/erp5_loader.js
+68
-18
No files found.
js/erp5_loader.js
View file @
556f8af9
...
...
@@ -70,8 +70,36 @@
erp5
.
map_actions
=
{
/**
* generic pagination method going forward
* @method next
* generic pagination method changing number of records displayed
* @method limit
* @param {object} e Event
* @param {string} value Value of select
*/
limit
:
function
(
e
,
value
)
{
init
.
paginate
(
e
,
"
limit
"
,
value
);
},
/**
* generic pagination method going to first page
* @method first
* @param {object} e Event
*/
first
:
function
(
e
)
{
init
.
paginate
(
e
,
"
first
"
);
},
/**
* generic pagination method going to last page
* @method last
* @param {object} e Event
*/
last
:
function
(
e
)
{
init
.
paginate
(
e
,
"
last
"
);
},
/**
* generic pagination method going backward
* @method prev
* @param {object} e Event
*/
prev
:
function
(
e
)
{
...
...
@@ -2038,8 +2066,9 @@
* @paginate
* @param {object} e Element triggering pagination
* @param {string} type Where to paginate to
* @param {string} value New limit when changing number of records
*/
init
.
paginate
=
function
(
e
,
type
)
{
init
.
paginate
=
function
(
e
,
type
,
value
)
{
var
element
,
gadget
,
state
,
id
,
start
,
records
;
element
=
e
.
target
;
...
...
@@ -2047,28 +2076,35 @@
gadget
=
document
.
getElementById
(
id
);
state
=
ram_cache
[
init
.
getActivePageId
()].
gadgets
[
id
];
// TODO: validate here again?
if
(
gadget
)
{
if
(
state
)
{
switch
(
type
)
{
case
"
first
"
:
start
=
0
;
records
=
state
.
query
.
limit
[
1
];
break
;
case
"
next
"
:
start
=
state
.
query
.
limit
[
0
]
+
state
.
query
.
limit
[
1
];
records
=
state
.
query
.
limit
[
1
];
if
(
start
>
state
.
total
)
{
return
;
}
break
;
case
"
prev
"
:
start
=
state
.
query
.
limit
[
0
]
-
state
.
query
.
limit
[
1
];
records
=
state
.
query
.
limit
[
1
];
if
(
start
<
0
)
{
return
;
}
break
;
case
"
last
"
:
start
=
state
.
total
-
state
.
query
.
limit
[
1
];
records
=
state
.
query
.
limit
[
1
];
break
;
case
"
limit
"
:
start
=
state
.
query
.
limit
[
0
];
records
=
parseInt
(
value
);
break
;
};
if
(
start
>
state
.
total
||
start
<
0
)
{
return
;
}
// set new limits
state
.
query
.
limit
=
[
start
,
records
];
...
...
@@ -2252,6 +2288,7 @@
);
// go fetching...
// TODO: almost same as updating (no field definitions). Combine?
init
.
fetchConfiguration
(
"
settings
"
,
"
gadgets
"
,
gadget_id
)
.
then
(
function
(
gadget_configuration
)
{
gadget_config
=
gadget_configuration
;
...
...
@@ -2603,18 +2640,32 @@
})
// global actions
.
on
(
"
click
"
,
"
.action
"
,
function
(
e
)
{
var
action
,
handler
,
test
,
target
,
href
,
element
,
form
,
valid
;
// stop
e
.
preventDefault
();
.
on
(
"
click change
"
,
"
.action
"
,
function
(
e
)
{
var
action
,
handler
,
test
,
target
,
href
,
element
,
form
,
valid
,
val
;
// stop links triggering
if
(
e
.
type
===
"
click
"
)
{
e
.
preventDefault
();
if
(
e
.
type
===
"
click
"
&&
e
.
target
.
tagName
===
"
SELECT
"
)
{
return
;
}
}
if
(
e
.
type
===
"
change
"
)
{
val
=
e
.
target
.
options
[
e
.
target
.
selectedIndex
].
value
;
}
// JQM bug on selects
// TODO: remove once fixed
if
(
e
.
target
.
tagName
===
"
SPAN
"
||
e
.
target
.
tagName
===
"
OPTION
"
)
{
return
;
}
// map
action
=
e
.
target
.
getAttribute
(
"
data-action
"
);
handler
=
factory
.
map_actions
[
action
];
if
(
action
)
{
if
(
handler
)
{
handler
(
e
);
handler
(
e
,
val
);
}
else
{
throw
"
No handler defined for this action!
"
;
}
...
...
@@ -2768,7 +2819,6 @@
}
if
(
init
.
storages
[
attachment
])
{
console
.
log
(
"
ENDE
"
);
return
;
}
else
{
// actually this is the only case we end up at
...
...
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