Add MemberManage dashboard
This commit is contained in:
@@ -0,0 +1,720 @@
|
||||
/**
|
||||
* @ngdoc controller
|
||||
* @name MemberManager.List.ViewController
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* The controller for the member list view
|
||||
*
|
||||
* @param {object} $scope Scope
|
||||
* @param {object} $routeParams Route Parameters
|
||||
* @param {object} $timeout Timeout
|
||||
* @param {object} $location Location
|
||||
* @param {object} memberResource Member Resource
|
||||
* @param {object} memberExtResource Member Extension Resource (custom)
|
||||
* @param {object} memberTypeResource Member Type Resource
|
||||
* @param {object} notificationsService Notifications Service
|
||||
* @param {object} iconHelper Icon Helper
|
||||
* @param {object} dialogService Dialog Service
|
||||
* @param {object} editorState Editor State
|
||||
* @param {object} localizationService Localisation Service
|
||||
* @param {object} listViewHelper Listview Helper
|
||||
*/
|
||||
function memberListViewController($scope, $routeParams, $timeout, $location, memberResource, memberExtResource, memberTypeResource, notificationsService, iconHelper, dialogService, editorState, localizationService, listViewHelper) {
|
||||
|
||||
var deleteItemCallback, getIdCallback, createEditUrlCallback;
|
||||
|
||||
$scope.model = {};
|
||||
$scope.model.config = {
|
||||
pageSize: 100,
|
||||
orderBy: 'Name',
|
||||
orderDirection: 'asc',
|
||||
includeProperties: [
|
||||
{ alias: 'email', header: 'Email', isSystem: 1 },
|
||||
{ alias: 'memberGroups', header: 'Group', isSystem: 1 },
|
||||
{ alias: 'firstName', header: 'First Name', isSystem: 0 },
|
||||
{ alias: 'lastName', header: 'Last Name', isSystem: 0 },
|
||||
{ alias: 'phone', header: 'Phone', isSystem: 0 },
|
||||
{ alias: 'isApproved', header: 'Approved', isSystem: 1 },
|
||||
{ alias: 'isLockedOut', header: 'Locked Out', isSystem: 1 }
|
||||
],
|
||||
layouts: [
|
||||
{ name: 'List', path: 'views/propertyeditors/listview/layouts/list/list.html', icon: 'icon-list', isSystem: 1, selected: true }
|
||||
],
|
||||
bulkActionPermissions: {
|
||||
allowBulkDelete: true,
|
||||
allowExport: true
|
||||
}
|
||||
};
|
||||
|
||||
$scope.currentNodePermissions = null;
|
||||
|
||||
if (editorState.current) {
|
||||
//Fetch current node allowed actions for the current user
|
||||
//This is the current node & not each individual child node in the list
|
||||
var currentUserPermissions = editorState.current.allowedActions;
|
||||
|
||||
//Create a nicer model rather than the funky & hard to remember permissions strings
|
||||
$scope.currentNodePermissions = {
|
||||
"canCopy": _.contains(currentUserPermissions, 'O'), //Magic Char = O
|
||||
"canCreate": _.contains(currentUserPermissions, 'C'), //Magic Char = C
|
||||
"canDelete": _.contains(currentUserPermissions, 'D'), //Magic Char = D
|
||||
"canMove": _.contains(currentUserPermissions, 'M'), //Magic Char = M
|
||||
};
|
||||
}
|
||||
|
||||
$scope.entityType = "member";
|
||||
$scope.memberGroups = null;
|
||||
|
||||
getContentTypesCallback = memberTypeResource.getTypes;
|
||||
deleteItemCallback = memberResource.deleteByKey;
|
||||
getIdCallback = function (selected) {
|
||||
return selected.key;
|
||||
};
|
||||
createEditUrlCallback = function (item) {
|
||||
return "/" + $scope.entityType + "/" + $scope.entityType + "/edit/" + item.key;
|
||||
};
|
||||
|
||||
$scope.pagination = [];
|
||||
$scope.isNew = false;
|
||||
$scope.actionInProgress = false;
|
||||
$scope.selection = [];
|
||||
$scope.folders = [];
|
||||
$scope.listViewResultSet = {
|
||||
totalPages: 0,
|
||||
items: []
|
||||
};
|
||||
|
||||
$scope.createAllowedButtonSingle = false;
|
||||
$scope.createAllowedButtonMulti = false;
|
||||
|
||||
$scope.options = {
|
||||
pageSize: $scope.model.config.pageSize ? $scope.model.config.pageSize : 10,
|
||||
pageNumber: $routeParams.page && !isNaN($routeParams.page) && Number($routeParams.page) > 0 ? $routeParams.page : 1,
|
||||
filterData: {
|
||||
filter: null
|
||||
},
|
||||
orderBy: ($scope.model.config.orderBy ? $scope.model.config.orderBy : 'Name').trim(),
|
||||
orderDirection: $scope.model.config.orderDirection ? $scope.model.config.orderDirection.trim() : "asc",
|
||||
orderBySystemField: true,
|
||||
includeProperties: $scope.model.config.includeProperties ? $scope.model.config.includeProperties : [
|
||||
{ alias: 'updateDate', header: 'Last edited', isSystem: 1 },
|
||||
{ alias: 'updater', header: 'Last edited by', isSystem: 1 }
|
||||
],
|
||||
layout: {
|
||||
layouts: $scope.model.config.layouts,
|
||||
activeLayout: listViewHelper.getLayout($routeParams.id, $scope.model.config.layouts)
|
||||
},
|
||||
allowBulkDelete: $scope.model.config.bulkActionPermissions.allowBulkDelete,
|
||||
allowExport: $scope.model.config.bulkActionPermissions.allowExport
|
||||
};
|
||||
|
||||
// Check if selected order by field is actually custom field
|
||||
for (var j = 0; j < $scope.options.includeProperties.length; j++) {
|
||||
var includedProperty = $scope.options.includeProperties[j];
|
||||
if (includedProperty.alias.toLowerCase() === $scope.options.orderBy.toLowerCase()) {
|
||||
$scope.options.orderBySystemField = includedProperty.isSystem === 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//update all of the system includeProperties to enable sorting
|
||||
_.each($scope.options.includeProperties, function (e, i) {
|
||||
|
||||
//NOTE: special case for contentTypeAlias, it's a system property that cannot be sorted
|
||||
// to do that, we'd need to update the base query for content to include the content type alias column
|
||||
// which requires another join and would be slower. BUT We are doing this for members so not sure it makes a diff?
|
||||
if (e.alias !== "contentTypeAlias") {
|
||||
e.allowSorting = true;
|
||||
}
|
||||
|
||||
if (e.isSystem) {
|
||||
//localize the header
|
||||
var key = getLocalizedKey(e.alias);
|
||||
localizationService.localize(key).then(function (v) {
|
||||
e.header = v;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function showNotificationsAndReset(err, reload, successMsg) {
|
||||
|
||||
//check if response is ysod
|
||||
if (err.status && err.status >= 500) {
|
||||
|
||||
// Open ysod overlay
|
||||
$scope.ysodOverlay = {
|
||||
view: "ysod",
|
||||
error: err,
|
||||
show: true
|
||||
};
|
||||
}
|
||||
|
||||
$timeout(function () {
|
||||
$scope.bulkStatus = "";
|
||||
$scope.actionInProgress = false;
|
||||
},
|
||||
500);
|
||||
|
||||
if (reload === true) {
|
||||
$scope.reloadView();
|
||||
}
|
||||
|
||||
if (err.data && angular.isArray(err.data.notifications)) {
|
||||
for (var i = 0; i < err.data.notifications.length; i++) {
|
||||
notificationsService.showNotification(err.data.notifications[i]);
|
||||
}
|
||||
} else if (successMsg) {
|
||||
localizationService.localize("bulk_done")
|
||||
.then(function (v) {
|
||||
notificationsService.success(v, successMsg);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$scope.next = function (pageNumber) {
|
||||
$scope.options.pageNumber = pageNumber;
|
||||
$scope.reloadView();
|
||||
};
|
||||
|
||||
$scope.goToPage = function (pageNumber) {
|
||||
$scope.options.pageNumber = pageNumber;
|
||||
$scope.reloadView();
|
||||
};
|
||||
|
||||
$scope.prev = function (pageNumber) {
|
||||
$scope.options.pageNumber = pageNumber;
|
||||
$scope.getContent();
|
||||
};
|
||||
|
||||
$scope.isSortDirection = function (col, direction) {
|
||||
return $scope.options.orderBy.toUpperCase() === col.toUpperCase() && $scope.options.orderDirection === direction;
|
||||
};
|
||||
|
||||
$scope.sort = function (field) {
|
||||
|
||||
$scope.options.orderBy = field;
|
||||
|
||||
if ($scope.options.orderDirection === "desc") {
|
||||
$scope.options.orderDirection = "asc";
|
||||
} else {
|
||||
$scope.options.orderDirection = "desc";
|
||||
}
|
||||
|
||||
$scope.reloadView();
|
||||
};
|
||||
|
||||
$scope.getContent = function (contentId) {
|
||||
$scope.reloadView();
|
||||
};
|
||||
|
||||
/*Loads the search results, based on parameters set in prev,next,sort and so on*/
|
||||
/*Pagination is done by an array of objects, due angularJS's funky way of monitoring state
|
||||
with simple values */
|
||||
|
||||
$scope.reloadView = function () {
|
||||
$scope.viewLoaded = false;
|
||||
$scope.folders = [];
|
||||
|
||||
listViewHelper.clearSelection($scope.listViewResultSet.items, $scope.folders, $scope.selection);
|
||||
|
||||
memberExtResource.getMembers($scope.options).then(function (data) {
|
||||
|
||||
$scope.actionInProgress = false;
|
||||
$scope.listViewResultSet = data;
|
||||
|
||||
//update all values for display
|
||||
if ($scope.listViewResultSet.items) {
|
||||
_.each($scope.listViewResultSet.items, function (e, index) {
|
||||
setPropertyValues(e);
|
||||
});
|
||||
}
|
||||
|
||||
$scope.viewLoaded = true;
|
||||
|
||||
//NOTE: This might occur if we are requesting a higher page number than what is actually available, for example
|
||||
// if you have more than one page and you delete all items on the last page. In this case, we need to reset to the last
|
||||
// available page and then re-load again
|
||||
if ($scope.options.pageNumber > $scope.listViewResultSet.totalPages) {
|
||||
$scope.options.pageNumber = $scope.listViewResultSet.totalPages;
|
||||
|
||||
//reload!
|
||||
$scope.reloadView();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
var searchListView = _.debounce(function () {
|
||||
$scope.$apply(function () {
|
||||
makeSearch();
|
||||
});
|
||||
}, 500);
|
||||
|
||||
$scope.forceSearch = function (ev) {
|
||||
//13: enter
|
||||
switch (ev.keyCode) {
|
||||
case 13:
|
||||
makeSearch();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.enterSearch = function () {
|
||||
$scope.viewLoaded = false;
|
||||
searchListView();
|
||||
};
|
||||
|
||||
function makeSearch() {
|
||||
if ($scope.options.filterData.filter !== null && $scope.options.filterData.filter !== undefined) {
|
||||
$scope.options.pageNumber = 1;
|
||||
$scope.getContent();
|
||||
}
|
||||
}
|
||||
|
||||
$scope.isAnythingSelected = function () {
|
||||
if ($scope.selection.length === 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.selectedItemsCount = function () {
|
||||
return $scope.selection.length;
|
||||
};
|
||||
|
||||
$scope.clearSelection = function () {
|
||||
listViewHelper.clearSelection($scope.listViewResultSet.items, $scope.folders, $scope.selection);
|
||||
};
|
||||
|
||||
$scope.getIcon = function (entry) {
|
||||
return iconHelper.convertFromLegacyIcon(entry.icon);
|
||||
};
|
||||
|
||||
function serial(selected, fn, getStatusMsg, index) {
|
||||
return fn(selected, index).then(function (content) {
|
||||
index++;
|
||||
$scope.bulkStatus = getStatusMsg(index, selected.length);
|
||||
return index < selected.length ? serial(selected, fn, getStatusMsg, index) : content;
|
||||
}, function (err) {
|
||||
var reload = index > 0;
|
||||
showNotificationsAndReset(err, reload);
|
||||
return err;
|
||||
});
|
||||
}
|
||||
|
||||
function applySelected(fn, getStatusMsg, getSuccessMsg, confirmMsg) {
|
||||
var selected = $scope.selection;
|
||||
if (selected.length === 0)
|
||||
return;
|
||||
if (confirmMsg && !confirm(confirmMsg))
|
||||
return;
|
||||
|
||||
$scope.actionInProgress = true;
|
||||
$scope.bulkStatus = getStatusMsg(0, selected.length);
|
||||
|
||||
return serial(selected, fn, getStatusMsg, 0).then(function (result) {
|
||||
// executes once the whole selection has been processed
|
||||
// in case of an error (caught by serial), result will be the error
|
||||
if (!(result.data && angular.isArray(result.data.notifications)))
|
||||
showNotificationsAndReset(result, true, getSuccessMsg(selected.length));
|
||||
});
|
||||
}
|
||||
|
||||
function getCustomPropertyValue(alias, properties) {
|
||||
var value = '';
|
||||
var index = 0;
|
||||
var foundAlias = false;
|
||||
for (var i = 0; i < properties.length; i++) {
|
||||
if (properties[i].alias === alias) {
|
||||
foundAlias = true;
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
if (foundAlias) {
|
||||
value = properties[index].value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/** This ensures that the correct value is set for each item in a row, we don't want to call a function during interpolation or ng-bind as performance is really bad that way */
|
||||
|
||||
function setPropertyValues(result) {
|
||||
|
||||
//set the edit url
|
||||
result.editPath = createEditUrlCallback(result);
|
||||
|
||||
_.each($scope.options.includeProperties, function (e, i) {
|
||||
|
||||
var alias = e.alias;
|
||||
|
||||
// First try to pull the value directly from the alias (e.g. updatedBy)
|
||||
var value = result[alias];
|
||||
|
||||
// If we have IsApproved or IsLocked, then customise the display.
|
||||
if (alias === "isLockedOut") {
|
||||
value = getLockedDescription(value);
|
||||
}
|
||||
if (alias === "isApproved") {
|
||||
value = getSuspendedDescription(value);
|
||||
}
|
||||
|
||||
// if we have an array, then concat all values separated by comma
|
||||
if (Array.isArray(value) && value.length > 0) {
|
||||
value = _.reduce(value, function (memo, val) { return memo + ', ' + val; });
|
||||
}
|
||||
|
||||
// If this returns an object, look for the name property of that (e.g. owner.name)
|
||||
if (value === Object(value)) {
|
||||
value = value['name'];
|
||||
}
|
||||
|
||||
// If we've got nothing yet, look at a user defined property
|
||||
if (typeof value === 'undefined') {
|
||||
value = getCustomPropertyValue(alias, result.properties);
|
||||
}
|
||||
|
||||
// If we have a date, format it
|
||||
if (isDate(value)) {
|
||||
value = value.substring(0, value.length - 3);
|
||||
}
|
||||
|
||||
// set what we've got on the result
|
||||
result[alias] = value;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function isDate(val) {
|
||||
if (angular.isString(val)) {
|
||||
return val.match(/^(\d{4})\-(\d{2})\-(\d{2})\ (\d{2})\:(\d{2})\:(\d{2})$/);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function initView() {
|
||||
//default to root id if the id is undefined
|
||||
var id = $routeParams.id;
|
||||
if (id === undefined) {
|
||||
id = -1;
|
||||
}
|
||||
|
||||
memberExtResource.getMemberGroups().then(function (groups) {
|
||||
$scope.memberGroups = groups;
|
||||
});
|
||||
|
||||
getContentTypesCallback(id).then(function (listViewAllowedTypes) {
|
||||
$scope.listViewAllowedTypes = listViewAllowedTypes;
|
||||
$scope.createAllowedButtonSingle = listViewAllowedTypes.length === 1;
|
||||
$scope.createAllowedButtonMulti = listViewAllowedTypes.length > 1;
|
||||
});
|
||||
|
||||
$scope.contentId = id;
|
||||
$scope.isTrashed = id === "-20" || id === "-21";
|
||||
|
||||
if ($scope.options.allowExport) {
|
||||
memberExtResource.canExport().then(function (result) {
|
||||
$scope.options.allowExport = result;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.options.bulkActionsAllowed = $scope.options.allowBulkDelete;
|
||||
|
||||
$scope.getContent();
|
||||
}
|
||||
|
||||
function getLocalizedKey(alias) {
|
||||
|
||||
switch (alias) {
|
||||
case "updateDate":
|
||||
return "content_updateDate";
|
||||
case "createDate":
|
||||
return "content_createDate";
|
||||
case "contentTypeAlias":
|
||||
return "content_membertype";
|
||||
case "email":
|
||||
return "general_email";
|
||||
case "username":
|
||||
return "general_username";
|
||||
case "memberGroups":
|
||||
return "general_memberGroups";
|
||||
}
|
||||
return alias;
|
||||
}
|
||||
|
||||
$scope.createBlank = function (entityType, docTypeAlias) {
|
||||
$location
|
||||
.path("/" + entityType + "/" + entityType + "/edit/")
|
||||
.search("doctype=" + docTypeAlias + "&create=true");
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
var confirmDeleteText = "";
|
||||
|
||||
localizationService.localize("defaultdialogs_confirmdelete")
|
||||
.then(function (value) {
|
||||
confirmDeleteText = value;
|
||||
|
||||
var attempt =
|
||||
applySelected(
|
||||
function (selected, index) { return deleteItemCallback(getIdCallback(selected[index])); },
|
||||
function (count, total) {
|
||||
var key = (total === 1 ? "bulk_deletedItemOfItem" : "bulk_deletedItemOfItems");
|
||||
return localizationService.localize(key, [count, total]);
|
||||
},
|
||||
function (total) {
|
||||
var key = (total === 1 ? "bulk_deletedItem" : "bulk_deletedItems");
|
||||
return localizationService.localize(key, [total]);
|
||||
},
|
||||
confirmDeleteText + "?");
|
||||
});
|
||||
};
|
||||
|
||||
$scope.canUnlock = function () {
|
||||
if (!angular.isArray($scope.selection)) {
|
||||
return false;
|
||||
}
|
||||
return _.some($scope.selection, function (item) {
|
||||
return !isUnlocked(item);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$scope.canApprove = function () {
|
||||
if (!angular.isArray($scope.selection)) {
|
||||
return false;
|
||||
}
|
||||
return _.some($scope.selection, function (item) {
|
||||
return isSuspended(item);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$scope.canSuspend = function () {
|
||||
if (!angular.isArray($scope.selection)) {
|
||||
return false;
|
||||
}
|
||||
return _.some($scope.selection, function (item) {
|
||||
return isApproved(item);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
isSuspended = function (item) {
|
||||
return _.some($scope.listViewResultSet.items, function (member) {
|
||||
if (member.key === item.key)
|
||||
return member.isApproved === 'Suspended';
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
isApproved = function (item) {
|
||||
return _.some($scope.listViewResultSet.items, function (member) {
|
||||
if (member.key === item.key)
|
||||
return member.isApproved === 'Approved';
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
isUnlocked = function (item) {
|
||||
return _.some($scope.listViewResultSet.items, function (member) {
|
||||
if (member.key === item.key)
|
||||
return member.isLockedOut === 'Unlocked';
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
getLockedIcon = function (locked) {
|
||||
return locked ? 'icon-lock color-red' : 'icon-unlocked color-green';
|
||||
};
|
||||
|
||||
getSuspendedIcon = function (approved) {
|
||||
return approved ? 'icon-check color-green' : 'icon-block color-red';
|
||||
};
|
||||
|
||||
getLockedDescription = function (locked) {
|
||||
return locked ? 'Locked Out' : 'Unlocked';
|
||||
};
|
||||
|
||||
getSuspendedDescription = function (approved) {
|
||||
return approved ? 'Approved' : 'Suspended';
|
||||
};
|
||||
|
||||
$scope.export = function () {
|
||||
dialogService.closeAll();
|
||||
dialogService.open({
|
||||
template: '/app_plugins/MemberManager/backoffice/dialogs/member/export.html',
|
||||
closeOnSave: false,
|
||||
filterData: $scope.options.filterData,
|
||||
memberTypes: $scope.listViewAllowedTypes,
|
||||
memberGroups: $scope.memberGroups,
|
||||
totalItems: $scope.listViewResultSet.totalItems,
|
||||
columns: $scope.options.columns,
|
||||
callback: function (columns) {
|
||||
$scope.options.columns = columns;
|
||||
memberExtResource.getMemberExport($scope.options);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.unlock = function () {
|
||||
var confirmUnlockText = "";
|
||||
|
||||
localizationService.localize("memberManager_confirmUnlock")
|
||||
.then(function (value) {
|
||||
confirmUnlockText = value;
|
||||
|
||||
let tmpSelected = $scope.selected;
|
||||
$scope.selected = _.filter(tmpSelected, function (item) { return isUnlocked(item); });
|
||||
var attempt =
|
||||
applySelected(
|
||||
function (selected, index) { return memberExtResource.unlockById(getIdCallback(selected[index])); },
|
||||
function (count, total) {
|
||||
var key = total === 1 ? "bulk_unlockItemOfItem" : "bulk_unlockItemOfItems";
|
||||
return localizationService.localize(key, [count, total]);
|
||||
},
|
||||
function (total) {
|
||||
var key = total === 1 ? "bulk_unlockedItem" : "bulk_unlockedItems";
|
||||
return localizationService.localize(key, [total]);
|
||||
},
|
||||
confirmUnlockText + "?");
|
||||
if (attempt) {
|
||||
attempt.then(function () {
|
||||
$timeout($scope.getContent, 1000);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.approve = function () {
|
||||
var confirmApproveText = "";
|
||||
|
||||
localizationService.localize("memberManager_confirmApprove")
|
||||
.then(function (value) {
|
||||
confirmApproveText = value;
|
||||
|
||||
let tmpSelected = $scope.selected;
|
||||
$scope.selected = _.filter(tmpSelected, function (item) { return isApproved(item); });
|
||||
|
||||
var attempt =
|
||||
applySelected(
|
||||
function (selected, index) { return memberExtResource.approveById(getIdCallback(selected[index])); },
|
||||
function (count, total) {
|
||||
var key = total === 1 ? "bulk_approveItemOfItem" : "bulk_approveItemOfItems";
|
||||
return localizationService.localize(key, [count, total]);
|
||||
},
|
||||
function (total) {
|
||||
var key = total === 1 ? "bulk_approvedItem" : "bulk_approvedItems";
|
||||
return localizationService.localize(key, [total]);
|
||||
},
|
||||
confirmApproveText + "?");
|
||||
if (attempt) {
|
||||
attempt.then(function () {
|
||||
$timeout($scope.getContent, 1000);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.suspend = function () {
|
||||
var confirmSuspendText = "";
|
||||
|
||||
let tmpSelected = $scope.selected;
|
||||
$scope.selected = _.filter(tmpSelected, function (item) { return isSuspended(item); });
|
||||
|
||||
localizationService.localize("memberManager_confirmSuspend")
|
||||
.then(function (value) {
|
||||
confirmSuspendText = value;
|
||||
|
||||
var attempt =
|
||||
applySelected(
|
||||
function (selected, index) { return memberExtResource.suspendById(getIdCallback(selected[index])); },
|
||||
function (count, total) {
|
||||
var key = total === 1 ? "bulk_suspendItemOfItem" : "bulk_suspendItemOfItems";
|
||||
return localizationService.localize(key, [count, total]);
|
||||
},
|
||||
function (total) {
|
||||
var key = total === 1 ? "bulk_suspendedItem" : "bulk_suspendedItems";
|
||||
return localizationService.localize(key, [total]);
|
||||
},
|
||||
confirmSuspendText + "?");
|
||||
if (attempt) {
|
||||
attempt.then(function () {
|
||||
$timeout($scope.getContent, 1000);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.editMember = function (key) {
|
||||
dialogService.closeAll();
|
||||
dialogService.open({
|
||||
template: '/app_plugins/MemberManager/backoffice/dialogs/member/edit.html',
|
||||
key: key,
|
||||
closeOnSave: true,
|
||||
//tabFilter: ["Generic properties"],
|
||||
callback: function (data) {
|
||||
$scope.getContent();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.clearFilter = function () {
|
||||
dialogService.closeAll();
|
||||
$scope.options.filterData = {
|
||||
filter: null
|
||||
};
|
||||
//$scope.searchDisplay = null;
|
||||
$scope.getContent();
|
||||
};
|
||||
|
||||
$scope.edit = function () {
|
||||
$scope.filterDialog = {};
|
||||
$scope.filterDialog.title = localizationService.localize("memberManager_filter");
|
||||
$scope.filterDialog.section = $scope.entityType;
|
||||
$scope.filterDialog.currentNode = $scope.contentId;
|
||||
$scope.filterDialog.view = "move";
|
||||
$scope.filterDialog.show = true;
|
||||
|
||||
$scope.moveDialog.submit = function (model) {
|
||||
|
||||
if (model.target) {
|
||||
performMove(model.target);
|
||||
}
|
||||
|
||||
$scope.moveDialog.show = false;
|
||||
$scope.moveDialog = null;
|
||||
};
|
||||
|
||||
$scope.moveDialog.close = function (oldModel) {
|
||||
$scope.moveDialog.show = false;
|
||||
$scope.moveDialog = null;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
$scope.filter = function () {
|
||||
dialogService.closeAll();
|
||||
dialogService.open({
|
||||
template: '/app_plugins/MemberManager/backoffice/dialogs/member/filter.html',
|
||||
closeOnSave: false,
|
||||
filterData: $scope.options.filterData,
|
||||
memberTypes: $scope.listViewAllowedTypes,
|
||||
memberGroups: $scope.memberGroups,
|
||||
callback: function (data) {
|
||||
$scope.options.filterData = data;
|
||||
$scope.getContent();
|
||||
}
|
||||
});
|
||||
};
|
||||
initView();
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("MemberManager.Dashboard.MemberListViewController", memberListViewController);
|
||||
@@ -0,0 +1,187 @@
|
||||
<div ng-controller="MemberManager.Dashboard.MemberListViewController" class="umb-editor umb-listview membermanager clearfix">
|
||||
<style>
|
||||
canvas {
|
||||
width: 100% !important;
|
||||
max-width: 800px;
|
||||
height: auto !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="row-fluid">
|
||||
<umb-editor-sub-header>
|
||||
<umb-editor-sub-header-content-left>
|
||||
<umb-editor-sub-header-section ng-if="(listViewAllowedTypes && listViewAllowedTypes.length > 0 && !isAnythingSelected()) && (currentNodePermissions == null || currentNodePermissions.canCreate)">
|
||||
<div class="btn-group" ng-show="createAllowedButtonSingle">
|
||||
<a class="btn" ng-click="createBlank(entityType,listViewAllowedTypes[0].alias)">
|
||||
<localize key="actions_create">Create</localize> {{listViewAllowedTypes[0].name}}
|
||||
</a>
|
||||
</div>
|
||||
<div class="btn-group" ng-show="createAllowedButtonMulti">
|
||||
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
<localize key="actions_create">Create</localize>
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li ng-repeat="contentType in listViewAllowedTypes | orderBy:'name':false">
|
||||
<a href="" ng-click="createBlank(entityType,contentType.alias)" prevent-default>
|
||||
<i class="{{contentType.icon}}"></i> {{contentType.name}}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</umb-editor-sub-header-section>
|
||||
|
||||
<umb-editor-sub-header-section ng-if="isAnythingSelected()">
|
||||
<umb-button type="button"
|
||||
label="Clear selection"
|
||||
label-key="buttons_clearSelection"
|
||||
action="clearSelection()"
|
||||
disabled="actionInProgress">
|
||||
</umb-button>
|
||||
</umb-editor-sub-header-section>
|
||||
|
||||
<umb-editor-sub-header-section ng-if="isAnythingSelected()">
|
||||
<strong ng-show="!actionInProgress">{{ selectedItemsCount() }} <localize key="general_of">of</localize> {{ listViewResultSet.items.length }} <localize key="general_selected">selected</localize></strong>
|
||||
<strong ng-show="actionInProgress" ng-bind="bulkStatus"></strong>
|
||||
|
||||
<div class="umb-loader-wrapper -bottom" ng-show="actionInProgress">
|
||||
<div class="umb-loader"></div>
|
||||
</div>
|
||||
</umb-editor-sub-header-section>
|
||||
</umb-editor-sub-header-content-left>
|
||||
<umb-editor-sub-header-content-right>
|
||||
|
||||
<umb-editor-sub-header-section ng-if="!isAnythingSelected()">
|
||||
<form class="form-search -no-margin-bottom pull-right" novalidate>
|
||||
<div class="inner-addon left-addon">
|
||||
<i class="icon icon-search" ng-click="enterSearch($event)"></i>
|
||||
<input class="form-control search-input"
|
||||
type="text"
|
||||
localize="placeholder"
|
||||
placeholder="@general_typeToSearch"
|
||||
ng-model="options.filterData.filter"
|
||||
ng-change="enterSearch()"
|
||||
ng-keydown="forceSearch($event)"
|
||||
prevent-enter-submit
|
||||
no-dirty-check>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<umb-button type="button"
|
||||
button-style="link"
|
||||
label="Filter"
|
||||
label-key="memberManager_filter"
|
||||
icon="icon-filter"
|
||||
action="filter()"
|
||||
disabled="actionInProgress">
|
||||
</umb-button>
|
||||
|
||||
<umb-button ng-if="options.filterData.display"
|
||||
type="link"
|
||||
button-style="link"
|
||||
label="Clear Filter"
|
||||
label-key="memberManager_clearFilter"
|
||||
icon="icon-block"
|
||||
action="clearFilter()"
|
||||
disabled="actionInProgress">
|
||||
</umb-button>
|
||||
</umb-editor-sub-header-section>
|
||||
|
||||
<umb-editor-sub-header-section ng-if="options.allowExport">
|
||||
<umb-button type="button"
|
||||
button-style="link"
|
||||
label="Export"
|
||||
label-key="memberManager_exportMembers"
|
||||
icon="icon-download"
|
||||
action="export()"
|
||||
disabled="actionInProgress">
|
||||
</umb-button>
|
||||
</umb-editor-sub-header-section>
|
||||
|
||||
<umb-editor-sub-header-section ng-if="isAnythingSelected()">
|
||||
<span class="umb-status-label" ng-bind="vm.bulkStatus" ng-show="vm.isAnythingSelected()"></span>
|
||||
|
||||
<umb-button ng-if="canUnlock()"
|
||||
type="button"
|
||||
button-style="link"
|
||||
label="Unlock"
|
||||
label-key="actions_unlock"
|
||||
icon="icon-unlocked color-green"
|
||||
action="unlock()"
|
||||
disabled="actionInProgress">
|
||||
</umb-button>
|
||||
|
||||
<umb-button ng-if="canApprove()"
|
||||
type="button"
|
||||
button-style="link"
|
||||
label="Approve"
|
||||
label-key="actions_approve"
|
||||
icon="icon-check color-green"
|
||||
action="approve()"
|
||||
disabled="actionInProgress">
|
||||
</umb-button>
|
||||
|
||||
<umb-button ng-if="canSuspend()"
|
||||
type="button"
|
||||
button-style="link"
|
||||
label="Suspend"
|
||||
label-key="actions_suspend"
|
||||
icon="icon-block color-red"
|
||||
action="suspend()"
|
||||
disabled="actionInProgress">
|
||||
</umb-button>
|
||||
|
||||
<umb-button ng-if="options.allowBulkDelete"
|
||||
type="button"
|
||||
button-style="link"
|
||||
label="Delete"
|
||||
label-key="actions_delete"
|
||||
icon="icon-trash color-red"
|
||||
action="delete()"
|
||||
disabled="actionInProgress">
|
||||
</umb-button>
|
||||
|
||||
</umb-editor-sub-header-section>
|
||||
|
||||
</umb-editor-sub-header-content-right>
|
||||
</umb-editor-sub-header>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="filter-display" ng-if="options.filterData.display">
|
||||
<div ng-repeat="displayFilter in options.filterData.display">
|
||||
<strong>{{displayFilter.title}}</strong>
|
||||
<span>{{displayFilter.value}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<umb-list-view-layout ng-if="viewLoaded"
|
||||
content-id=""
|
||||
folders="folders"
|
||||
items="listViewResultSet.items"
|
||||
selection="selection"
|
||||
options="options"
|
||||
entity-type="{{entityType}}"
|
||||
on-get-content="getContent">
|
||||
</umb-list-view-layout>
|
||||
|
||||
<umb-load-indicator ng-show="!viewLoaded"></umb-load-indicator>
|
||||
|
||||
<div class="flex justify-center">
|
||||
<umb-pagination ng-if="listViewResultSet.totalPages"
|
||||
page-number="options.pageNumber"
|
||||
total-pages="listViewResultSet.totalPages"
|
||||
on-next="next"
|
||||
on-prev="prev"
|
||||
on-go-to-page="goToPage">
|
||||
</umb-pagination>
|
||||
</div>
|
||||
|
||||
<umb-overlay ng-if="ysodOverlay.show"
|
||||
model="ysodOverlay"
|
||||
position="right"
|
||||
view="ysodOverlay.view">
|
||||
</umb-overlay>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* @ngdoc controller
|
||||
* @name MemberManager.Dialogs.Member.EditController
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* The controller for the member editor
|
||||
*
|
||||
* @param {any} $scope Scope
|
||||
* @param {any} $routeParams Route Parameters
|
||||
* @param {any} $q Queue
|
||||
* @param {any} memberResource Member Resource
|
||||
* @param {any} entityResource Entity Resource
|
||||
* @param {any} serverValidationManager Server Validation Manager
|
||||
* @param {any} contentEditingHelper Content Editing Helper
|
||||
* @param {any} fileManager File Manager
|
||||
* @param {any} formHelper Form Helper
|
||||
*/
|
||||
function MemberEditDialogController($scope, $routeParams, $q, memberResource, entityResource, serverValidationManager, contentEditingHelper, fileManager, formHelper) {
|
||||
//setup scope vars
|
||||
$scope.model = {};
|
||||
$scope.model.defaultButton = null;
|
||||
$scope.model.subButtons = [];
|
||||
$scope.model.nodeId = 0;
|
||||
$scope.loaded = false;
|
||||
|
||||
var dialogOptions = $scope.$parent.dialogOptions;
|
||||
|
||||
function performGet() {
|
||||
var deferred = $q.defer();
|
||||
if (angular.isObject(dialogOptions.entity)) {
|
||||
$scope.loaded = true;
|
||||
deferred.resolve(dialogOptions.entity);
|
||||
} else {
|
||||
if (dialogOptions.create) {
|
||||
//we are creating so get an empty member item
|
||||
memberResource.getScaffold(dialogOptions.contentType)
|
||||
.then(function (data) {
|
||||
|
||||
$scope.loaded = true;
|
||||
deferred.resolve(data);
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (dialogOptions.key && dialogOptions.key.toString().length < 9) {
|
||||
entityResource.getById(dialogOptions.key, "Member").then(function (entity) {
|
||||
memberResource.getByKey(entity.key).then(function (data) {
|
||||
|
||||
//in one particular special case, after we've created a new item we redirect back to the edit
|
||||
// route but there might be server validation errors in the collection which we need to display
|
||||
// after the redirect, so we will bind all subscriptions which will show the server validation errors
|
||||
// if there are any and then clear them so the collection no longer persists them.
|
||||
serverValidationManager.executeAndClearAllSubscriptions();
|
||||
$scope.loaded = true;
|
||||
|
||||
deferred.resolve(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
//we are editing so get the content item from the server
|
||||
memberResource.getByKey(dialogOptions.key)
|
||||
.then(function (data) {
|
||||
|
||||
$scope.loaded = true;
|
||||
|
||||
//in one particular special case, after we've created a new item we redirect back to the edit
|
||||
// route but there might be server validation errors in the collection which we need to display
|
||||
// after the redirect, so we will bind all subscriptions which will show the server validation errors
|
||||
// if there are any and then clear them so the collection no longer persists them.
|
||||
serverValidationManager.executeAndClearAllSubscriptions();
|
||||
|
||||
deferred.resolve(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function performSave(args) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
$scope.busy = true;
|
||||
|
||||
if (formHelper.submitForm({ scope: $scope, statusMessage: args.statusMessage })) {
|
||||
|
||||
$scope.busy = true;
|
||||
|
||||
args.saveMethod($scope.model.entity, $routeParams.create, fileManager.getFiles())
|
||||
.then(function (data) {
|
||||
|
||||
formHelper.resetForm({ scope: $scope, notifications: data.notifications });
|
||||
|
||||
contentEditingHelper.handleSuccessfulSave({
|
||||
scope: $scope,
|
||||
savedContent: data,
|
||||
rebindCallback: contentEditingHelper.reBindChangedProperties($scope.model.entity, data)
|
||||
});
|
||||
|
||||
$scope.busy = false;
|
||||
deferred.resolve(data);
|
||||
|
||||
}, function (err) {
|
||||
|
||||
contentEditingHelper.handleSaveError({
|
||||
redirectOnFailure: false,
|
||||
err: err,
|
||||
rebindCallback: contentEditingHelper.reBindChangedProperties($scope.model.entity, err.data)
|
||||
});
|
||||
|
||||
$scope.busy = false;
|
||||
deferred.reject(err);
|
||||
});
|
||||
} else {
|
||||
$scope.busy = false;
|
||||
deferred.reject();
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
performGet().then(function (content) {
|
||||
$scope.model.entity = $scope.filterTabs(content, dialogOptions.tabFilter);
|
||||
});
|
||||
|
||||
$scope.filterTabs = function (entity, blackList) {
|
||||
if (blackList) {
|
||||
_.each(entity.tabs, function (tab) {
|
||||
tab.hide = _.contains(blackList, tab.alias);
|
||||
});
|
||||
}
|
||||
|
||||
return entity;
|
||||
};
|
||||
|
||||
$scope.save = function () {
|
||||
performSave({ saveMethod: memberResource.save, statusMessage: "Saving..." })
|
||||
.then(function (content) {
|
||||
if (dialogOptions.closeOnSave) {
|
||||
$scope.submit(content);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("MemberManager.Dialogs.Member.EditController", MemberEditDialogController);
|
||||
@@ -0,0 +1,45 @@
|
||||
<form novalidate name="contentForm"
|
||||
ng-controller="MemberManager.Dialogs.Member.EditController"
|
||||
ng-show="loaded"
|
||||
ng-submit="save()"
|
||||
val-form-manager>
|
||||
|
||||
<div class="umb-panel">
|
||||
<div class="umb-panel-header">
|
||||
<umb-content-name placeholder="@placeholders_entername"
|
||||
ng-model="model.entity.name" />
|
||||
</div>
|
||||
|
||||
<div class="umb-panel-body with-footer">
|
||||
<div id="tab{{tab.id}}" ng-repeat="tab in model.entity.tabs">
|
||||
<div class="umb-pane" ng-if="!tab.hide">
|
||||
<h5>{{tab.label}}</h5>
|
||||
<umb-property property="property"
|
||||
ng-repeat="property in tab.properties">
|
||||
<umb-editor model="property"></umb-editor>
|
||||
</umb-property>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="umb-panel-footer">
|
||||
<div class="umb-el-wrap umb-panel-buttons">
|
||||
<div class="btn-toolbar umb-btn-toolbar pull-right">
|
||||
<a href ng-click="close()" class="btn btn-link">
|
||||
<localize key="general_close">Close</localize>
|
||||
</a>
|
||||
|
||||
|
||||
<div class="btn-group dropup">
|
||||
<!-- primary button -->
|
||||
<a class="btn btn-success" href="#" ng-click="save()" prevent-default>
|
||||
Save
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,116 @@
|
||||
angular.module("umbraco").controller("MemberManager.Dialogs.Member.ExportController",
|
||||
function ($scope, memberExtResource) {
|
||||
|
||||
$scope.defaultButton = null;
|
||||
$scope.subButtons = [];
|
||||
|
||||
var dialogOptions = $scope.$parent.dialogOptions;
|
||||
|
||||
$scope.filterData = dialogOptions.filterData;
|
||||
$scope.columns = dialogOptions.columns;
|
||||
//$scope.memberType = dialogOptions.filterData.memberType;
|
||||
$scope.totalItems = dialogOptions.totalItems;
|
||||
$scope.memberTypes = dialogOptions.memberTypes;
|
||||
$scope.format = "Excel";
|
||||
|
||||
$scope.allColumnsSelected = false;
|
||||
|
||||
function init() {
|
||||
var buttons = {
|
||||
defaultButton: createButtonDefinition("E"),
|
||||
subButtons: []
|
||||
};
|
||||
|
||||
$scope.defaultButton = buttons.defaultButton;
|
||||
$scope.subButtons = buttons.subButtons;
|
||||
|
||||
memberExtResource.getMemberColumns(dialogOptions.filterData.memberType).then(function (data) {
|
||||
// We use this to preserve the original filter data.
|
||||
$scope.columnList = setSelected(data, $scope.columns);
|
||||
$scope.allColumnsSelected = $scope.allSelected($scope.columnList);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function createButtonDefinition(ch) {
|
||||
switch (ch) {
|
||||
case "E":
|
||||
//export action
|
||||
return {
|
||||
letter: ch,
|
||||
labelKey: "memberManager_export",
|
||||
label: "Export",
|
||||
handler: $scope.export,
|
||||
hotKey: "ctrl+e",
|
||||
hotKeyWhenHidden: true,
|
||||
alias: "export"
|
||||
};
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through a list of select options and set selected for values that appear in a filter list
|
||||
setSelected = function (list, filter) {
|
||||
// Convert string arrays to a select item object.
|
||||
list = _.map(list, function (item) {
|
||||
if (typeof item === "string") {
|
||||
let value = item;
|
||||
item = {
|
||||
id: value.replace(" ", "_"),
|
||||
name: value,
|
||||
alias: value,
|
||||
selected: false
|
||||
};
|
||||
}
|
||||
return item;
|
||||
});
|
||||
|
||||
if (filter) {
|
||||
for (var i = 0; i < filter.length; i++) {
|
||||
for (var j = 0; j < list.length; j++) {
|
||||
if (list[j].id === filter[i].replace(" ", "_")) {
|
||||
list[j].selected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
};
|
||||
|
||||
processColumnList = function (list) {
|
||||
var filteredList = _.filter(list, function (i) {
|
||||
return i.selected;
|
||||
});
|
||||
|
||||
return _.map(filteredList, function (item) {
|
||||
return item.alias;
|
||||
});
|
||||
};
|
||||
|
||||
// Methods to manage select/deselect all in checkbox lists.
|
||||
$scope.selectAll = function (selectionList) {
|
||||
_.each(selectionList, function (item) { item.selected = $scope.allColumnsSelected; });
|
||||
};
|
||||
|
||||
$scope.allSelected = function (selectionList) {
|
||||
return _.filter(selectionList, function (item) { return item.selected; }).length === selectionList.length;
|
||||
};
|
||||
|
||||
$scope.export = function () {
|
||||
$scope.submit(processColumnList($scope.columnList));
|
||||
};
|
||||
|
||||
// this method is called for all action buttons and then we proxy based on the btn definition
|
||||
$scope.performAction = function (btn) {
|
||||
|
||||
if (!btn || !angular.isFunction(btn.handler)) {
|
||||
throw "btn.handler must be a function reference";
|
||||
}
|
||||
|
||||
btn.handler.apply(this);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
@@ -0,0 +1,90 @@
|
||||
<form novalidate name="contentForm"
|
||||
ng-controller="MemberManager.Dialogs.Member.ExportController"
|
||||
ng-submit="export()"
|
||||
val-form-manager
|
||||
class="umb-mini-editor">
|
||||
|
||||
<div class="umb-panel">
|
||||
<div class="umb-panel-header">
|
||||
<h1>
|
||||
<localize key="memberManager_export">Export</localize>
|
||||
</h1>
|
||||
</div>
|
||||
<div class="umb-panel-body with-footer">
|
||||
<div class="umb-pane filter-options">
|
||||
<div class="umb-el-wrap">
|
||||
<label class="control-label">Exportable records:</label> <span>{{totalItems}} members</span>
|
||||
<div class="alert alert-warning" ng-if="totalItems > 100">Exporting a large number of members may take some time.</div>
|
||||
</div>
|
||||
<div class="umb-el-wrap" ng-if="filterData.display">
|
||||
<label class="control-label">Applied Filters: </label>
|
||||
|
||||
<div class="filter-display">
|
||||
<div ng-repeat="displayFilter in filterData.display">
|
||||
<strong>{{displayFilter.title}}</strong>
|
||||
<span>{{displayFilter.value}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="umb-el-wrap filter-checkbox-list" ng-show="columnList && columnList.length > 1">
|
||||
<h5>Columns</h5>
|
||||
<p>Select the columns to include in the exported data</p>
|
||||
<div class="filter-header">
|
||||
<div>
|
||||
<input type="checkbox" ng-model="allColumnsSelected" ng-click="selectAll(columnList)" id="column-all" />
|
||||
<label class="control-label" for="column-all">Select / deselect all columns</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter-content">
|
||||
<div ng-repeat="column in columnList">
|
||||
<input type="checkbox" ng-model="column.selected" id="column-{{column.id}}" />
|
||||
<label class="control-label" for="column-{{column.id}}">{{column.name}}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="umb-el-wrap">
|
||||
<label class="control-label">Format: </label>
|
||||
<div class="controls controls-row">
|
||||
<select ng-model="format">
|
||||
<option value="Excel">Excel Spreadsheet (*.xlsx)</option>
|
||||
<option value="CSV">Comma Separated Values (*.csv)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="umb-panel-footer">
|
||||
<div class="umb-el-wrap umb-panel-buttons">
|
||||
<div class="btn-toolbar umb-btn-toolbar pull-right">
|
||||
<a ng-click="close()" class="btn btn-link">
|
||||
<localize key="general_close">Close</localize>
|
||||
</a>
|
||||
|
||||
|
||||
<div class="btn-group dropup" ng-if="defaultButton">
|
||||
<!-- primary button -->
|
||||
<a class="btn btn-success" href="#" ng-click="performAction(defaultButton)" prevent-default>
|
||||
<localize key="{{defaultButton.labelKey}}">{{defaultButton.label}}</localize>
|
||||
</a>
|
||||
|
||||
<a class="btn btn-success dropdown-toggle" data-toggle="dropdown" ng-if="subButtons.length > 0">
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
|
||||
<!-- sub buttons -->
|
||||
<ul class="dropdown-menu bottom-up" role="menu" aria-labelledby="dLabel" ng-if="subButtons.length > 0">
|
||||
<li ng-repeat="btn in subButtons">
|
||||
<a href="#" ng-click="performAction(btn)" prevent-default>
|
||||
<localize key="{{btn.labelKey}}">{{btn.label}}</localize>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,167 @@
|
||||
angular.module("umbraco").controller("MemberManager.Dialogs.Member.FilterController",
|
||||
function ($scope) {
|
||||
|
||||
$scope.defaultButton = null;
|
||||
$scope.subButtons = [];
|
||||
var dialogOptions = $scope.$parent.dialogOptions;
|
||||
|
||||
$scope.filterData = dialogOptions.filterData;
|
||||
$scope.memberTypes = dialogOptions.memberTypes;
|
||||
$scope.memberGroups = dialogOptions.memberGroups;
|
||||
|
||||
function init() {
|
||||
var buttons = {
|
||||
defaultButton: createButtonDefinition("F"),
|
||||
subButtons: [
|
||||
createButtonDefinition("C")
|
||||
]
|
||||
};
|
||||
|
||||
$scope.defaultButton = buttons.defaultButton;
|
||||
$scope.subButtons = buttons.subButtons;
|
||||
|
||||
// We use this to preserve the original filter data.
|
||||
$scope.memberGroupFilter = setSelected($scope.memberGroups, $scope.filterData.memberGroups);
|
||||
}
|
||||
|
||||
function createButtonDefinition(ch) {
|
||||
switch (ch) {
|
||||
case "F":
|
||||
//publish action
|
||||
return {
|
||||
letter: ch,
|
||||
labelKey: "memberManager_applyFilter",
|
||||
label: "Apply Filter",
|
||||
handler: $scope.applyFilter,
|
||||
hotKey: "ctrl+f",
|
||||
hotKeyWhenHidden: true,
|
||||
alias: "applyFilter"
|
||||
};
|
||||
case "C":
|
||||
//send to publish
|
||||
return {
|
||||
letter: ch,
|
||||
labelKey: "memberManager_clearFilter",
|
||||
label: "Clear Filter",
|
||||
handler: $scope.clearFilter,
|
||||
hotKey: "ctrl+c",
|
||||
hotKeyWhenHidden: true,
|
||||
alias: "sendToPublish"
|
||||
};
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Generate model for representing the search
|
||||
getFilterModel = function () {
|
||||
var displaySearch = new Array();
|
||||
|
||||
//if ($scope.filterData.filter) {
|
||||
// displaySearch.push({ title: "Search", value: $scope.filterData.filter });
|
||||
//}
|
||||
if ($scope.filterData.memberType) {
|
||||
displaySearch.push({ title: "Member Type", value: _getMemberTypeName() });
|
||||
}
|
||||
if ($scope.filterData.f_umbracoMemberApproved) {
|
||||
displaySearch.push({ title: "Approved", value: $scope.filterData.f_umbracoMemberApproved === "true,1" ? "Approved" : "Suspended" });
|
||||
}
|
||||
|
||||
if ($scope.filterData.f_umbracoMemberLockedOut) {
|
||||
displaySearch.push({ title: "Locked Out", value: $scope.filterData.f_umbracoMemberLockedOut === "true,1" ? "Locked Out" : "Active" });
|
||||
}
|
||||
|
||||
return {
|
||||
filter: $scope.filterData.filter,
|
||||
memberType: $scope.filterData.memberType,
|
||||
memberGroups: processFilterList(displaySearch, "Member Groups", $scope.memberGroupFilter),
|
||||
f_umbracoMemberApproved: !$scope.filterData.f_umbracoMemberApproved ? "" : $scope.filterData.f_umbracoMemberApproved,
|
||||
f_umbracoMemberLockedOut: !$scope.filterData.f_umbracoMemberLockedOut ? "" : $scope.filterData.f_umbracoMemberLockedOut,
|
||||
|
||||
display: displaySearch
|
||||
};
|
||||
};
|
||||
|
||||
function _getMemberTypeName() {
|
||||
|
||||
var type = _.filter($scope.memberTypes, function (item) {
|
||||
return item.alias === $scope.filterData.memberType;
|
||||
});
|
||||
|
||||
return _.map(type, function (item) {
|
||||
return ' ' + item.name;
|
||||
}).join();
|
||||
|
||||
}
|
||||
|
||||
// Loop through a list of select options and set selected for values that appear in a filter list
|
||||
setSelected = function (list, filter) {
|
||||
// Convert string arrays to a select item object.
|
||||
list = _.map(list, function (item) {
|
||||
if (typeof item === "string") {
|
||||
let value = item;
|
||||
item = {
|
||||
id: value.replace(" ", "_"),
|
||||
name: value,
|
||||
alias: value,
|
||||
selected: false
|
||||
};
|
||||
}
|
||||
return item;
|
||||
});
|
||||
|
||||
if (filter) {
|
||||
for (var i = 0; i < filter.length; i++) {
|
||||
for (var j = 0; j < list.length; j++) {
|
||||
if (list[j].id === filter[i].replace(" ", "_")) {
|
||||
list[j].selected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
};
|
||||
|
||||
|
||||
processFilterList = function (display, title, list) {
|
||||
var filteredList = _.filter(list, function (i) {
|
||||
return i.selected;
|
||||
});
|
||||
|
||||
var displayVal = _.map(filteredList, function (item) {
|
||||
return ' ' + item.name;
|
||||
}).join();
|
||||
|
||||
if (displayVal) {
|
||||
display.push({ title: title, value: displayVal });
|
||||
}
|
||||
return _.map(filteredList, function (item) {
|
||||
return item.alias;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.applyFilter = function () {
|
||||
$scope.submit(getFilterModel());
|
||||
};
|
||||
|
||||
$scope.clearFilter = function () {
|
||||
$scope.filterData = {
|
||||
filter: null
|
||||
};
|
||||
$scope.submit($scope.filterData);
|
||||
};
|
||||
|
||||
// this method is called for all action buttons and then we proxy based on the btn definition
|
||||
$scope.performAction = function (btn) {
|
||||
|
||||
if (!btn || !angular.isFunction(btn.handler)) {
|
||||
throw "btn.handler must be a function reference";
|
||||
}
|
||||
|
||||
btn.handler.apply(this);
|
||||
};
|
||||
|
||||
|
||||
init();
|
||||
});
|
||||
@@ -0,0 +1,95 @@
|
||||
<form novalidate name="contentForm"
|
||||
ng-controller="MemberManager.Dialogs.Member.FilterController"
|
||||
ng-submit="applyFilter()"
|
||||
val-form-manager
|
||||
class="umb-mini-editor">
|
||||
|
||||
<div class="umb-panel">
|
||||
<div class="umb-panel-header">
|
||||
<h1>
|
||||
<localize key="memberManager_filter">Filter</localize>
|
||||
</h1>
|
||||
</div>
|
||||
<div class="umb-panel-body with-footer">
|
||||
<div class="umb-pane filter-options">
|
||||
<div class="umb-property">
|
||||
<label class="control-label">Search</label>
|
||||
<div class="controls controls-row">
|
||||
<input type="text" ng-model="filterData.filter" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="umb-el-wrap" ng-show="memberTypes && memberTypes.length > 1">
|
||||
<label class="control-label">Member Type</label>
|
||||
<div class="controls controls-row">
|
||||
<select ng-model="filterData.memberType">
|
||||
<option value="">- All -</option>
|
||||
<option ng-repeat="memberType in memberTypes" ng-value="{{memberType.alias}}">{{memberType.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter-checkbox-list" ng-show="memberGroupFilter && memberGroupFilter.length > 1">
|
||||
<h5>Member Groups</h5>
|
||||
<div class="filter-content">
|
||||
<div ng-repeat="group in memberGroupFilter">
|
||||
<input type="checkbox" ng-model="group.selected" id="group-{{group.id}}" />
|
||||
<label class="control-label" for="group-{{group.id}}">{{group.name}}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="umb-el-wrap">
|
||||
<label class="control-label">Approved</label>
|
||||
<div class="controls controls-row">
|
||||
<select ng-model="filterData.f_umbracoMemberApproved">
|
||||
<option value="">- All -</option>
|
||||
<option value="true,1">Approved Only</option>
|
||||
<option value="false,0">Suspended Only</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="umb-el-wrap">
|
||||
<label class="control-label">Locked Out</label>
|
||||
<div class="controls controls-row">
|
||||
<select ng-model="filterData.f_umbracoMemberLockedOut">
|
||||
<option value="">- All -</option>
|
||||
<option value="true,1">Locked Out Only</option>
|
||||
<option value="false,0">Active Only</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="umb-panel-footer">
|
||||
<div class="umb-el-wrap umb-panel-buttons">
|
||||
<div class="btn-toolbar umb-btn-toolbar pull-right">
|
||||
<a ng-click="close()" class="btn btn-link">
|
||||
<localize key="general_close">Close</localize>
|
||||
</a>
|
||||
|
||||
|
||||
<div class="btn-group dropup" ng-if="defaultButton">
|
||||
<!-- primary button -->
|
||||
<a class="btn btn-success" href="#" ng-click="performAction(defaultButton)" prevent-default>
|
||||
<localize key="{{defaultButton.labelKey}}">{{defaultButton.label}}</localize>
|
||||
</a>
|
||||
|
||||
<a class="btn btn-success dropdown-toggle" data-toggle="dropdown" ng-if="subButtons.length > 0">
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
|
||||
<!-- sub buttons -->
|
||||
<ul class="dropdown-menu bottom-up" role="menu" aria-labelledby="dLabel" ng-if="subButtons.length > 0">
|
||||
<li ng-repeat="btn in subButtons">
|
||||
<a href="#" ng-click="performAction(btn)" prevent-default>
|
||||
<localize key="{{btn.labelKey}}">{{btn.label}}</localize>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
Reference in New Issue
Block a user