UNPKG

@gsp-cmp/ccmp-ui

Version:

CCMP UI Component Library for Angular

2 lines 11.9 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@gsp-cmp/common-component"),require("@gsp-cmp/wscmp-models"),require("@angular/common"),require("@farris/ui-dialog"),require("@farris/ui-messager"),require("@farris/ui-notify"),require("@farris/ui-datagrid"),require("@farris/ui-modal"),require("@angular/common/http"),require("rxjs/operators"),require("@farris/rtf"),require("@angular/core")):"function"==typeof define&&define.amd?define("@gsp-cmp/ccmp-ui",["exports","@gsp-cmp/common-component","@gsp-cmp/wscmp-models","@angular/common","@farris/ui-dialog","@farris/ui-messager","@farris/ui-notify","@farris/ui-datagrid","@farris/ui-modal","@angular/common/http","rxjs/operators","@farris/rtf","@angular/core"],t):t((e["gsp-cmp"]=e["gsp-cmp"]||{},e["gsp-cmp"]["ccmp-ui"]={}),e.commonComponent,e.wscmpModels,e.ng.common,e.uiDialog,e.i1,e.i2,e.uiDatagrid,e.i2$1,e.ng.common.http,e.rxjs.operators,e.rtf,e.ng.core)}(this,function(e,i,o,t,n,r,s,a,c,p,l,m,u){"use strict";var d={operation_code:"Operation Code",operation_name:"Operation Name",operation_list:"Operation List",operation_choose:"Please select a widget action",confirm:"OK",cancel:"Cancel"},f={operation_code:"操作编号",operation_name:"操作名称",operation_list:"操作列表",operation_choose:"请选择构件操作",confirm:"确定",cancel:"取消"},h={operation_code:"操作編號",operation_name:"操作名稱",operation_list:"操作列表",operation_choose:"請選擇構件操作",confirm:"確定",cancel:"取消"},v=(g.en="en",g.zhCHS="zh-CHS",g.zhCHT="zh-CHT",g);function g(){}C.prototype.instant=function(e){return e?this.getI18nValue(e)||e:""},C.prototype.getI18nValue=function(e){var t=this.i18nSource.get(this.langCode);return t?t[e]:""};var y=C;function C(e){this.notify=e,this.i18nSource=new Map;e=e.localeService.localeId;this.langCode=e||v.zhCHS,this.i18nSource.set(v.en,d),this.i18nSource.set(v.zhCHS,f),this.i18nSource.set(v.zhCHT,h)}I.prototype.getModalConfig=function(e,t){return{title:t&&t.title?t.title:this.translateService.instant("operation_list"),width:t&&t.width?t.width:450,height:t&&t.height?t.width:500,resizable:!t||!t.resizable||t.resizable,showButtons:!0,showMaxButton:!1,enableScroll:!1,buttons:e}},I.prototype.showObseleteDialog=function(e){this.messagerService.show("warning","通用构件"+e.code+"已过时!\n 升级步骤:\n 1. 重新定义通用构件元数据;\n 2. 开发新版本构件代码。\n 请参考GSPCloud开发文档->高级开发->构件开发->通用构件开发",{safeHtml:!1})},I.prototype.showInfo=function(e,t,n,o){this.notify.config.position="top-center","success"==t?this.notify.success({title:n,msg:e,timeout:o}):"info"==t?this.notify.info({title:n,msg:e,timeout:o}):"warning"==t?this.notify.warning({title:n,msg:e,timeout:o}):"error"==t&&this.notify.error({title:n,msg:e,timeout:o})},I.decorators=[{type:u.Injectable,args:[{providedIn:"root"}]}],I.ctorParameters=function(){return[{type:r.MessagerService},{type:s.NotifyService}]},I.ngInjectableDef=u.defineInjectable({factory:function(){return new I(u.inject(r.MessagerService),u.inject(s.NotifyService))},token:I,providedIn:"root"});var b=I;function I(e,t){this.messagerService=e,this.notify=t,this.translateService=new y(t)}S.prototype.convertorToObject=function(e,t){var n=new i.GspComponentConvertor,o=new Object;return n.convertToObject(o,e,t),o},S.prototype.initFromObject=function(e,t){var n=new i.GspComponentConvertor,o=new i.GspComponent;return n.initFromObject(o,e,t),o};var w=S;function S(){}E.prototype.init=function(e){if(this.id=e.id,this.obselete=e.obselete,this.code=e.code,this.name=e.name,this.nameSpace=e.nameSpace,this.fileName=e.fileName,this.type=e.type,this.bizobjectID=e.bizobjectID,this.language=e.language,e.metadata){var t=new w;switch(this.type){case"CommonComponent":var n=new i.DefaultGspComponentSerializeContext;this.metadata=t.initFromObject(e.metadata,n);break;case"WebServiceComponent":n=new o.WebServiceComponentSerializerContext;this.metadata=t.initFromObject(e.metadata,n);break;default:throw new Error("不支持的构件类型"+this.type)}}};var j=E;function E(){}Object.defineProperty(O.prototype,"componentInfo",{set:function(e){switch(this._componentInfo=e,this._componentInfo.type){case"CommonComponent":this.CommonComponentInit(this._componentInfo);break;case"WebServiceComponent":this.WebServiceComponentInit(this._componentInfo);break;default:throw new Error("不支持的构件类型"+this._componentInfo.type)}},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"_options",{set:function(e){this.multiSelection=e&&e.multiSelection||!1},enumerable:!0,configurable:!0}),O.prototype.ngOnInit=function(){this._componentInfo=this._componentInfo||new j,this.columnsInit()},O.prototype.columnsInit=function(){this.columns=[{field:"code",width:100,title:this.utils.translateService.instant("operation_code")},{field:"name",width:100,title:this.utils.translateService.instant("operation_name")}]},O.prototype.CommonComponentInit=function(e){var t=new w,n=new i.DefaultGspComponentSerializeContext;this.metadata=t.initFromObject(t.convertorToObject(e.metadata,n),n),this.metadata.operations=new Array},O.prototype.WebServiceComponentInit=function(e){var t=new w,n=new o.WebServiceComponentSerializerContext;this.metadata=t.initFromObject(t.convertorToObject(e.metadata,n),n),this.metadata.operations=new Array},O.prototype.confirm=function(){var n=this;this.selectedIds.length<=0?this.utils.showInfo(this.utils.translateService.instant("operation_choose"),"info","",1500):(this.metadata.operations=[],this.selectedIds.map(function(t){var e=n._componentInfo.metadata.operations.find(function(e){return e.code===t});e&&n.metadata.operations.push(e)}),this.dialog&&this.dialog.close(),this.confirmEmitter.emit(this.metadata),this.selectedIds=[])},O.prototype.close=function(){this.dialog&&this.dialog.close(),this.closeEmitter.emit()},O.prototype.checkedHandler=function(t){-1==this.selectedIds.findIndex(function(e){return e===t.id})&&this.selectedIds.push(t.id)},O.prototype.unCheckedHandler=function(t){var e=this.selectedIds.findIndex(function(e){return e===t.id});-1!==e&&this.selectedIds.splice(e,1)},O.prototype.checkAllHandler=function(e){var n=this;e&&0<e.length&&e.forEach(function(t){-1==n.selectedIds.findIndex(function(e){return e===t.id})&&n.selectedIds.push(t.id)})},O.prototype.unCheckAllHandler=function(e){var n=this;e&&0<e.length&&e.forEach(function(t){var e=n.selectedIds.findIndex(function(e){return e===t.id});-1!==e&&n.selectedIds.splice(e,1)})},O.decorators=[{type:u.Component,args:[{selector:"common-component-selector",template:'<div class="d-flex" style="position: absolute;top: 0;bottom: 0;left: 0;right: 0;">\r\n <div class="f-utils-fill selector-modal">\r\n <farris-datagrid #dg="datagrid" [showLineNumber]="true" [fit]="true" [pagination]="true" [virtualized]="false"\r\n [fitColumns]="true" [showAllCheckbox]="true" [selectOnCheck]="true" [showCheckbox]="true" [idField]="\'code\'"\r\n [multiSelect]="multiSelection" [showPageList]="true" [onlySelectSelf]="true" [columns]="columns" [data]="_componentInfo.metadata.operations"\r\n (checkAll)="checkAllHandler($event)" (unCheckAll)="unCheckAllHandler($event)" (checked)="checkedHandler($event)" (unChecked)="unCheckedHandler($event)">\r\n </farris-datagrid>\r\n </div>\r\n</div>\r\n\r\n\r\n<ng-template #btnRef>\r\n <div style="width: 100%;line-height: 50px; text-align: center;min-width: 140px;"> \r\n <button class="btn btn-primary" (click)=confirm() style="float:right;margin-right: 5px">{{\'confirm\'|i18n}}</button>\r\n <button class="btn btn-secondary" (click)="close()" style="float:right;margin-right: 5px">{{\'cancel\'|i18n}}</button>\r\n </div>\r\n</ng-template>',styles:[".selector-modal{padding:0 8px;width:100%;display:flex}"]}]}],O.ctorParameters=function(){return[{type:b}]},O.propDecorators={componentInfo:[{type:u.Input}],dg:[{type:u.ViewChild,args:["dg"]}],btnRef:[{type:u.ViewChild,args:["btnRef"]}],confirmEmitter:[{type:u.Output}],closeEmitter:[{type:u.Output}]};var _=O;function O(e){this.utils=e,this.selectedIds=[],this.columns=[],this.multiSelection=!1,this.confirmEmitter=new u.EventEmitter,this.closeEmitter=new u.EventEmitter}H.prototype.openSelector=function(e,t,n){var o=this;return this.getComponentInfo(e,t).pipe(l.map(function(e){return e.obselete?(o.util.showObseleteDialog(e),{confirmEvent:new u.EventEmitter,closeEvent:new u.EventEmitter}):o.create(e,n)}))},H.prototype.getComponentInfo=function(e,t){var n=new p.HttpHeaders;return n.set("sessionId",t),this.http.get(m.BasePathService.convertPath("/api/runtime/sys/v1.0/common-component/component-info/"+e),{headers:n}).pipe(l.map(function(e){var t;if(e)return(t=new j).init(e),t}))},H.prototype.create=function(e,t){var n=this.resolver.resolveComponentFactory(_).create(this.injector),e=(n.instance.componentInfo=e,n.instance._options=t,this.util.getModalConfig(n.instance.btnRef,t)),t=this.modalService.show(n,e);return n.instance.dialog=t,{confirmEvent:n.instance.confirmEmitter,closeEvent:n.instance.closeEmitter}},H.decorators=[{type:u.Injectable,args:[{providedIn:"root"}]}],H.ctorParameters=function(){return[{type:u.ComponentFactoryResolver},{type:u.Injector},{type:b},{type:c.BsModalService},{type:p.HttpClient}]},H.ngInjectableDef=u.defineInjectable({factory:function(){return new H(u.inject(u.ComponentFactoryResolver),u.inject(u.INJECTOR),u.inject(b),u.inject(c.BsModalService),u.inject(p.HttpClient))},token:H,providedIn:"root"});var x=H;function H(e,t,n,o,i){this.resolver=e,this.injector=t,this.util=n,this.modalService=o,this.http=i}M.prototype.openSelector=function(e,t,n){var o=this;return this.getComponentInfo(e,t).pipe(l.map(function(e){return e.obselete?(o.util.showObseleteDialog(e),{confirmEvent:new u.EventEmitter,closeEvent:new u.EventEmitter}):o.create(e,n)}))},M.prototype.getComponentInfo=function(e,t){var n=new p.HttpHeaders;return n.set("sessionId",t),this.http.get(m.BasePathService.convertPath("/api/dev/main/v1.0/common-component/component-info/"+e),{headers:n}).pipe(l.map(function(e){var t;if(e)return(t=new j).init(e),t}))},M.prototype.create=function(e,t){var n=this.resolver.resolveComponentFactory(_).create(this.injector),e=(n.instance._options=t,n.instance.componentInfo=e,this.util.getModalConfig(n.instance.btnRef,t)),t=this.modalService.show(n,e);return n.instance.dialog=t,{confirmEvent:n.instance.confirmEmitter,closeEvent:n.instance.closeEmitter}},M.decorators=[{type:u.Injectable,args:[{providedIn:"root"}]}],M.ctorParameters=function(){return[{type:u.ComponentFactoryResolver},{type:u.Injector},{type:b},{type:c.BsModalService},{type:p.HttpClient}]},M.ngInjectableDef=u.defineInjectable({factory:function(){return new M(u.inject(u.ComponentFactoryResolver),u.inject(u.INJECTOR),u.inject(b),u.inject(c.BsModalService),u.inject(p.HttpClient))},token:M,providedIn:"root"});var k=M;function M(e,t,n,o,i){this.resolver=e,this.injector=t,this.util=n,this.modalService=o,this.http=i}D.prototype.transform=function(e){return this.utils.translateService.instant(e)},D.decorators=[{type:u.Pipe,args:[{name:"i18n"}]}],D.ctorParameters=function(){return[{type:b}]};var z=D;function D(e){this.utils=e}function P(){}P.decorators=[{type:u.NgModule,args:[{declarations:[_,z],imports:[s.NotifyModule,t.CommonModule,p.HttpClientModule,c.ModalModule.forRoot(),n.FarrisDialogModule,a.DatagridModule,r.MessagerModule.forRoot()],entryComponents:[_],providers:[x,k,b],exports:[_]}]}];t=function(){};e.CommonComponentUiModule=P,e.CommonComponentSelectorComponent=_,e.CommonComponentUiRTService=x,e.CommonComponentUiDTService=k,e.SelectorResult=t,e.ɵb=z,e.ɵa=b,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=gsp-cmp-ccmp-ui.umd.min.js.map