@hedhog/pagination 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pagination.service.d.ts","sourceRoot":"","sources":["../src/pagination.service.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,eAAe,EACf,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAElC,qBACa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsC;IAEvD,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,SAAS,EACnC,KAAK,EAAE,CAAC,EACR,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GAC5B,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAuG9B,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,EAAE;
|
1
|
+
{"version":3,"file":"pagination.service.d.ts","sourceRoot":"","sources":["../src/pagination.service.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,eAAe,EACf,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAElC,qBACa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsC;IAEvD,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,SAAS,EACnC,KAAK,EAAE,CAAC,EACR,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GAC5B,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAuG9B,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,EAAE;IAavD,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO;IAI5D,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO;CAK7D"}
|
@@ -73,7 +73,7 @@ let PaginationService = PaginationService_1 = class PaginationService {
|
|
73
73
|
return {
|
74
74
|
total,
|
75
75
|
lastPage,
|
76
|
-
page
|
76
|
+
page,
|
77
77
|
pageSize,
|
78
78
|
prev: page > 1 ? page - 1 : null,
|
79
79
|
next: page < lastPage ? page + 1 : null,
|
@@ -92,17 +92,17 @@ let PaginationService = PaginationService_1 = class PaginationService {
|
|
92
92
|
const fieldNames = [];
|
93
93
|
const fields = model.fields;
|
94
94
|
for (const key in fields) {
|
95
|
-
if (fields.hasOwnProperty(key)) {
|
95
|
+
if (fields && fields.hasOwnProperty(key)) {
|
96
96
|
fieldNames.push(key);
|
97
97
|
}
|
98
98
|
}
|
99
99
|
return fieldNames;
|
100
100
|
}
|
101
101
|
isInvalidField(sortField, model) {
|
102
|
-
return !model.fields[sortField];
|
102
|
+
return model && model.fields ? !model.fields[sortField] : true;
|
103
103
|
}
|
104
104
|
isInvalidFields(fields, model) {
|
105
|
-
return !fields.every((field) => model.fields[field]);
|
105
|
+
return !fields.every((field) => model.fields ? model && model.fields[field] : false);
|
106
106
|
}
|
107
107
|
};
|
108
108
|
exports.PaginationService = PaginationService;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pagination.service.js","sourceRoot":"","sources":["../src/pagination.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAyE;AACzE,2EAG0C;AAC1C,+DAA8D;AASvD,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAAvB;QACY,WAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;
|
1
|
+
{"version":3,"file":"pagination.service.js","sourceRoot":"","sources":["../src/pagination.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAyE;AACzE,2EAG0C;AAC1C,+DAA8D;AASvD,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAAvB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;YACzB,IAAI,MAAM,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,cAAc,CAAC,SAAiB,EAAE,KAAgB;QAChD,OAAO,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjE,CAAC;IAED,eAAe,CAAC,MAAgB,EAAE,KAAgB;QAChD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAC7B,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CACpD,CAAC;IACJ,CAAC;CACF,CAAA;AApIY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAoI7B"}
|
package/package.json
CHANGED
@@ -105,7 +105,7 @@ export class PaginationService {
|
|
105
105
|
return {
|
106
106
|
total,
|
107
107
|
lastPage,
|
108
|
-
page
|
108
|
+
page,
|
109
109
|
pageSize,
|
110
110
|
prev: page > 1 ? page - 1 : null,
|
111
111
|
next: page < lastPage ? page + 1 : null,
|
@@ -124,11 +124,10 @@ export class PaginationService {
|
|
124
124
|
|
125
125
|
extractFieldNames(model: Record<string, any>): string[] {
|
126
126
|
const fieldNames: string[] = [];
|
127
|
-
|
128
127
|
const fields = model.fields;
|
129
128
|
|
130
129
|
for (const key in fields) {
|
131
|
-
if (fields.hasOwnProperty(key)) {
|
130
|
+
if (fields && fields.hasOwnProperty(key)) {
|
132
131
|
fieldNames.push(key);
|
133
132
|
}
|
134
133
|
}
|
@@ -137,10 +136,12 @@ export class PaginationService {
|
|
137
136
|
}
|
138
137
|
|
139
138
|
isInvalidField(sortField: string, model: BaseModel): boolean {
|
140
|
-
return !model.fields[sortField];
|
139
|
+
return model && model.fields ? !model.fields[sortField] : true;
|
141
140
|
}
|
142
141
|
|
143
142
|
isInvalidFields(fields: string[], model: BaseModel): boolean {
|
144
|
-
return !fields.every((field) =>
|
143
|
+
return !fields.every((field) =>
|
144
|
+
model.fields ? model && model.fields[field] : false,
|
145
|
+
);
|
145
146
|
}
|
146
147
|
}
|