UNPKG

11.9 kBJavaScriptView Raw
1!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@angular/core"),require("@angular/common"),require("@angular/forms")):"function"==typeof define&&define.amd?define("ng-simplegrid",["@angular/core","@angular/common","@angular/forms"],e):"object"==typeof exports?exports["ng-simplegrid"]=e(require("@angular/core"),require("@angular/common"),require("@angular/forms")):t["ng-simplegrid"]=e(t["@angular/core"],t["@angular/common"],t["@angular/forms"])}(this,function(t,e,n){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=9)}([function(e,n){e.exports=t},function(t,e,n){"use strict";var o=n(0);n.n(o);n.d(e,"a",function(){return i});var r=this&&this.__decorate||function(t,e,n,o){var r,a=arguments.length,i=a<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,n,o);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(i=(a<3?r(i):a>3?r(e,n,i):r(e,n))||i);return a>3&&i&&Object.defineProperty(e,n,i),i},a=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},i=function(){function t(){this.rowsPerPage=10,this.dataList=[],this.emptyMessage="검색한 내역이 없습니다",this.dataListToShow=[],this.totalPageCount=1,this.currentPageIndex=0,this.emptyRows=[]}return t.prototype.ngOnInit=function(){this.columns||console.error("ng-simpleGrid: grid.columns is not exists.")},t.prototype.setDataList=function(t){this.dataList=t,this.initializeData(t)},t.prototype.initializeData=function(t){this.totalPageCount=this._getTotalPageCount(this.rowsPerPage,t),this.dataListPerPage=this._getDataListPerPage(this.rowsPerPage,t),this.dataListToShow=this.dataListPerPage[0],this.emptyRows=this._getEmptyRowsToBeFilled(this.rowsPerPage,this.dataListToShow)},t.prototype.search=function(t,e){if(this.dataList){if(""===e)return void this.initializeData(this.dataList);for(var n=[],o=0,r=this.dataList;o<r.length;o++){var a=r[o];a[t].include(a)&&n.push(a)}this.initializeData(n)}},t.prototype.onClickDataItem=function(t,e,n,o,r){var a=this._getColumnByProperty(this.columns,o,"onClick");null!=a&&a.onClick(t,e,r,n)},t.prototype.onMovePage=function(t){this.dataListPerPage&&(this.dataListToShow=this.dataListPerPage[t],this.emptyRows=this._getEmptyRowsToBeFilled(this.rowsPerPage,this.dataListToShow),this.currentPageIndex=t)},t.prototype.onClickDataRow=function(t,e,n){this.event&&this.event.onClickRow&&this.event.onClickRow(e,n)},t.prototype._getColumnByProperty=function(t,e,n){for(var o=null,r=0,a=t;r<a.length;r++){var i=a[r];if(i.key==e&&i.hasOwnProperty(n)){o=i;break}}return o},t.prototype._getTotalPageCount=function(t,e){var n=e.length;return Math.ceil(n/t)},t.prototype._getDataListPerPage=function(t,e){for(var n=[],o=0;o<=this.totalPageCount;o++)n.push(this.dataList.splice(0,t));return n},t.prototype._getEmptyRowsToBeFilled=function(t,e){var n=t-e.length;return new Array(n)},t}();r([n.i(o.Input)(),a("design:type",Array)],i.prototype,"columns",void 0),r([n.i(o.Input)(),a("design:type",Object)],i.prototype,"event",void 0),r([n.i(o.Input)(),a("design:type",Number)],i.prototype,"rowsPerPage",void 0),r([n.i(o.Input)(),a("design:type",Array)],i.prototype,"dataList",void 0),r([n.i(o.Input)(),a("design:type",String)],i.prototype,"emptyMessage",void 0),r([n.i(o.Input)(),a("design:type",String)],i.prototype,"emptySubMessage",void 0),i=r([n.i(o.Component)({selector:"ng-simpleGrid",styles:[n(4)],template:n(6)}),a("design:paramtypes",[])],i)},function(t,e,n){"use strict";var o=n(0);n.n(o);n.d(e,"a",function(){return i});var r=this&&this.__decorate||function(t,e,n,o){var r,a=arguments.length,i=a<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,n,o);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(i=(a<3?r(i):a>3?r(e,n,i):r(e,n))||i);return a>3&&i&&Object.defineProperty(e,n,i),i},a=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},i=function(){function t(){this.movePage=new o.EventEmitter}return t.prototype.ngOnInit=function(){console.log("oninit pagination")},t.prototype.createRange=function(t){for(var e=[],n=0;n<t;n++)e.push(n);return e},t.prototype.onMovePage=function(t){this.movePage.emit(t)},t.prototype.onMoveFirst=function(){0!=this.currentPageIndex&&this.onMovePage(0)},t.prototype.onMoveLast=function(){var t=this.totalPageCount-1;this.currentPageIndex!=t&&this.onMovePage(t)},t.prototype.onMoveNext=function(){var t=this.totalPageCount-1;this.currentPageIndex!=t&&(this.currentPageIndex=this.currentPageIndex+1,this.onMovePage(this.currentPageIndex))},t.prototype.onMovePrev=function(){0!=this.currentPageIndex&&(this.currentPageIndex=this.currentPageIndex-1,this.onMovePage(this.currentPageIndex))},t}();r([n.i(o.Input)(),a("design:type",Number)],i.prototype,"totalPageCount",void 0),r([n.i(o.Input)(),a("design:type",Number)],i.prototype,"currentPageIndex",void 0),r([n.i(o.Output)(),a("design:type",o.EventEmitter)],i.prototype,"movePage",void 0),i=r([n.i(o.Component)({selector:"ng-simplePagination",styles:[n(5)],template:n(7)}),a("design:paramtypes",[])],i)},function(t,e,n){"use strict";var o=n(1);n.d(e,"b",function(){return o.a});var r=n(2);n.d(e,"c",function(){return r.a});var a=n(8);n.d(e,"a",function(){return a.a})},function(t,e){t.exports=".tbl-search-result {\n margin: 0;\n padding: 0;\n border: 0;\n outline: 0;\n vertical-align: middle;\n background: transparent;\n border-spacing: 0;\n width: 100%;\n border: 1px solid #dee1e6;\n border-width: 1px 1px 0 1px;\n table-layout: fixed; }\n .tbl-search-result thead th {\n border-top: 1px;\n height: 40px;\n text-align: center;\n color: #6d6e73;\n background: #f2f5fa;\n font-size: 14px;\n padding: 0 5px; }\n .tbl-search-result tbody tr:hover {\n background-color: beige; }\n .tbl-search-result tbody td {\n cursor: pointer;\n text-align: center;\n font-size: 14px;\n color: #6d6e73;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n height: 40px;\n border-bottom: 1px solid #dee1e6;\n padding: 0 5px; }\n .tbl-search-result tbody td.no-data {\n padding: 0;\n height: 200px;\n color: #4d5662;\n font-size: 16px;\n font-weight: bold; }\n .tbl-search-result tbody td.no-data .sub {\n font-size: 14px;\n color: #6d6e73;\n line-height: 150%;\n margin-top: 20px;\n font-weight: 400; }\n .tbl-search-result tbody td button {\n background-color: #555555;\n /* Green */\n cursor: pointer;\n border: none;\n color: white;\n padding: 5px 10px;\n margin: 5px;\n text-align: center;\n text-decoration: none;\n display: inline-block;\n font-size: 16px; }\n"},function(t,e){t.exports='.paginate {\n text-align: center;\n padding: 10px 0;\n font: 0/0 "Noto Sans KR"; }\n .paginate a {\n display: inline-block;\n width: 30px;\n height: 30px;\n text-align: center;\n font-size: 15px;\n line-height: 30px;\n cursor: pointer;\n vertical-align: middle; }\n .paginate strong {\n display: inline-block;\n width: 30px;\n height: 30px;\n text-align: center;\n font-size: 15px;\n line-height: 30px;\n cursor: pointer;\n vertical-align: middle;\n border: 1px solid #fcd20c;\n font-size: 15px;\n line-height: 26px; }\n .paginate .button-prev {\n font: 0/0 "Noto Sans KR";\n background: url("/assets/images/icon/ico-paginate-prev.png") 50% 50% no-repeat; }\n .paginate .button-next {\n font: 0/0 "Noto Sans KR";\n background: url("/assets/images/icon/ico-paginate-next.png") 50% 50% no-repeat; }\n'},function(t,e){t.exports='<table class="tbl-search-result">\n <thead>\n <tr>\n <ng-template ngFor let-column [ngForOf]="columns">\n <th [width]="column.width || \'10%\'">{{ column.name }}</th>\n </ng-template>\n </tr>\n </thead>\n <tbody>\n <ng-template ngFor let-datarow [ngForOf]="dataListToShow" let-i="index">\n <tr (click)="onClickDataRow($event, datarow, i)">\n <ng-template ngFor let-column [ngForOf]="columns" let-i="index">\n \n <ng-template [ngIf]="column.type == \'text\'">\n <td (click)="onClickDataItem($event, column.value ? column.value : datarow[column.key], datarow, column.key, i)">\n {{ column.value ? column.value : datarow[column.key] }}\n </td>\n </ng-template>\n\n <ng-template [ngIf]="column.type == \'button\'">\n <td>\n <button\n (click)="onClickDataItem($event, column.value ? column.value : datarow[column.key], datarow, column.key, i)">\n {{ column.value ? column.value : datarow[column.key] }}\n </button>\n </td>\n </ng-template>\n\n </ng-template>\n </tr>\n </ng-template>\n <ng-template ngFor let-emptyRow [ngForOf]="emptyRows">\n <tr>\n <ng-template ngFor let-column [ngForOf]="columns" let-i="index">\n <td>\n </td>\n </ng-template>\n </tr>\n </ng-template>\n <ng-template [ngIf]="dataListToShow.length === 0">\n <tr>\n <td class="no-data"\n [style.height.px]="rowsPerPage * 30"\n [attr.colspan]="columns.length">\n <p>{{ emptyMessage }}</p>\n <p class="sub" [innerHTML]="emptySubMessage">\n </p>\n </td>\n </tr>\n </ng-template>\n </tbody>\n</table>\n<ng-simplePagination\n [totalPageCount]="totalPageCount"\n [currentPageIndex]="currentPageIndex"\n (movePage)="onMovePage($event)">\n</ng-simplePagination>'},function(t,e){t.exports='<div class="paginate">\n <a class="item" (click)="onMoveFirst()">First</a>\n <a class="button-prev" (click)="onMovePrev()">처음</a>\n \n <ng-template ngFor let-pageIndex [ngForOf]="createRange(totalPageCount)">\n <ng-template [ngIf]="currentPageIndex === pageIndex">\n <strong (click)="onMovePage(pageIndex)">\n {{ pageIndex + 1 }} \n </strong> \n </ng-template>\n\n <ng-template [ngIf]="currentPageIndex !== pageIndex">\n <a (click)="onMovePage(pageIndex)">\n {{ pageIndex + 1 }} \n </a>\n </ng-template>\n </ng-template>\n \n <a class="button-next" (click)="onMoveNext()">끝</a>\n <a class="item" (click)="onMoveLast()">Last</a>\n</div>'},function(t,e,n){"use strict";var o=n(0),r=(n.n(o),n(11)),a=(n.n(r),n(10)),i=(n.n(a),n(1)),s=n(2);n.d(e,"a",function(){return c});var l=this&&this.__decorate||function(t,e,n,o){var r,a=arguments.length,i=a<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,n,o);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(i=(a<3?r(i):a>3?r(e,n,i):r(e,n))||i);return a>3&&i&&Object.defineProperty(e,n,i),i},c=function(){function t(){}return t}();c=l([n.i(o.NgModule)({imports:[a.CommonModule,r.ReactiveFormsModule],declarations:[i.a,s.a],exports:[a.CommonModule,i.a,s.a]})],c)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(3);n.d(e,"GridModule",function(){return o.a}),n.d(e,"GridComponent",function(){return o.b}),n.d(e,"PaginationComponent",function(){return o.c})},function(t,n){t.exports=e},function(t,e){t.exports=n}])});
\No newline at end of file