ngx-academia-uniandes-library
Version:
This library is used for Academia-Uniandes system.
123 lines • 7.86 kB
JavaScript
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var search_combo_box_service_1 = require("../search-combo-box.service");
var service_locator_1 = require("../../service-locator");
var search_combo_box_generic_model_1 = require("../search-combo-box-generic/search-combo-box-generic.model");
var search_academy_combo_box_component_1 = require("../search-academy-combo-box/search-academy-combo-box.component");
var core_2 = require("@ngx-translate/core");
var titlecase_academia_pipe_1 = require("../../utils/titlecase-academia.pipe");
var SearchDependencyComboBoxComponent = /** @class */ (function (_super) {
__extends(SearchDependencyComboBoxComponent, _super);
function SearchDependencyComboBoxComponent(urlService, searchBoxUtils, transService, titlecasePipe, ref) {
var _this = _super.call(this, urlService, searchBoxUtils, transService, new search_combo_box_generic_model_1.SearchComboBoxGenericModel(urlService.getDependencyUrl(), [{ "name": "limit", "value": 10 }], null, "dependencies", "name", 'Search Dependencies', null, null, 'totalDependencies'), titlecasePipe) || this;
_this.urlService = urlService;
_this.searchBoxUtils = searchBoxUtils;
_this.transService = transService;
_this.titlecasePipe = titlecasePipe;
_this.ref = ref;
_this.multiSelect = false;
_this.itemsSelected = new core_1.EventEmitter();
return _this;
}
Object.defineProperty(SearchDependencyComboBoxComponent.prototype, "depComboSetup", {
set: function (depCombo) {
this.depCombo = depCombo;
},
enumerable: true,
configurable: true
});
SearchDependencyComboBoxComponent.prototype.ngOnInit = function () {
_super.prototype.ngOnInit.call(this);
this.setUrlServiceHost();
this.ref.detectChanges();
this.addUserNameRestriction(this.userRestrict);
};
SearchDependencyComboBoxComponent.prototype.ngOnChanges = function (changes) {
_super.prototype.ngOnChanges.call(this, changes);
if (this.userRestrict && this.depCombo) {
this.addUserNameRestriction(this.userRestrict);
}
};
SearchDependencyComboBoxComponent.prototype.setUrlServiceHost = function () {
if (this.debugFlag) {
this.model.urlService = this.urlService.getDependencyUrl(this.debugFlag);
}
};
SearchDependencyComboBoxComponent.prototype.addUserNameRestriction = function (userData) {
if (userData != null) {
this.setUrlServiceHost();
this.depCombo.componentModel = this.model;
if (userData['facultyDependency'] && userData['currentRole'] === "PROFESSOR") {
var extId = userData['facultyDependency']['externalId'];
_super.prototype.addQueryParams.call(this, { "name": "parentDependencyExternalId", "value": extId });
_super.prototype.addQueryParams.call(this, { "name": "includeParent", "value": true });
if (this.initialValue) {
this.depCombo.setInitialValue(this.initialValue);
}
else {
this.depCombo.setInitialValue(userData['facultyDependency']);
}
}
else if (userData['dependency']) {
var extId = userData['dependency']['externalId'];
_super.prototype.addQueryParams.call(this, { "name": "parentDependencyExternalId", "value": extId });
_super.prototype.addQueryParams.call(this, { "name": "includeParent", "value": true });
if (this.initialValue) {
this.depCombo.setInitialValue(this.initialValue);
}
else {
this.depCombo.setInitialValue(userData['dependency']);
}
}
}
};
SearchDependencyComboBoxComponent.prototype.setTotalRecordsForSearch = function (event) {
if (event) {
this.totalRecordsForSearch.emit(event);
}
};
SearchDependencyComboBoxComponent.prototype.sendItemSelectedEvent = function (event) {
this.itemSelected.emit(event);
};
SearchDependencyComboBoxComponent.prototype.multiItemsPropagateEvent = function (event) {
this.itemsSelected.emit(event);
};
SearchDependencyComboBoxComponent.decorators = [
{ type: core_1.Component, args: [{
selector: 'search-dependency-combo-box',
template: "\n\n <ng-container *ngIf=\"!multiSelect; else multiDependencies\">\n <ng-template #customItemTemplate let-model=\"item\" let-index=\"index\">\n <div class=\"card-container\">\n <div class=\"item\"><p><span>{{model.name | titleCaseAcademia}}</span></p></div>\n <div class=\"item\"><b>({{model.externalId}})</b></div>\n </div>\n </ng-template>\n <app-search-combo-box-generic #depcombo [customTemplate]=\"customItemTemplate\" [preSelectedValue]= \"preSelectedValue\" [componentModel]=\"model\" [itemControl]=\"itemControl\" [isScrollable]=\"isScrollable\" (noResults)=\"sendNoResults($event)\" (itemSelected)=\"sendItemSelectedEvent($event)\" (totalRecordsForSearch)=\"setTotalRecordsForSearch($event)\"></app-search-combo-box-generic>\n </ng-container>\n <ng-template #multiDependencies>\n <app-search-dependency-multi-choice [preSelectedValues]=\"preSelectedValues\" [userRestrict]= \"userRestrict\" (itemsSelected)=\"multiItemsPropagateEvent($event)\"></app-search-dependency-multi-choice>\n </ng-template>\n ",
styles: ["\n .card-container{\n display: grid;\n grid-template-columns: minmax(150px, 300px) minmax(100px, 1fr);\n }\n\n .item{\n align-self: center;\n justify-content: center;\n overflow: hidden;\n }\n\n p{\n margin: 0;\n }\n\n p span \n {\n display: block;\n white-space: pre-line;\n }\n "]
},] },
];
/** @nocollapse */
SearchDependencyComboBoxComponent.ctorParameters = function () { return [
{ type: service_locator_1.ServiceLocator, },
{ type: search_combo_box_service_1.SearchComboBoxService, },
{ type: core_2.TranslateService, },
{ type: titlecase_academia_pipe_1.TitleCaseAcademiaPipe, },
{ type: core_1.ChangeDetectorRef, },
]; };
SearchDependencyComboBoxComponent.propDecorators = {
"depComboSetup": [{ type: core_1.ViewChild, args: ["depcombo",] },],
"userRestrict": [{ type: core_1.Input, args: ['userRestrict',] },],
"multiSelect": [{ type: core_1.Input },],
"itemsSelected": [{ type: core_1.Output },],
"preSelectedValues": [{ type: core_1.Input },],
"initialValue": [{ type: core_1.Input },],
"debugFlag": [{ type: core_1.Input },],
};
return SearchDependencyComboBoxComponent;
}(search_academy_combo_box_component_1.SearchAcademyComboBoxComponent));
exports.SearchDependencyComboBoxComponent = SearchDependencyComboBoxComponent;
//# sourceMappingURL=search-dependency-combo-box.component.js.map