@mikezimm/npmfunctions
Version:
Functions used in my SPFx webparts
56 lines • 2.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDateFromDetails = exports.processSharedItems = exports.sharedWithExpand = exports.sharedWithSelect = void 0;
exports.sharedWithSelect = ["SharedWithUsers/Title", "SharedWithUsers/Name", "SharedWithUsers/Id", "SharedWithDetails"];
exports.sharedWithExpand = ['SharedWithUsers'];
function processSharedItems(items) {
items.map(function (item) {
if (item.SharedWithDetails) {
if (item.SharedWithUsers) {
item.SharedWithUsers.map(function (user) {
delete user['odata.type']; //Not needed
delete user['odata.id']; //Not needed
});
}
item.SharedDetails = JSON.parse(item.SharedWithDetails);
item.sharedEvents = Object.keys(item.SharedDetails).map(function (shareKey) {
//This splits the Name prop which looks like this: "Name":"i:0#.f|membership|first.lastName@tenant.com"
var keys = shareKey.split('|');
var detail = item.SharedDetails[shareKey];
var SharedTime = getDateFromDetails(detail.DateTime);
return {
key: shareKey,
keys: keys,
sharedWith: keys[2],
sharedBy: detail.LoginName,
DateTime: detail.DateTime,
LoginName: detail.LoginName,
TimeMS: SharedTime ? SharedTime.getTime() : null,
SharedTime: SharedTime,
// Removed these items brought in from Pivot Tiles
// GUID: item.GUID ,
// odataEditLink: item.odataEditLink ,
// AuthorId: item.AuthorId ,
// Created: item.Created ,
FileRef: item.FileRef,
FileLeafRef: item.FileLeafRef,
FileSystemObjectType: item.FileSystemObjectType,
// Modified: item.Modified ,
// EditorId: item.EditorId ,
// CheckoutUserId: item.CheckoutUserId ,
};
});
}
});
return items;
}
exports.processSharedItems = processSharedItems;
//SEND THIS TO npmFunctions
function getDateFromDetails(details) {
var re = /-?\d+/;
var m = re.exec(details);
var d = m ? new Date(parseInt(m[0])) : null;
return d;
}
exports.getDateFromDetails = getDateFromDetails;
//# sourceMappingURL=SharingFunctions2.js.map