Мне нужна помощь в получении этого кода JS (Team Directory) для отображения всех сотрудников, которые находятся в шаблоне списка SharePoint.
В настоящее время на странице SharePoint отображаются только 3 человека. Не уверен, как заставить других сотрудников отображаться на странице. Другие сотрудники, которые не появляются;у них разные коды команд.
var DCMA = window.DCMA || {};
DCMA.Team = DCMA.Team || {};
DCMA.Common = DCMA.Common || {};
ExecuteOrDelayUntilBodyLoaded(function() {
/*********************************************************/
/************ BEGIN CONFIGS ************/
/*********************************************************/
var appConfigs = {
'teamName': 'CMD', /* Empty string by default...it will be changed below */
'teamCode': 'P8-WC', /* Empty string by default...it will be changed below */
'listLocation': '/CMO/P8-WC', /* Change to the relative path to your list (no trailing slash) */
'listName': 'empList', /* Change to your list name */
'imageLocation': '/CMO/P8-WC/SiteAssets/images/', /* Change this path (add trailing slash) */
'version': 2.0 /* Do NOT Change */
}
/*********************************************************/
/************ END CONFIGS ************/
/*********************************************************/
/*********************************************************/
/************ PARSE URL BEGIN ************/
/*********************************************************/
// The appConfigs above are defaults...here is where the team parameter is extracted and evaluated.
// Based on the value, the appConfigs.teamCode and appConfigs.teamName are changed appropriately.
var param = DCMA.Common.getParameterByName('team');
if (param === null || param === undefined) {
param = 'WC'; // Default team code in case the parameter is missing or invalid
}
// Change the codes below for your organization.
switch (param.toUpperCase()) {
case 'WCD':
appConfigs.teamCode = 'P8-WCD';
appConfigs.teamName = 'Command'
break;
case 'WCA':
appConfigs.teamCode = 'P8-WCA';
appConfigs.teamName = 'Contracts'
break;
case 'WCE':
appConfigs.teamCode = 'P8-WCE';
appConfigs.teamName = 'Technical'
break;
case 'WCF':
appConfigs.teamCode = 'P8-WCF';
appConfigs.teamName = 'Mission Support'
break;
case 'WCQ':
appConfigs.teamCode = 'P8-WCQ';
appConfigs.teamName = 'Quality'
break;
default:
appConfigs.teamCode = 'P8-WCD';
appConfigs.teamName = 'Command'
};
/*********************************************************/
/************ PARSE URL END ************/
/*********************************************************/
/* Get the page name */
JSRequest.EnsureSetup();
var page = JSRequest.FileName;
var pageTitle = page.split('.');
/* Change the Page Title to something more reader friendly */
var titleElem = document.querySelector('[title=' + pageTitle[0] + ']>a');
titleElem.textContent = 'Meet Your ' + appConfigs.teamName + ' Team!';
/* Get the data and generate the list */
DCMA.Team.generateEmployeeList(appConfigs);
/* Create the Office-Fabric-UI Persona Elements */
DCMA.Team.wireUpPersonas();
});
//////////////////////////////////////////////////////////////////////////////////////////
// Retrieve Employee Data using REST
DCMA.Team.getEmployeeData = function (opts) {
var empListLocation = opts.listLocation;
var empListName = opts.listName;
var empTeamCode = opts.teamCode;
/* Generate the REST URL */
var empUrl = empListLocation + "/_api/web/lists/";
empUrl += "GetByTitle('" + empListName + "')/items?";
empUrl += "$select=ID, Title, empFirstName, empSalutation, empAvatar, empPosition, empOfficePhone, empCellPhone, empEmailAddress, empDuties, empRole";
empUrl += "&$orderby=empRole, empIsChief desc, Title asc";
empUrl += '&$filter=(empTeam eq \'' + empTeamCode + '\')';
var empData = [];
$.ajax({
url: encodeURI(empUrl),
type: "GET",
dataType: "json",
async: false,
headers: {
"accept": "application/json; odata=verbose",
},
success: function(data) {
empData = data.d.results;
},
error: function(err) {
console.log(err);
}
});
//console.log(empData);
return empData;
}
DCMA.Team.generateEmployeeList = function(opts) {
var empImageLocation = opts.imageLocation;
/* Get the data via REST call */
var employeeData = DCMA.Team.getEmployeeData(opts);
var emp = emp || {};
document.getElementById('empList').appendChild(document.createElement('br'));
for (var i=0; i<employeeData.length; i++) {
emp = employeeData[i];
var vModalID = 'modal' + emp.ID;
var modalSelector = '#modal' + emp.ID;
var avatarPic = empImageLocation + emp.empAvatar;
//Main Persona DIV
var personaDiv = document.createElement('div');
personaDiv.className = 'ms-Persona ms-Persona--lg';
// Create and append the Image DIV
var imageAreaDiv = document.createElement('div');
imageAreaDiv.className = 'ms-Persona-imageArea';
var personaImage = document.createElement('img');
personaImage.className = 'ms-Persona-image';
personaImage.setAttribute('src',avatarPic);
imageAreaDiv.appendChild(personaImage);
personaDiv.appendChild(imageAreaDiv);
// Create and append the Details DIV
var empFullName = emp.empSalutation + ' ' + emp.empFirstName + ' ' + emp.Title;
var detailsDiv = document.createElement('div');
detailsDiv.className = 'ms-Persona-details';
detailsDiv.setAttribute('rel','personaDiv' + emp.ID);
var nameDiv = document.createElement('div');
nameDiv.className = 'ms-Persona-primaryText';
nameDiv.textContent = empFullName;
var positionDiv = document.createElement('div');
positionDiv.className = 'ms-Person-secondaryText';
positionDiv.innerHTML = emp.empPosition;
var contactDiv = document.createElement('div');
contactDiv.className = 'ms-Persona-tertiaryText';
var contactInformation = '<i class="ms-Icon ms-Icon--Phone"></i>  ' + emp.empOfficePhone.substr(emp.empOfficePhone.indexOf(' '));
contactInformation += '<span class="orangedivider"> || </span><i class="ms-Icon ms-Icon--Mail"></i>  <a href="mailto:';
contactInformation += emp.empEmailAddress + '">'+ emp.empEmailAddress + '</a>';
contactInformation += '<span class="orangedivider"> || </span><i class="far fa-address-card"></i>  ';
contactInformation += '<a style="cursor: Pointer" onclick=\'openModal("' + vModalID + '","' + empFullName + '");\'>About Me</a>';
contactDiv.innerHTML = contactInformation;
detailsDiv.appendChild(nameDiv);
detailsDiv.appendChild(positionDiv);
detailsDiv.appendChild(contactDiv);
personaDiv.appendChild(detailsDiv);
var employeeDutiesDiv = document.createElement('div');
employeeDutiesDiv.setAttribute('id',vModalID);
var dutiesHTML = '<div class="ms-Persona ms-Persona--xl"><div class="ms-Persona-imageArea">';
dutiesHTML += '<img class="ms-Persona-image" src="' + avatarPic + '"></div><div class="ms-Persona-details">';
employeeDutiesDiv.innerHTML = dutiesHTML + emp.empDuties + '</div></div>';
document.getElementById('empDetails').appendChild(employeeDutiesDiv);
// Now add these elements to the page
document.getElementById('empList').appendChild(personaDiv);
if (i != employeeData.length) {
document.getElementById('empList').appendChild(document.createElement('br'));
}
}
}
DCMA.Team.wireUpPersonas = function() {
// Cycle through elements and create the Office-Fabric-UI Persona Elements
var PersonaElements = document.querySelectorAll('.ms-Persona');
for (var k = 0; k < PersonaElements.length; k++) {
new fabric['Persona'](PersonaElements[k]);
}
}
// Function to open the 'About Me' modal dialog
function openModal(pElement, pTitle) {
var e = document.getElementById(pElement);
var options = {
title: pTitle,
width: 1200,
//height: 800, //Comment out if you want dynamic height based on content.
html: e.cloneNode(true),
dialogReturnValueCallback: dialogCallback};
SP.UI.ModalDialog.showModalDialog(options);
}
function dialogCallback (dialogResult, returnValue) {
}