-
Notifications
You must be signed in to change notification settings - Fork 0
/
page_controls.xslt
70 lines (66 loc) · 2.65 KB
/
page_controls.xslt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xo="http://panax.io/xover"
xmlns:px="http://panax.io/entity"
xmlns:appendTo-data="http://panax.io/listener"
xmlns:data="http://panax.io/source"
xmlns:meta="http://panax.io/metadata"
xmlns:site="http://panax.io/site"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
exclude-result-prefixes="#default xsl px xsi xo data site"
>
<xsl:output method="xml"
omit-xml-declaration="yes"
indent="yes"/>
<xsl:param name="site:seed">''</xsl:param>
<xsl:template match="/">
<div id="page_controls" class="nav col-md-8 justify-content-center list-unstyled d-flex" xo-source="active">
<xsl:apply-templates select="px:Entity/@xo:id"/>
</div>
</xsl:template>
<xsl:template match="@*" priority="-1"/>
<xsl:template match="px:Entity/@*">
<xsl:apply-templates select="../data:rows/@xo:id"/>
</xsl:template>
<xsl:template match="px:Entity[@controlType='datagridView']/data:rows/@*">
<xsl:for-each select="..">
<xsl:variable name="scope" select="."/>
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center">
<xsl:variable name="pageIndex" select="@meta:pageIndex"/>
<xsl:variable name="pageSize" select="@meta:pageSize"/>
<xsl:variable name="totalRows" select="*/@meta:totalCount"/>
<xsl:if test="$totalRows > $pageSize or $pageIndex > 1">
<li class="page-item" xo-scope="{$scope/@xo:id}" xo-slot="meta:pageIndex">
<xsl:if test="$pageIndex = 1">
<xsl:attribute name="class">page-item disabled</xsl:attribute>
</xsl:if>
<a class="page-link" href="#" onclick="scope.set({$pageIndex - 1})">
Anterior
</a>
</li>
<xsl:for-each select="(//*)[position() <= ceiling($totalRows div $pageSize) and position()<10]">
<li class="page-item" xo-scope="{$scope/@xo:id}" xo-slot="meta:pageIndex">
<xsl:if test="$pageIndex = position()">
<xsl:attribute name="class">page-item active</xsl:attribute>
</xsl:if>
<a class="page-link" href="#" onclick="scope.set({position()})">
<xsl:value-of select="position()"/>
</a>
</li>
</xsl:for-each>
<li class="page-item" xo-scope="{$scope/@xo:id}" xo-slot="meta:pageIndex">
<xsl:if test="$pageIndex + 1 > ceiling($totalRows div $pageSize)">
<xsl:attribute name="class">page-item disabled</xsl:attribute>
</xsl:if>
<a class="page-link" href="#" onclick="scope.set({$pageIndex + 1})">
Siguiente
</a>
</li>
</xsl:if>
</ul>
</nav>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>