Refactoring part 2 of umb-editor, splitview, variants.

This commit is contained in:
Niels Lyngsø
2020-01-23 19:09:48 +01:00
parent f302b373ac
commit d4d7425c24
6 changed files with 39 additions and 38 deletions

View File

@@ -19,8 +19,8 @@
var viewFocusY = scrollableNode.scrollTop + scrollableNode.clientHeight * .5;
for(var i in $scope.variant.tabs) {
var group = $scope.variant.tabs[i];
for(var i in $scope.content.tabs) {
var group = $scope.content.tabs[i];
var node = propertyGroupNodesDictionary[group.id];
if (viewFocusY >= node.offsetTop && viewFocusY <= node.offsetTop + node.clientHeight) {
setActiveAnchor(group);
@@ -32,18 +32,18 @@
function setActiveAnchor(tab) {
if (tab.active !== true) {
var i = $scope.variant.tabs.length;
var i = $scope.content.tabs.length;
while(i--) {
$scope.variant.tabs[i].active = false;
$scope.content.tabs[i].active = false;
}
tab.active = true;
}
}
function getActiveAnchor() {
var i = $scope.variant.tabs.length;
var i = $scope.content.tabs.length;
while(i--) {
if ($scope.variant.tabs[i].active === true)
return $scope.variant.tabs[i];
if ($scope.content.tabs[i].active === true)
return $scope.content.tabs[i];
}
return false;
}
@@ -115,18 +115,17 @@
}
function controller($scope, $element, $attrs) {
function controller($scope) {
//expose the property/methods for other directives to use
this.content = $scope.content;
console.log($scope)
console.log(this.content);
$scope.defaultVariant = _.find(this.content.variants, variant => {
return variant.language && variant.language.isDefault;
});
if($scope.variantNodeModel) {
$scope.defaultVariant = _.find($scope.variantNodeModel.variants, variant => {
return variant.language && variant.language.isDefault;
});
}
$scope.unlockInvariantValue = function(property) {
property.unlockInvariantValue = !property.unlockInvariantValue;
};
@@ -134,7 +133,7 @@
$scope.$watch("tabbedContentForm.$dirty",
function (newValue, oldValue) {
if (newValue === true) {
$scope.variant.isDirty = true;
$scope.content.isDirty = true;
}
}
);
@@ -148,7 +147,7 @@
link: link,
scope: {
content: "=",
variant: "="
variantNodeModel: "=?"
}
};

View File

@@ -20,7 +20,7 @@
templateUrl: 'views/components/editor/umb-editor-sub-view.html',
scope: {
model: "=",
variant: "=?",
variantContent: "=?",
content: "="
},
link: link

View File

@@ -1,6 +1,6 @@
<div>
<ng-form name="tabbedContentForm">
<div class="umb-group-panel" retrive-dom-element="registerPropertyGroup(element[0], attributes.appAnchor)" data-app-anchor="{{group.id}}" data-element="group-{{group.alias}}" ng-repeat="group in variant.tabs track by group.label">
<div class="umb-group-panel" retrive-dom-element="registerPropertyGroup(element[0], attributes.appAnchor)" data-app-anchor="{{group.id}}" data-element="group-{{group.alias}}" ng-repeat="group in content.tabs track by group.label">
<div class="umb-group-panel__header">
<div id="group-{{group.id}}">{{ group.label }}</div>
@@ -11,13 +11,13 @@
data-element="property-{{property.alias}}"
ng-repeat="property in group.properties track by property.alias"
property="property"
show-inherit="content.variants.length > 1 && ((!variant.language.isDefault && !property.culture) || (variant.segment && !property.segment)) && !property.unlockInvariantValue"
show-inherit="variantNodeModel.variants.length > 1 && ((!content.language.isDefault && !property.culture) || (content.segment && !property.segment)) && !property.unlockInvariantValue"
inherits-from="defaultVariant.language.name">
<div ng-class="{'o-40 cursor-not-allowed': content.variants.length > 1 && ((!variant.language.isDefault && !property.culture) || (variant.segment && !property.segment)) && !property.unlockInvariantValue}">
<div ng-class="{'o-40 cursor-not-allowed': variantNodeModel.variants.length > 1 && ((!content.language.isDefault && !property.culture) || (content.segment && !property.segment)) && !property.unlockInvariantValue}">
<umb-property-editor
model="property"
preview="content.variants.length > 1 && ((!variant.language.isDefault && !property.culture) || (variant.segment && !property.segment)) && !property.unlockInvariantValue">
preview="variantNodeModel.variants.length > 1 && ((!content.language.isDefault && !property.culture) || (content.segment && !property.segment)) && !property.unlockInvariantValue">
</umb-property-editor>
</div>

View File

@@ -35,7 +35,7 @@
<div class="umb-editor-sub-views">
<div ng-repeat="app in vm.content.apps track by app.alias">
<umb-editor-sub-view model="app" content="vm.content" variant="vm.editor.content" />
<umb-editor-sub-view model="app" content="vm.content" variant-content="vm.editor.content"/>
</div>
</div>
</umb-editor-container>

View File

@@ -23,25 +23,27 @@
//if this variant has a culture/language assigned, then we need to watch it since it will change
//if the language drop down changes and we need to re-init
if ($scope.variant.language) {
unbindLanguageWatcher = $scope.$watch(function () {
return $scope.variant.language.culture;
if ($scope.variantContent) {
if ($scope.variantContent.language) {
unbindLanguageWatcher = $scope.$watch(function () {
return $scope.variantContent.language.culture;
}, function (newVal, oldVal) {
if (newVal !== oldVal) {
requestUpdate();
}
});
} else {
unbindLanguageWatcher = function() {}
}
unbindSegmentWatcher = $scope.$watch(function () {
return $scope.variantContent.segment;
}, function (newVal, oldVal) {
if (newVal !== oldVal) {
requestUpdate();
}
});
} else {
unbindLanguageWatcher = function() {}
}
unbindSegmentWatcher = $scope.$watch(function () {
return $scope.variant.segment;
}, function (newVal, oldVal) {
if (newVal !== oldVal) {
requestUpdate();
}
});
}

View File

@@ -2,8 +2,8 @@
<umb-tabbed-content
ng-if="!vm.loading"
variant="variant"
content="content">
variant-node-model="content"
content="variantContent">
</umb-tabbed-content>
</div>