From 19037ee1bacd780c3e7e144c234affc5c342cf48 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 15 Jan 2015 12:40:09 +1100 Subject: [PATCH] Ensures all stylesheet usages in RTE are working as expected --- .../directives/grid/grid.rte.directive.js | 3 ++ .../common/resources/stylesheet.resource.js | 31 +------------------ .../contentpicker/contentpicker.controller.js | 7 +++-- .../Editors/StylesheetController.cs | 13 ++------ .../Models/ContentEditing/StyleSheet.cs | 3 -- .../Models/ContentEditing/StylesheetRule.cs | 2 -- .../umbraco/create/stylesheetPropertyTasks.cs | 2 +- 7 files changed, 12 insertions(+), 49 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/grid/grid.rte.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/grid/grid.rte.directive.js index fd617a497e..18cfa77acd 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/grid/grid.rte.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/grid/grid.rte.directive.js @@ -65,6 +65,9 @@ angular.module("umbraco.directives") r.inline = "span"; r.classes = rule.selector.substring(1); }else if (rule.selector[0] === "#") { + //Even though this will render in the style drop down, it will not actually be applied + // to the elements, don't think TinyMCE even supports this and it doesn't really make much sense + // since only one element can have one id. r.inline = "span"; r.attributes = { id: rule.selector.substring(1) }; }else { diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/stylesheet.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/stylesheet.resource.js index f5eab4e902..36f2b4c591 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/stylesheet.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/stylesheet.resource.js @@ -36,36 +36,7 @@ function stylesheetResource($q, $http, umbRequestHelper) { "stylesheetApiBaseUrl", "GetAll")), 'Failed to retrieve stylesheets '); - }, - - /** - * @ngdoc method - * @name umbraco.resources.stylesheetResource#getRules - * @methodOf umbraco.resources.stylesheetResource - * - * @description - * Returns all defined child rules for a stylesheet with a given ID - * - * ##usage - *
-         * stylesheetResource.getRules(2345)
-         *    .then(function(rules) {
-         *        alert('its here!');
-         *    });
-         * 
- * - * @returns {Promise} resourcePromise object containing the rules. - * - */ - getRules: function (id) { - return umbRequestHelper.resourcePromise( - $http.get( - umbRequestHelper.getApiUrl( - "stylesheetApiBaseUrl", - "GetRules", - [{ id: id }])), - 'Failed to retrieve stylesheets '); - }, + }, /** * @ngdoc method diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js index 9d755d7d3f..83c6c3e013 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js @@ -175,8 +175,11 @@ function contentPickerController($scope, dialogService, entityResource, editorSt return d.id == id; }); - entity.icon = iconHelper.convertFromLegacyIcon(entity.icon); - $scope.renderModel.push({ name: entity.name, id: entity.id, icon: entity.icon }); + if (entity) { + entity.icon = iconHelper.convertFromLegacyIcon(entity.icon); + $scope.renderModel.push({ name: entity.name, id: entity.id, icon: entity.icon }); + } + }); diff --git a/src/Umbraco.Web/Editors/StylesheetController.cs b/src/Umbraco.Web/Editors/StylesheetController.cs index 119d959263..d40f6f2290 100644 --- a/src/Umbraco.Web/Editors/StylesheetController.cs +++ b/src/Umbraco.Web/Editors/StylesheetController.cs @@ -11,6 +11,7 @@ using System.Web.Http; using System.Web.Services.Description; using Newtonsoft.Json.Linq; using umbraco.cms.businesslogic.web; +using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Mvc; @@ -31,23 +32,13 @@ namespace Umbraco.Web.Editors .Select(x => new Stylesheet() { Name = x.Alias, - Id = x.Id, Path = x.VirtualPath }); } - - //public IEnumerable GetRules(string name) - //{ - // var css = Services.FileService.GetStylesheetByName(name); - // if (css == null) - // return Enumerable.Empty(); - - // return css.Properties.Select(x => new StylesheetRule() { Name = x.Name, Selector = x.Alias }); - //} public IEnumerable GetRulesByName(string name) { - var css = Services.FileService.GetStylesheetByName(name); + var css = Services.FileService.GetStylesheetByName(name.EnsureEndsWith(".css")); if (css == null) return Enumerable.Empty(); diff --git a/src/Umbraco.Web/Models/ContentEditing/StyleSheet.cs b/src/Umbraco.Web/Models/ContentEditing/StyleSheet.cs index 97387a7083..6162aebfd7 100644 --- a/src/Umbraco.Web/Models/ContentEditing/StyleSheet.cs +++ b/src/Umbraco.Web/Models/ContentEditing/StyleSheet.cs @@ -14,8 +14,5 @@ namespace Umbraco.Web.Models.ContentEditing [DataMember(Name = "path")] public string Path { get; set; } - - [DataMember(Name = "id")] - public int Id { get; set; } } } diff --git a/src/Umbraco.Web/Models/ContentEditing/StylesheetRule.cs b/src/Umbraco.Web/Models/ContentEditing/StylesheetRule.cs index 343031ba19..c8ef582f82 100644 --- a/src/Umbraco.Web/Models/ContentEditing/StylesheetRule.cs +++ b/src/Umbraco.Web/Models/ContentEditing/StylesheetRule.cs @@ -16,7 +16,5 @@ namespace Umbraco.Web.Models.ContentEditing [DataMember(Name = "selector")] public string Selector { get; set; } - //[DataMember(Name = "id")] - //public int Id { get; set; } } } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/create/stylesheetPropertyTasks.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/create/stylesheetPropertyTasks.cs index c1a05e7237..0b37a65f3b 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/create/stylesheetPropertyTasks.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/create/stylesheetPropertyTasks.cs @@ -22,7 +22,7 @@ namespace umbraco var stylesheetName = AdditionalValues["nodeId"].ToString(); var s = Umbraco.Core.ApplicationContext.Current.Services.FileService.GetStylesheetByName(stylesheetName.EnsureEndsWith(".css")); - s.AddProperty(new StylesheetProperty(Alias, "#" + Alias, "")); + s.AddProperty(new StylesheetProperty(Alias, "." + Alias.ToSafeAlias(), "")); Umbraco.Core.ApplicationContext.Current.Services.FileService.SaveStylesheet(s); _returnUrl = string.Format("settings/stylesheet/property/EditStyleSheetProperty.aspx?id={0}&prop={1}", s.Name, Alias);