From e3b1550f99ba0d82b036994b53d8a06051bd8469 Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Fri, 10 Jan 2025 10:38:30 -0800 Subject: [PATCH 1/6] Pagination support for Bootstrap 5 --- .../plugins/web/taglib/UrlMappingTagLib.groovy | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/UrlMappingTagLib.groovy b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/UrlMappingTagLib.groovy index b3be410c02..026c232c4d 100644 --- a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/UrlMappingTagLib.groovy +++ b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/UrlMappingTagLib.groovy @@ -69,6 +69,10 @@ class UrlMappingTagLib implements TagLibrary{ } } + private void appendClass(Map linkTagAttrs, String cssClass) { + [linkTagAttrs.get('class')?:'',cssClass].join(' ') + } + /** * Creates next/previous links to support pagination for the current controller.
* @@ -139,6 +143,11 @@ class UrlMappingTagLib implements TagLibrary{ if (attrs.id != null) { linkTagAttrs.id = attrs.id } + if (attrs.containsKey('class')) { + linkTagAttrs.put('class', attrs.get('class')) + } + String activeClass = attrs.activeClass?:'currentStep' + if (attrs.fragment != null) { linkTagAttrs.fragment = attrs.fragment } @@ -152,7 +161,7 @@ class UrlMappingTagLib implements TagLibrary{ // display previous link when not on firststep unless omitPrev is true if (currentstep > firststep && !attrs.boolean('omitPrev')) { - linkTagAttrs.put('class', 'prevLink') + appendClass(linkTagAttrs, 'prevLink') linkParams.offset = offset - max writer << callLink((Map)linkTagAttrs.clone()) { (attrs.prev ?: messageSource.getMessage('paginate.prev', null, messageSource.getMessage('default.paginate.prev', null, 'Previous', locale), locale)) @@ -161,7 +170,7 @@ class UrlMappingTagLib implements TagLibrary{ // display steps when steps are enabled and laststep is not firststep if (steps && laststep > firststep) { - linkTagAttrs.put('class', 'step') + appendClass(linkTagAttrs, 'step') // determine begin and endstep paging variables int beginstep = currentstep - (Math.round(maxsteps / 2.0d) as int) + (maxsteps % 2) @@ -192,7 +201,7 @@ class UrlMappingTagLib implements TagLibrary{ // display paginate steps (beginstep..endstep).each { int i -> if (currentstep == i) { - writer << "${i}" + writer << "${i}" } else { linkParams.offset = (i - 1) * max @@ -213,7 +222,7 @@ class UrlMappingTagLib implements TagLibrary{ // display next link when not on laststep unless omitNext is true if (currentstep < laststep && !attrs.boolean('omitNext')) { - linkTagAttrs.put('class', 'nextLink') + appendClass(linkTagAttrs, 'nextLink') linkParams.offset = offset + max writer << callLink((Map)linkTagAttrs.clone()) { (attrs.next ? attrs.next : messageSource.getMessage('paginate.next', null, messageSource.getMessage('default.paginate.next', null, 'Next', locale), locale)) From ee539dd6d140d56dbc4ababec92831ae3624bed2 Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Sun, 12 Jan 2025 12:09:40 -0800 Subject: [PATCH 2/6] .sdkmanrc --- .sdkmanrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.sdkmanrc b/.sdkmanrc index 865d5672d9..1af8bdefb9 100644 --- a/.sdkmanrc +++ b/.sdkmanrc @@ -1,3 +1,3 @@ java=17.0.13-librca -gradle=8.11.1 +gradle=8.12 From cadfbb4a3b1d8c1e006914170d9b5c1ae0388b32 Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Sun, 12 Jan 2025 13:15:56 -0800 Subject: [PATCH 3/6] Cleanup --- .../web/taglib/UrlMappingTagLib.groovy | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/UrlMappingTagLib.groovy b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/UrlMappingTagLib.groovy index 026c232c4d..556e25e9a5 100644 --- a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/UrlMappingTagLib.groovy +++ b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/UrlMappingTagLib.groovy @@ -69,8 +69,9 @@ class UrlMappingTagLib implements TagLibrary{ } } - private void appendClass(Map linkTagAttrs, String cssClass) { - [linkTagAttrs.get('class')?:'',cssClass].join(' ') + Map appendClass(Map attrs, String cssClass) { + attrs['class'] = [attrs['class'] ?: '', cssClass].join(' ').trim() + attrs } /** @@ -161,16 +162,15 @@ class UrlMappingTagLib implements TagLibrary{ // display previous link when not on firststep unless omitPrev is true if (currentstep > firststep && !attrs.boolean('omitPrev')) { - appendClass(linkTagAttrs, 'prevLink') linkParams.offset = offset - max - writer << callLink((Map)linkTagAttrs.clone()) { + writer << callLink(appendClass((Map) linkTagAttrs.clone(), 'prevLink')) { (attrs.prev ?: messageSource.getMessage('paginate.prev', null, messageSource.getMessage('default.paginate.prev', null, 'Previous', locale), locale)) } } // display steps when steps are enabled and laststep is not firststep if (steps && laststep > firststep) { - appendClass(linkTagAttrs, 'step') + Map stepAttrs = appendClass((Map) linkTagAttrs.clone(), 'step') // determine begin and endstep paging variables int beginstep = currentstep - (Math.round(maxsteps / 2.0d) as int) + (maxsteps % 2) @@ -191,7 +191,7 @@ class UrlMappingTagLib implements TagLibrary{ // display firststep link when beginstep is not firststep if (beginstep > firststep && !attrs.boolean('omitFirst')) { linkParams.offset = 0 - writer << callLink((Map)linkTagAttrs.clone()) {firststep.toString()} + writer << callLink((Map)stepAttrs.clone()) {firststep.toString()} } //show a gap if beginstep isn't immediately after firststep, and if were not omitting first or rev if (beginstep > firststep+1 && (!attrs.boolean('omitFirst') || !attrs.boolean('omitPrev')) ) { @@ -201,11 +201,11 @@ class UrlMappingTagLib implements TagLibrary{ // display paginate steps (beginstep..endstep).each { int i -> if (currentstep == i) { - writer << "${i}" + writer << "${i}" } else { linkParams.offset = (i - 1) * max - writer << callLink((Map)linkTagAttrs.clone()) {i.toString()} + writer << callLink((Map)stepAttrs.clone()) {i.toString()} } } @@ -216,15 +216,14 @@ class UrlMappingTagLib implements TagLibrary{ // display laststep link when endstep is not laststep if (endstep < laststep && !attrs.boolean('omitLast')) { linkParams.offset = (laststep - 1) * max - writer << callLink((Map)linkTagAttrs.clone()) { laststep.toString() } + writer << callLink((Map)stepAttrs.clone()) { laststep.toString() } } } // display next link when not on laststep unless omitNext is true if (currentstep < laststep && !attrs.boolean('omitNext')) { - appendClass(linkTagAttrs, 'nextLink') linkParams.offset = offset + max - writer << callLink((Map)linkTagAttrs.clone()) { + writer << callLink(appendClass((Map) linkTagAttrs.clone(), 'nextLink')) { (attrs.next ? attrs.next : messageSource.getMessage('paginate.next', null, messageSource.getMessage('default.paginate.next', null, 'Next', locale), locale)) } } From 0536858cb85dc5ea2eff50e215bdbafdae82464e Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Sun, 12 Jan 2025 13:16:21 -0800 Subject: [PATCH 4/6] Back to 7.0.0-SNAPSHOT --- gradle.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 1166fcf4e2..956474df88 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ title=Groovy Server Pages (GSP) authors=Puneet Behl -projectVersion=7.0.0-M1 +projectVersion=7.0.0-SNAPSHOT projectDesc=GSP (Groovy Server Pages) - A server-side view rendering technology based on Groovy projectUrl=https://github.com/grails/grails-gsp githubSlug=grails/grails-gsp @@ -10,12 +10,12 @@ developers=Puneet Behl, Graeme Rocher commonsTextVersion=1.13.0 elApiVersion=6.0.1 grailsGradlePluginVersion=7.0.0-SNAPSHOT -grailsVersion=7.0.0-M1 +grailsVersion=7.0.0-SNAPSHOT groovyVersion=4.0.24 jspApiVersion=4.0.0 jstlVersion=3.0.1 servletApiVersion=6.0.0 -sitemeshVersion=7.0.0-M1 +sitemeshVersion=7.0.0-SNAPSHOT controllersRef=https://docs.grails.org/latest/ref/Controllers commandLineRef=https://docs.grails.org/latest/ref/Command%20Line grailsDocsVersion=7.0.0-SNAPSHOT From c8a84fc62b9d966212a1cbba34ef64fd8a3a823c Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Sun, 12 Jan 2025 13:34:12 -0800 Subject: [PATCH 5/6] datePicker selectClass needed for bootstrap 5 formatting --- .../grails/plugins/web/taglib/FormTagLib.groovy | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/FormTagLib.groovy b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/FormTagLib.groovy index b2f6b2c659..532183b9dc 100644 --- a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/FormTagLib.groovy +++ b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/FormTagLib.groovy @@ -677,6 +677,7 @@ class FormTagLib implements ApplicationContextAware, InitializingBean, TagLibrar * @attr disabled Makes the resulting inputs and selects to be disabled. Is treated as a Groovy Truth. * @attr readonly Makes the resulting inputs and selects to be made read only. Is treated as a Groovy Truth. * @attr locale The locale to use for display formatting. Defaults to the current request locale and then the system default locale if not specified. + * @attr selectClass css class added to each select tag */ Closure datePicker = { attrs -> def out = out // let x = x ? @@ -797,6 +798,9 @@ class FormTagLib implements ApplicationContextAware, InitializingBean, TagLibrar if (attrs.readonly) { out << ' readonly="readonly"' } + if (attrs.selectClass) { + out << ' class="'+attrs.selectClass+'"' + } out << '>' if (noSelection) { @@ -821,6 +825,9 @@ class FormTagLib implements ApplicationContextAware, InitializingBean, TagLibrar if (attrs.readonly) { out << ' readonly="readonly"' } + if (attrs.selectClass) { + out << ' class="'+attrs.selectClass+'"' + } out << '>' if (noSelection) { @@ -847,6 +854,9 @@ class FormTagLib implements ApplicationContextAware, InitializingBean, TagLibrar if (attrs.readonly) { out << ' readonly="readonly"' } + if (attrs.selectClass) { + out << ' class="'+attrs.selectClass+'"' + } out << '>' if (noSelection) { @@ -871,6 +881,9 @@ class FormTagLib implements ApplicationContextAware, InitializingBean, TagLibrar if (attrs.readonly) { out << ' readonly="readonly"' } + if (attrs.selectClass) { + out << ' class="'+attrs.selectClass+'"' + } out << '>' if (noSelection) { @@ -902,6 +915,9 @@ class FormTagLib implements ApplicationContextAware, InitializingBean, TagLibrar if (attrs.readonly) { out << 'readonly="readonly"' } + if (attrs.selectClass) { + out << ' class="'+attrs.selectClass+'"' + } out << '>' if (noSelection) { From 179bf93c9d1faa2c6ffa0e99616edc31837d8002 Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Sun, 12 Jan 2025 13:58:31 -0800 Subject: [PATCH 6/6] Use unique name for widget propagation --- .../plugins/web/taglib/FormTagLib.groovy | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/FormTagLib.groovy b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/FormTagLib.groovy index 532183b9dc..f4bc04dee6 100644 --- a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/FormTagLib.groovy +++ b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/FormTagLib.groovy @@ -677,7 +677,7 @@ class FormTagLib implements ApplicationContextAware, InitializingBean, TagLibrar * @attr disabled Makes the resulting inputs and selects to be disabled. Is treated as a Groovy Truth. * @attr readonly Makes the resulting inputs and selects to be made read only. Is treated as a Groovy Truth. * @attr locale The locale to use for display formatting. Defaults to the current request locale and then the system default locale if not specified. - * @attr selectClass css class added to each select tag + * @attr selectDateClass css class added to each select tag */ Closure datePicker = { attrs -> def out = out // let x = x ? @@ -798,8 +798,8 @@ class FormTagLib implements ApplicationContextAware, InitializingBean, TagLibrar if (attrs.readonly) { out << ' readonly="readonly"' } - if (attrs.selectClass) { - out << ' class="'+attrs.selectClass+'"' + if (attrs.selectDateClass) { + out << ' class="'+attrs.selectDateClass+'"' } out << '>' @@ -825,8 +825,8 @@ class FormTagLib implements ApplicationContextAware, InitializingBean, TagLibrar if (attrs.readonly) { out << ' readonly="readonly"' } - if (attrs.selectClass) { - out << ' class="'+attrs.selectClass+'"' + if (attrs.selectDateClass) { + out << ' class="'+attrs.selectDateClass+'"' } out << '>' @@ -854,8 +854,8 @@ class FormTagLib implements ApplicationContextAware, InitializingBean, TagLibrar if (attrs.readonly) { out << ' readonly="readonly"' } - if (attrs.selectClass) { - out << ' class="'+attrs.selectClass+'"' + if (attrs.selectDateClass) { + out << ' class="'+attrs.selectDateClass+'"' } out << '>' @@ -881,8 +881,8 @@ class FormTagLib implements ApplicationContextAware, InitializingBean, TagLibrar if (attrs.readonly) { out << ' readonly="readonly"' } - if (attrs.selectClass) { - out << ' class="'+attrs.selectClass+'"' + if (attrs.selectDateClass) { + out << ' class="'+attrs.selectDateClass+'"' } out << '>' @@ -915,8 +915,8 @@ class FormTagLib implements ApplicationContextAware, InitializingBean, TagLibrar if (attrs.readonly) { out << 'readonly="readonly"' } - if (attrs.selectClass) { - out << ' class="'+attrs.selectClass+'"' + if (attrs.selectDateClass) { + out << ' class="'+attrs.selectDateClass+'"' } out << '>'