jitz-sharepoint-utilities 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -199,7 +199,7 @@ export default class CommonRepository implements ICommonRepository {
|
|
199
199
|
}
|
200
200
|
|
201
201
|
public async updateMetadata(listName: string, item: any): Promise<any> {
|
202
|
-
|
202
|
+
await this.getEntityType(listName).then((entityType) => {
|
203
203
|
item.__metadata = {
|
204
204
|
//etag: "1",
|
205
205
|
type: entityType,
|
package/data/context/List.ts
CHANGED
@@ -19,6 +19,7 @@ export default class List<T extends IModel> implements IList<T> {
|
|
19
19
|
simpleFields: string[] = [];
|
20
20
|
userTypeFields: string[] = [];
|
21
21
|
lookUpFields: string[] = [];
|
22
|
+
additionalExpandFields: string[] = [];
|
22
23
|
repository: IRepository<T>;
|
23
24
|
|
24
25
|
filters?: string = "";
|
@@ -31,13 +32,15 @@ export default class List<T extends IModel> implements IList<T> {
|
|
31
32
|
listName: string,
|
32
33
|
simpleFields: string[],
|
33
34
|
userTypeFields: string[],
|
34
|
-
lookUpFields: string[]
|
35
|
+
lookUpFields: string[],
|
36
|
+
additionalExpandFields: string[]
|
35
37
|
) {
|
36
38
|
this.context = jitzContext;
|
37
39
|
this.listName = listName;
|
38
40
|
this.simpleFields = simpleFields || [];
|
39
41
|
this.userTypeFields = userTypeFields || [];
|
40
42
|
this.lookUpFields = lookUpFields || [];
|
43
|
+
this.additionalExpandFields = additionalExpandFields || [];
|
41
44
|
this.repository = new Repository<T>(this.context.spContext, listName);
|
42
45
|
}
|
43
46
|
|
@@ -344,6 +347,7 @@ export default class List<T extends IModel> implements IList<T> {
|
|
344
347
|
var selectFields = "";
|
345
348
|
var userTypeFields: string[] = [];
|
346
349
|
var lookUpFields: string[] = [];
|
350
|
+
var additionalExpandFields: string[] = [];
|
347
351
|
if (this.userTypeFields.length > 0) {
|
348
352
|
for (var i = 0; i < this.userTypeFields.length; i++) {
|
349
353
|
userTypeFields.push(`${this.userTypeFields[i]}Id`);
|
@@ -361,8 +365,18 @@ export default class List<T extends IModel> implements IList<T> {
|
|
361
365
|
lookUpFields.push(`${this.lookUpFields[i]}/Title`);
|
362
366
|
}
|
363
367
|
}
|
368
|
+
if (this.additionalExpandFields.length > 0) {
|
369
|
+
for (var i = 0; i < this.additionalExpandFields.length; i++) {
|
370
|
+
additionalExpandFields.push(this.additionalExpandFields[i]);
|
371
|
+
}
|
372
|
+
}
|
364
373
|
selectFields = (
|
365
|
-
[
|
374
|
+
[
|
375
|
+
...this.simpleFields,
|
376
|
+
...userTypeFields,
|
377
|
+
...lookUpFields,
|
378
|
+
...additionalExpandFields,
|
379
|
+
] || []
|
366
380
|
).join(",");
|
367
381
|
return selectFields;
|
368
382
|
};
|
@@ -205,7 +205,6 @@ var CommonRepository = /** @class */ (function () {
|
|
205
205
|
return __awaiter(this, void 0, void 0, function () {
|
206
206
|
var url;
|
207
207
|
var _this = this;
|
208
|
-
var item;
|
209
208
|
return __generator(this, function (_a) {
|
210
209
|
switch (_a.label) {
|
211
210
|
case 0: return [4 /*yield*/, this.getEntityType(listName).then(function (entityType) {
|
@@ -233,7 +232,7 @@ var CommonRepository = /** @class */ (function () {
|
|
233
232
|
});
|
234
233
|
})];
|
235
234
|
case 1:
|
236
|
-
|
235
|
+
_a.sent();
|
237
236
|
url = "/_api/web/lists/getbytitle('".concat(listName, "')/items(").concat(item.Id, ")?$select=*,File/Name,File/ServerRelativeUrl&$expand=File");
|
238
237
|
return [2 /*return*/, this.context.client.get(url).then(function (response) {
|
239
238
|
if (response.status >= 200 && response.status <= 300) {
|
@@ -11,12 +11,13 @@ export default class List<T extends IModel> implements IList<T> {
|
|
11
11
|
simpleFields: string[];
|
12
12
|
userTypeFields: string[];
|
13
13
|
lookUpFields: string[];
|
14
|
+
additionalExpandFields: string[];
|
14
15
|
repository: IRepository<T>;
|
15
16
|
filters?: string;
|
16
17
|
upperId: number;
|
17
18
|
lowerId: number;
|
18
19
|
orderBy?: string | undefined;
|
19
|
-
constructor(jitzContext: IJitzContext, listName: string, simpleFields: string[], userTypeFields: string[], lookUpFields: string[]);
|
20
|
+
constructor(jitzContext: IJitzContext, listName: string, simpleFields: string[], userTypeFields: string[], lookUpFields: string[], additionalExpandFields: string[]);
|
20
21
|
getItems: (filters?: string, orderby?: string, top?: number, skip?: number) => Promise<T[]>;
|
21
22
|
loadMore: () => Promise<T[]>;
|
22
23
|
getItemsIndexed: (filterQuery?: string, orderby?: string, top?: number) => Promise<T[]>;
|
package/lib/data/context/List.js
CHANGED
@@ -47,7 +47,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
48
48
|
var Repository_1 = require("./Repository");
|
49
49
|
var List = /** @class */ (function () {
|
50
|
-
function List(jitzContext, listName, simpleFields, userTypeFields, lookUpFields) {
|
50
|
+
function List(jitzContext, listName, simpleFields, userTypeFields, lookUpFields, additionalExpandFields) {
|
51
51
|
var _this = this;
|
52
52
|
// items: any[];
|
53
53
|
this.top = 100;
|
@@ -55,6 +55,7 @@ var List = /** @class */ (function () {
|
|
55
55
|
this.simpleFields = [];
|
56
56
|
this.userTypeFields = [];
|
57
57
|
this.lookUpFields = [];
|
58
|
+
this.additionalExpandFields = [];
|
58
59
|
this.filters = "";
|
59
60
|
this.upperId = 0;
|
60
61
|
this.lowerId = 0;
|
@@ -360,6 +361,7 @@ var List = /** @class */ (function () {
|
|
360
361
|
var selectFields = "";
|
361
362
|
var userTypeFields = [];
|
362
363
|
var lookUpFields = [];
|
364
|
+
var additionalExpandFields = [];
|
363
365
|
if (_this.userTypeFields.length > 0) {
|
364
366
|
for (var i = 0; i < _this.userTypeFields.length; i++) {
|
365
367
|
userTypeFields.push("".concat(_this.userTypeFields[i], "Id"));
|
@@ -377,7 +379,12 @@ var List = /** @class */ (function () {
|
|
377
379
|
lookUpFields.push("".concat(_this.lookUpFields[i], "/Title"));
|
378
380
|
}
|
379
381
|
}
|
380
|
-
|
382
|
+
if (_this.additionalExpandFields.length > 0) {
|
383
|
+
for (var i = 0; i < _this.additionalExpandFields.length; i++) {
|
384
|
+
additionalExpandFields.push(_this.additionalExpandFields[i]);
|
385
|
+
}
|
386
|
+
}
|
387
|
+
selectFields = (__spreadArray(__spreadArray(__spreadArray(__spreadArray([], _this.simpleFields, true), userTypeFields, true), lookUpFields, true), additionalExpandFields, true) || []).join(",");
|
381
388
|
return selectFields;
|
382
389
|
};
|
383
390
|
this.getSelectFieldsForGraphApi = function () {
|
@@ -405,6 +412,7 @@ var List = /** @class */ (function () {
|
|
405
412
|
this.simpleFields = simpleFields || [];
|
406
413
|
this.userTypeFields = userTypeFields || [];
|
407
414
|
this.lookUpFields = lookUpFields || [];
|
415
|
+
this.additionalExpandFields = additionalExpandFields || [];
|
408
416
|
this.repository = new Repository_1.default(this.context.spContext, listName);
|
409
417
|
}
|
410
418
|
List.prototype.loadMoreIndexed = function () {
|