cloud-ide-lms-model
Version:
Package for Model management of Cloud IDEsys LMS
60 lines (59 loc) • 1.94 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initialTableData = exports.MTableQueries = void 0;
class MTableQueries {
constructor(init) {
this.total = 1;
this.pageIndex = 1;
this.pageSize = 10;
this.query = "";
this.sort = {
order: "",
key: ""
};
Object.assign(this, init);
}
Validate() {
var _a, _b, _c, _d, _e;
let errorLogger = {};
if (this.sort) {
if (((_a = this.sort) === null || _a === void 0 ? void 0 : _a.order) != 'asc' && ((_b = this.sort) === null || _b === void 0 ? void 0 : _b.order) != 'desc' && ((_c = this.sort) === null || _c === void 0 ? void 0 : _c.order) != '') {
errorLogger.sort = "Incorrect Sort order!";
}
if (typeof ((_d = this.sort) === null || _d === void 0 ? void 0 : _d.key) != 'string' && typeof ((_e = this.sort) === null || _e === void 0 ? void 0 : _e.key) != 'number') {
errorLogger.sort = "Incorrect Sort key!";
}
}
else {
errorLogger.sort = "Sort order and key are required!";
}
if (typeof (this.pageIndex) == 'number') {
if (this.pageIndex < 1) {
errorLogger.pageIndex = "Incorrect Page Index!";
}
}
else {
errorLogger.pageIndex = "Page index is required";
}
if (typeof (this.pageSize) == 'number') {
if (this.pageSize < 1) {
errorLogger.pageSize = "Incorrect Page Size!";
}
}
else {
errorLogger.pageSize = "Page Size is required";
}
return errorLogger;
}
}
exports.MTableQueries = MTableQueries;
exports.initialTableData = {
total: 0,
pageIndex: 1,
pageSize: 10,
query: '',
sort: {
order: '',
key: '',
},
};