@mescius/wijmo.rest 5.20242.20-nightly.d20240814.t020153 → 5.20242.20-nightly.d20240814.t111510
Sign up to get free protection for your applications and to get access to all the features.
- package/es2015-commonjs.js +2 -2
- package/es2015-esm.js +2 -2
- package/es5-esm.js +2 -2
- package/index.d.ts +93 -3
- package/index.js +2 -2
- package/package.json +2 -2
package/es2015-commonjs.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
*
|
3
|
-
* Wijmo Library 5.20242.20-nightly.d20240814.
|
3
|
+
* Wijmo Library 5.20242.20-nightly.d20240814.t111510
|
4
4
|
* https://developer.mescius.com/wijmo
|
5
5
|
*
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
@@ -11,4 +11,4 @@
|
|
11
11
|
*
|
12
12
|
*/
|
13
13
|
|
14
|
-
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(s,o){function fulfilled(e){try{step(i.next(e))}catch(e){o(e)}}function rejected(e){try{step(i.throw(e))}catch(e){o(e)}}function step(e){e.done?s(e.value):new r((function(t){t(e.value)})).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())}))},__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);t.default=e;return t};Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_1=require("@mescius/wijmo"),selfModule=__importStar(require("@mescius/wijmo.rest"));class RestCollectionView extends wijmo_1.CollectionView{constructor(e){super();this._loading=!1;this._fields=null;this._keys=null;this._sortOnServer=!0;this._pageOnServer=!0;this._filterOnServer=!0;this._totalItemCount=0;this.loading=new wijmo_1.Event;this.loaded=new wijmo_1.Event;this.error=new wijmo_1.Event;e&&wijmo_1.copy(this,e);this.sortDescriptions.collectionChanged.addHandler(()=>{this.sortOnServer&&this._getData()});this._getData()}get fields(){return this._fields}set fields(e){if(this._fields!=e){this._fields=wijmo_1.asArray(e);this._getData()}}get sortOnServer(){return this._sortOnServer}set sortOnServer(e){if(e!=this._sortOnServer){this._sortOnServer=wijmo_1.asBoolean(e);this._getData()}}get pageOnServer(){return this._pageOnServer}set pageOnServer(e){if(e!=this._pageOnServer){this._pageOnServer=wijmo_1.asBoolean(e);this._getData()}}get filterOnServer(){return this._filterOnServer}set filterOnServer(e){if(e!=this._filterOnServer){this._filterOnServer=wijmo_1.asBoolean(e);this._getData()}}get requestHeaders(){return this._requestHeaders}set requestHeaders(e){this._requestHeaders=e}updateFilterDefinition(e){if(this.filterOnServer){this._filterProvider=e;this._getData()}}get isLoading(){return this._loading}onLoading(e){this.loading.raise(this,e)}onLoaded(e){this.loaded.raise(this,e)}load(){this._getData()}onError(e){this.error.raise(this,e);return!e.cancel}_performRefresh(){let e=this._canFilter,t=this._canSort;this._canFilter=!this._filterOnServer;this._canSort=!this._sortOnServer;super._performRefresh();this._canFilter=e;this._canSort=t}get totalItemCount(){return this.pageOnServer?this._totalItemCount:this._view.length}get pageCount(){return this.pageSize?Math.ceil(this.totalItemCount/this.pageSize):1}get pageSize(){return this._pgSz}set pageSize(e){if(e!=this._pgSz){this._pgSz=wijmo_1.asInt(e);if(this.pageOnServer){this._pgIdx=wijmo_1.clamp(this._pgIdx,0,this.pageCount-1);this._getData()}else this.refresh()}}onPageChanging(e){super.onPageChanging(e);this.pageOnServer&&!e.cancel&&this._getData();return!e.cancel}commitNew(){let e=this.currentAddItem;if(e)try{let t=this.addItem(e);t&&t.then&&t.then(()=>this.refresh())}catch(e){this._raiseError(e,!0)}super.commitNew()}commitEdit(){let e=this.currentEditItem;if(e&&!this.currentAddItem&&!this._sameContent(e,this._edtClone)&&this.items.indexOf(e)>-1)try{let t=this.patchItem(e);t&&t.then&&t.then(()=>this.refresh())}catch(e){this._raiseError(e,!0)}super.commitEdit()}remove(e){if(e&&e!=this.currentAddItem&&this.items.indexOf(e)>-1)try{let t=this.deleteItem(e);t&&t.then&&t.then(()=>this.refresh())}catch(e){this._raiseError(e,!0)}super.remove(e)}_getPageView(){return this.pageOnServer?this._view:super._getPageView()}_getData(){this._toGetData&&clearTimeout(this._toGetData);this._toGetData=setTimeout(()=>__awaiter(this,void 0,void 0,(function*(){this._toGetData=null;this._loading=!0;this.onLoading();let e=null,t=null;try{let t=this.currentPosition;e=yield this.getItems();this.sourceCollection=e;this.refresh();t>-1&&this.moveCurrentToPosition(t);this.pageIndex>0&&this.pageIndex>=this.pageCount&&this.moveToLastPage()}catch(e){t=e}this._loading=!1;this.onLoaded();t&&this._raiseError(t,!1)})),100)}_raiseError(e,t){if(this.onError(new RESTErrorEventArgs(e))){t&&this._getData();throw"Server Error: "+e}}getItems(){throw"This method is virtual: it should be overridden"}addItem(e){throw"This method is virtual: it should be overridden"}patchItem(e){throw"This method is virtual: it should be overridden"}deleteItem(e){throw"This method is virtual: it should be overridden"}}exports.RestCollectionView=RestCollectionView;class RESTErrorEventArgs extends wijmo_1.CancelEventArgs{constructor(e){super();this._error=e}get error(){return this._error}}exports.RESTErrorEventArgs=RESTErrorEventArgs;wijmo_1._registerModule("wijmo.rest",selfModule);
|
14
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(t,e,i,s){return new(i||(i=Promise))((function(r,o){function fulfilled(t){try{step(s.next(t))}catch(t){o(t)}}function rejected(t){try{step(s.throw(t))}catch(t){o(t)}}function step(t){t.done?r(t.value):new i((function(e){e(t.value)})).then(fulfilled,rejected)}step((s=s.apply(t,e||[])).next())}))},__importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)Object.hasOwnProperty.call(t,i)&&(e[i]=t[i]);e.default=t;return e};Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_1=require("@mescius/wijmo"),selfModule=__importStar(require("@mescius/wijmo.rest")),_MIN_DATA_WINDOW=100;class RestCollectionView extends wijmo_1.CollectionView{constructor(t){super();this._loading=!1;this._fields=null;this._keys=null;this._sortOnServer=!0;this._pageOnServer=!0;this._filterOnServer=!0;this._totalItemCount=0;this._aggregates="";this._groupOnServer=!0;this._groupLazyLoading=!1;this._virtualization=!1;this._start=0;this._end=_MIN_DATA_WINDOW;this._expandedGroups=[];this._groupItems=[];this._groupRefresh=!1;this._refresh=!1;this.loading=new wijmo_1.Event;this.loaded=new wijmo_1.Event;this.error=new wijmo_1.Event;t&&wijmo_1.copy(this,t);this.sortDescriptions.collectionChanged.addHandler(()=>{this.sortOnServer&&this._getData()});this._getData();(this._groupOnServer||this._virtualization)&&(this._data=[]);this._virtualization&&this.setWindow(this._start,_MIN_DATA_WINDOW);this._firstLoad=this._groupRefresh=!0}get totalGroupItemCount(){return this.groupOnServer?this._totalGroupItemCount:0}get groupOnServer(){return this._groupOnServer}set groupOnServer(t){if(t!=this._groupOnServer){this._groupOnServer=wijmo_1.asBoolean(t);this._getData()}}get groupLazyLoading(){return this._groupLazyLoading}set groupLazyLoading(t){t!=this._groupLazyLoading&&this._groupOnServer&&(this._groupLazyLoading=wijmo_1.asBoolean(t))}get virtualization(){return this._virtualization}set virtualization(t){t!=this.virtualization&&(this._virtualization=wijmo_1.asBoolean(t))}get fields(){return this._fields}set fields(t){if(this._fields!=t){this._fields=wijmo_1.asArray(t);this._getData()}}get sortOnServer(){return this._sortOnServer}set sortOnServer(t){if(t!=this._sortOnServer){this._sortOnServer=wijmo_1.asBoolean(t);this._getData()}}get pageOnServer(){return this._pageOnServer}set pageOnServer(t){if(t!=this._pageOnServer){this._pageOnServer=wijmo_1.asBoolean(t);this._getData()}}get filterOnServer(){return this._filterOnServer}set filterOnServer(t){if(t!=this._filterOnServer){this._filterOnServer=wijmo_1.asBoolean(t);this._getData()}}get requestHeaders(){return this._requestHeaders}set requestHeaders(t){this._requestHeaders=t}get aggregates(){return this._aggregates}set aggregates(t){wijmo_1.assert(this._groupOnServer,"groupOnServer should be enabled");wijmo_1.isString(t)&&t!=this._aggregates&&(this._aggregates=t)}updateFilterDefinition(t){if(this.filterOnServer){this._filterProvider=t;this._getData()}}lazyLoadGroup(t){if(this._groupLazyLoading){t.groups.length>0&&null==t.groups[0].name&&this._getData(t);0==t.groups.length&&t.isBottomLevel&&this._getData(t)}else wijmo_1.assert(this._groupLazyLoading,"groupLazyLoading should be enabled lazy load the groups.")}setWindow(t,e){this._toSetWindow&&clearTimeout(this._toSetWindow);this._toSetWindow=setTimeout(()=>{this._toSetWindow=null;this._performSetWindow(t,e)},50)}_getFilterGroupItems(t){let e=this._groupItems,i=t.items[0];for(let s=0;s<=t.level;s++){let t=this.groupDescriptions[s].propertyName;e=e.filter(e=>e.groupKey[t]==i[t])}return e}getGroupAggregate(t,e,i=wijmo_1.Aggregate.Sum){if(this.groupLazyLoading||this.virtualization){let s="",r=this._getFilterGroupItems(e);r&&0!=r.length&&r.length!=this._groupItems.length&&r[0].aggregates&&(s=wijmo_1.getAggregate(i,r,`aggregates.${t}`));return s}}get isLoading(){return this._loading}onLoading(t){this.loading.raise(this,t)}onLoaded(t){this.loaded.raise(this,t)}load(){this._getData()}onError(t){this.error.raise(this,t);return!t.cancel}_performRefresh(){this.isLoading||(this._refresh=!0);let t=this._canFilter,e=this._canSort;this._canFilter=!this._filterOnServer;this._canSort=!this._sortOnServer;super._performRefresh();this._canFilter=t;this._canSort=e}get totalItemCount(){return this.pageOnServer?this._totalItemCount:this._view.length}get pageCount(){return this.pageSize?Math.ceil(this.totalItemCount/this.pageSize):1}get pageSize(){return this._pgSz}set pageSize(t){if(t!=this._pgSz){this._pgSz=wijmo_1.asInt(t);if(this.pageOnServer){this._pgIdx=wijmo_1.clamp(this._pgIdx,0,this.pageCount-1);this._getData()}else this.refresh()}}onPageChanging(t){super.onPageChanging(t);this.pageOnServer&&!t.cancel&&this._getData();return!t.cancel}commitNew(){let t=this.currentAddItem;if(t)try{let e=this.addItem(t);e&&e.then&&e.then(()=>this.refresh())}catch(t){this._raiseError(t,!0)}super.commitNew()}commitEdit(){let t=this.currentEditItem;if(t&&!this.currentAddItem&&!this._sameContent(t,this._edtClone)&&this.items.indexOf(t)>-1)try{let e=this.patchItem(t);e&&e.then&&e.then(()=>this.refresh())}catch(t){this._raiseError(t,!0)}super.commitEdit()}remove(t){if(t&&t!=this.currentAddItem&&this.items.indexOf(t)>-1)try{let e=this.deleteItem(t);e&&e.then&&e.then(()=>this.refresh())}catch(t){this._raiseError(t,!0)}super.remove(t)}_getPageView(){return this.pageOnServer?this._view:super._getPageView()}_getData(t){this._toGetData&&clearTimeout(this._toGetData);this._toGetData=setTimeout(()=>__awaiter(this,void 0,void 0,(function*(){this._toGetData=null;this._loading=!0;this.onLoading();let e=null;if(this._groupOnServer||this._virtualization){let e=-1;this.currentPosition>-1&&(e=this.currentPosition);let i=this.groupDescriptions;this._data||(this._data=[]);let s,r=[];if((this._groupRefresh||this._groupLazyLoading&&(!t||!t.isBottomLevel))&&this._groupOnServer&&i.length>0){r=yield this.getGroupItems(t);t?this._updateSubGroups(t,r):this._groupItems=r;this._groupRefresh=!1}this._groupLazyLoading||(s=yield this.getItems());this._groupLazyLoading&&t&&t.isBottomLevel&&(s=yield this.getItems(t));this.deferUpdate(()=>__awaiter(this,void 0,void 0,(function*(){this._virtualization||this._groupLazyLoading||(this._data=s);if(this._groupLazyLoading&&!this._virtualization)if(t)this._loadSubGroupsData(t,r,s);else{this._data=new Array;const e=i[0].propertyName;for(let t=0;t<r.length;t++){let i=new Object,s=r[t].count;i[e]=r[t].groupKey[e];for(let t=0;t<s;t++)this._data.push(i)}this._expandedGroups.length>0&&(yield this._loadExpandedGroups(t))}this._virtualization&&!this._groupLazyLoading&&this._storeItems(s,!1);this.sourceCollection=this._data})));this.refresh();e>-1&&this.moveCurrentToPosition(e)}else{let t=null;try{let e=this.currentPosition;t=yield this.getItems();this.sourceCollection=t;this.refresh();e>-1&&this.moveCurrentToPosition(e);this.pageIndex>0&&this.pageIndex>=this.pageCount&&this.moveToLastPage()}catch(t){e=t}}this._loading=!1;this.onLoaded();e&&this._raiseError(e,!1)})),100)}_loadExpandedGroups(t){return __awaiter(this,void 0,void 0,(function*(){if(this._expandedGroups.length>0&&!t){let t=[];this._expandedGroups.forEach(e=>__awaiter(this,void 0,void 0,(function*(){e.isBottomLevel?t.push(this.getItems(e)):t.push(this.getGroupItems(e))})));return new Promise(e=>{Promise.all(t).then(t=>{for(let e=0;e<this._expandedGroups.length;e++)if(this._expandedGroups[e].isBottomLevel)this._loadSubGroupsData(this._expandedGroups[e],[],t[e]);else{this._updateSubGroups(this._expandedGroups[e],t[e]);this._loadSubGroupsData(this._expandedGroups[e],t[e],[])}e(!0)}).catch(t=>{e(!1)})})}}))}_updateSubGroups(t,e){let i=this._getFilterGroupItems(t);if(1==i.length){for(let t=0;t<e.length;t++)e[t].groupKey=Object.assign({},i[0].groupKey,e[t].groupKey);let t=this._groupItems.indexOf(i[0]);this._groupItems.splice(t,1,...e)}else console.error("unable to find exact match for targetted group")}_loadSubGroupsData(t,e,i){let s=this.groupDescriptions,r=this._data;for(let e=0;e<=(t.isBottomLevel?s.length-1:t.level);e++){const i=s[e].propertyName,o=t.items[e][i];r=r.filter(t=>t[i]===o)}let o=this._data.indexOf(r[0]);r=JSON.parse(JSON.stringify(r));if(t.isBottomLevel)for(let t=0;t<i.length;t++)Object.assign(r[t],i[t]);else{let i=t.groups[0].groupDescription.propertyName,s=0;for(let t=0;t<e.length;t++){s+=t>0?e[t-1].count:0;for(let o=0;o<e[t].count;o++)r[s+o][i]=e[t].groupKey[i]}}this._data.splice(o,r.length,...r)}_updateExpandedGroups(t,e){if(!this._loading){let i=this._expandedGroups.filter(e=>e._path.indexOf(t._path)>-1);if(e)this._expandedGroups.push(t);else if(i.length>0)for(let t=0;t<i.length;t++)this._expandedGroups.splice(this._expandedGroups.indexOf(i[t]),1)}}_storeItems(t,e){return __awaiter(this,void 0,void 0,(function*(){if(this._refresh||this._data.length!=this.totalItemCount||this.groups&&this.groups.length!=this._totalGroupItemCount){if(this._data.length!=this.totalItemCount&&this.groups&&this.groups.length>0){this._groupRefresh=!0;this._getData()}this._data.length=this.totalItemCount;if(this._groupOnServer&&this._groupItems.length>0&&this.groupDescriptions.length>0){let t=JSON.parse(JSON.stringify(this.groups)),e=0;for(let t=0;t<this._groupItems.length;t++){let i=Object.keys(this._groupItems[t].groupKey);for(let s=0;s<this._groupItems[t].count;s++){let s=new wijmo_1._NullValue(e);i.forEach(e=>{s[e]=this._groupItems[t].groupKey[e]});this._data[e]=s;e++}}if(0!=this.groups.length&&this.groups.length<t.length){let e=this._data[this._start],i=this.groupDescriptions.length,s=this.groupDescriptions[i-1].propertyName,r=this.groups.findIndex(t=>t.name==e[s]),o=t.findIndex(t=>t.name==e[s]);this._start+=r-o;this._getData()}}else for(let t=0;t<this._data.length;t++)this._data[t]=new wijmo_1._NullValue(t);this._refresh=!1}e||(this._loadOffset=0);let i=this._loadOffset+(this._start||0);for(let e=0;e<t.length;e++)this._data[e+i]=t[e];this._loadOffset+=t.length;setTimeout(()=>{this._firstLoad&&this.currentPosition<0&&t.length&&this.moveCurrentToFirst();this._firstLoad=!1})}))}_performSetWindow(t,e){if(this._pendingRequest){this._pendingRequest.abort();this._pendingRequest=null;this.onRequestCanceled()}t=wijmo_1.asInt(t);e=wijmo_1.asInt(e);wijmo_1.assert(t<=e,"start must be <= end.");let i=t<this._start,s=this._data;this._start=this._end=t;for(let i=t;i<=e&&i<s.length;i++)if(s[i]instanceof wijmo_1._NullValue){this._start=i;break}for(let t=e;t>=this._start&&t<s.length;t--)if(s[t]instanceof wijmo_1._NullValue){this._end=t;break}if(this._start!=this._end||s[this._start]instanceof wijmo_1._NullValue){i&&(this._start=Math.max(0,this._end-this._fetchSize()+1));this._getData()}}_fetchSize(){return Math.max(this._end-this._start+1,this.pageSize,_MIN_DATA_WINDOW)}_raiseError(t,e){if(this.onError(new RESTErrorEventArgs(t))){e&&this._getData();throw"Server Error: "+t}}get requestCanceled(){this._requestCanceled||(this._requestCanceled=new wijmo_1.Event);return this._requestCanceled}onRequestCanceled(t){this.requestCanceled.raise(this,t)}getGroupItems(t){throw"This method is virtual: it should be overridden"}getItems(t){throw"This method is virtual: it should be overridden"}addItem(t){throw"This method is virtual: it should be overridden"}patchItem(t){throw"This method is virtual: it should be overridden"}deleteItem(t){throw"This method is virtual: it should be overridden"}}exports.RestCollectionView=RestCollectionView;class RESTErrorEventArgs extends wijmo_1.CancelEventArgs{constructor(t){super();this._error=t}get error(){return this._error}}exports.RESTErrorEventArgs=RESTErrorEventArgs;wijmo_1._registerModule("wijmo.rest",selfModule);
|
package/es2015-esm.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
*
|
3
|
-
* Wijmo Library 5.20242.20-nightly.d20240814.
|
3
|
+
* Wijmo Library 5.20242.20-nightly.d20240814.t111510
|
4
4
|
* https://developer.mescius.com/wijmo
|
5
5
|
*
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
@@ -11,4 +11,4 @@
|
|
11
11
|
*
|
12
12
|
*/
|
13
13
|
|
14
|
-
var __awaiter=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(s,n){function fulfilled(e){try{step(i.next(e))}catch(e){n(e)}}function rejected(e){try{step(i.throw(e))}catch(e){n(e)}}function step(e){e.done?s(e.value):new r((function(t){t(e.value)})).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())}))};import{asArray,asBoolean,asInt,copy,clamp,CollectionView,Event,CancelEventArgs,_registerModule}from"@mescius/wijmo";import*as selfModule from"@mescius/wijmo.rest";export class RestCollectionView extends CollectionView{constructor(e){super();this._loading=!1;this._fields=null;this._keys=null;this._sortOnServer=!0;this._pageOnServer=!0;this._filterOnServer=!0;this._totalItemCount=0;this.loading=new Event;this.loaded=new Event;this.error=new Event;e&©(this,e);this.sortDescriptions.collectionChanged.addHandler(()=>{this.sortOnServer&&this._getData()});this._getData()}get fields(){return this._fields}set fields(e){if(this._fields!=e){this._fields=asArray(e);this._getData()}}get sortOnServer(){return this._sortOnServer}set sortOnServer(e){if(e!=this._sortOnServer){this._sortOnServer=asBoolean(e);this._getData()}}get pageOnServer(){return this._pageOnServer}set pageOnServer(e){if(e!=this._pageOnServer){this._pageOnServer=asBoolean(e);this._getData()}}get filterOnServer(){return this._filterOnServer}set filterOnServer(e){if(e!=this._filterOnServer){this._filterOnServer=asBoolean(e);this._getData()}}get requestHeaders(){return this._requestHeaders}set requestHeaders(e){this._requestHeaders=e}updateFilterDefinition(e){if(this.filterOnServer){this._filterProvider=e;this._getData()}}get isLoading(){return this._loading}onLoading(e){this.loading.raise(this,e)}onLoaded(e){this.loaded.raise(this,e)}load(){this._getData()}onError(e){this.error.raise(this,e);return!e.cancel}_performRefresh(){let e=this._canFilter,t=this._canSort;this._canFilter=!this._filterOnServer;this._canSort=!this._sortOnServer;super._performRefresh();this._canFilter=e;this._canSort=t}get totalItemCount(){return this.pageOnServer?this._totalItemCount:this._view.length}get pageCount(){return this.pageSize?Math.ceil(this.totalItemCount/this.pageSize):1}get pageSize(){return this._pgSz}set pageSize(e){if(e!=this._pgSz){this._pgSz=asInt(e);if(this.pageOnServer){this._pgIdx=clamp(this._pgIdx,0,this.pageCount-1);this._getData()}else this.refresh()}}onPageChanging(e){super.onPageChanging(e);this.pageOnServer&&!e.cancel&&this._getData();return!e.cancel}commitNew(){let e=this.currentAddItem;if(e)try{let t=this.addItem(e);t&&t.then&&t.then(()=>this.refresh())}catch(e){this._raiseError(e,!0)}super.commitNew()}commitEdit(){let e=this.currentEditItem;if(e&&!this.currentAddItem&&!this._sameContent(e,this._edtClone)&&this.items.indexOf(e)>-1)try{let t=this.patchItem(e);t&&t.then&&t.then(()=>this.refresh())}catch(e){this._raiseError(e,!0)}super.commitEdit()}remove(e){if(e&&e!=this.currentAddItem&&this.items.indexOf(e)>-1)try{let t=this.deleteItem(e);t&&t.then&&t.then(()=>this.refresh())}catch(e){this._raiseError(e,!0)}super.remove(e)}_getPageView(){return this.pageOnServer?this._view:super._getPageView()}_getData(){this._toGetData&&clearTimeout(this._toGetData);this._toGetData=setTimeout(()=>__awaiter(this,void 0,void 0,(function*(){this._toGetData=null;this._loading=!0;this.onLoading();let e=null,t=null;try{let t=this.currentPosition;e=yield this.getItems();this.sourceCollection=e;this.refresh();t>-1&&this.moveCurrentToPosition(t);this.pageIndex>0&&this.pageIndex>=this.pageCount&&this.moveToLastPage()}catch(e){t=e}this._loading=!1;this.onLoaded();t&&this._raiseError(t,!1)})),100)}_raiseError(e,t){if(this.onError(new RESTErrorEventArgs(e))){t&&this._getData();throw"Server Error: "+e}}getItems(){throw"This method is virtual: it should be overridden"}addItem(e){throw"This method is virtual: it should be overridden"}patchItem(e){throw"This method is virtual: it should be overridden"}deleteItem(e){throw"This method is virtual: it should be overridden"}}export class RESTErrorEventArgs extends CancelEventArgs{constructor(e){super();this._error=e}get error(){return this._error}}_registerModule("wijmo.rest",selfModule);
|
14
|
+
var __awaiter=this&&this.__awaiter||function(t,e,i,s){return new(i||(i=Promise))((function(r,o){function fulfilled(t){try{step(s.next(t))}catch(t){o(t)}}function rejected(t){try{step(s.throw(t))}catch(t){o(t)}}function step(t){t.done?r(t.value):new i((function(e){e(t.value)})).then(fulfilled,rejected)}step((s=s.apply(t,e||[])).next())}))};import{asArray,asBoolean,asInt,copy,clamp,CollectionView,Event,CancelEventArgs,assert,isString,getAggregate,_NullValue,Aggregate,_registerModule}from"@mescius/wijmo";import*as selfModule from"@mescius/wijmo.rest";const _MIN_DATA_WINDOW=100;export class RestCollectionView extends CollectionView{constructor(t){super();this._loading=!1;this._fields=null;this._keys=null;this._sortOnServer=!0;this._pageOnServer=!0;this._filterOnServer=!0;this._totalItemCount=0;this._aggregates="";this._groupOnServer=!0;this._groupLazyLoading=!1;this._virtualization=!1;this._start=0;this._end=_MIN_DATA_WINDOW;this._expandedGroups=[];this._groupItems=[];this._groupRefresh=!1;this._refresh=!1;this.loading=new Event;this.loaded=new Event;this.error=new Event;t&©(this,t);this.sortDescriptions.collectionChanged.addHandler(()=>{this.sortOnServer&&this._getData()});this._getData();(this._groupOnServer||this._virtualization)&&(this._data=[]);this._virtualization&&this.setWindow(this._start,_MIN_DATA_WINDOW);this._firstLoad=this._groupRefresh=!0}get totalGroupItemCount(){return this.groupOnServer?this._totalGroupItemCount:0}get groupOnServer(){return this._groupOnServer}set groupOnServer(t){if(t!=this._groupOnServer){this._groupOnServer=asBoolean(t);this._getData()}}get groupLazyLoading(){return this._groupLazyLoading}set groupLazyLoading(t){t!=this._groupLazyLoading&&this._groupOnServer&&(this._groupLazyLoading=asBoolean(t))}get virtualization(){return this._virtualization}set virtualization(t){t!=this.virtualization&&(this._virtualization=asBoolean(t))}get fields(){return this._fields}set fields(t){if(this._fields!=t){this._fields=asArray(t);this._getData()}}get sortOnServer(){return this._sortOnServer}set sortOnServer(t){if(t!=this._sortOnServer){this._sortOnServer=asBoolean(t);this._getData()}}get pageOnServer(){return this._pageOnServer}set pageOnServer(t){if(t!=this._pageOnServer){this._pageOnServer=asBoolean(t);this._getData()}}get filterOnServer(){return this._filterOnServer}set filterOnServer(t){if(t!=this._filterOnServer){this._filterOnServer=asBoolean(t);this._getData()}}get requestHeaders(){return this._requestHeaders}set requestHeaders(t){this._requestHeaders=t}get aggregates(){return this._aggregates}set aggregates(t){assert(this._groupOnServer,"groupOnServer should be enabled");isString(t)&&t!=this._aggregates&&(this._aggregates=t)}updateFilterDefinition(t){if(this.filterOnServer){this._filterProvider=t;this._getData()}}lazyLoadGroup(t){if(this._groupLazyLoading){t.groups.length>0&&null==t.groups[0].name&&this._getData(t);0==t.groups.length&&t.isBottomLevel&&this._getData(t)}else assert(this._groupLazyLoading,"groupLazyLoading should be enabled lazy load the groups.")}setWindow(t,e){this._toSetWindow&&clearTimeout(this._toSetWindow);this._toSetWindow=setTimeout(()=>{this._toSetWindow=null;this._performSetWindow(t,e)},50)}_getFilterGroupItems(t){let e=this._groupItems,i=t.items[0];for(let s=0;s<=t.level;s++){let t=this.groupDescriptions[s].propertyName;e=e.filter(e=>e.groupKey[t]==i[t])}return e}getGroupAggregate(t,e,i=Aggregate.Sum){if(this.groupLazyLoading||this.virtualization){let s="",r=this._getFilterGroupItems(e);r&&0!=r.length&&r.length!=this._groupItems.length&&r[0].aggregates&&(s=getAggregate(i,r,`aggregates.${t}`));return s}}get isLoading(){return this._loading}onLoading(t){this.loading.raise(this,t)}onLoaded(t){this.loaded.raise(this,t)}load(){this._getData()}onError(t){this.error.raise(this,t);return!t.cancel}_performRefresh(){this.isLoading||(this._refresh=!0);let t=this._canFilter,e=this._canSort;this._canFilter=!this._filterOnServer;this._canSort=!this._sortOnServer;super._performRefresh();this._canFilter=t;this._canSort=e}get totalItemCount(){return this.pageOnServer?this._totalItemCount:this._view.length}get pageCount(){return this.pageSize?Math.ceil(this.totalItemCount/this.pageSize):1}get pageSize(){return this._pgSz}set pageSize(t){if(t!=this._pgSz){this._pgSz=asInt(t);if(this.pageOnServer){this._pgIdx=clamp(this._pgIdx,0,this.pageCount-1);this._getData()}else this.refresh()}}onPageChanging(t){super.onPageChanging(t);this.pageOnServer&&!t.cancel&&this._getData();return!t.cancel}commitNew(){let t=this.currentAddItem;if(t)try{let e=this.addItem(t);e&&e.then&&e.then(()=>this.refresh())}catch(t){this._raiseError(t,!0)}super.commitNew()}commitEdit(){let t=this.currentEditItem;if(t&&!this.currentAddItem&&!this._sameContent(t,this._edtClone)&&this.items.indexOf(t)>-1)try{let e=this.patchItem(t);e&&e.then&&e.then(()=>this.refresh())}catch(t){this._raiseError(t,!0)}super.commitEdit()}remove(t){if(t&&t!=this.currentAddItem&&this.items.indexOf(t)>-1)try{let e=this.deleteItem(t);e&&e.then&&e.then(()=>this.refresh())}catch(t){this._raiseError(t,!0)}super.remove(t)}_getPageView(){return this.pageOnServer?this._view:super._getPageView()}_getData(t){this._toGetData&&clearTimeout(this._toGetData);this._toGetData=setTimeout(()=>__awaiter(this,void 0,void 0,(function*(){this._toGetData=null;this._loading=!0;this.onLoading();let e=null;if(this._groupOnServer||this._virtualization){let e=-1;this.currentPosition>-1&&(e=this.currentPosition);let i=this.groupDescriptions;this._data||(this._data=[]);let s,r=[];if((this._groupRefresh||this._groupLazyLoading&&(!t||!t.isBottomLevel))&&this._groupOnServer&&i.length>0){r=yield this.getGroupItems(t);t?this._updateSubGroups(t,r):this._groupItems=r;this._groupRefresh=!1}this._groupLazyLoading||(s=yield this.getItems());this._groupLazyLoading&&t&&t.isBottomLevel&&(s=yield this.getItems(t));this.deferUpdate(()=>__awaiter(this,void 0,void 0,(function*(){this._virtualization||this._groupLazyLoading||(this._data=s);if(this._groupLazyLoading&&!this._virtualization)if(t)this._loadSubGroupsData(t,r,s);else{this._data=new Array;const e=i[0].propertyName;for(let t=0;t<r.length;t++){let i=new Object,s=r[t].count;i[e]=r[t].groupKey[e];for(let t=0;t<s;t++)this._data.push(i)}this._expandedGroups.length>0&&(yield this._loadExpandedGroups(t))}this._virtualization&&!this._groupLazyLoading&&this._storeItems(s,!1);this.sourceCollection=this._data})));this.refresh();e>-1&&this.moveCurrentToPosition(e)}else{let t=null;try{let e=this.currentPosition;t=yield this.getItems();this.sourceCollection=t;this.refresh();e>-1&&this.moveCurrentToPosition(e);this.pageIndex>0&&this.pageIndex>=this.pageCount&&this.moveToLastPage()}catch(t){e=t}}this._loading=!1;this.onLoaded();e&&this._raiseError(e,!1)})),100)}_loadExpandedGroups(t){return __awaiter(this,void 0,void 0,(function*(){if(this._expandedGroups.length>0&&!t){let t=[];this._expandedGroups.forEach(e=>__awaiter(this,void 0,void 0,(function*(){e.isBottomLevel?t.push(this.getItems(e)):t.push(this.getGroupItems(e))})));return new Promise(e=>{Promise.all(t).then(t=>{for(let e=0;e<this._expandedGroups.length;e++)if(this._expandedGroups[e].isBottomLevel)this._loadSubGroupsData(this._expandedGroups[e],[],t[e]);else{this._updateSubGroups(this._expandedGroups[e],t[e]);this._loadSubGroupsData(this._expandedGroups[e],t[e],[])}e(!0)}).catch(t=>{e(!1)})})}}))}_updateSubGroups(t,e){let i=this._getFilterGroupItems(t);if(1==i.length){for(let t=0;t<e.length;t++)e[t].groupKey=Object.assign({},i[0].groupKey,e[t].groupKey);let t=this._groupItems.indexOf(i[0]);this._groupItems.splice(t,1,...e)}else console.error("unable to find exact match for targetted group")}_loadSubGroupsData(t,e,i){let s=this.groupDescriptions,r=this._data;for(let e=0;e<=(t.isBottomLevel?s.length-1:t.level);e++){const i=s[e].propertyName,o=t.items[e][i];r=r.filter(t=>t[i]===o)}let o=this._data.indexOf(r[0]);r=JSON.parse(JSON.stringify(r));if(t.isBottomLevel)for(let t=0;t<i.length;t++)Object.assign(r[t],i[t]);else{let i=t.groups[0].groupDescription.propertyName,s=0;for(let t=0;t<e.length;t++){s+=t>0?e[t-1].count:0;for(let o=0;o<e[t].count;o++)r[s+o][i]=e[t].groupKey[i]}}this._data.splice(o,r.length,...r)}_updateExpandedGroups(t,e){if(!this._loading){let i=this._expandedGroups.filter(e=>e._path.indexOf(t._path)>-1);if(e)this._expandedGroups.push(t);else if(i.length>0)for(let t=0;t<i.length;t++)this._expandedGroups.splice(this._expandedGroups.indexOf(i[t]),1)}}_storeItems(t,e){return __awaiter(this,void 0,void 0,(function*(){if(this._refresh||this._data.length!=this.totalItemCount||this.groups&&this.groups.length!=this._totalGroupItemCount){if(this._data.length!=this.totalItemCount&&this.groups&&this.groups.length>0){this._groupRefresh=!0;this._getData()}this._data.length=this.totalItemCount;if(this._groupOnServer&&this._groupItems.length>0&&this.groupDescriptions.length>0){let t=JSON.parse(JSON.stringify(this.groups)),e=0;for(let t=0;t<this._groupItems.length;t++){let i=Object.keys(this._groupItems[t].groupKey);for(let s=0;s<this._groupItems[t].count;s++){let s=new _NullValue(e);i.forEach(e=>{s[e]=this._groupItems[t].groupKey[e]});this._data[e]=s;e++}}if(0!=this.groups.length&&this.groups.length<t.length){let e=this._data[this._start],i=this.groupDescriptions.length,s=this.groupDescriptions[i-1].propertyName,r=this.groups.findIndex(t=>t.name==e[s]),o=t.findIndex(t=>t.name==e[s]);this._start+=r-o;this._getData()}}else for(let t=0;t<this._data.length;t++)this._data[t]=new _NullValue(t);this._refresh=!1}e||(this._loadOffset=0);let i=this._loadOffset+(this._start||0);for(let e=0;e<t.length;e++)this._data[e+i]=t[e];this._loadOffset+=t.length;setTimeout(()=>{this._firstLoad&&this.currentPosition<0&&t.length&&this.moveCurrentToFirst();this._firstLoad=!1})}))}_performSetWindow(t,e){if(this._pendingRequest){this._pendingRequest.abort();this._pendingRequest=null;this.onRequestCanceled()}t=asInt(t);e=asInt(e);assert(t<=e,"start must be <= end.");let i=t<this._start,s=this._data;this._start=this._end=t;for(let i=t;i<=e&&i<s.length;i++)if(s[i]instanceof _NullValue){this._start=i;break}for(let t=e;t>=this._start&&t<s.length;t--)if(s[t]instanceof _NullValue){this._end=t;break}if(this._start!=this._end||s[this._start]instanceof _NullValue){i&&(this._start=Math.max(0,this._end-this._fetchSize()+1));this._getData()}}_fetchSize(){return Math.max(this._end-this._start+1,this.pageSize,_MIN_DATA_WINDOW)}_raiseError(t,e){if(this.onError(new RESTErrorEventArgs(t))){e&&this._getData();throw"Server Error: "+t}}get requestCanceled(){this._requestCanceled||(this._requestCanceled=new Event);return this._requestCanceled}onRequestCanceled(t){this.requestCanceled.raise(this,t)}getGroupItems(t){throw"This method is virtual: it should be overridden"}getItems(t){throw"This method is virtual: it should be overridden"}addItem(t){throw"This method is virtual: it should be overridden"}patchItem(t){throw"This method is virtual: it should be overridden"}deleteItem(t){throw"This method is virtual: it should be overridden"}}export class RESTErrorEventArgs extends CancelEventArgs{constructor(t){super();this._error=t}get error(){return this._error}}_registerModule("wijmo.rest",selfModule);
|
package/es5-esm.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
*
|
3
|
-
* Wijmo Library 5.20242.20-nightly.d20240814.
|
3
|
+
* Wijmo Library 5.20242.20-nightly.d20240814.t111510
|
4
4
|
* https://developer.mescius.com/wijmo
|
5
5
|
*
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
@@ -11,4 +11,4 @@
|
|
11
11
|
*
|
12
12
|
*/
|
13
13
|
|
14
|
-
var __extends=this&&this.__extends||function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};return function(e,t){extendStatics(e,t);function __(){this.constructor=e}e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}(),__awaiter=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(i,n){function fulfilled(e){try{step(o.next(e))}catch(e){n(e)}}function rejected(e){try{step(o.throw(e))}catch(e){n(e)}}function step(e){e.done?i(e.value):new r((function(t){t(e.value)})).then(fulfilled,rejected)}step((o=o.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,o,i,n,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return n={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function verb(n){return function(a){return function step(n){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,o&&(i=2&n[0]?o.return:n[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,n[1])).done)return i;(o=0,i)&&(n=[2&n[0],i.value]);switch(n[0]){case 0:case 1:i=n;break;case 4:s.label++;return{value:n[1],done:!1};case 5:s.label++;o=n[1];n=[0];continue;case 7:n=s.ops.pop();s.trys.pop();continue;default:if(!(i=s.trys,i=i.length>0&&i[i.length-1])&&(6===n[0]||2===n[0])){s=0;continue}if(3===n[0]&&(!i||n[1]>i[0]&&n[1]<i[3])){s.label=n[1];break}if(6===n[0]&&s.label<i[1]){s.label=i[1];i=n;break}if(i&&s.label<i[2]){s.label=i[2];s.ops.push(n);break}i[2]&&s.ops.pop();s.trys.pop();continue}n=t.call(e,s)}catch(e){n=[6,e];o=0}finally{r=i=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,a])}}};import{asArray,asBoolean,asInt,copy,clamp,CollectionView,Event,CancelEventArgs,_registerModule}from"@mescius/wijmo";import*as selfModule from"@mescius/wijmo.rest";var RestCollectionView=function(e){__extends(RestCollectionView,e);function RestCollectionView(t){var r=e.call(this)||this;r._loading=!1;r._fields=null;r._keys=null;r._sortOnServer=!0;r._pageOnServer=!0;r._filterOnServer=!0;r._totalItemCount=0;r.loading=new Event;r.loaded=new Event;r.error=new Event;t&©(r,t);r.sortDescriptions.collectionChanged.addHandler((function(){r.sortOnServer&&r._getData()}));r._getData();return r}Object.defineProperty(RestCollectionView.prototype,"fields",{get:function(){return this._fields},set:function(e){if(this._fields!=e){this._fields=asArray(e);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"sortOnServer",{get:function(){return this._sortOnServer},set:function(e){if(e!=this._sortOnServer){this._sortOnServer=asBoolean(e);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"pageOnServer",{get:function(){return this._pageOnServer},set:function(e){if(e!=this._pageOnServer){this._pageOnServer=asBoolean(e);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"filterOnServer",{get:function(){return this._filterOnServer},set:function(e){if(e!=this._filterOnServer){this._filterOnServer=asBoolean(e);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"requestHeaders",{get:function(){return this._requestHeaders},set:function(e){this._requestHeaders=e},enumerable:!0,configurable:!0});RestCollectionView.prototype.updateFilterDefinition=function(e){if(this.filterOnServer){this._filterProvider=e;this._getData()}};Object.defineProperty(RestCollectionView.prototype,"isLoading",{get:function(){return this._loading},enumerable:!0,configurable:!0});RestCollectionView.prototype.onLoading=function(e){this.loading.raise(this,e)};RestCollectionView.prototype.onLoaded=function(e){this.loaded.raise(this,e)};RestCollectionView.prototype.load=function(){this._getData()};RestCollectionView.prototype.onError=function(e){this.error.raise(this,e);return!e.cancel};RestCollectionView.prototype._performRefresh=function(){var t=this._canFilter,r=this._canSort;this._canFilter=!this._filterOnServer;this._canSort=!this._sortOnServer;e.prototype._performRefresh.call(this);this._canFilter=t;this._canSort=r};Object.defineProperty(RestCollectionView.prototype,"totalItemCount",{get:function(){return this.pageOnServer?this._totalItemCount:this._view.length},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"pageCount",{get:function(){return this.pageSize?Math.ceil(this.totalItemCount/this.pageSize):1},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"pageSize",{get:function(){return this._pgSz},set:function(e){if(e!=this._pgSz){this._pgSz=asInt(e);if(this.pageOnServer){this._pgIdx=clamp(this._pgIdx,0,this.pageCount-1);this._getData()}else this.refresh()}},enumerable:!0,configurable:!0});RestCollectionView.prototype.onPageChanging=function(t){e.prototype.onPageChanging.call(this,t);this.pageOnServer&&!t.cancel&&this._getData();return!t.cancel};RestCollectionView.prototype.commitNew=function(){var t=this,r=this.currentAddItem;if(r)try{var o=this.addItem(r);o&&o.then&&o.then((function(){return t.refresh()}))}catch(e){this._raiseError(e,!0)}e.prototype.commitNew.call(this)};RestCollectionView.prototype.commitEdit=function(){var t=this,r=this.currentEditItem;if(r&&!this.currentAddItem&&!this._sameContent(r,this._edtClone)&&this.items.indexOf(r)>-1)try{var o=this.patchItem(r);o&&o.then&&o.then((function(){return t.refresh()}))}catch(e){this._raiseError(e,!0)}e.prototype.commitEdit.call(this)};RestCollectionView.prototype.remove=function(t){var r=this;if(t&&t!=this.currentAddItem&&this.items.indexOf(t)>-1)try{var o=this.deleteItem(t);o&&o.then&&o.then((function(){return r.refresh()}))}catch(e){this._raiseError(e,!0)}e.prototype.remove.call(this,t)};RestCollectionView.prototype._getPageView=function(){return this.pageOnServer?this._view:e.prototype._getPageView.call(this)};RestCollectionView.prototype._getData=function(){var e=this;this._toGetData&&clearTimeout(this._toGetData);this._toGetData=setTimeout((function(){return __awaiter(e,void 0,void 0,(function(){var e,t,r,o;return __generator(this,(function(i){switch(i.label){case 0:this._toGetData=null;this._loading=!0;this.onLoading();e=null;t=null;i.label=1;case 1:i.trys.push([1,3,,4]);r=this.currentPosition;return[4,this.getItems()];case 2:e=i.sent();this.sourceCollection=e;this.refresh();r>-1&&this.moveCurrentToPosition(r);this.pageIndex>0&&this.pageIndex>=this.pageCount&&this.moveToLastPage();return[3,4];case 3:o=i.sent();t=o;return[3,4];case 4:this._loading=!1;this.onLoaded();t&&this._raiseError(t,!1);return[2]}}))}))}),100)};RestCollectionView.prototype._raiseError=function(e,t){if(this.onError(new RESTErrorEventArgs(e))){t&&this._getData();throw"Server Error: "+e}};RestCollectionView.prototype.getItems=function(){throw"This method is virtual: it should be overridden"};RestCollectionView.prototype.addItem=function(e){throw"This method is virtual: it should be overridden"};RestCollectionView.prototype.patchItem=function(e){throw"This method is virtual: it should be overridden"};RestCollectionView.prototype.deleteItem=function(e){throw"This method is virtual: it should be overridden"};return RestCollectionView}(CollectionView);export{RestCollectionView};var RESTErrorEventArgs=function(e){__extends(RESTErrorEventArgs,e);function RESTErrorEventArgs(t){var r=e.call(this)||this;r._error=t;return r}Object.defineProperty(RESTErrorEventArgs.prototype,"error",{get:function(){return this._error},enumerable:!0,configurable:!0});return RESTErrorEventArgs}(CancelEventArgs);export{RESTErrorEventArgs};_registerModule("wijmo.rest",selfModule);
|
14
|
+
var __extends=this&&this.__extends||function(){var extendStatics=function(t,e){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};return function(t,e){extendStatics(t,e);function __(){this.constructor=t}t.prototype=null===e?Object.create(e):(__.prototype=e.prototype,new __)}}(),__assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(o,n){function fulfilled(t){try{step(i.next(t))}catch(t){n(t)}}function rejected(t){try{step(i.throw(t))}catch(t){n(t)}}function step(t){t.done?o(t.value):new r((function(e){e(t.value)})).then(fulfilled,rejected)}step((i=i.apply(t,e||[])).next())}))},__generator=this&&this.__generator||function(t,e){var r,i,o,n,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return n={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function verb(n){return function(a){return function step(n){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(o=2&n[0]?i.return:n[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,n[1])).done)return o;(i=0,o)&&(n=[2&n[0],o.value]);switch(n[0]){case 0:case 1:o=n;break;case 4:s.label++;return{value:n[1],done:!1};case 5:s.label++;i=n[1];n=[0];continue;case 7:n=s.ops.pop();s.trys.pop();continue;default:if(!(o=s.trys,o=o.length>0&&o[o.length-1])&&(6===n[0]||2===n[0])){s=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]<o[3])){s.label=n[1];break}if(6===n[0]&&s.label<o[1]){s.label=o[1];o=n;break}if(o&&s.label<o[2]){s.label=o[2];s.ops.push(n);break}o[2]&&s.ops.pop();s.trys.pop();continue}n=e.call(t,s)}catch(t){n=[6,t];i=0}finally{r=o=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,a])}}};import{asArray,asBoolean,asInt,copy,clamp,CollectionView,Event,CancelEventArgs,assert,isString,getAggregate,_NullValue,Aggregate,_registerModule}from"@mescius/wijmo";import*as selfModule from"@mescius/wijmo.rest";var _MIN_DATA_WINDOW=100,RestCollectionView=function(t){__extends(RestCollectionView,t);function RestCollectionView(e){var r=t.call(this)||this;r._loading=!1;r._fields=null;r._keys=null;r._sortOnServer=!0;r._pageOnServer=!0;r._filterOnServer=!0;r._totalItemCount=0;r._aggregates="";r._groupOnServer=!0;r._groupLazyLoading=!1;r._virtualization=!1;r._start=0;r._end=_MIN_DATA_WINDOW;r._expandedGroups=[];r._groupItems=[];r._groupRefresh=!1;r._refresh=!1;r.loading=new Event;r.loaded=new Event;r.error=new Event;e&©(r,e);r.sortDescriptions.collectionChanged.addHandler((function(){r.sortOnServer&&r._getData()}));r._getData();(r._groupOnServer||r._virtualization)&&(r._data=[]);r._virtualization&&r.setWindow(r._start,_MIN_DATA_WINDOW);r._firstLoad=r._groupRefresh=!0;return r}Object.defineProperty(RestCollectionView.prototype,"totalGroupItemCount",{get:function(){return this.groupOnServer?this._totalGroupItemCount:0},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"groupOnServer",{get:function(){return this._groupOnServer},set:function(t){if(t!=this._groupOnServer){this._groupOnServer=asBoolean(t);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"groupLazyLoading",{get:function(){return this._groupLazyLoading},set:function(t){t!=this._groupLazyLoading&&this._groupOnServer&&(this._groupLazyLoading=asBoolean(t))},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"virtualization",{get:function(){return this._virtualization},set:function(t){t!=this.virtualization&&(this._virtualization=asBoolean(t))},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"fields",{get:function(){return this._fields},set:function(t){if(this._fields!=t){this._fields=asArray(t);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"sortOnServer",{get:function(){return this._sortOnServer},set:function(t){if(t!=this._sortOnServer){this._sortOnServer=asBoolean(t);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"pageOnServer",{get:function(){return this._pageOnServer},set:function(t){if(t!=this._pageOnServer){this._pageOnServer=asBoolean(t);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"filterOnServer",{get:function(){return this._filterOnServer},set:function(t){if(t!=this._filterOnServer){this._filterOnServer=asBoolean(t);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"requestHeaders",{get:function(){return this._requestHeaders},set:function(t){this._requestHeaders=t},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"aggregates",{get:function(){return this._aggregates},set:function(t){assert(this._groupOnServer,"groupOnServer should be enabled");isString(t)&&t!=this._aggregates&&(this._aggregates=t)},enumerable:!0,configurable:!0});RestCollectionView.prototype.updateFilterDefinition=function(t){if(this.filterOnServer){this._filterProvider=t;this._getData()}};RestCollectionView.prototype.lazyLoadGroup=function(t){if(this._groupLazyLoading){t.groups.length>0&&null==t.groups[0].name&&this._getData(t);0==t.groups.length&&t.isBottomLevel&&this._getData(t)}else assert(this._groupLazyLoading,"groupLazyLoading should be enabled lazy load the groups.")};RestCollectionView.prototype.setWindow=function(t,e){var r=this;this._toSetWindow&&clearTimeout(this._toSetWindow);this._toSetWindow=setTimeout((function(){r._toSetWindow=null;r._performSetWindow(t,e)}),50)};RestCollectionView.prototype._getFilterGroupItems=function(t){for(var e=this._groupItems,r=t.items[0],_loop_1=function(t){var o=i.groupDescriptions[t].propertyName;e=e.filter((function(t){return t.groupKey[o]==r[o]}))},i=this,o=0;o<=t.level;o++)_loop_1(o);return e};RestCollectionView.prototype.getGroupAggregate=function(t,e,r){void 0===r&&(r=Aggregate.Sum);if(this.groupLazyLoading||this.virtualization){var i="",o=this._getFilterGroupItems(e);o&&0!=o.length&&o.length!=this._groupItems.length&&o[0].aggregates&&(i=getAggregate(r,o,"aggregates."+t));return i}};Object.defineProperty(RestCollectionView.prototype,"isLoading",{get:function(){return this._loading},enumerable:!0,configurable:!0});RestCollectionView.prototype.onLoading=function(t){this.loading.raise(this,t)};RestCollectionView.prototype.onLoaded=function(t){this.loaded.raise(this,t)};RestCollectionView.prototype.load=function(){this._getData()};RestCollectionView.prototype.onError=function(t){this.error.raise(this,t);return!t.cancel};RestCollectionView.prototype._performRefresh=function(){this.isLoading||(this._refresh=!0);var e=this._canFilter,r=this._canSort;this._canFilter=!this._filterOnServer;this._canSort=!this._sortOnServer;t.prototype._performRefresh.call(this);this._canFilter=e;this._canSort=r};Object.defineProperty(RestCollectionView.prototype,"totalItemCount",{get:function(){return this.pageOnServer?this._totalItemCount:this._view.length},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"pageCount",{get:function(){return this.pageSize?Math.ceil(this.totalItemCount/this.pageSize):1},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"pageSize",{get:function(){return this._pgSz},set:function(t){if(t!=this._pgSz){this._pgSz=asInt(t);if(this.pageOnServer){this._pgIdx=clamp(this._pgIdx,0,this.pageCount-1);this._getData()}else this.refresh()}},enumerable:!0,configurable:!0});RestCollectionView.prototype.onPageChanging=function(e){t.prototype.onPageChanging.call(this,e);this.pageOnServer&&!e.cancel&&this._getData();return!e.cancel};RestCollectionView.prototype.commitNew=function(){var e=this,r=this.currentAddItem;if(r)try{var i=this.addItem(r);i&&i.then&&i.then((function(){return e.refresh()}))}catch(t){this._raiseError(t,!0)}t.prototype.commitNew.call(this)};RestCollectionView.prototype.commitEdit=function(){var e=this,r=this.currentEditItem;if(r&&!this.currentAddItem&&!this._sameContent(r,this._edtClone)&&this.items.indexOf(r)>-1)try{var i=this.patchItem(r);i&&i.then&&i.then((function(){return e.refresh()}))}catch(t){this._raiseError(t,!0)}t.prototype.commitEdit.call(this)};RestCollectionView.prototype.remove=function(e){var r=this;if(e&&e!=this.currentAddItem&&this.items.indexOf(e)>-1)try{var i=this.deleteItem(e);i&&i.then&&i.then((function(){return r.refresh()}))}catch(t){this._raiseError(t,!0)}t.prototype.remove.call(this,e)};RestCollectionView.prototype._getPageView=function(){return this.pageOnServer?this._view:t.prototype._getPageView.call(this)};RestCollectionView.prototype._getData=function(t){var e=this;this._toGetData&&clearTimeout(this._toGetData);this._toGetData=setTimeout((function(){return __awaiter(e,void 0,void 0,(function(){var e,r,i,o,n,s,a,u=this;return __generator(this,(function(l){switch(l.label){case 0:this._toGetData=null;this._loading=!0;this.onLoading();e=null;if(this._groupOnServer||this._virtualization)return[3,5];r=null;l.label=1;case 1:l.trys.push([1,3,,4]);o=this.currentPosition;return[4,this.getItems()];case 2:r=l.sent();this.sourceCollection=r;this.refresh();o>-1&&this.moveCurrentToPosition(o);this.pageIndex>0&&this.pageIndex>=this.pageCount&&this.moveToLastPage();return[3,4];case 3:i=l.sent();e=i;return[3,4];case 4:return[3,12];case 5:o=-1;this.currentPosition>-1&&(o=this.currentPosition);n=this.groupDescriptions;this._data||(this._data=[]);s=[];return(this._groupRefresh||!(!this._groupLazyLoading||t&&t.isBottomLevel))&&this._groupOnServer&&n.length>0?[4,this.getGroupItems(t)]:[3,7];case 6:s=l.sent();t?this._updateSubGroups(t,s):this._groupItems=s;this._groupRefresh=!1;l.label=7;case 7:return this._groupLazyLoading?[3,9]:[4,this.getItems()];case 8:a=l.sent();l.label=9;case 9:return this._groupLazyLoading&&t&&t.isBottomLevel?[4,this.getItems(t)]:[3,11];case 10:a=l.sent();l.label=11;case 11:this.deferUpdate((function(){return __awaiter(u,void 0,void 0,(function(){var e,r,i,o,u;return __generator(this,(function(l){switch(l.label){case 0:this._virtualization||this._groupLazyLoading||(this._data=a);if(!this._groupLazyLoading||this._virtualization)return[3,4];if(t)return[3,3];this._data=new Array;e=n[0].propertyName;for(r=0;r<s.length;r++){i=new Object,o=s[r].count;i[e]=s[r].groupKey[e];for(u=0;u<o;u++)this._data.push(i)}return this._expandedGroups.length>0?[4,this._loadExpandedGroups(t)]:[3,2];case 1:l.sent();l.label=2;case 2:return[3,4];case 3:this._loadSubGroupsData(t,s,a);l.label=4;case 4:this._virtualization&&!this._groupLazyLoading&&this._storeItems(a,!1);this.sourceCollection=this._data;return[2]}}))}))}));this.refresh();o>-1&&this.moveCurrentToPosition(o);l.label=12;case 12:this._loading=!1;this.onLoaded();e&&this._raiseError(e,!1);return[2]}}))}))}),100)};RestCollectionView.prototype._loadExpandedGroups=function(t){return __awaiter(this,void 0,void 0,(function(){var e,r=this;return __generator(this,(function(i){if(this._expandedGroups.length>0&&!t){e=[];this._expandedGroups.forEach((function(t){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(r){t.isBottomLevel?e.push(this.getItems(t)):e.push(this.getGroupItems(t));return[2]}))}))}));return[2,new Promise((function(t){Promise.all(e).then((function(e){for(var i=0;i<r._expandedGroups.length;i++)if(r._expandedGroups[i].isBottomLevel)r._loadSubGroupsData(r._expandedGroups[i],[],e[i]);else{r._updateSubGroups(r._expandedGroups[i],e[i]);r._loadSubGroupsData(r._expandedGroups[i],e[i],[])}t(!0)})).catch((function(e){t(!1)}))}))]}return[2]}))}))};RestCollectionView.prototype._updateSubGroups=function(t,e){var r,i=this._getFilterGroupItems(t);if(1==i.length){for(var o=0;o<e.length;o++)e[o].groupKey=__assign({},i[0].groupKey,e[o].groupKey);var n=this._groupItems.indexOf(i[0]);(r=this._groupItems).splice.apply(r,[n,1].concat(e))}else console.error("unable to find exact match for targetted group")};RestCollectionView.prototype._loadSubGroupsData=function(t,e,r){for(var i,o=this.groupDescriptions,n=this._data,_loop_2=function(e){var r=o[e].propertyName,i=t.items[e][r];n=n.filter((function(t){return t[r]===i}))},s=0;s<=(t.isBottomLevel?o.length-1:t.level);s++)_loop_2(s);var a=this._data.indexOf(n[0]);n=JSON.parse(JSON.stringify(n));if(t.isBottomLevel)for(s=0;s<r.length;s++)Object.assign(n[s],r[s]);else for(var u=t.groups[0].groupDescription.propertyName,l=0,s=0;s<e.length;s++){l+=s>0?e[s-1].count:0;for(var h=0;h<e[s].count;h++)n[l+h][u]=e[s].groupKey[u]}(i=this._data).splice.apply(i,[a,n.length].concat(n))};RestCollectionView.prototype._updateExpandedGroups=function(t,e){if(!this._loading){var r=this._expandedGroups.filter((function(e){return e._path.indexOf(t._path)>-1}));if(e)this._expandedGroups.push(t);else if(r.length>0)for(var i=0;i<r.length;i++)this._expandedGroups.splice(this._expandedGroups.indexOf(r[i]),1)}};RestCollectionView.prototype._storeItems=function(t,e){return __awaiter(this,void 0,void 0,(function(){var r,i,o,n,s,a,u,l,h,p,c,g=this;return __generator(this,(function(_){if(this._refresh||this._data.length!=this.totalItemCount||this.groups&&this.groups.length!=this._totalGroupItemCount){if(this._data.length!=this.totalItemCount&&this.groups&&this.groups.length>0){this._groupRefresh=!0;this._getData()}this._data.length=this.totalItemCount;if(this._groupOnServer&&this._groupItems.length>0&&this.groupDescriptions.length>0){r=JSON.parse(JSON.stringify(this.groups));i=0;o=function(t){for(var e=Object.keys(n._groupItems[t].groupKey),_loop_4=function(r){var o=new _NullValue(i);e.forEach((function(e){o[e]=g._groupItems[t].groupKey[e]}));n._data[i]=o;i++},r=0;r<n._groupItems[t].count;r++)_loop_4()};n=this;for(c=0;c<this._groupItems.length;c++)o(c);if(0!=this.groups.length&&this.groups.length<r.length){s=this._data[this._start];a=this.groupDescriptions.length;u=this.groupDescriptions[a-1].propertyName;l=this.groups.findIndex((function(t){return t.name==s[u]}));h=r.findIndex((function(t){return t.name==s[u]}));this._start+=l-h;this._getData()}}else for(c=0;c<this._data.length;c++)this._data[c]=new _NullValue(c);this._refresh=!1}e||(this._loadOffset=0);p=this._loadOffset+(this._start||0);for(c=0;c<t.length;c++)this._data[c+p]=t[c];this._loadOffset+=t.length;setTimeout((function(){g._firstLoad&&g.currentPosition<0&&t.length&&g.moveCurrentToFirst();g._firstLoad=!1}));return[2]}))}))};RestCollectionView.prototype._performSetWindow=function(t,e){if(this._pendingRequest){this._pendingRequest.abort();this._pendingRequest=null;this.onRequestCanceled()}t=asInt(t);e=asInt(e);assert(t<=e,"start must be <= end.");var r=t<this._start,i=this._data;this._start=this._end=t;for(var o=t;o<=e&&o<i.length;o++)if(i[o]instanceof _NullValue){this._start=o;break}for(o=e;o>=this._start&&o<i.length;o--)if(i[o]instanceof _NullValue){this._end=o;break}if(this._start!=this._end||i[this._start]instanceof _NullValue){r&&(this._start=Math.max(0,this._end-this._fetchSize()+1));this._getData()}};RestCollectionView.prototype._fetchSize=function(){return Math.max(this._end-this._start+1,this.pageSize,_MIN_DATA_WINDOW)};RestCollectionView.prototype._raiseError=function(t,e){if(this.onError(new RESTErrorEventArgs(t))){e&&this._getData();throw"Server Error: "+t}};Object.defineProperty(RestCollectionView.prototype,"requestCanceled",{get:function(){this._requestCanceled||(this._requestCanceled=new Event);return this._requestCanceled},enumerable:!0,configurable:!0});RestCollectionView.prototype.onRequestCanceled=function(t){this.requestCanceled.raise(this,t)};RestCollectionView.prototype.getGroupItems=function(t){throw"This method is virtual: it should be overridden"};RestCollectionView.prototype.getItems=function(t){throw"This method is virtual: it should be overridden"};RestCollectionView.prototype.addItem=function(t){throw"This method is virtual: it should be overridden"};RestCollectionView.prototype.patchItem=function(t){throw"This method is virtual: it should be overridden"};RestCollectionView.prototype.deleteItem=function(t){throw"This method is virtual: it should be overridden"};return RestCollectionView}(CollectionView);export{RestCollectionView};var RESTErrorEventArgs=function(t){__extends(RESTErrorEventArgs,t);function RESTErrorEventArgs(e){var r=t.call(this)||this;r._error=e;return r}Object.defineProperty(RESTErrorEventArgs.prototype,"error",{get:function(){return this._error},enumerable:!0,configurable:!0});return RESTErrorEventArgs}(CancelEventArgs);export{RESTErrorEventArgs};_registerModule("wijmo.rest",selfModule);
|
package/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
*
|
3
|
-
* Wijmo Library 5.20242.20-nightly.d20240814.
|
3
|
+
* Wijmo Library 5.20242.20-nightly.d20240814.t111510
|
4
4
|
* https://developer.mescius.com/wijmo
|
5
5
|
*
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
@@ -26,7 +26,7 @@
|
|
26
26
|
*
|
27
27
|
*/
|
28
28
|
export declare var ___keepComment: any;
|
29
|
-
import { CollectionView, Event, EventArgs, CancelEventArgs, PageChangingEventArgs } from '@mescius/wijmo';
|
29
|
+
import { CollectionView, Event, EventArgs, CancelEventArgs, PageChangingEventArgs, CollectionViewGroup, Aggregate } from '@mescius/wijmo';
|
30
30
|
/**
|
31
31
|
* Base class for REST-based CollectionView classes.
|
32
32
|
*
|
@@ -57,6 +57,23 @@ export declare class RestCollectionView extends CollectionView {
|
|
57
57
|
_filterProvider: any;
|
58
58
|
_totalItemCount: number;
|
59
59
|
_requestHeaders: any;
|
60
|
+
_aggregates: string;
|
61
|
+
_groupOnServer: boolean;
|
62
|
+
_groupLazyLoading: boolean;
|
63
|
+
_virtualization: boolean;
|
64
|
+
_totalGroupItemCount: number;
|
65
|
+
_start: number;
|
66
|
+
_end: number;
|
67
|
+
_firstLoad: boolean;
|
68
|
+
_expandedGroups: CollectionViewGroup[];
|
69
|
+
_groupItems: any[];
|
70
|
+
_data: any[];
|
71
|
+
_loadOffset: number;
|
72
|
+
_toSetWindow: any;
|
73
|
+
_pendingRequest: XMLHttpRequest;
|
74
|
+
_groupRefresh: boolean;
|
75
|
+
_refresh: boolean;
|
76
|
+
_requestCanceled: Event<RestCollectionView, EventArgs>;
|
60
77
|
/**
|
61
78
|
* Initializes a new instance of the @see:ServerCollectionViewBase class.
|
62
79
|
*
|
@@ -64,6 +81,24 @@ export declare class RestCollectionView extends CollectionView {
|
|
64
81
|
* values and event handlers) for the @see:ServerCollectionView.
|
65
82
|
*/
|
66
83
|
constructor(options?: any);
|
84
|
+
/**
|
85
|
+
* Gets the total number of group items in the view.
|
86
|
+
*/
|
87
|
+
readonly totalGroupItemCount: number;
|
88
|
+
/**
|
89
|
+
* Gets or sets a value that determines whether grouping should be performed on
|
90
|
+
* the server or on the client.
|
91
|
+
*/
|
92
|
+
groupOnServer: boolean;
|
93
|
+
/**
|
94
|
+
* Gets or Sets a value that detemines whether the group data should be loaded
|
95
|
+
* on demand or at once
|
96
|
+
*/
|
97
|
+
groupLazyLoading: boolean;
|
98
|
+
/**
|
99
|
+
* Gets or Set a value that determines whether the data should be loaded virtually or not
|
100
|
+
*/
|
101
|
+
virtualization: boolean;
|
67
102
|
/**
|
68
103
|
* Gets or sets an array containing the names of the fields to retrieve from
|
69
104
|
* the data source.
|
@@ -109,6 +144,25 @@ export declare class RestCollectionView extends CollectionView {
|
|
109
144
|
* ```
|
110
145
|
*/
|
111
146
|
requestHeaders: any;
|
147
|
+
/**
|
148
|
+
* Gets or Sets the aggregates query which would parsed by the REST/Web API and returns the aggregates as result.
|
149
|
+
* This property is should be set when aggregate property is set for FlexGrid columns and {@see groupOnServer} is
|
150
|
+
* set to true with groupDescriptions.
|
151
|
+
*
|
152
|
+
* ```typescript
|
153
|
+
* // instance of RestCollectionView / derived class from RestCollectionView
|
154
|
+
* let cv = new RestCollectionView({
|
155
|
+
* groupOnServer:true,
|
156
|
+
* aggregates: `Sum(actualCost) as actualCost,Sum(quantity) as quantity`,
|
157
|
+
* groupDescriptions: [
|
158
|
+
* // group description to add groups
|
159
|
+
* new PropertyGroupDescription('productName'),
|
160
|
+
* new PropertyGroupDescription('transactionType')
|
161
|
+
* ]
|
162
|
+
* });
|
163
|
+
* ```
|
164
|
+
*/
|
165
|
+
aggregates: string;
|
112
166
|
/**
|
113
167
|
* Updates the filter definition based on a known filter provider such as
|
114
168
|
* the @see:FlexGridFilter.
|
@@ -117,6 +171,29 @@ export declare class RestCollectionView extends CollectionView {
|
|
117
171
|
* a @see:FlexGridFilter.
|
118
172
|
*/
|
119
173
|
updateFilterDefinition(filterProvider: any): void;
|
174
|
+
/**
|
175
|
+
* This method would allow to load the items for specified group {@link CollectionViewGroup} when {@link groupLazyLoading} is enabled.
|
176
|
+
* @param item {@link CollectionViewGroup} items to load the data
|
177
|
+
*/
|
178
|
+
lazyLoadGroup(item: CollectionViewGroup): void;
|
179
|
+
/**
|
180
|
+
* Sets the data window to ensure a range of records are loaded into the view.
|
181
|
+
*
|
182
|
+
* @param start Index of the first item in the data window.
|
183
|
+
* @param end Index of the last item in the data window.
|
184
|
+
*/
|
185
|
+
setWindow(start: number, end: number): void;
|
186
|
+
private _getFilterGroupItems;
|
187
|
+
/**
|
188
|
+
* Gets the aggregate value for specific GroupRow
|
189
|
+
*
|
190
|
+
* @param columnBinding Name of the property to aggregate on
|
191
|
+
* @param groupItem {@link CollectionViewGroup} GroupItem for which aggregate should be calculate
|
192
|
+
* @param aggregate Type of {@link Aggregate} to calculate
|
193
|
+
* @returns The aggregate value
|
194
|
+
*
|
195
|
+
*/
|
196
|
+
getGroupAggregate(columnBinding: string, groupItem: CollectionViewGroup, aggregate?: Aggregate): any;
|
120
197
|
/**
|
121
198
|
* Gets a value that indicates the @see:ServerCollectionView is
|
122
199
|
* currently loading data.
|
@@ -193,12 +270,25 @@ export declare class RestCollectionView extends CollectionView {
|
|
193
270
|
remove(item: any): void;
|
194
271
|
_getPageView(): any[];
|
195
272
|
private _getData;
|
273
|
+
private _loadExpandedGroups;
|
274
|
+
private _updateSubGroups;
|
275
|
+
private _loadSubGroupsData;
|
276
|
+
_updateExpandedGroups(item: CollectionViewGroup, isCollapsed: boolean): void;
|
277
|
+
_storeItems(items: any[], append: boolean): Promise<void>;
|
278
|
+
_performSetWindow(start: number, end: number): void;
|
279
|
+
protected _fetchSize(): number;
|
196
280
|
protected _raiseError(error: any, reload: boolean): void;
|
281
|
+
readonly requestCanceled: Event<RestCollectionView, EventArgs>;
|
282
|
+
/**
|
283
|
+
* Raises the {@link requestCanceled} event.
|
284
|
+
*/
|
285
|
+
onRequestCanceled(e?: EventArgs): void;
|
286
|
+
protected getGroupItems(item?: CollectionViewGroup): Promise<any[]>;
|
197
287
|
/**
|
198
288
|
* Gets a Promise that returns an array containing all the items,
|
199
289
|
* possibly filtered/paged/and sorted on the server.
|
200
290
|
*/
|
201
|
-
protected getItems(): Promise<any[]>;
|
291
|
+
protected getItems(item?: CollectionViewGroup): Promise<any[]>;
|
202
292
|
/**
|
203
293
|
* Gets a Promise that adds a new item to the database.
|
204
294
|
*/
|
package/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
*
|
3
|
-
* Wijmo Library 5.20242.20-nightly.d20240814.
|
3
|
+
* Wijmo Library 5.20242.20-nightly.d20240814.t111510
|
4
4
|
* https://developer.mescius.com/wijmo
|
5
5
|
*
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
@@ -11,4 +11,4 @@
|
|
11
11
|
*
|
12
12
|
*/
|
13
13
|
|
14
|
-
"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};return function(e,t){extendStatics(e,t);function __(){this.constructor=e}e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}(),__awaiter=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(o,n){function fulfilled(e){try{step(i.next(e))}catch(e){n(e)}}function rejected(e){try{step(i.throw(e))}catch(e){n(e)}}function step(e){e.done?o(e.value):new r((function(t){t(e.value)})).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,i,o,n,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return n={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function verb(n){return function(a){return function step(n){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(o=2&n[0]?i.return:n[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,n[1])).done)return o;(i=0,o)&&(n=[2&n[0],o.value]);switch(n[0]){case 0:case 1:o=n;break;case 4:s.label++;return{value:n[1],done:!1};case 5:s.label++;i=n[1];n=[0];continue;case 7:n=s.ops.pop();s.trys.pop();continue;default:if(!(o=s.trys,o=o.length>0&&o[o.length-1])&&(6===n[0]||2===n[0])){s=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]<o[3])){s.label=n[1];break}if(6===n[0]&&s.label<o[1]){s.label=o[1];o=n;break}if(o&&s.label<o[2]){s.label=o[2];s.ops.push(n);break}o[2]&&s.ops.pop();s.trys.pop();continue}n=t.call(e,s)}catch(e){n=[6,e];i=0}finally{r=o=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,a])}}},__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);t.default=e;return t};Object.defineProperty(exports,"__esModule",{value:!0});var wijmo_1=require("@mescius/wijmo"),selfModule=__importStar(require("@mescius/wijmo.rest")),RestCollectionView=function(e){__extends(RestCollectionView,e);function RestCollectionView(t){var r=e.call(this)||this;r._loading=!1;r._fields=null;r._keys=null;r._sortOnServer=!0;r._pageOnServer=!0;r._filterOnServer=!0;r._totalItemCount=0;r.loading=new wijmo_1.Event;r.loaded=new wijmo_1.Event;r.error=new wijmo_1.Event;t&&wijmo_1.copy(r,t);r.sortDescriptions.collectionChanged.addHandler((function(){r.sortOnServer&&r._getData()}));r._getData();return r}Object.defineProperty(RestCollectionView.prototype,"fields",{get:function(){return this._fields},set:function(e){if(this._fields!=e){this._fields=wijmo_1.asArray(e);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"sortOnServer",{get:function(){return this._sortOnServer},set:function(e){if(e!=this._sortOnServer){this._sortOnServer=wijmo_1.asBoolean(e);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"pageOnServer",{get:function(){return this._pageOnServer},set:function(e){if(e!=this._pageOnServer){this._pageOnServer=wijmo_1.asBoolean(e);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"filterOnServer",{get:function(){return this._filterOnServer},set:function(e){if(e!=this._filterOnServer){this._filterOnServer=wijmo_1.asBoolean(e);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"requestHeaders",{get:function(){return this._requestHeaders},set:function(e){this._requestHeaders=e},enumerable:!0,configurable:!0});RestCollectionView.prototype.updateFilterDefinition=function(e){if(this.filterOnServer){this._filterProvider=e;this._getData()}};Object.defineProperty(RestCollectionView.prototype,"isLoading",{get:function(){return this._loading},enumerable:!0,configurable:!0});RestCollectionView.prototype.onLoading=function(e){this.loading.raise(this,e)};RestCollectionView.prototype.onLoaded=function(e){this.loaded.raise(this,e)};RestCollectionView.prototype.load=function(){this._getData()};RestCollectionView.prototype.onError=function(e){this.error.raise(this,e);return!e.cancel};RestCollectionView.prototype._performRefresh=function(){var t=this._canFilter,r=this._canSort;this._canFilter=!this._filterOnServer;this._canSort=!this._sortOnServer;e.prototype._performRefresh.call(this);this._canFilter=t;this._canSort=r};Object.defineProperty(RestCollectionView.prototype,"totalItemCount",{get:function(){return this.pageOnServer?this._totalItemCount:this._view.length},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"pageCount",{get:function(){return this.pageSize?Math.ceil(this.totalItemCount/this.pageSize):1},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"pageSize",{get:function(){return this._pgSz},set:function(e){if(e!=this._pgSz){this._pgSz=wijmo_1.asInt(e);if(this.pageOnServer){this._pgIdx=wijmo_1.clamp(this._pgIdx,0,this.pageCount-1);this._getData()}else this.refresh()}},enumerable:!0,configurable:!0});RestCollectionView.prototype.onPageChanging=function(t){e.prototype.onPageChanging.call(this,t);this.pageOnServer&&!t.cancel&&this._getData();return!t.cancel};RestCollectionView.prototype.commitNew=function(){var t=this,r=this.currentAddItem;if(r)try{var i=this.addItem(r);i&&i.then&&i.then((function(){return t.refresh()}))}catch(e){this._raiseError(e,!0)}e.prototype.commitNew.call(this)};RestCollectionView.prototype.commitEdit=function(){var t=this,r=this.currentEditItem;if(r&&!this.currentAddItem&&!this._sameContent(r,this._edtClone)&&this.items.indexOf(r)>-1)try{var i=this.patchItem(r);i&&i.then&&i.then((function(){return t.refresh()}))}catch(e){this._raiseError(e,!0)}e.prototype.commitEdit.call(this)};RestCollectionView.prototype.remove=function(t){var r=this;if(t&&t!=this.currentAddItem&&this.items.indexOf(t)>-1)try{var i=this.deleteItem(t);i&&i.then&&i.then((function(){return r.refresh()}))}catch(e){this._raiseError(e,!0)}e.prototype.remove.call(this,t)};RestCollectionView.prototype._getPageView=function(){return this.pageOnServer?this._view:e.prototype._getPageView.call(this)};RestCollectionView.prototype._getData=function(){var e=this;this._toGetData&&clearTimeout(this._toGetData);this._toGetData=setTimeout((function(){return __awaiter(e,void 0,void 0,(function(){var e,t,r,i;return __generator(this,(function(o){switch(o.label){case 0:this._toGetData=null;this._loading=!0;this.onLoading();e=null;t=null;o.label=1;case 1:o.trys.push([1,3,,4]);r=this.currentPosition;return[4,this.getItems()];case 2:e=o.sent();this.sourceCollection=e;this.refresh();r>-1&&this.moveCurrentToPosition(r);this.pageIndex>0&&this.pageIndex>=this.pageCount&&this.moveToLastPage();return[3,4];case 3:i=o.sent();t=i;return[3,4];case 4:this._loading=!1;this.onLoaded();t&&this._raiseError(t,!1);return[2]}}))}))}),100)};RestCollectionView.prototype._raiseError=function(e,t){if(this.onError(new RESTErrorEventArgs(e))){t&&this._getData();throw"Server Error: "+e}};RestCollectionView.prototype.getItems=function(){throw"This method is virtual: it should be overridden"};RestCollectionView.prototype.addItem=function(e){throw"This method is virtual: it should be overridden"};RestCollectionView.prototype.patchItem=function(e){throw"This method is virtual: it should be overridden"};RestCollectionView.prototype.deleteItem=function(e){throw"This method is virtual: it should be overridden"};return RestCollectionView}(wijmo_1.CollectionView);exports.RestCollectionView=RestCollectionView;var RESTErrorEventArgs=function(e){__extends(RESTErrorEventArgs,e);function RESTErrorEventArgs(t){var r=e.call(this)||this;r._error=t;return r}Object.defineProperty(RESTErrorEventArgs.prototype,"error",{get:function(){return this._error},enumerable:!0,configurable:!0});return RESTErrorEventArgs}(wijmo_1.CancelEventArgs);exports.RESTErrorEventArgs=RESTErrorEventArgs;wijmo_1._registerModule("wijmo.rest",selfModule);
|
14
|
+
"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(t,e){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};return function(t,e){extendStatics(t,e);function __(){this.constructor=t}t.prototype=null===e?Object.create(e):(__.prototype=e.prototype,new __)}}(),__assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(o,n){function fulfilled(t){try{step(i.next(t))}catch(t){n(t)}}function rejected(t){try{step(i.throw(t))}catch(t){n(t)}}function step(t){t.done?o(t.value):new r((function(e){e(t.value)})).then(fulfilled,rejected)}step((i=i.apply(t,e||[])).next())}))},__generator=this&&this.__generator||function(t,e){var r,i,o,n,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return n={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function verb(n){return function(a){return function step(n){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(o=2&n[0]?i.return:n[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,n[1])).done)return o;(i=0,o)&&(n=[2&n[0],o.value]);switch(n[0]){case 0:case 1:o=n;break;case 4:s.label++;return{value:n[1],done:!1};case 5:s.label++;i=n[1];n=[0];continue;case 7:n=s.ops.pop();s.trys.pop();continue;default:if(!(o=s.trys,o=o.length>0&&o[o.length-1])&&(6===n[0]||2===n[0])){s=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]<o[3])){s.label=n[1];break}if(6===n[0]&&s.label<o[1]){s.label=o[1];o=n;break}if(o&&s.label<o[2]){s.label=o[2];s.ops.push(n);break}o[2]&&s.ops.pop();s.trys.pop();continue}n=e.call(t,s)}catch(t){n=[6,t];i=0}finally{r=o=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,a])}}},__importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);e.default=t;return e};Object.defineProperty(exports,"__esModule",{value:!0});var wijmo_1=require("@mescius/wijmo"),selfModule=__importStar(require("@mescius/wijmo.rest")),_MIN_DATA_WINDOW=100,RestCollectionView=function(t){__extends(RestCollectionView,t);function RestCollectionView(e){var r=t.call(this)||this;r._loading=!1;r._fields=null;r._keys=null;r._sortOnServer=!0;r._pageOnServer=!0;r._filterOnServer=!0;r._totalItemCount=0;r._aggregates="";r._groupOnServer=!0;r._groupLazyLoading=!1;r._virtualization=!1;r._start=0;r._end=_MIN_DATA_WINDOW;r._expandedGroups=[];r._groupItems=[];r._groupRefresh=!1;r._refresh=!1;r.loading=new wijmo_1.Event;r.loaded=new wijmo_1.Event;r.error=new wijmo_1.Event;e&&wijmo_1.copy(r,e);r.sortDescriptions.collectionChanged.addHandler((function(){r.sortOnServer&&r._getData()}));r._getData();(r._groupOnServer||r._virtualization)&&(r._data=[]);r._virtualization&&r.setWindow(r._start,_MIN_DATA_WINDOW);r._firstLoad=r._groupRefresh=!0;return r}Object.defineProperty(RestCollectionView.prototype,"totalGroupItemCount",{get:function(){return this.groupOnServer?this._totalGroupItemCount:0},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"groupOnServer",{get:function(){return this._groupOnServer},set:function(t){if(t!=this._groupOnServer){this._groupOnServer=wijmo_1.asBoolean(t);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"groupLazyLoading",{get:function(){return this._groupLazyLoading},set:function(t){t!=this._groupLazyLoading&&this._groupOnServer&&(this._groupLazyLoading=wijmo_1.asBoolean(t))},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"virtualization",{get:function(){return this._virtualization},set:function(t){t!=this.virtualization&&(this._virtualization=wijmo_1.asBoolean(t))},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"fields",{get:function(){return this._fields},set:function(t){if(this._fields!=t){this._fields=wijmo_1.asArray(t);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"sortOnServer",{get:function(){return this._sortOnServer},set:function(t){if(t!=this._sortOnServer){this._sortOnServer=wijmo_1.asBoolean(t);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"pageOnServer",{get:function(){return this._pageOnServer},set:function(t){if(t!=this._pageOnServer){this._pageOnServer=wijmo_1.asBoolean(t);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"filterOnServer",{get:function(){return this._filterOnServer},set:function(t){if(t!=this._filterOnServer){this._filterOnServer=wijmo_1.asBoolean(t);this._getData()}},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"requestHeaders",{get:function(){return this._requestHeaders},set:function(t){this._requestHeaders=t},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"aggregates",{get:function(){return this._aggregates},set:function(t){wijmo_1.assert(this._groupOnServer,"groupOnServer should be enabled");wijmo_1.isString(t)&&t!=this._aggregates&&(this._aggregates=t)},enumerable:!0,configurable:!0});RestCollectionView.prototype.updateFilterDefinition=function(t){if(this.filterOnServer){this._filterProvider=t;this._getData()}};RestCollectionView.prototype.lazyLoadGroup=function(t){if(this._groupLazyLoading){t.groups.length>0&&null==t.groups[0].name&&this._getData(t);0==t.groups.length&&t.isBottomLevel&&this._getData(t)}else wijmo_1.assert(this._groupLazyLoading,"groupLazyLoading should be enabled lazy load the groups.")};RestCollectionView.prototype.setWindow=function(t,e){var r=this;this._toSetWindow&&clearTimeout(this._toSetWindow);this._toSetWindow=setTimeout((function(){r._toSetWindow=null;r._performSetWindow(t,e)}),50)};RestCollectionView.prototype._getFilterGroupItems=function(t){for(var e=this._groupItems,r=t.items[0],_loop_1=function(t){var o=i.groupDescriptions[t].propertyName;e=e.filter((function(t){return t.groupKey[o]==r[o]}))},i=this,o=0;o<=t.level;o++)_loop_1(o);return e};RestCollectionView.prototype.getGroupAggregate=function(t,e,r){void 0===r&&(r=wijmo_1.Aggregate.Sum);if(this.groupLazyLoading||this.virtualization){var i="",o=this._getFilterGroupItems(e);o&&0!=o.length&&o.length!=this._groupItems.length&&o[0].aggregates&&(i=wijmo_1.getAggregate(r,o,"aggregates."+t));return i}};Object.defineProperty(RestCollectionView.prototype,"isLoading",{get:function(){return this._loading},enumerable:!0,configurable:!0});RestCollectionView.prototype.onLoading=function(t){this.loading.raise(this,t)};RestCollectionView.prototype.onLoaded=function(t){this.loaded.raise(this,t)};RestCollectionView.prototype.load=function(){this._getData()};RestCollectionView.prototype.onError=function(t){this.error.raise(this,t);return!t.cancel};RestCollectionView.prototype._performRefresh=function(){this.isLoading||(this._refresh=!0);var e=this._canFilter,r=this._canSort;this._canFilter=!this._filterOnServer;this._canSort=!this._sortOnServer;t.prototype._performRefresh.call(this);this._canFilter=e;this._canSort=r};Object.defineProperty(RestCollectionView.prototype,"totalItemCount",{get:function(){return this.pageOnServer?this._totalItemCount:this._view.length},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"pageCount",{get:function(){return this.pageSize?Math.ceil(this.totalItemCount/this.pageSize):1},enumerable:!0,configurable:!0});Object.defineProperty(RestCollectionView.prototype,"pageSize",{get:function(){return this._pgSz},set:function(t){if(t!=this._pgSz){this._pgSz=wijmo_1.asInt(t);if(this.pageOnServer){this._pgIdx=wijmo_1.clamp(this._pgIdx,0,this.pageCount-1);this._getData()}else this.refresh()}},enumerable:!0,configurable:!0});RestCollectionView.prototype.onPageChanging=function(e){t.prototype.onPageChanging.call(this,e);this.pageOnServer&&!e.cancel&&this._getData();return!e.cancel};RestCollectionView.prototype.commitNew=function(){var e=this,r=this.currentAddItem;if(r)try{var i=this.addItem(r);i&&i.then&&i.then((function(){return e.refresh()}))}catch(t){this._raiseError(t,!0)}t.prototype.commitNew.call(this)};RestCollectionView.prototype.commitEdit=function(){var e=this,r=this.currentEditItem;if(r&&!this.currentAddItem&&!this._sameContent(r,this._edtClone)&&this.items.indexOf(r)>-1)try{var i=this.patchItem(r);i&&i.then&&i.then((function(){return e.refresh()}))}catch(t){this._raiseError(t,!0)}t.prototype.commitEdit.call(this)};RestCollectionView.prototype.remove=function(e){var r=this;if(e&&e!=this.currentAddItem&&this.items.indexOf(e)>-1)try{var i=this.deleteItem(e);i&&i.then&&i.then((function(){return r.refresh()}))}catch(t){this._raiseError(t,!0)}t.prototype.remove.call(this,e)};RestCollectionView.prototype._getPageView=function(){return this.pageOnServer?this._view:t.prototype._getPageView.call(this)};RestCollectionView.prototype._getData=function(t){var e=this;this._toGetData&&clearTimeout(this._toGetData);this._toGetData=setTimeout((function(){return __awaiter(e,void 0,void 0,(function(){var e,r,i,o,n,s,a,u=this;return __generator(this,(function(l){switch(l.label){case 0:this._toGetData=null;this._loading=!0;this.onLoading();e=null;if(this._groupOnServer||this._virtualization)return[3,5];r=null;l.label=1;case 1:l.trys.push([1,3,,4]);o=this.currentPosition;return[4,this.getItems()];case 2:r=l.sent();this.sourceCollection=r;this.refresh();o>-1&&this.moveCurrentToPosition(o);this.pageIndex>0&&this.pageIndex>=this.pageCount&&this.moveToLastPage();return[3,4];case 3:i=l.sent();e=i;return[3,4];case 4:return[3,12];case 5:o=-1;this.currentPosition>-1&&(o=this.currentPosition);n=this.groupDescriptions;this._data||(this._data=[]);s=[];return(this._groupRefresh||!(!this._groupLazyLoading||t&&t.isBottomLevel))&&this._groupOnServer&&n.length>0?[4,this.getGroupItems(t)]:[3,7];case 6:s=l.sent();t?this._updateSubGroups(t,s):this._groupItems=s;this._groupRefresh=!1;l.label=7;case 7:return this._groupLazyLoading?[3,9]:[4,this.getItems()];case 8:a=l.sent();l.label=9;case 9:return this._groupLazyLoading&&t&&t.isBottomLevel?[4,this.getItems(t)]:[3,11];case 10:a=l.sent();l.label=11;case 11:this.deferUpdate((function(){return __awaiter(u,void 0,void 0,(function(){var e,r,i,o,u;return __generator(this,(function(l){switch(l.label){case 0:this._virtualization||this._groupLazyLoading||(this._data=a);if(!this._groupLazyLoading||this._virtualization)return[3,4];if(t)return[3,3];this._data=new Array;e=n[0].propertyName;for(r=0;r<s.length;r++){i=new Object,o=s[r].count;i[e]=s[r].groupKey[e];for(u=0;u<o;u++)this._data.push(i)}return this._expandedGroups.length>0?[4,this._loadExpandedGroups(t)]:[3,2];case 1:l.sent();l.label=2;case 2:return[3,4];case 3:this._loadSubGroupsData(t,s,a);l.label=4;case 4:this._virtualization&&!this._groupLazyLoading&&this._storeItems(a,!1);this.sourceCollection=this._data;return[2]}}))}))}));this.refresh();o>-1&&this.moveCurrentToPosition(o);l.label=12;case 12:this._loading=!1;this.onLoaded();e&&this._raiseError(e,!1);return[2]}}))}))}),100)};RestCollectionView.prototype._loadExpandedGroups=function(t){return __awaiter(this,void 0,void 0,(function(){var e,r=this;return __generator(this,(function(i){if(this._expandedGroups.length>0&&!t){e=[];this._expandedGroups.forEach((function(t){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(r){t.isBottomLevel?e.push(this.getItems(t)):e.push(this.getGroupItems(t));return[2]}))}))}));return[2,new Promise((function(t){Promise.all(e).then((function(e){for(var i=0;i<r._expandedGroups.length;i++)if(r._expandedGroups[i].isBottomLevel)r._loadSubGroupsData(r._expandedGroups[i],[],e[i]);else{r._updateSubGroups(r._expandedGroups[i],e[i]);r._loadSubGroupsData(r._expandedGroups[i],e[i],[])}t(!0)})).catch((function(e){t(!1)}))}))]}return[2]}))}))};RestCollectionView.prototype._updateSubGroups=function(t,e){var r,i=this._getFilterGroupItems(t);if(1==i.length){for(var o=0;o<e.length;o++)e[o].groupKey=__assign({},i[0].groupKey,e[o].groupKey);var n=this._groupItems.indexOf(i[0]);(r=this._groupItems).splice.apply(r,[n,1].concat(e))}else console.error("unable to find exact match for targetted group")};RestCollectionView.prototype._loadSubGroupsData=function(t,e,r){for(var i,o=this.groupDescriptions,n=this._data,_loop_2=function(e){var r=o[e].propertyName,i=t.items[e][r];n=n.filter((function(t){return t[r]===i}))},s=0;s<=(t.isBottomLevel?o.length-1:t.level);s++)_loop_2(s);var a=this._data.indexOf(n[0]);n=JSON.parse(JSON.stringify(n));if(t.isBottomLevel)for(s=0;s<r.length;s++)Object.assign(n[s],r[s]);else for(var u=t.groups[0].groupDescription.propertyName,l=0,s=0;s<e.length;s++){l+=s>0?e[s-1].count:0;for(var h=0;h<e[s].count;h++)n[l+h][u]=e[s].groupKey[u]}(i=this._data).splice.apply(i,[a,n.length].concat(n))};RestCollectionView.prototype._updateExpandedGroups=function(t,e){if(!this._loading){var r=this._expandedGroups.filter((function(e){return e._path.indexOf(t._path)>-1}));if(e)this._expandedGroups.push(t);else if(r.length>0)for(var i=0;i<r.length;i++)this._expandedGroups.splice(this._expandedGroups.indexOf(r[i]),1)}};RestCollectionView.prototype._storeItems=function(t,e){return __awaiter(this,void 0,void 0,(function(){var r,i,o,n,s,a,u,l,h,p,c,_=this;return __generator(this,(function(g){if(this._refresh||this._data.length!=this.totalItemCount||this.groups&&this.groups.length!=this._totalGroupItemCount){if(this._data.length!=this.totalItemCount&&this.groups&&this.groups.length>0){this._groupRefresh=!0;this._getData()}this._data.length=this.totalItemCount;if(this._groupOnServer&&this._groupItems.length>0&&this.groupDescriptions.length>0){r=JSON.parse(JSON.stringify(this.groups));i=0;o=function(t){for(var e=Object.keys(n._groupItems[t].groupKey),_loop_4=function(r){var o=new wijmo_1._NullValue(i);e.forEach((function(e){o[e]=_._groupItems[t].groupKey[e]}));n._data[i]=o;i++},r=0;r<n._groupItems[t].count;r++)_loop_4()};n=this;for(c=0;c<this._groupItems.length;c++)o(c);if(0!=this.groups.length&&this.groups.length<r.length){s=this._data[this._start];a=this.groupDescriptions.length;u=this.groupDescriptions[a-1].propertyName;l=this.groups.findIndex((function(t){return t.name==s[u]}));h=r.findIndex((function(t){return t.name==s[u]}));this._start+=l-h;this._getData()}}else for(c=0;c<this._data.length;c++)this._data[c]=new wijmo_1._NullValue(c);this._refresh=!1}e||(this._loadOffset=0);p=this._loadOffset+(this._start||0);for(c=0;c<t.length;c++)this._data[c+p]=t[c];this._loadOffset+=t.length;setTimeout((function(){_._firstLoad&&_.currentPosition<0&&t.length&&_.moveCurrentToFirst();_._firstLoad=!1}));return[2]}))}))};RestCollectionView.prototype._performSetWindow=function(t,e){if(this._pendingRequest){this._pendingRequest.abort();this._pendingRequest=null;this.onRequestCanceled()}t=wijmo_1.asInt(t);e=wijmo_1.asInt(e);wijmo_1.assert(t<=e,"start must be <= end.");var r=t<this._start,i=this._data;this._start=this._end=t;for(var o=t;o<=e&&o<i.length;o++)if(i[o]instanceof wijmo_1._NullValue){this._start=o;break}for(o=e;o>=this._start&&o<i.length;o--)if(i[o]instanceof wijmo_1._NullValue){this._end=o;break}if(this._start!=this._end||i[this._start]instanceof wijmo_1._NullValue){r&&(this._start=Math.max(0,this._end-this._fetchSize()+1));this._getData()}};RestCollectionView.prototype._fetchSize=function(){return Math.max(this._end-this._start+1,this.pageSize,_MIN_DATA_WINDOW)};RestCollectionView.prototype._raiseError=function(t,e){if(this.onError(new RESTErrorEventArgs(t))){e&&this._getData();throw"Server Error: "+t}};Object.defineProperty(RestCollectionView.prototype,"requestCanceled",{get:function(){this._requestCanceled||(this._requestCanceled=new wijmo_1.Event);return this._requestCanceled},enumerable:!0,configurable:!0});RestCollectionView.prototype.onRequestCanceled=function(t){this.requestCanceled.raise(this,t)};RestCollectionView.prototype.getGroupItems=function(t){throw"This method is virtual: it should be overridden"};RestCollectionView.prototype.getItems=function(t){throw"This method is virtual: it should be overridden"};RestCollectionView.prototype.addItem=function(t){throw"This method is virtual: it should be overridden"};RestCollectionView.prototype.patchItem=function(t){throw"This method is virtual: it should be overridden"};RestCollectionView.prototype.deleteItem=function(t){throw"This method is virtual: it should be overridden"};return RestCollectionView}(wijmo_1.CollectionView);exports.RestCollectionView=RestCollectionView;var RESTErrorEventArgs=function(t){__extends(RESTErrorEventArgs,t);function RESTErrorEventArgs(e){var r=t.call(this)||this;r._error=e;return r}Object.defineProperty(RESTErrorEventArgs.prototype,"error",{get:function(){return this._error},enumerable:!0,configurable:!0});return RESTErrorEventArgs}(wijmo_1.CancelEventArgs);exports.RESTErrorEventArgs=RESTErrorEventArgs;wijmo_1._registerModule("wijmo.rest",selfModule);
|
package/package.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "@mescius/wijmo.rest",
|
3
|
-
"version": "5.20242.20-nightly.d20240814.
|
3
|
+
"version": "5.20242.20-nightly.d20240814.t111510",
|
4
4
|
"description": "UI library for pure JS, Angular, React, Vue and more...",
|
5
5
|
"author": "MESCIUS inc",
|
6
6
|
"license": "Commercial",
|
7
7
|
"main": "./index.js",
|
8
8
|
"types": "./index.d.ts",
|
9
9
|
"dependencies": {
|
10
|
-
"@mescius/wijmo": "5.20242.20-nightly.d20240814.
|
10
|
+
"@mescius/wijmo": "5.20242.20-nightly.d20240814.t111510"
|
11
11
|
},
|
12
12
|
"homepage": "https://developer.mescius.com/wijmo",
|
13
13
|
"bugs": {
|