NewPath-Consulting / warm

Pro Reports for Wild Apricot is a Google Data Studio connector that helps Wild Apricot administrators understand your organization’s membership engagement, renewal rates, and demographics. Trend your revenue and get expense analyses. Whatever your question, enjoy all the organized data you need at your fingertips to make the business decisions want.
https://newpathconsulting.com/warm
GNU General Public License v3.0
6 stars 4 forks source link

Return a proper list of admin roles for contacts object #87

Open asirota opened 3 years ago

asirota commented 3 years ago

Reference to enhancement request

The administrator role end point needs to have a comma delimited list, in alphabetical order of all admin roles granted.

Currently the admin role is assigned a hard coded value for administrator (full access) no matter what the admin roles are.

Here's an example structure that should be flattened into an alphabetical sorted string delimited with commas.

{ "FieldName": "Administrator role", "Value": [ { "Id": 2, "Label": "Membership manager" }, { "Id": 4, "Label": "Event manager" }, { "Id": 16, "Label": "Restricted website editor" }, { "Id": 32, "Label": "Newsletter manager" }, { "Id": 64, "Label": "Online store manager" } ], "SystemCode": "AdminRole" }

asirota commented 3 years ago

Could use this array Walker

case "Groupparticipation":
                var result = "";
                member.FieldValues.forEach(function(e) {
                  if (e.SystemCode === "Groups") {
                    var values = e.Value;
                    for (var j = 0; j < values.length; j++) {
                      var value = values[j].Label;
                      result += (value || null) + ", ";
                    }
                  }
                });
                row.push(result.substring(0, result.length - 2));
                break;
asirota commented 3 years ago

Use this code snippet to create comma separated string

var arrayObjects = [
  {
    property1: "A",
    property2: "1"
  },
  {
    property1: "B",
    property2: "2"
  },
  {
    property1: "C",
    property2: "3"
  }
];

Array.prototype.map.call(arrayObjects, function(item) { return item.property1; }).join(",");