Updates user section routing so that it has nice urls

This commit is contained in:
Shannon
2019-01-31 11:03:25 +11:00
parent 2036da5e84
commit dcacff0124
6 changed files with 22 additions and 23 deletions

View File

@@ -164,6 +164,13 @@ app.config(function ($routeProvider) {
return;
}
//special case for the users section
var usersPages = ["user", "group"];
if ($routeParams.section.toLowerCase() === "users" && $routeParams.tree.toLowerCase() === "users" && usersPages.indexOf($routeParams.method.toLowerCase()) === -1) {
$scope.templateUrl = "views/users/overview.html";
return;
}
// Here we need to figure out if this route is for a user's package tree and if so then we need
// to change it's convention view path to:
// /App_Plugins/{mypackage}/backoffice/{treetype}/{method}.html

View File

@@ -100,7 +100,7 @@
}
function goToPage(ancestor) {
$location.path(ancestor.path).search("subview", ancestor.subView);
$location.path(ancestor.path);
}
function openSectionPicker() {
@@ -292,8 +292,7 @@
vm.breadcrumbs = [
{
"name": vm.labels.groups,
"path": "/users/users/overview",
"subView": "groups"
"path": "/users/users/groups"
},
{
"name": vm.userGroup.name

View File

@@ -1,17 +1,11 @@
(function () {
"use strict";
function UsersOverviewController($scope, $location, localizationService) {
function UsersOverviewController($scope, $location, $routeParams, localizationService) {
var vm = this;
var usersUri = $location.search().subview;
if (!usersUri) {
$location.search("subview", "users");
//exit after this, we don't want to initialize anything further since this
//is going to change the route
return;
}
let usersUri = $routeParams.method;
//note on the below, we dont assign a view unless it's the right route since if we did that it will load in that controller
//for the view which is unecessary and will cause extra overhead/requests to occur
vm.page = {};
@@ -30,7 +24,7 @@
var labels = ["sections_users", "general_groups"];
localizationService.localizeMany(labels).then(function(data){
localizationService.localizeMany(labels).then(function (data) {
vm.page.labels.users = data[0];
vm.page.labels.groups = data[1];
@@ -38,8 +32,8 @@
{
"name": vm.page.labels.users,
"icon": "icon-user",
"action": function() {
$location.search("subview", "users")
"action": function () {
$location.path("/users/users/users").search("create", null);
},
"view": !usersUri || usersUri === "users" ? "views/users/views/users/users.html" : null,
"active": !usersUri || usersUri === "users",
@@ -49,7 +43,7 @@
"name": vm.page.labels.groups,
"icon": "icon-users",
"action": function () {
$location.search("subview", "groups")
$location.path("/users/users/groups").search("create", null);
},
"view": usersUri === "groups" ? "views/users/views/groups/groups.html" : null,
"active": usersUri === "groups",
@@ -60,11 +54,11 @@
}
function setPageName() {
localizationService.localize("user_userManagement").then(function(data){
localizationService.localize("user_userManagement").then(function (data) {
vm.page.name = data;
})
}
onInit();
}

View File

@@ -205,7 +205,7 @@
}
function goToPage(ancestor) {
$location.path(ancestor.path).search("subview", ancestor.subView);
$location.path(ancestor.path);
}
function openUserGroupPicker() {
@@ -458,8 +458,7 @@
vm.breadcrumbs = [
{
"name": vm.labels.users,
"path": "/users/users/overview",
"subView": "users"
"path": "/users/users/users"
},
{
"name": vm.user.name

View File

@@ -558,7 +558,7 @@
}
function goToUser(userId) {
$location.path('users/users/user/' + userId);
$location.path('users/users/user/' + userId).search("create", null).search("invite", null);
}
// helpers

View File

@@ -21,7 +21,7 @@ namespace Umbraco.Web.Trees
var root = base.CreateRootNode(queryStrings);
//this will load in a custom UI instead of the dashboard for the root node
root.RoutePath = string.Format("{0}/{1}/{2}", Constants.Applications.Users, Constants.Trees.Users, "overview");
root.RoutePath = $"{Constants.Applications.Users}/{Constants.Trees.Users}/users";
root.Icon = "icon-users";
root.HasChildren = false;