Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit951b623

Browse files
authored
OBPIH-6991 Add multi-select product filter to consumption report (#5560)
1 parentffc48be commit951b623

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

‎grails-app/controllers/org/pih/warehouse/reporting/ConsumptionController.groovy‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ class ConsumptionController {
239239
if (command.fromLocations) {
240240
products= command.rows.keySet().asList()
241241

242+
// Filter products by selected products
243+
if (command.selectedProducts) {
244+
List<String> selectedIds= command.selectedProducts*.id
245+
command.rows.keySet().removeAll {row->!(row.idin selectedIds) }
246+
}
247+
242248
// Filter products by tags
243249
if (command.selectedTags) {
244250
def productsToRemove= products.findAll {product->
@@ -478,6 +484,7 @@ class ShowConsumptionCommand implements Validateable {
478484
List<String> selectedDates=LazyList.decorate(newArrayList(),FactoryUtils.instantiateFactory(String.class))
479485
List<Location> selectedLocations=LazyList.decorate(newArrayList(),FactoryUtils.instantiateFactory(Location.class))
480486
List<Category> selectedCategories=LazyList.decorate(newArrayList(),FactoryUtils.instantiateFactory(Category.class))
487+
List<Product> selectedProducts=LazyList.decorate(newArrayList(),FactoryUtils.instantiateFactory(Product.class))
481488
List<Tag> selectedTags=LazyList.decorate(newArrayList(),FactoryUtils.instantiateFactory(Tag.class))
482489

483490
Boolean includeLocationBreakdown=Boolean.TRUE

‎grails-app/i18n/messages.properties‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ consumption.beforeDate.label=Consumed on or before
149149
consumption.filters.label=Filters
150150
consumption.categories.label=Categories
151151
consumption.toLocations.label=Destinations(s)
152+
consumption.products.label=Products
152153
consumption.renderOptions.label=Render Options
153154
consumption.additionalColumns.label=Additional columns (CSV only)
154155
consumption.format.label=Format

‎grails-app/taglib/org/pih/warehouse/SelectTagLib.groovy‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,22 @@ class SelectTagLib {
100100
String searchParameter= attrs.searchParameter?:"name"
101101
boolean multiple= attrs.multiple?.asBoolean()?:false
102102
String placeholder="${g.message(code: 'default.selectOptions.label', default: 'Select Options')}"
103+
Object values= attrs.value
104+
String selectedOptionsHtml=""
105+
106+
if (values&& values.any { it?.hasProperty('id') }) {
107+
selectedOptionsHtml= values.collect {val->
108+
String text= val.name?: val.toString()
109+
"<option value='${val.id}' selected='true'>${text.encodeAsHTML()}</option>"
110+
}.join("\n")
111+
}
103112

104113
def html="""
105114
<select id="${id}"
106115
name="${name}"
107116
${multiple ? "multiple" : ""}
108117
type="text">
118+
${selectedOptionsHtml}
109119
</select>
110120
111121
<script type=\'text/javascript\'>

‎grails-app/views/consumption/_filters.gsp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@
8686
data-placeholder="${g.message(code:'default.selectOptions.label',default:'Select Options')}"
8787
/>
8888
</div>
89+
<divclass="filter-list-item">
90+
<label>
91+
<g:messagecode="consumption.products.label"default="Products"/>
92+
</label>
93+
<g:selectProductAjax
94+
id="selectedProducts"
95+
value="${command?.selectedProducts}"
96+
multiple="true"
97+
/>
98+
</div>
8999
<g:iftest="${!command?.toLocations}">
90100
<divclass="filter-list-item">
91101
<label>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp