open the correct view based on which item you are creating and on the content of the stylesheet file
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
</li>
|
||||
<li class="umb-action">
|
||||
<a href="" ng-click="vm.createRichtextStyle()" class="umb-action-link">
|
||||
<i class="large icon icon-folder"></i>
|
||||
<i class="large icon icon-script"></i>
|
||||
<span class="menu-label"><localize key="create_newRteStyleSheetFile">New richtext style sheet file</localize></span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -12,24 +12,6 @@
|
||||
vm.page.menu.currentNode = null;
|
||||
vm.page.saveButtonState = "init";
|
||||
|
||||
localizationService.localizeMany(["stylesheet_tabCode", "stylesheet_tabRules"]).then(function (data) {
|
||||
vm.page.navigation = [
|
||||
{
|
||||
"name": data[0],
|
||||
"alias": "code",
|
||||
"icon": "icon-brackets",
|
||||
"view": "views/stylesheets/views/code/code.html",
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"name": data[1],
|
||||
"alias": "rules",
|
||||
"icon": "icon-font",
|
||||
"view": "views/stylesheets/views/rules/rules.html"
|
||||
}
|
||||
];
|
||||
});
|
||||
|
||||
//Used to toggle the keyboard shortcut modal
|
||||
//From a custom keybinding in ace editor - that conflicts with our own to show the dialog
|
||||
vm.showKeyboardShortcut = false;
|
||||
@@ -45,7 +27,10 @@
|
||||
vm.page.keyboardShortcutsOverview.push(shortcuts);
|
||||
});
|
||||
|
||||
vm.stylesheet = {};
|
||||
vm.stylesheet = {
|
||||
content: "",
|
||||
rules: []
|
||||
};
|
||||
|
||||
// bind functions to view model
|
||||
vm.save = interpolateAndSave;
|
||||
@@ -139,16 +124,47 @@
|
||||
|
||||
if ($routeParams.create) {
|
||||
codefileResource.getScaffold("stylesheets", $routeParams.id).then(function (stylesheet) {
|
||||
const mode = $routeParams.rtestyle ? "RTE" : null;
|
||||
ready(stylesheet, false);
|
||||
generateNavigation(mode);
|
||||
});
|
||||
} else {
|
||||
codefileResource.getByPath('stylesheets', $routeParams.id).then(function (stylesheet) {
|
||||
ready(stylesheet, true);
|
||||
extractRules().then(rules => {
|
||||
vm.stylesheet.rules = rules;
|
||||
const mode = rules && rules.length > 0 ? "RTE" : null;
|
||||
generateNavigation(mode);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function generateNavigation(mode) {
|
||||
localizationService.localizeMany(["stylesheet_tabRules", "stylesheet_tabCode"]).then(function (data) {
|
||||
vm.page.navigation = [
|
||||
{
|
||||
"name": data[0],
|
||||
"alias": "rules",
|
||||
"icon": "icon-font",
|
||||
"view": "views/stylesheets/views/rules/rules.html"
|
||||
},
|
||||
{
|
||||
"name": data[1],
|
||||
"alias": "code",
|
||||
"icon": "icon-brackets",
|
||||
"view": "views/stylesheets/views/code/code.html"
|
||||
}
|
||||
];
|
||||
if(mode === "RTE") {
|
||||
vm.page.navigation[0].active = true;
|
||||
} else {
|
||||
vm.page.navigation[1].active = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function ready(stylesheet, syncTree) {
|
||||
|
||||
vm.page.loading = false;
|
||||
@@ -244,7 +260,7 @@
|
||||
}
|
||||
|
||||
function extractRules() {
|
||||
return codefileResource.extractStylesheetRules(vm.stylesheet.content, null);
|
||||
return codefileResource.extractStylesheetRules(vm.stylesheet.content);
|
||||
}
|
||||
|
||||
$scope.selectApp = function (app) {
|
||||
|
||||
@@ -16,6 +16,9 @@ angular.module("umbraco").controller("Umbraco.Editors.StyleSheets.RulesControlle
|
||||
evt.preventDefault();
|
||||
|
||||
openOverlay({}, $scope.labels.addRule, (newRule) => {
|
||||
if(!$scope.model.stylesheet.rules) {
|
||||
$scope.model.stylesheet.rules = [];
|
||||
}
|
||||
$scope.model.stylesheet.rules.push(newRule);
|
||||
setDirty();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user