페이징 처리 공통 기능으로 구현되어 제거

main
이범준 1 year ago
parent 0dd6818cc2
commit ef82831738

@ -28,92 +28,3 @@ class CodeFormat {
return txt; return txt;
} }
} }
class FimsDatasetControl extends DatasetControl {
constructor(conf) {
super(conf);
this.dataset = new FimsDataset(conf);
this.infoSizes = conf.infoSizes || {};
this.titles = conf.titles || {};
}
_paginationInfo = {
paging : true,
pagingType : "nav",
fetchSize : 15,
scrollFuncName : null,
pageNum : 1
}
totalCountSetting(obj){
if(document.getElementById('totCnt')){
var prefix = obj.infoPrefix;
$('#totCnt span').text(obj[prefix+"Total"]);
}
}
load(pageNum,flag) {
if(this._paginationInfo.paging){
this.query.fetchSize = this._paginationInfo.fetchSize;
this.query.pageNum = pageNum;
} else {
this.query.fetchSize = 0;
this.query.pageNum = 0;
}
this._load(flag);
}
_load(flag) {
if (!this.query.pageNum)
this.query.pageNum = 1;
ajax.get({
url:this.urls.load,
data:this.query,
success:resp => this.setData(resp,flag)
});
}
setData(obj, flag) {
this.dataset.setData(obj,flag);
}
}
class FimsDataset extends Dataset {
setData(obj, flag) {
let state = this.state;
this._byKeys = {};
this._current = null;
obj = obj || {};
let array = Array.isArray(obj) ? obj : this.conf.dataGetter(obj) || [];
if (!Array.isArray(array))
throw new Error("The data must be an array");
let oldItems = [];
if(flag != null && flag == "more"){
oldItems = this._items;
}
let newitems = [];
newitems = array.map(e => new DataItem(e, this._formats));
newitems.forEach(item => {
let key = "key-" + this.getKey(item.data);
this._byKeys[key] = item;
});
if(flag != null && flag == "more"){
this._items = oldItems.concat(newitems);
} else {
this._items = newitems;
}
this.onDatasetChange(obj);
this.setState(!Array.isArray(obj) ? obj.state : state);
this.onDirtiesChange(this.dirty);
return this;
}
}
Loading…
Cancel
Save