Simple List Widget displaying incorrect count
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2025 01:33 PM
On the footer of my simple list widget, for specific users, the count of the records is off, and seems to be taking the number from the maximum entries number that's configured. As an admin, it displays correctly which is a bit puzzling. Can anyone spot what's going wrong? I have tried making some tweaks to the end of the html template, but i am not getting anywhere. My goal is to have the footer of this widget display at all times so users can view all of their requests and also have the count display the correct number of records.
Any tips would be greatly appreciated!
HTML Template
<div class="panel panel-{{::c.options.color}} b" ng-if="c.data.isValid && (c.options.always_show == 'true' || c.options.always_show == true || c.data.filterText || c.data.list.length)">
<div class="panel-heading" ng-if="::!c.options.hide_header">
<h3 class="h4 panel-title">
<span ng-if="c.options.glyph">
<fa name="{{::c.options.glyph}}"></fa>
</span>{{::c.options.title}}</h3>
<!-- <i class="fa fa-filter" ng-click="c.toggleFilter()" ng-class="{'disabled-filter': !c.showFilter}"></i> -->
<div ng-show="c.showFilter">
<input aria-label="${Filter}" ng-model="c.data.filterText" ng-model-options="{debounce: 300}" sn-focus="c.showFilter" placeholder="{{::data.filterMsg}}" ng-change="c.update()" class="form-control input-sm filter-box">
</div>
</div>
<ul class="list-group hide-x-overflow" ng-style="::{maxHeight: c.getMaxHeight()}" style="overflow-y: auto;" ng-if="c.data.list.length > 0">
<li ng-repeat="item in c.data.list track by item.sys_id" class="list-group-item">
<a ng-if="action.glyph || c.options.image_field || (item.display_field.type == 'translated_html' ? item.display_field.value : item.display_field.display_value)" ng-click="c.onClick($event, item, item.url, {})" href="javascript:void(0)" oncontextmenu="return false;">
<span ng-repeat="action in c.data.actions" href="" ng-click="c.onClick($event, item, action.url, action)" ng-if="action.glyph"
class="list-action l-h-40 pull-right">
<fa name="{{action.glyph}}" ng-class="c.getActionColor(action)"></fa>
</span>
<span ng-if="c.options.image_field" class="pull-left m-r"
ng-class="{'avatar': c.options.rounded_images, 'thumb-sm': c.options.rounded_images}">
<img ng-src="{{item.image_field}}" alt="..." class="img-sm" ng-class="{'img-circle': c.options.rounded_images}">
</span>
<div ng-switch on="item.display_field.type" ng-class="{'l-h-40': !item.secondary_fields.length}">
<span class="translated-html" ng-switch-when="translated_html" ng-bind-html="item.display_field.value"></span>
<div ng-switch-default>{{item.display_field.display_value}}</div>
</div>
</a>
<div>
<small class="text-muted" ng-repeat="f in item.secondary_fields">
<span ng-if="!$first"> • </span>
<span ng-switch="f.type" title="{{::f.label}}">
<span ng-switch-when="glide_date">
<span ng-if="!f.isFuture"> <sn-day-ago date="::f.value"></sn-day-ago> </span>
<span ng-if="f.isFuture"> {{f.display_value}}</span>
</span>
<span ng-switch-when="glide_date_time">
<span ng-if="!f.isFuture"> <sn-time-ago timestamp="::f.value"></sn-time-ago></span>
<span ng-if="f.isFuture"> {{f.display_value}}</span>
</span>
<span ng-switch-default="">{{f.display_value}}</span>
</span>
</small>
</div>
</li>
</ul>
<div ng-if="!c.data.list.length" class="list-group-item">
${No records found}
</div>
<div class="panel-footer" ng-if="!c.options.hide_footer && c.options.maximum_entries && c.data.count">
<div class="h4 number-shown-label">{{c.getMaxShownLabel(c.options.maximum_entries, c.data.count)}}</div>
<a class="pull-right" ng-href="?id={{c.seeAllPage}}&table={{c.options.table}}&filter={{c.options.filter}}{{c.targetPageID}}" aria-label="{{::data.viewAllMsg}} - {{::c.options.title}}">${View all}</a>
</div>
</div>
Client script
function ($scope, $location, $rootScope, spUtil, $interpolate, spAriaFocusManager, $timeout) {
var c = this;
this.data.filterText = "";
this.showFilter = false;
this.onClick = function($event, item, url, action) {
$event.stopPropagation();
$event.preventDefault();
if (typeof url == "string") {
var urlExp = $interpolate(url);
url = urlExp(item);
$location.url(url);
} else if (url && typeof url == "object")
$location.search(url);
else {
var evt = {};
evt.url = url;
evt.table = item.className;
evt.sys_id = item.sys_id;
evt.record = item;
evt.rectangle_id = c.options.sys_id;
evt.action = action;
// put out the selection with simple list "sl_" prefix
$location.search('sl_sys_id', evt.sys_id);
$location.search('sl_table', evt.table);
$location.search('spa', 1); // spa means "I've got this"
$rootScope.$broadcast('$sp.list.click', evt);
}
$rootScope.$on('sp.page.loaded', function() {
$timeout(function(){
spAriaFocusManager.focusOnPageTitle();
})
})
};
if (c.options.table && c.options.disable_record_watcher != 'true')
spUtil.recordWatch($scope, c.options.table, c.options.filter);
this.getMaxShownLabel = function(maxEntries, totalCount) {
if(maxEntries == -1)
maxEntries = totalCount;
if (totalCount == c.data.maxCount || c.data.showGM) {
if(maxEntries == 1)
return "${Showing [0] record}".replace('[0]', maxEntries);
return "${Showing first [0] records}".replace('[0]', maxEntries);
}
return "${First [0] of [1]}".replace('[0]', maxEntries).replace('[1]', totalCount);
};
this.seeAllPage = c.options.list_page_dv || 'list';
this.targetPageID = (c.options.sp_page) ? "&target_page_id=" + c.options.sp_page : "";
c.getMaxHeight = function() {
return c.options.panel_body_height || 'none';
};
c.getActionColor = function(action) {
return "text-" + action.color;
};
c.update = function update() {
c.server.update();
}
c.toggleFilter = function() {
c.showFilter = !c.showFilter;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2025 03:12 PM
Hi @lando321
That is happening basically for a ACL perspective, that is calculated on the server side, something like items is build like:
item = [
{
"name": "Display Name 1"
"number": "1234"
},
{
"name": "Display Name 2"
"number": "56789"
},
{},{},{}
]
That can be happening because that user doesnt have all the permisions to read the record but counting the array get a length of 8 but only build 2 (the ones are showin). To solve that you need on your server method only push if you have your desired values, you maybe have something like:
items.push ({
"name": gr.getValue("name");
"number": gr.getValue("number);
})
You can replace for something like:
if(gr.canRead()){
items.push ({
"name": gr.getValue("name");
"number": gr.getValue("number");
})
}
That will make sure you don't have any empty value on your array of items.