Implemented config setting to show total number of objects in a grouping in a table view.
This commit is contained in:
parent
76df6d32f9
commit
2688c23d9a
4 changed files with 80 additions and 3 deletions
|
@ -466,6 +466,7 @@ class App.ControllerTable extends App.Controller
|
|||
if @checkbox || @radio
|
||||
columnsLength++
|
||||
groupLast = ''
|
||||
groupLastName = ''
|
||||
tableBody = []
|
||||
objectsToShow = @objectsOfPage(@shownPage)
|
||||
for object in objectsToShow
|
||||
|
@ -473,16 +474,31 @@ class App.ControllerTable extends App.Controller
|
|||
position++
|
||||
if @groupBy
|
||||
groupByName = App.viewPrint(object, @groupBy, @attributesList)
|
||||
if groupLast isnt groupByName
|
||||
groupLast = groupByName
|
||||
if groupLastName isnt groupByName
|
||||
groupLastName = groupByName
|
||||
tableBody.push @renderTableGroupByRow(object, position, groupByName)
|
||||
tableBody.push @renderTableRow(object, position)
|
||||
tableBody
|
||||
|
||||
renderTableGroupByRow: (object, position, groupByName) =>
|
||||
ui_table_group_by_show_count = @Config.get('ui_table_group_by_show_count')
|
||||
groupByCount = undefined
|
||||
if ui_table_group_by_show_count is true
|
||||
groupBy = @groupBy
|
||||
groupLast = object[@groupBy]
|
||||
if !groupLast
|
||||
groupBy = "#{@groupBy}_id"
|
||||
groupLast = object[groupBy]
|
||||
groupByCount = 0
|
||||
if @objects
|
||||
for localObject in @objects
|
||||
if localObject[groupBy] is groupLast
|
||||
groupByCount += 1
|
||||
|
||||
App.view('generic/table_row_group_by')(
|
||||
position: position
|
||||
groupByName: groupByName
|
||||
groupByCount: groupByCount
|
||||
columnsLength: @columnsLength
|
||||
)
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<tr>
|
||||
<td colspan="<%= @columnsLength %>"><b><%= @groupByName %></b></td>
|
||||
<td colspan="<%= @columnsLength %>"><b><%= @groupByName %><% if @groupByCount:%> (<%= @groupByCount %>)<% end %></b></td>
|
||||
</tr>
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
class SettingTableGroupByShowCount < ActiveRecord::Migration[5.1]
|
||||
def up
|
||||
|
||||
# return if it's a new setup
|
||||
return if !Setting.find_by(name: 'system_init_done')
|
||||
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Open ticket indicator',
|
||||
name: 'ui_table_group_by_show_count',
|
||||
area: 'UI::Base',
|
||||
description: 'Total display of the number of objects in a grouping.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'ui_table_group_by_show_count',
|
||||
tag: 'boolean',
|
||||
translate: true,
|
||||
options: {
|
||||
true => 'yes',
|
||||
false => 'no',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
state: false,
|
||||
preferences: {
|
||||
permission: ['admin.ui'],
|
||||
},
|
||||
frontend: true
|
||||
)
|
||||
end
|
||||
end
|
|
@ -822,6 +822,33 @@ Setting.create_if_not_exists(
|
|||
frontend: true
|
||||
)
|
||||
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Open ticket indicator',
|
||||
name: 'ui_table_group_by_show_count',
|
||||
area: 'UI::Base',
|
||||
description: 'Total display of the number of objects in a grouping.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'ui_table_group_by_show_count',
|
||||
tag: 'boolean',
|
||||
translate: true,
|
||||
options: {
|
||||
true => 'yes',
|
||||
false => 'no',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
state: false,
|
||||
preferences: {
|
||||
permission: ['admin.ui'],
|
||||
},
|
||||
frontend: true
|
||||
)
|
||||
|
||||
Setting.create_if_not_exists(
|
||||
title: 'New User Accounts',
|
||||
name: 'user_create_account',
|
||||
|
|
Loading…
Reference in a new issue