Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V8: Accessibility Changes For umbEditorHeader Directive (edit user) #7102

Merged
merged 5 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Use this directive to construct a header inside the main editor window.
(function () {
'use strict';

function EditorHeaderDirective(editorService, localizationService, editorState) {
function EditorHeaderDirective(editorService, localizationService, editorState, $rootScope) {

function link(scope, $injector) {

Expand All @@ -224,27 +224,9 @@ Use this directive to construct a header inside the main editor window.
if (editorState.current) {
//to do make work for user create/edit
// to do make it work for user group create/ edit
// to do make it work for language edit/create
// to do make it work for log viewer
scope.isNew = editorState.current.id === 0 ||
editorState.current.id === "0" ||
editorState.current.id === -1 ||
editorState.current.id === 0 ||
editorState.current.id === "-1";

var localizeVars = [
scope.isNew ? "visuallyHiddenTexts_createItem" : "visuallyHiddenTexts_edit",
"visuallyHiddenTexts_name",
scope.isNew ? "general_new" : "general_edit"
];

if (scope.editorfor) {
localizeVars.push(scope.editorfor);
}
localizationService.localizeMany(localizeVars).then(function(data) {
setAccessibilityForEditor(data);
scope.loading = false;
});
// to make it work for language edit/create
setAccessibilityForEditorState();
scope.loading = false;
} else {
scope.loading = false;
}
Expand Down Expand Up @@ -283,59 +265,91 @@ Use this directive to construct a header inside the main editor window.
editorService.iconPicker(iconPicker);
};

function setAccessibilityForEditor(data) {

if (editorState.current) {
if (scope.nameLocked) {
scope.accessibility.a11yName = scope.name;
SetPageTitle(scope.name);
} else {

scope.accessibility.a11yMessage = data[0];
scope.accessibility.a11yName = data[1];
var title = data[2] + ":";
if (!scope.isNew) {
scope.accessibility.a11yMessage += " " + scope.name;
title += " " + scope.name;
} else {
var name = "";
if (editorState.current.contentTypeName) {
name = editorState.current.contentTypeName;
} else if (scope.editorfor) {
name = data[3];
}
if (name !== "") {
scope.accessibility.a11yMessage += " " + name;
scope.accessibility.a11yName = name + " " + scope.accessibility.a11yName;
title += " " + name;
}
}
if (title !== data[2] + ":") {
SetPageTitle(title);
}

}
scope.accessibility.a11yMessageVisible = !isEmptyOrSpaces(scope.accessibility.a11yMessage);
scope.accessibility.a11yNameVisible = !isEmptyOrSpaces(scope.accessibility.a11yName);
function setAccessibilityForEditorState() {
var isNew = editorState.current.id === 0 ||
editorState.current.id === "0" ||
editorState.current.id === -1 ||
editorState.current.id === 0 ||
editorState.current.id === "-1";

var contentTypeName = "";
if (editorState.current.contentTypeName) {
contentTypeName = editorState.current.contentTypeName;
}

var setTitle = false;
if (scope.setpagetitle !== undefined) {
setTitle = scope.setpagetitle;
}

setAccessibilityHeaderDirective(isNew, scope.editorfor, scope.nameLocked, scope.name, contentTypeName, setTitle);
}

function setAccessibilityHeaderDirective(isNew, editorFor, nameLocked, entityName, contentTypeName, setTitle) {

var localizeVars = [
isNew ? "visuallyHiddenTexts_createItem" : "visuallyHiddenTexts_edit",
"visuallyHiddenTexts_name",
isNew ? "general_new" : "general_edit"
];

if (editorFor) {
localizeVars.push(editorFor);
}
localizationService.localizeMany(localizeVars).then(function(data) {
if (nameLocked) {
scope.accessibility.a11yName = entityName;
if (setTitle) {
SetPageTitle(entityName);
}
} else {

scope.accessibility.a11yMessage = data[0];
scope.accessibility.a11yName = data[1];
var title = data[2] + ":";
if (!isNew) {
scope.accessibility.a11yMessage += " " + entityName;
title += " " + entityName;
} else {
var name = "";
if (contentTypeName) {
name = editorState.current.contentTypeName;
} else if (editorFor) {
name = data[3];
}
if (name !== "") {
scope.accessibility.a11yMessage += " " + name;
scope.accessibility.a11yName = name + " " + scope.accessibility.a11yName;
title += " " + name;
}
}
if (setTitle && title !== data[2] + ":") {
SetPageTitle(title);
}

}
scope.accessibility.a11yMessageVisible = !isEmptyOrSpaces(scope.accessibility.a11yMessage);
scope.accessibility.a11yNameVisible = !isEmptyOrSpaces(scope.accessibility.a11yName);

});
}



function isEmptyOrSpaces(str) {
return str === null || str===undefined || str.trim ==='';
}

function SetPageTitle(title) {
var setTitle = false;
if (scope.setpagetitle !== undefined) {
setTitle = scope.setpagetitle;
}
if (setTitle) {
scope.$emit("$changeTitle", title);
}
}

$rootScope.$on('$setAccessibleHeader', function (event, isNew, editorFor, nameLocked, name, contentTypeName, setTitle) {
setAccessibilityHeaderDirective(isNew, editorFor, nameLocked, name, contentTypeName, setTitle);
});
}



var directive = {
transclude: true,
restrict: 'E',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
vm.changePasswordModel.config.allowManuallyChangingPassword = true;
}

$scope.$emit("$setAccessibleHeader", false, "general_user", false, vm.user.name, "", true);
vm.loading = false;
});
});
Expand Down