UNPKG

20 kBJavaScriptView Raw
1(function webpackUniversalModuleDefinition(root, factory) {
2 if(typeof exports === 'object' && typeof module === 'object')
3 module.exports = factory(require("@angular/core"), require("@angular/common"));
4 else if(typeof define === 'function' && define.amd)
5 define("ng-simplegrid", ["@angular/core", "@angular/common"], factory);
6 else if(typeof exports === 'object')
7 exports["ng-simplegrid"] = factory(require("@angular/core"), require("@angular/common"));
8 else
9 root["ng-simplegrid"] = factory(root["@angular/core"], root["@angular/common"]);
10})(this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_10__) {
11return /******/ (function(modules) { // webpackBootstrap
12/******/ // The module cache
13/******/ var installedModules = {};
14/******/
15/******/ // The require function
16/******/ function __webpack_require__(moduleId) {
17/******/
18/******/ // Check if module is in cache
19/******/ if(installedModules[moduleId])
20/******/ return installedModules[moduleId].exports;
21/******/
22/******/ // Create a new module (and put it into the cache)
23/******/ var module = installedModules[moduleId] = {
24/******/ i: moduleId,
25/******/ l: false,
26/******/ exports: {}
27/******/ };
28/******/
29/******/ // Execute the module function
30/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31/******/
32/******/ // Flag the module as loaded
33/******/ module.l = true;
34/******/
35/******/ // Return the exports of the module
36/******/ return module.exports;
37/******/ }
38/******/
39/******/
40/******/ // expose the modules object (__webpack_modules__)
41/******/ __webpack_require__.m = modules;
42/******/
43/******/ // expose the module cache
44/******/ __webpack_require__.c = installedModules;
45/******/
46/******/ // identity function for calling harmony imports with the correct context
47/******/ __webpack_require__.i = function(value) { return value; };
48/******/
49/******/ // define getter function for harmony exports
50/******/ __webpack_require__.d = function(exports, name, getter) {
51/******/ if(!__webpack_require__.o(exports, name)) {
52/******/ Object.defineProperty(exports, name, {
53/******/ configurable: false,
54/******/ enumerable: true,
55/******/ get: getter
56/******/ });
57/******/ }
58/******/ };
59/******/
60/******/ // getDefaultExport function for compatibility with non-harmony modules
61/******/ __webpack_require__.n = function(module) {
62/******/ var getter = module && module.__esModule ?
63/******/ function getDefault() { return module['default']; } :
64/******/ function getModuleExports() { return module; };
65/******/ __webpack_require__.d(getter, 'a', getter);
66/******/ return getter;
67/******/ };
68/******/
69/******/ // Object.prototype.hasOwnProperty.call
70/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
71/******/
72/******/ // __webpack_public_path__
73/******/ __webpack_require__.p = "";
74/******/
75/******/ // Load entry module and return exports
76/******/ return __webpack_require__(__webpack_require__.s = 5);
77/******/ })
78/************************************************************************/
79/******/ ([
80/* 0 */
81/***/ (function(module, exports) {
82
83module.exports = __WEBPACK_EXTERNAL_MODULE_0__;
84
85/***/ }),
86/* 1 */
87/***/ (function(module, exports, __webpack_require__) {
88
89"use strict";
90
91var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
92 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
93 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
94 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
95 return c > 3 && r && Object.defineProperty(target, key, r), r;
96};
97var __metadata = (this && this.__metadata) || function (k, v) {
98 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
99};
100Object.defineProperty(exports, "__esModule", { value: true });
101var core_1 = __webpack_require__(0);
102var GridComponent = (function () {
103 function GridComponent() {
104 this.rowsPerPage = 10;
105 this.dataList = [];
106 this.emptyMessage = '검색한 내역이 없습니다';
107 this.dataListToShow = [];
108 this.totalPageCount = 1;
109 this.currentPageIndex = 0;
110 this.emptyRows = [];
111 }
112 GridComponent.prototype.ngOnInit = function () {
113 if (!this.columns)
114 console.error('ng-simpleGrid: grid.columns is not exists.');
115 };
116 GridComponent.prototype.setDataList = function (dataList) {
117 this.dataList = dataList;
118 this.initializeData(dataList);
119 };
120 GridComponent.prototype.initializeData = function (dataList) {
121 this.totalPageCount = this._getTotalPageCount(this.rowsPerPage, dataList);
122 this.dataListPerPage = this._getDataListPerPage(this.rowsPerPage, dataList);
123 this.dataListToShow = this.dataListPerPage[0];
124 this.emptyRows = this._getEmptyRowsToBeFilled(this.rowsPerPage, this.dataListToShow);
125 };
126 GridComponent.prototype.search = function (key, value) {
127 if (!this.dataList)
128 return;
129 if (value === '') {
130 this.initializeData(this.dataList);
131 return;
132 }
133 var filteredList = [];
134 for (var _i = 0, _a = this.dataList; _i < _a.length; _i++) {
135 var data = _a[_i];
136 if (data[key].include(data))
137 filteredList.push(data);
138 }
139 this.initializeData(filteredList);
140 };
141 GridComponent.prototype.onClickDataItem = function (e, value, datarow, key, index) {
142 var column = this._getColumnByProperty(this.columns, key, 'onClick');
143 if (column == null)
144 return;
145 column.onClick(e, value, index, datarow);
146 };
147 GridComponent.prototype.onMovePage = function (pageIndex) {
148 if (!this.dataListPerPage)
149 return;
150 this.dataListToShow = this.dataListPerPage[pageIndex];
151 this.emptyRows = this._getEmptyRowsToBeFilled(this.rowsPerPage, this.dataListToShow);
152 this.currentPageIndex = pageIndex;
153 };
154 GridComponent.prototype.onClickDataRow = function (e, row, index) {
155 if (this.event && this.event.onClickRow) {
156 this.event.onClickRow(row, index);
157 }
158 };
159 GridComponent.prototype._getColumnByProperty = function (columns, key, property) {
160 var selectedColumn = null;
161 for (var _i = 0, columns_1 = columns; _i < columns_1.length; _i++) {
162 var column = columns_1[_i];
163 if (column.key == key) {
164 if (column.hasOwnProperty(property)) {
165 selectedColumn = column;
166 break;
167 }
168 }
169 }
170 return selectedColumn;
171 };
172 GridComponent.prototype._getTotalPageCount = function (rowsPerPage, dataList) {
173 var dataListSize = dataList.length;
174 return Math.ceil(dataListSize / rowsPerPage);
175 };
176 GridComponent.prototype._getDataListPerPage = function (rowsPerPage, dataList) {
177 var dataListPerPage = [];
178 for (var i = 0; i <= this.totalPageCount; i++) {
179 dataListPerPage.push(this.dataList.splice(0, rowsPerPage));
180 }
181 return dataListPerPage;
182 };
183 GridComponent.prototype._getEmptyRowsToBeFilled = function (rowsPerPage, dataList) {
184 var emptyRowsCount = rowsPerPage - dataList.length;
185 return new Array(emptyRowsCount);
186 };
187 return GridComponent;
188}());
189__decorate([
190 core_1.Input(),
191 __metadata("design:type", Array)
192], GridComponent.prototype, "columns", void 0);
193__decorate([
194 core_1.Input(),
195 __metadata("design:type", Object)
196], GridComponent.prototype, "event", void 0);
197__decorate([
198 core_1.Input(),
199 __metadata("design:type", Number)
200], GridComponent.prototype, "rowsPerPage", void 0);
201__decorate([
202 core_1.Input(),
203 __metadata("design:type", Array)
204], GridComponent.prototype, "dataList", void 0);
205__decorate([
206 core_1.Input(),
207 __metadata("design:type", String)
208], GridComponent.prototype, "emptyMessage", void 0);
209__decorate([
210 core_1.Input(),
211 __metadata("design:type", String)
212], GridComponent.prototype, "emptySubMessage", void 0);
213GridComponent = __decorate([
214 core_1.Component({
215 selector: 'ng-simpleGrid',
216 styles: [__webpack_require__(6)],
217 template: __webpack_require__(8)
218 }),
219 __metadata("design:paramtypes", [])
220], GridComponent);
221exports.GridComponent = GridComponent;
222
223
224/***/ }),
225/* 2 */
226/***/ (function(module, exports, __webpack_require__) {
227
228"use strict";
229
230var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
231 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
232 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
233 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
234 return c > 3 && r && Object.defineProperty(target, key, r), r;
235};
236var __metadata = (this && this.__metadata) || function (k, v) {
237 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
238};
239Object.defineProperty(exports, "__esModule", { value: true });
240var core_1 = __webpack_require__(0);
241var PaginationComponent = (function () {
242 function PaginationComponent() {
243 this.movePage = new core_1.EventEmitter();
244 }
245 PaginationComponent.prototype.ngOnInit = function () {
246 console.log('oninit pagination');
247 };
248 PaginationComponent.prototype.createRange = function (number) {
249 var numberList = [];
250 for (var i = 0; i < number; i++) {
251 numberList.push(i);
252 }
253 return numberList;
254 };
255 PaginationComponent.prototype.onMovePage = function (pageIndex) {
256 this.movePage.emit(pageIndex);
257 };
258 PaginationComponent.prototype.onMoveFirst = function () {
259 var FIRST_PAGE_INDEX = 0;
260 if (this.currentPageIndex == FIRST_PAGE_INDEX)
261 return;
262 this.onMovePage(FIRST_PAGE_INDEX);
263 };
264 PaginationComponent.prototype.onMoveLast = function () {
265 var LAST_PAGE_INDEX = this.totalPageCount - 1;
266 if (this.currentPageIndex == LAST_PAGE_INDEX)
267 return;
268 this.onMovePage(LAST_PAGE_INDEX);
269 };
270 PaginationComponent.prototype.onMoveNext = function () {
271 var LAST_PAGE_INDEX = this.totalPageCount - 1;
272 if (this.currentPageIndex == LAST_PAGE_INDEX)
273 return;
274 this.currentPageIndex = this.currentPageIndex + 1;
275 this.onMovePage(this.currentPageIndex);
276 };
277 PaginationComponent.prototype.onMovePrev = function () {
278 var FIRST_PAGE_INDEX = 0;
279 if (this.currentPageIndex == FIRST_PAGE_INDEX)
280 return;
281 this.currentPageIndex = this.currentPageIndex - 1;
282 this.onMovePage(this.currentPageIndex);
283 };
284 return PaginationComponent;
285}());
286__decorate([
287 core_1.Input(),
288 __metadata("design:type", Number)
289], PaginationComponent.prototype, "totalPageCount", void 0);
290__decorate([
291 core_1.Input(),
292 __metadata("design:type", Number)
293], PaginationComponent.prototype, "currentPageIndex", void 0);
294__decorate([
295 core_1.Output(),
296 __metadata("design:type", core_1.EventEmitter)
297], PaginationComponent.prototype, "movePage", void 0);
298PaginationComponent = __decorate([
299 core_1.Component({
300 selector: 'ng-simplePagination',
301 styles: [__webpack_require__(7)],
302 template: __webpack_require__(9)
303 }),
304 __metadata("design:paramtypes", [])
305], PaginationComponent);
306exports.PaginationComponent = PaginationComponent;
307
308
309/***/ }),
310/* 3 */
311/***/ (function(module, exports, __webpack_require__) {
312
313"use strict";
314
315Object.defineProperty(exports, "__esModule", { value: true });
316var grid_component_1 = __webpack_require__(1);
317exports.GridComponent = grid_component_1.GridComponent;
318var pagination_component_1 = __webpack_require__(2);
319exports.PaginationComponent = pagination_component_1.PaginationComponent;
320var grid_module_1 = __webpack_require__(4);
321exports.GridModule = grid_module_1.GridModule;
322
323
324/***/ }),
325/* 4 */
326/***/ (function(module, exports, __webpack_require__) {
327
328"use strict";
329
330var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
331 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
332 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
333 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
334 return c > 3 && r && Object.defineProperty(target, key, r), r;
335};
336Object.defineProperty(exports, "__esModule", { value: true });
337var core_1 = __webpack_require__(0);
338var common_1 = __webpack_require__(10);
339var grid_component_1 = __webpack_require__(1);
340var pagination_component_1 = __webpack_require__(2);
341var GridModule = (function () {
342 function GridModule() {
343 }
344 return GridModule;
345}());
346GridModule = __decorate([
347 core_1.NgModule({
348 imports: [common_1.CommonModule],
349 declarations: [grid_component_1.GridComponent, pagination_component_1.PaginationComponent],
350 exports: [common_1.CommonModule, grid_component_1.GridComponent, pagination_component_1.PaginationComponent]
351 })
352], GridModule);
353exports.GridModule = GridModule;
354
355
356/***/ }),
357/* 5 */
358/***/ (function(module, exports, __webpack_require__) {
359
360"use strict";
361
362Object.defineProperty(exports, "__esModule", { value: true });
363var index_1 = __webpack_require__(3);
364exports.GridModule = index_1.GridModule;
365exports.GridComponent = index_1.GridComponent;
366exports.PaginationComponent = index_1.PaginationComponent;
367
368
369/***/ }),
370/* 6 */
371/***/ (function(module, exports) {
372
373module.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"
374
375/***/ }),
376/* 7 */
377/***/ (function(module, exports) {
378
379module.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"
380
381/***/ }),
382/* 8 */
383/***/ (function(module, exports) {
384
385module.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>"
386
387/***/ }),
388/* 9 */
389/***/ (function(module, exports) {
390
391module.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>"
392
393/***/ }),
394/* 10 */
395/***/ (function(module, exports) {
396
397module.exports = __WEBPACK_EXTERNAL_MODULE_10__;
398
399/***/ })
400/******/ ]);
401});
402//# sourceMappingURL=ng-simplegrid.umd.js.map
\No newline at end of file