Skip to content

Commit

Permalink
Fix for switching languages in seo tab (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdemooij9 committed Aug 21, 2023
1 parent 8d99c92 commit f6f570a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(function() {
(function () {

function SeoContentController($scope, $http, editorState, eventsService, notificationsService)
{
function SeoContentController($scope, $http, editorState, eventsService, notificationsService) {
var unsubscribe = [];

var vm = this;
Expand Down Expand Up @@ -35,48 +34,50 @@
if (response.status === 200) {
vm.displays = response.data.displays;
vm.displays[0].active = true;

const maxTries = 20;
var tries = 0;
var currentScope = $scope.$parent;
while (!currentScope.hasOwnProperty("defaultButton") && tries <= maxTries) {
currentScope = currentScope.$parent;
tries++;
}

if (maxTries > tries) {
vm.defaultButtonScope = currentScope;
}

if (vm.defaultButtonScope) {
vm.defaultButtonScope.defaultButton = {
letter: 'S',
labelKey: "buttons_save",
handler: save,
hotKey: "ctrl+s",
hotKeyWhenHidden: true,
alias: "save",
addEllipsis: "true"
}
}

vm.loading = false;
}
});
}

function initSaveButton() {
const maxTries = 20;
var tries = 0;
var currentScope = $scope.$parent;
while (currentScope && !currentScope.hasOwnProperty("defaultButton") && tries <= maxTries) {
currentScope = currentScope.$parent;
tries++;
}

if (maxTries > tries) {
vm.defaultButtonScope = currentScope;
}

if (vm.defaultButtonScope) {
vm.defaultButtonScope.defaultButton = {
letter: 'S',
labelKey: "buttons_save",
handler: save,
hotKey: "ctrl+s",
hotKeyWhenHidden: true,
alias: "save",
addEllipsis: "true"
}
}
}

unsubscribe.push(eventsService.on("app.tabChange",
(e, data) => {
if (data.alias !== "seoContent") {
return;
}

init();
initSaveButton();
}));

vm.$onDestroy = function () {
unsubscribe.forEach(x => x());
}

init();
}

angular.module("umbraco").controller("SeoToolkit.ContentApps.SeoContentController", SeoContentController);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<div ng-controller="SeoToolkit.ContentApps.SeoContentController as vm" class="form-horizontal">
<div ng-show="vm.loading === false">
<div class="umb-editor-tab-bar">
<ul class="umb-tabs-nav">
<li class="umb-tab" ng-class="{'umb-tab--active' : display.active}" ng-repeat="display in vm.displays track by display.alias">
<button type="button" class="umb-tab-button btn-reset" ng-click="vm.setActive(display)">{{display.name}}</button>
</li>
</ul>
</div>

<umb-editor-sub-views sub-views="vm.displays">
</umb-editor-sub-views>
<div class="umb-editor-tab-bar">
<ul class="umb-tabs-nav">
<li class="umb-tab" ng-class="{'umb-tab--active' : display.active}" ng-repeat="display in vm.displays track by display.alias">
<button type="button" class="umb-tab-button btn-reset" ng-click="vm.setActive(display)">{{display.name}}</button>
</li>
</ul>
</div>

<umb-editor-sub-views sub-views="vm.displays">
</umb-editor-sub-views>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public object Convert(object value, IPublishedContent currentContent, string fie
if (stringValue?.Contains("%CurrentUrl%") is true)
{
var url = currentContent.Url(mode: UrlMode.Absolute);
if (url.Equals("#")) return ""; //No URL yet.
if (new Uri(url).PathAndQuery.Equals("/"))
{
url = url.TrimEnd('/');
Expand Down

0 comments on commit f6f570a

Please sign in to comment.