bitfront-library
Version:
Angular CLI project with components and classes used by other Angular projects of the BIT foundation.
98 lines • 5.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BitBreadCrumbComponent = void 0;
var core_1 = require("@angular/core");
var router_1 = require("@angular/router");
var i0 = require("@angular/core");
var i1 = require("@angular/router");
var i2 = require("@angular/common");
function BitBreadCrumbComponent_li_1_a_1_Template(rf, ctx) { if (rf & 1) {
var _r7 = i0.ɵɵgetCurrentView();
i0.ɵɵelementStart(0, "a", 4);
i0.ɵɵlistener("click", function BitBreadCrumbComponent_li_1_a_1_Template_a_click_0_listener() { i0.ɵɵrestoreView(_r7); var path_r1 = i0.ɵɵnextContext().$implicit; var ctx_r5 = i0.ɵɵnextContext(); return ctx_r5.goAddress(path_r1); });
i0.ɵɵtext(1);
i0.ɵɵelementEnd();
} if (rf & 2) {
var path_r1 = i0.ɵɵnextContext().$implicit;
i0.ɵɵadvance(1);
i0.ɵɵtextInterpolate(path_r1.label);
} }
function BitBreadCrumbComponent_li_1_span_2_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementStart(0, "span");
i0.ɵɵtext(1);
i0.ɵɵelementEnd();
} if (rf & 2) {
var path_r1 = i0.ɵɵnextContext().$implicit;
i0.ɵɵadvance(1);
i0.ɵɵtextInterpolate(path_r1.label);
} }
function BitBreadCrumbComponent_li_1_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementStart(0, "li");
i0.ɵɵtemplate(1, BitBreadCrumbComponent_li_1_a_1_Template, 2, 1, "a", 2);
i0.ɵɵtemplate(2, BitBreadCrumbComponent_li_1_span_2_Template, 2, 1, "span", 3);
i0.ɵɵelementEnd();
} if (rf & 2) {
var path_r1 = ctx.$implicit;
var i_r2 = ctx.index;
var ctx_r0 = i0.ɵɵnextContext();
i0.ɵɵclassProp("active", i_r2 == ctx_r0.bc.length - 1);
i0.ɵɵadvance(1);
i0.ɵɵproperty("ngIf", i_r2 < ctx_r0.bc.length - 1 && path_r1.url);
i0.ɵɵadvance(1);
i0.ɵɵproperty("ngIf", i_r2 == ctx_r0.bc.length - 1 || !path_r1.url);
} }
/**
* Componenente que muestra la miga de pan en función de los datos de entrada. Estos datos corresponden con
* un array de objetos que tendrán tres campos: label, url y params. El label debe ser obligatorio y corresponde con la
* información en pantalla a mostrar. La url y params son opcionales y correposnden con la dirección a la que el usuario podrá ir
* si pulsa en ella.
* Ejemplos: [
* {label: 'Desenvolupament', url: 'developer/exceptions'},
* {label: 'Log'},
* {label: 'Usuaris', url: 'mantenimiento/users', params: {query: 'true'}}
* ]
**/
var BitBreadCrumbComponent = /** @class */ (function () {
function BitBreadCrumbComponent(router) {
this.router = router;
}
/** Comprobamos si los datos de entrada no están definidos para inicializarlos en blanco */
BitBreadCrumbComponent.prototype.ngOnInit = function () {
if (this.bc == undefined)
this.bc = [];
if (this.bc.length == 0)
this.bc.push({ label: " " });
};
/** Vamos a la URL que contenga el path */
BitBreadCrumbComponent.prototype.goAddress = function (path) {
if (path.params) {
this.router.navigate([path.url, path.params]);
}
else {
this.router.navigate([path.url]);
}
return false; //para evitar que navegue al href="#"
};
BitBreadCrumbComponent.ɵfac = function BitBreadCrumbComponent_Factory(t) { return new (t || BitBreadCrumbComponent)(i0.ɵɵdirectiveInject(i1.Router)); };
BitBreadCrumbComponent.ɵcmp = i0.ɵɵdefineComponent({ type: BitBreadCrumbComponent, selectors: [["bit-breadcrumb"]], inputs: { bc: ["breadcrumb", "bc"] }, decls: 2, vars: 1, consts: [[1, "breadcrumb"], [3, "active", 4, "ngFor", "ngForOf"], ["href", "#", 3, "click", 4, "ngIf"], [4, "ngIf"], ["href", "#", 3, "click"]], template: function BitBreadCrumbComponent_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementStart(0, "ol", 0);
i0.ɵɵtemplate(1, BitBreadCrumbComponent_li_1_Template, 3, 4, "li", 1);
i0.ɵɵelementEnd();
} if (rf & 2) {
i0.ɵɵadvance(1);
i0.ɵɵproperty("ngForOf", ctx.bc);
} }, directives: [i2.NgForOf, i2.NgIf], encapsulation: 2 });
return BitBreadCrumbComponent;
}());
exports.BitBreadCrumbComponent = BitBreadCrumbComponent;
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BitBreadCrumbComponent, [{
type: core_1.Component,
args: [{
selector: "bit-breadcrumb",
template: "\n <ol class=\"breadcrumb\">\n <li [class.active]=\"i == bc.length - 1\" *ngFor=\"let path of bc; let i = index\">\n <a *ngIf=\"i < bc.length - 1 && path.url\" (click)=\"goAddress(path)\" href=\"#\">{{ path.label }}</a>\n <span *ngIf=\"i == bc.length - 1 || !path.url\">{{ path.label }}</span>\n </li>\n </ol>\n "
}]
}], function () { return [{ type: i1.Router }]; }, { bc: [{
type: core_1.Input,
args: ["breadcrumb"]
}] }); })();
//# sourceMappingURL=bit-breadcrumb.component.js.map