ng-jhipster
Version:
A Jhipster util library for Angular 2
60 lines (55 loc) • 2.84 kB
JavaScript
/*
Copyright 2013-2017 the original author or authors from the JHipster project.
This file is part of the JHipster project, see https://jhipster.github.io/
for more information.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { Component, Input } from '@angular/core';
import { JhiConfigService } from '../config.service';
/**
* A component that will take care of item count statistics of a pagination.
*/
var JhiItemCountComponent = (function () {
function JhiItemCountComponent(config) {
this.i18nEnabled = config.CONFIG_OPTIONS.i18nEnabled;
}
/**
* "translate-values" JSON of the template
*/
/**
* "translate-values" JSON of the template
*/
JhiItemCountComponent.prototype.i18nValues = /**
* "translate-values" JSON of the template
*/
function () {
var first = ((this.page - 1) * this.itemsPerPage) === 0 ? 1 : ((this.page - 1) * this.itemsPerPage + 1);
var second = (this.page * this.itemsPerPage) < this.total ? (this.page * this.itemsPerPage) : this.total;
return '{first: \'' + first + '\', second: \'' + second + '\', total: \'' + this.total + '\'}';
};
JhiItemCountComponent.decorators = [
{ type: Component, args: [{
selector: 'jhi-item-count',
template: "\n <div *ngIf=\"i18nEnabled; else noI18n\" class=\"info jhi-item-count\"\n jhiTranslate=\"global.item-count\"\n translateValues=\"{{i18nValues()}}\"\n [attr.translateValues]=\"i18nValues()\"> /* [attr.translateValues] is used to get entire values in tests */\n </div>\n <ng-template #noI18n class=\"info jhi-item-count\">\n Showing {{((page - 1) * itemsPerPage) == 0 ? 1 : ((page - 1) * itemsPerPage + 1)}} -\n {{(page * itemsPerPage) < total ? (page * itemsPerPage) : total}}\n of {{total}} items.\n </ng-template>"
},] },
];
/** @nocollapse */
JhiItemCountComponent.ctorParameters = function () { return [
{ type: JhiConfigService, },
]; };
JhiItemCountComponent.propDecorators = {
"page": [{ type: Input },],
"total": [{ type: Input },],
"itemsPerPage": [{ type: Input },],
};
return JhiItemCountComponent;
}());
export { JhiItemCountComponent };