From 817f318dc52d6dcb222c184bb4c16e4e36dda336 Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Mon, 29 Jul 2024 09:45:17 +0900 Subject: [PATCH] =?UTF-8?q?paging=20=EC=88=98=EC=A0=95,=20DatasetControl.f?= =?UTF-8?q?ind(..),=20findAll(..)=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/webapp/resources/js/base/base.js | 12 +++++++----- src/main/webapp/resources/js/base/dataset.js | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/main/webapp/resources/js/base/base.js b/src/main/webapp/resources/js/base/base.js index 3adcff6..c3ce975 100644 --- a/src/main/webapp/resources/js/base/base.js +++ b/src/main/webapp/resources/js/base/base.js @@ -630,14 +630,16 @@ $.fn.setPaging = function(config) { config.next = function(index, label) {return ''.replace(/{func}/, config.func.replace(/{index}/, label));}; config.last = function(index, label) {return '
  • '.replace(/{func}/, config.func.replace(/{index}/, label));}; + return this.each(function(){ let length = config.list ? config.list.length : config.dataLength, empty = length < 1, start = empty ? 0 : config.start + 1, end = empty ? 0 : config.start + length, - pagingInfo = empty ? "" : start + " ~ " + numberFormat.format(end) + " / " + numberFormat.format(config.totalSize); + pagingInfo = empty ? "" : start + " ~ " + numberFormat.format(end) + " / " + numberFormat.format(config.totalSize), + selector = "#"+ config.prefix + "PagingInfo,[name='" + config.prefix + "PagingInfo']"; - $("#"+ config.prefix + "PagingInfo").html(pagingInfo); + $(selector).html(pagingInfo); let tag = paginate(config), container = $(this); @@ -647,7 +649,6 @@ $.fn.setPaging = function(config) { if (config.hideIfEmpty != false) container.hide(); } - }); } @@ -658,9 +659,10 @@ $.fn.setPagingInfo = function(config) { pagingInfo = empty ? "" : 1 + " ~ " + numberFormat.format(length) - + " / " + numberFormat.format(config.totalSize); + + " / " + numberFormat.format(config.totalSize), + selector = "#"+ config.prefix + "PagingInfo,[name='" + config.prefix + "PagingInfo']"; - $("#"+ config.prefix + "PagingInfo").html(pagingInfo); + $(selector).html(pagingInfo); }); } diff --git a/src/main/webapp/resources/js/base/dataset.js b/src/main/webapp/resources/js/base/dataset.js index 3d2fa45..a1fff11 100644 --- a/src/main/webapp/resources/js/base/dataset.js +++ b/src/main/webapp/resources/js/base/dataset.js @@ -1372,8 +1372,8 @@ class DatasetControl { return this.dataset.getCurrent(option); } - currentToObject() { - return this.dataBinder().toObject(this.getCurrent("item")); + toObject(item) { + return this.dataBinder().toObject(item || this.getCurrent("item")); } dataBinder() { @@ -1500,6 +1500,14 @@ class DatasetControl { querySelectorAll(selector) { return this.dataBinder().querySelectorAll(selector); } + + find(name) { + return this.querySelector(!name.startsWith("#") ? "[name='" + name + "']" : name); + } + + findAll(name) { + return this.querySelectorAll("[name='" + name + "']"); + } } var dataBinder = { @@ -1616,9 +1624,11 @@ var dataBinder = { let result = {}; obj.inputs().forEach(input => { let dataMap = dataBinder.dataMap(input), - property = dataBinder.property(input) || dataMap; + property = dataBinder.property(input) || dataMap, + value = item.data[dataMap || property]; - result[property] = item.data[dataMap || property]; + if (value !== undefined) + result[property] = value; }); return result; }