@fdot/angular-staff
Version:
The angular-staff package wraps service calls to FDOT Staff API and also includes pipes and components based on bootstrap 4. ## Installation The angular staff package use a peer dependency of ng-bootstrap so you will need to also perform an NPM install
2 lines • 7.46 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("rxjs"),require("@angular/common/http"),require("rxjs/operators"),require("@angular/common"),require("@ng-bootstrap/ng-bootstrap"),require("@angular/forms")):"function"==typeof define&&define.amd?define("@fdot/angular-staff",["exports","@angular/core","rxjs","@angular/common/http","rxjs/operators","@angular/common","@ng-bootstrap/ng-bootstrap","@angular/forms"],t):t((e.fdot=e.fdot||{},e.fdot["angular-staff"]={}),e.ng.core,null,e.ng.common.http,e.Rx.Observable.prototype,e.ng.common,null,e.ng.forms)}(this,function(e,n,o,h,m,r,a,s){"use strict";var t=function(e,t){this.host=e,this.apiKey=t},i=function(){function e(e,t){if(this.http=e,this.config=t,this.staffByIdCache=new Map,this.staffByRacfIdCache=new Map,this.staffSearchCache=new Map,!t)throw Error("Call AngularStaffmodule with for root passing in the config object")}return e.prototype.Format=function(e,t){if(t){var n=t.replace("{firstName}",e.firstName);return n=(n=(n=(n=n.replace("{lastName}",e.lastName)).replace("{racfId}",e.racfId)).replace("{emailAddress}",e.emailAddress)).replace("{phone}",e.phone)}return e.firstName+" "+e.lastName},e.prototype.GetStaffById=function(t){var n=this;if(!this.staffByIdCache.get(t)){this.staffByIdCache.set(t,new o.BehaviorSubject(null));var e=new h.HttpHeaders,r=new h.HttpParams;t!==undefined&&null!==t&&(r=r.set("id",t+"")),this.sendRequest("get","/GetStaffById",e,r,null).toPromise().then(function(e){e&&e.body&&n.staffByIdCache.get(t).next(e.body)})}return this.staffByIdCache.get(t)},e.prototype.GetStaffByIds=function(e){var t=new h.HttpHeaders,n=new h.HttpParams;return e!==undefined&&null!==e&&(n=n.set("id",e+"")),this.sendRequest("get","/GetStaffByIds",t,n,null).pipe(m.map(function(e){if(e&&e.body)return e.body}))},e.prototype.GetStaffByRacfId=function(t){var n=this;if(!this.staffByRacfIdCache.get(t)){this.staffByRacfIdCache.set(t,new o.BehaviorSubject(null));var e=new h.HttpHeaders,r=new h.HttpParams;t!==undefined&&null!==t&&(r=r.set("racfId",t+"")),this.sendRequest("get","/GetStaffByRacfId",e,r,null).pipe(m.map(function(e){e&&e.body&&n.staffByRacfIdCache.get(t).next(e.body)}))}return this.staffByRacfIdCache.get(t)},e.prototype.GetStaffByRacfIds=function(e){var t=new h.HttpHeaders,n=new h.HttpParams;return e!==undefined&&null!==e&&(n=n.set("racfId",e+"")),this.sendRequest("get","/GetStaffByRacfIds",t,n,null).pipe(m.map(function(e){if(e&&e.body)return e.body}))},e.prototype.SearchStaffBySearchCriteriaGet=function(e,t,n,r,a,o,s,i,f,u,c,l){var p=new h.HttpHeaders,d=new h.HttpParams;return e!==undefined&&null!==e&&(d=d.set("racfId",e+"")),t!==undefined&&null!==t&&(d=d.set("peopleFirstId",t+"")),n!==undefined&&null!==n&&(d=d.set("status",n+"")),r!==undefined&&null!==r&&(d=d.set("partialName",r+"")),a!==undefined&&null!==a&&(d=d.set("firstName",a+"")),o!==undefined&&null!==o&&(d=d.set("lastName",o+"")),s!==undefined&&null!==s&&(d=d.set("districtCode",s+"")),i!==undefined&&null!==i&&(d=d.set("positionNumber",i+"")),f!==undefined&&null!==f&&(d=d.set("organizationalCode",f+"")),u!==undefined&&null!==u&&(d=d.set("emailAddress",u+"")),c!==undefined&&null!==c&&(d=d.set("staffTypeCode",c+"")),l!==undefined&&null!==l&&(d=d.set("staffId",l+"")),this.sendRequest("get","/SearchStaffBySearchCriteria",p,d,null).pipe(m.map(function(e){if(e&&e.body)return e.body}))},e.prototype.SearchActiveStaffByName=function(t){var n=this;return this.staffSearchCache.get(t)||(this.staffSearchCache.set(t,new o.BehaviorSubject([])),this.SearchStaffBySearchCriteriaGet(null,null,"active",t,null,null,null,null,null,null,null,null).toPromise().then(function(e){n.staffSearchCache.get(t).next(e)})),this.staffSearchCache.get(t)},e.prototype.SearchStaffBySearchCriteriaPost=function(e){var t=new h.HttpHeaders,n=new h.HttpParams;return this.sendRequest("post","/SearchStaffBySearchCriteria",t,n,JSON.stringify(e))},e.prototype.sendRequest=function(e,t,n,r,a){return n=n.set("Ocp-Apim-Subscription-Key",this.config.apiKey),"get"===e?this.http.get(this.config.host+t,{headers:n.set("Accept","application/json"),params:r,observe:"response"}):"put"===e?this.http.put(this.config.host+t,a,{headers:n.set("Content-Type","application/json"),params:r,observe:"response"}):"post"===e?this.http.post(this.config.host+t,a,{headers:n.set("Content-Type","application/json"),params:r,observe:"response"}):"delete"===e?this.http["delete"](this.config.host+t,{headers:n,params:r,observe:"response"}):(console.error("Unsupported request: "+e),o.Observable["throw"]("Unsupported request: "+e))},e.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:h.HttpClient},{type:t,decorators:[{type:n.Inject,args:["config"]}]}]},e.ngInjectableDef=n.defineInjectable({factory:function(){return new e(n.inject(h.HttpClient),n.inject("config"))},token:e,providedIn:"root"}),e}(),f=function(){function e(e){var t=this;this.staffService=e,this.selected=new n.EventEmitter,this.searching=!1,this.searchFailed=!1,this.search=function(e){return e.pipe(m.debounceTime(300),m.distinctUntilChanged(),m.tap(function(){return t.searching=!0}),m.switchMap(function(e){return e&&2<e.length?t.staffService.SearchActiveStaffByName(e).pipe(m.tap(function(){return t.searchFailed=!1}),m.catchError(function(){return t.searchFailed=!0,o.of([])})):o.of([])}),m.tap(function(){return t.searching=!1}))},this.formatter=function(e){return null!=e?t.staffService.Format(e,t.format):""}}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},set:function(e){var t=this;this._value=e,this.staffService.GetStaffById(e).subscribe(function(e){e&&(t.model=e,t.selected.emit(e))})},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){},e.prototype.onBlur=function(){"object"!=typeof this.model&&(this.model=null,this.selected.emit(null))},e.prototype.itemSelected=function(e){e&&this.selected.emit(e.item)},e.decorators=[{type:n.Component,args:[{selector:"fdot-staff-selector",template:'<div class="form-group">\n <input type="text" class="form-control" [class.is-invalid]="searchFailed" [(ngModel)]="model" [ngbTypeahead]="search" placeholder="{{placeholder}}"\n [editable]="false" (blur)="onBlur()" [resultFormatter]="formatter" (selectItem)="itemSelected($event)" [inputFormatter]="formatter"\n />\n <span *ngIf="searching">searching...</span>\n <div class="invalid-feedback" *ngIf="searchFailed">No results found</div>\n</div>',styles:[""]}]}],e.ctorParameters=function(){return[{type:i}]},e.propDecorators={selected:[{type:n.Output}],format:[{type:n.Input}],placeholder:[{type:n.Input}],value:[{type:n.Input}]},e}(),u=function(){function e(e){this.staffService=e}return e.prototype.transform=function(e,t){var n=this;return this.staffService.GetStaffById(e).pipe(m.map(function(e){if(e)return n.staffService.Format(e,t)}))},e.decorators=[{type:n.Pipe,args:[{name:"staff"}]}],e.ctorParameters=function(){return[{type:i}]},e}(),c=function(){function t(){}return t.forRoot=function(e){return{ngModule:t,providers:[{provide:"config",useValue:e}]}},t.decorators=[{type:n.NgModule,args:[{imports:[h.HttpClientModule,a.NgbModule,s.FormsModule,r.CommonModule],declarations:[u,f],exports:[u,f]}]}],t}();e.AngularStaffService=i,e.StaffSelectorComponent=f,e.Config=t,e.AngularStaffModule=c,e.ɵa=u,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=fdot-angular-staff.umd.min.js.map