Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
justinfreeman (Agileware)
Core
Commits
fe010227
Commit
fe010227
authored
11 years ago
by
colemanw
Browse files
Options
Downloads
Patches
Plain Diff
CRM-12872 - Ajax-enable pager rowCount
parent
d8249fcb
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Utils/Pager.php
+5
-26
5 additions, 26 deletions
CRM/Utils/Pager.php
CRM/Utils/System.php
+5
-3
5 additions, 3 deletions
CRM/Utils/System.php
templates/CRM/common/pager.tpl
+49
-18
49 additions, 18 deletions
templates/CRM/common/pager.tpl
with
59 additions
and
47 deletions
CRM/Utils/Pager.php
+
5
−
26
View file @
fe010227
...
...
@@ -112,9 +112,7 @@ class CRM_Utils_Pager extends Pager_Sliding {
'status'
=>
CRM_Utils_Array
::
value
(
'status'
,
$params
),
'buttonTop'
=>
CRM_Utils_Array
::
value
(
'buttonTop'
,
$params
),
'buttonBottom'
=>
CRM_Utils_Array
::
value
(
'buttonBottom'
,
$params
),
'twentyfive'
=>
$this
->
getPerPageLink
(
25
),
'fifty'
=>
$this
->
getPerPageLink
(
50
),
'onehundred'
=>
$this
->
getPerPageLink
(
100
),
'currentLocation'
=>
$this
->
getCurrentLocation
(),
);
/**
...
...
@@ -263,29 +261,10 @@ class CRM_Utils_Pager extends Pager_Sliding {
return
array
(
$offset
,
$this
->
_perPage
);
}
/**
* given a number create a link that will display the number of
* rows as specified by that link
*
* @param int $perPage the number of rows
*
* @return string the link
* @access void
*/
function
getPerPageLink
(
$perPage
)
{
if
(
$perPage
!=
$this
->
_perPage
)
{
$href
=
$this
->
makeURL
(
self
::
PAGE_ROWCOUNT
,
$perPage
);
$link
=
sprintf
(
'<a href="%s" %s>%s</a>'
,
$href
,
$this
->
_classString
,
$perPage
)
.
$this
->
_spacesBefore
.
$this
->
_spacesAfter
;
}
else
{
$link
=
$this
->
_spacesBefore
.
$perPage
.
$this
->
_spacesAfter
;
}
return
$link
;
function
getCurrentLocation
()
{
$config
=
CRM_Core_Config
::
singleton
();
$path
=
CRM_Utils_Array
::
value
(
$config
->
userFrameworkURLVar
,
$_GET
);
return
CRM_Utils_System
::
url
(
$path
,
CRM_Utils_System
::
getLinksUrl
(
self
::
PAGE_ID
,
FALSE
,
TRUE
),
FALSE
,
NULL
,
FALSE
)
.
$this
->
getCurrentPageID
();
}
function
getFirstPageLink
()
{
...
...
This diff is collapsed.
Click to expand it.
CRM/Utils/System.php
+
5
−
3
View file @
fe010227
...
...
@@ -147,11 +147,10 @@ class CRM_Utils_System {
}
$querystring
=
array_merge
(
$querystring
,
array_unique
(
$arrays
));
$querystring
=
array_map
(
'htmlentities'
,
$querystring
);
$url
=
implode
(
'&
amp;
'
,
$querystring
);
$url
=
implode
(
'&'
,
$querystring
);
if
(
$urlVar
)
{
$url
.
=
(
!
empty
(
$querystring
)
?
'&
amp;
'
:
''
)
.
$urlVar
.
'='
;
$url
.
=
(
!
empty
(
$querystring
)
?
'&'
:
''
)
.
$urlVar
.
'='
;
}
return
$url
;
...
...
@@ -207,6 +206,9 @@ class CRM_Utils_System {
* RSS feed.
* @param $fragment string A fragment identifier (named anchor) to append to the link.
*
* @param bool $htmlize
* @param bool $frontend
* @param bool $forceBackend
* @return string an HTML string containing a link to the given path.
* @access public
* @static
...
...
This diff is collapsed.
Click to expand it.
templates/CRM/common/pager.tpl
+
49
−
18
View file @
fe010227
...
...
@@ -48,10 +48,8 @@
{* Controller for 'Rows Per Page' *}
{
if
$location
eq
'bottom'
and
$pager
->
_totalItems
>
25
}
<div
class=
"form-item float-right"
>
<label>
{
ts
}
Rows per page:
{/
ts
}
</label>
{
$pager
->
_response
.
twentyfive
}
|
{
$pager
->
_response
.
fifty
}
|
{
$pager
->
_response
.
onehundred
}
<label
for=
"
{
$form.formName
}
-rows-per-page-select"
>
{
ts
}
Rows per page:
{/
ts
}
</label>
<input
class=
"crm-rows-per-page-select"
id=
"
{
$form.formName
}
-rows-per-page-select"
type=
"text"
size=
"3"
value=
"
{
$pager
->
_perPage
}
"
/>
</div>
<div
class=
"clear"
></div>
{/
if
}
...
...
@@ -61,9 +59,12 @@
{
literal
}
cj
(
function
(
$
)
{
{/
literal
}
var
$form
=
$
(
'
#
{
$form.formName
}
'
);
var
numPages
=
{
$pager
->
_response
.
numPages
}
;
var
currentPage
=
{
$pager
->
_response
.
currentPage
}
;
var
$form
=
$
(
'
#
{
$form.formName
}
'
),
numPages
=
{
$pager
->
_response
.
numPages
}
,
currentPage
=
{
$pager
->
_response
.
currentPage
}
,
perPageCount
=
{
$pager
->
_perPage
}
,
currentLocation
=
{
$pager
->
_response
.
currentLocation
|
json_encode
}
;
{
literal
}
function
refresh
(
url
)
{
var
options
=
url
?
{
url
:
url
}
:
{};
...
...
@@ -74,24 +75,54 @@
if
(
isNaN
(
num
)
||
num
<
1
||
num
>
numPages
||
num
===
currentPage
)
{
return
;
}
var
url
=
$
(
'
a.crm-pager-link
'
,
$form
).
attr
(
'
href
'
);
refresh
(
url
.
replace
(
/crmPID=
\d
/
,
'
crmPID=
'
+
num
));
refresh
(
currentLocation
.
replace
(
/crmPID=
\d
+/
,
'
crmPID=
'
+
num
));
}
$
(
'
input[name^=crmPID]
'
,
$form
).
spinner
({
min
:
1
,
max
:
numPages
})
function
changeCount
(
num
)
{
num
=
parseInt
(
num
,
10
);
if
(
isNaN
(
num
)
||
num
<
1
||
num
===
perPageCount
)
{
return
;
}
refresh
(
currentLocation
.
replace
(
/&crmRowCount=
\d
+/
,
''
)
+
'
&crmRowCount=
'
+
num
);
}
function
preventSubmit
(
e
)
{
if
(
e
.
keyCode
==
13
)
{
e
.
preventDefault
();
$
(
this
).
trigger
(
'
change
'
);
return
false
;
}
}
$
(
'
input[name^=crmPID]
'
,
$form
)
.
spinner
({
min
:
1
,
max
:
numPages
})
.
on
(
'
change
'
,
function
()
{
page
(
$
(
this
).
spinner
(
'
value
'
));
});
return
false
;
})
.
on
(
'
keyup keydown keypress
'
,
preventSubmit
);
$
(
'
input.crm-rows-per-page-select
'
,
$form
)
.
spinner
({
min
:
25
,
step
:
25
})
.
on
(
'
change
'
,
function
()
{
changeCount
(
$
(
this
).
spinner
(
'
value
'
));
return
false
;
})
.
on
(
'
keyup keydown keypress
'
,
preventSubmit
);
$form
.
on
(
'
click
'
,
'
a.ui-spinner-button
'
,
function
(
e
)
{
page
(
$
(
this
).
siblings
(
'
input[name^=crmPID]
'
).
spinner
(
'
value
'
));
if
(
$
(
this
).
is
(
'
.crm-pager a
'
))
{
page
(
$
(
this
).
siblings
(
'
input[name^=crmPID]
'
).
spinner
(
'
value
'
));
}
else
{
changeCount
(
$
(
this
).
siblings
(
'
input.crm-rows-per-page-select
'
).
spinner
(
'
value
'
));
}
})
.
on
(
'
click
'
,
'
a.crm-pager-link, #alpha-filter a
'
,
function
()
{
refresh
(
$
(
this
).
attr
(
'
href
'
));
return
false
;
});
refresh
(
$
(
this
).
attr
(
'
href
'
));
return
false
;
});
});
{/
literal
}
</script>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment