implemented section resource and mocks to load in the sections (applications)

This commit is contained in:
Shannon
2013-07-02 12:57:28 +10:00
parent 32d7b88b45
commit 357e29ebe1
19 changed files with 112 additions and 88 deletions

View File

@@ -0,0 +1,16 @@
/**
* @ngdoc filter
* @name umbraco.filters:sectionIcon
* @description This will properly render the tree icon image based on the tree icon set on the server
**/
function sectionIconFilter(iconHelper) {
return function (sectionIconClass) {
if (iconHelper.isLegacyIcon(sectionIconClass)) {
return iconHelper.convertFromLegacyIcon(sectionIconClass);
}
else {
return sectionIconClass;
}
};
}
angular.module('umbraco.filters').filter("sectionIcon", sectionIconFilter);

View File

@@ -3,10 +3,10 @@
* @name umbraco.filters:umbTreeIconClass
* @description This will properly render the tree icon class based on the tree icon set on the server
**/
function treeIconClassFilter(treeIconHelper) {
function treeIconClassFilter(iconHelper) {
return function (treeNode, standardClasses) {
if (treeNode.iconIsClass !== false) {
return standardClasses + " " + treeIconHelper.convertFromLegacyTreeNodeIcon(treeNode);
return standardClasses + " " + iconHelper.convertFromLegacyTreeNodeIcon(treeNode);
}
//we need an 'icon-' class in there for certain styles to work so if it is image based we'll add this
return standardClasses + " icon-custom-file";

View File

@@ -3,10 +3,10 @@
* @name umbraco.filters:umbTreeIconImage
* @description This will properly render the tree icon image based on the tree icon set on the server
**/
function treeIconStyleFilter(treeIconHelper) {
function treeIconStyleFilter(iconHelper) {
return function (treeNode) {
if (treeNode.iconIsClass) {
var converted = treeIconHelper.convertFromLegacyTreeNodeIcon(treeNode);
var converted = iconHelper.convertFromLegacyTreeNodeIcon(treeNode);
if (converted.startsWith('.')) {
//its legacy so add some width/height
return "height:16px;width:16px;";

View File

@@ -0,0 +1,30 @@
/**
* @ngdoc factory
* @name umbraco.mocks.sectionMocks
* @description Mocks data retreival for the sections
**/
function sectionMocks($httpBackend, mocksUtills) {
/** internal method to mock the sections to be returned */
function getSections() {
var sections = [
{ name: "Content", cssclass: "content", alias: "content" },
{ name: "Media", cssclass: "media", alias: "media" },
{ name: "Settings", cssclass: "settings", alias: "settings" },
{ name: "Developer", cssclass: "developer", alias: "developer" },
{ name: "Users", cssclass: "user", alias: "users" }
];
return [200, sections, null];
}
return {
register: function () {
$httpBackend
.whenGET(mocksUtills.urlRegex('/umbraco/UmbracoApi/Section/GetSections'))
.respond(getSections);
}
};
}
angular.module('umbraco.mocks').factory('sectionMocks', ['$httpBackend', 'mocksUtills', sectionMocks]);

View File

@@ -1,11 +1,11 @@
var umbracoAppDev = angular.module('umbraco.httpbackend', ['umbraco', 'ngMockE2E', 'umbraco.mocks']);
function initBackEnd($httpBackend, contentMocks, treeMocks, userMocks, contentTypeMocks) {
function initBackEnd($httpBackend, contentMocks, treeMocks, userMocks, contentTypeMocks, sectionMocks) {
//Register mocked http responses
contentMocks.register();
sectionMocks.register();
treeMocks.register();
userMocks.register();

View File

@@ -10,6 +10,7 @@ Umbraco.Sys.ServerVariables = {
"umbracoPath": "/umbraco",
"contentApiBaseUrl": "/umbraco/UmbracoApi/Content/",
"mediaApiBaseUrl": "/umbraco/UmbracoApi/Media/",
"sectionApiBaseUrl": "/umbraco/UmbracoApi/Section/",
"treeApplicationApiBaseUrl": "/umbraco/UmbracoTrees/ApplicationTreeApi/",
"contentTypeApiBaseUrl": "/umbraco/Api/ContentType/",
"mediaTypeApiBaseUrl": "/umbraco/Api/MediaTypeApi/",

View File

@@ -13,7 +13,7 @@ function sectionResource($q, $http) {
//the factory object returned
return {
/** Loads in the data to display the section list */
getSections: function (options) {
getSections: function () {
var deferred = $q.defer();

View File

@@ -50,17 +50,7 @@ angular.module('umbraco.services')
currentNode: currentNode,
mode: "default",
ui: ui,
sections: function(){
return [
{ name: "Content", cssclass: "content", alias: "content" },
{ name: "Media", cssclass: "media", alias: "media" },
{ name: "Settings", cssclass: "settings", alias: "settings" },
{ name: "Developer", cssclass: "developer", alias: "developer" },
{ name: "Users", cssclass: "user", alias: "users" }
];
},
/**
* @ngdoc function
* @name loadLegacyIFrame

View File

@@ -9,7 +9,7 @@
* @param myParam {object} Enter param description here
*/
function treeService($q, treeResource, treeIconHelper) {
function treeService($q, treeResource, iconHelper) {
//implement this in local storage
var treeArray = [];
var currentSection = "content";
@@ -70,7 +70,7 @@ function treeService($q, treeResource, treeIconHelper) {
//need to convert the icons to new ones
for (var i = 0; i < treeItem.node.menu.length; i++) {
treeItem.node.menu[i].cssclass = treeIconHelper.convertFromLegacyIcon(treeItem.node.menu[i].cssclass);
treeItem.node.menu[i].cssclass = iconHelper.convertFromLegacyIcon(treeItem.node.menu[i].cssclass);
}
return treeItem.node.menu;
},

View File

@@ -345,10 +345,10 @@ angular.module('umbraco.services').factory('umbDataFormatter', umbDataFormatter)
/**
* @ngdoc factory
* @name umbraco.services.tree:treeIconHelper
* @description A helper service for dealing with tree icons, mostly dealing with legacy tree icons
* @name umbraco.services.tree:iconHelper
* @description A helper service for dealing with icons, mostly dealing with legacy tree icons
**/
function treeIconHelper() {
function iconHelper() {
var converter = [
{ oldIcon: ".sprNew", newIcon: "plus" },
@@ -371,7 +371,16 @@ function treeIconHelper() {
{ oldIcon: ".sprTreeFolder_o", newIcon: "icon-folder-open" },
{ oldIcon: ".sprTreeMediaFile", newIcon: "icon-music" },
{ oldIcon: ".sprTreeMediaMovie", newIcon: "icon-movie" },
{ oldIcon: ".sprTreeMediaPhoto", newIcon: "icon-picture" }
{ oldIcon: ".sprTreeMediaPhoto", newIcon: "icon-picture" },
//tray icons
{ oldIcon: ".traycontent", newIcon: "content" },
{ oldIcon: ".traymedia", newIcon: "media" },
{ oldIcon: ".traysettings", newIcon: "settings" },
{ oldIcon: ".traydeveloper", newIcon: "developer" },
{ oldIcon: ".trayusers", newIcon: "user" },
{ oldIcon: ".traymember", newIcon: "member" },
{ oldIcon: ".traytranslation", newIcon: "translation" }
];
return {
@@ -409,4 +418,4 @@ function treeIconHelper() {
}
};
}
angular.module('umbraco.services').factory('treeIconHelper', treeIconHelper);
angular.module('umbraco.services').factory('iconHelper', iconHelper);

File diff suppressed because one or more lines are too long

View File

@@ -52,7 +52,7 @@
@import "../../lib/bootstrap/less/thumbnails.less";
@import "../../lib/bootstrap/less/media.less";
@import "../../lib/bootstrap/less/labels-badges.less";
@import "../../lib/bootstrap/less/progress-bars.less";
@import "../../lib/bootstrap/less/progress-bars.less";
@import "../../lib/bootstrap/less/accordion.less";
@import "../../lib/bootstrap/less/carousel.less";
@import "../../lib/bootstrap/less/hero-unit.less";

View File

@@ -9,7 +9,7 @@
*
* @param navigationService {navigationService} A reference to the navigationService
*/
function NavigationController($scope, navigationService) {
function NavigationController($scope, navigationService, sectionResource) {
//load navigation service handlers
$scope.changeSection = navigationService.changeSection;
$scope.showTree = navigationService.showTree;
@@ -21,7 +21,14 @@ function NavigationController($scope, navigationService) {
$scope.ui = navigationService.ui;
$scope.selectedId = navigationService.currentId;
$scope.sections = navigationService.sections();
sectionResource.getSections()
.then(function(result) {
$scope.sections = result;
}, function (reason) {
//TODO: handle error properly
alert(reason);
});
//events
$scope.$on("treeOptionsClick", function (ev, args) {

View File

@@ -11,7 +11,7 @@
ng-click="changeSection(section.alias)"
ng-mouseenter="showTree(section.alias)"
prevent-default>
<i class="{{section.cssclass}}"></i><span>{{section.name}}</span>
<i class="{{section.cssclass | sectionIcon}}"></i><span>{{section.name}}</span>
</a>
</li>

View File

@@ -1,10 +1,10 @@
<?xml version="1.0"?>
<applications>
<add alias="content" name="Content" icon=".traycontent" sortOrder="0" />
<add alias="media" name="Media" icon=".traymedia" sortOrder="1" />
<add alias="settings" name="Settings" icon=".traysettings" sortOrder="2" />
<add alias="developer" name="Developer" icon=".traydeveloper" sortOrder="3" />
<add alias="users" name="Users" icon=".trayusers" sortOrder="4" />
<add alias="member" name="Members" icon=".traymember" sortOrder="5" />
<add alias="translation" name="Translation" icon=".traytranslation" sortOrder="6" />
<add alias="content" name="Content" icon="content" sortOrder="0" />
<add alias="media" name="Media" icon="media" sortOrder="1" />
<add alias="settings" name="Settings" icon="settings" sortOrder="2" />
<add alias="developer" name="Developer" icon="developer" sortOrder="3" />
<add alias="users" name="Users" icon="user" sortOrder="4" />
<add alias="member" name="Members" icon="member" sortOrder="5" />
<add alias="translation" name="Translation" icon="translation" sortOrder="6" />
</applications>

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<applications>
<add alias="content" name="Content" icon=".traycontent" sortOrder="0" />
<add alias="media" name="Media" icon=".traymedia" sortOrder="1" />
<add alias="settings" name="Settings" icon=".traysettings" sortOrder="2" />
<add alias="developer" name="Developer" icon=".traydeveloper" sortOrder="3" />
<add alias="users" name="Users" icon=".trayusers" sortOrder="4" />
<add alias="member" name="Members" icon=".traymember" sortOrder="5" />
<add alias="translation" name="Translation" icon=".traytranslation" sortOrder="6" />
<add alias="content" name="Content" icon="content" sortOrder="0" />
<add alias="media" name="Media" icon="media" sortOrder="1" />
<add alias="settings" name="Settings" icon="settings" sortOrder="2" />
<add alias="developer" name="Developer" icon="developer" sortOrder="3" />
<add alias="users" name="Users" icon="user" sortOrder="4" />
<add alias="member" name="Members" icon="member" sortOrder="5" />
<add alias="translation" name="Translation" icon="translation" sortOrder="6" />
</applications>

View File

@@ -11,7 +11,7 @@
ng-click="changeSection(section.alias)"
ng-mouseenter="showTree(section.alias)"
prevent-default>
<i class="{{section.cssclass}}"></i><span>{{section.name}}</span>
<i class="{{section.cssclass | sectionIcon}}"></i><span>{{section.name}}</span>
</a>
</li>

View File

@@ -19,7 +19,7 @@ namespace Umbraco.Web.Models.ContentEditing
public string Name { get; set; }
[DataMember(Name = "cssclass")]
public string CssClass { get; set; }
public string Icon { get; set; }
[DataMember(Name = "alias")]
public string Alias { get; set; }

View File

@@ -9,12 +9,12 @@ using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Umbraco.Core.IO;
using umbraco.BasePages;
using System.Xml;
using System.Xml.XPath;
using umbraco.BusinessLogic.Actions;
using ClientDependency.Core;
using umbraco.IO;
using System.Linq;
using System.Text;
using ClientDependency.Core.Controls;
@@ -35,38 +35,38 @@ namespace umbraco.cms.presentation
protected void Page_Load(object sender, System.EventArgs e)
{
var apps = this.getUser().Applications.ToList();
var apps = UmbracoUser.Applications.ToList();
bool userHasAccesstodefaultApp = apps.Where(x => x.alias == Umbraco.Core.Constants.Applications.Content).Count() > 0;
// Load user module icons ..
if (apps.Count() > 1)
{
var JSEvents = new StringBuilder();
var jsEvents = new StringBuilder();
PlaceHolderAppIcons.Text = ui.Text("main", "sections", base.getUser());
PlaceHolderAppIcons.Text = ui.Text("main", "sections", UmbracoUser);
plcIcons.Text = "";
foreach (BusinessLogic.Application a in apps.OrderBy(x => x.sortOrder))
foreach (var a in apps.OrderBy(x => x.sortOrder))
{
string appClass = a.icon.StartsWith(".") ? a.icon.Substring(1, a.icon.Length - 1) : a.alias;
//adds client side event handlers to the icon buttons
JSEvents.Append(@"jQuery('." + appClass + "').click(function() { appClick.call(this, '" + a.alias + "'); } );");
JSEvents.Append(@"jQuery('." + appClass + "').dblclick(function() { appDblClick.call(this, '" + a.alias + "'); } );");
jsEvents.Append(@"jQuery('." + appClass + "').click(function() { appClick.call(this, '" + a.alias + "'); } );");
jsEvents.Append(@"jQuery('." + appClass + "').dblclick(function() { appDblClick.call(this, '" + a.alias + "'); } );");
string iconElement = String.Format("<li><a class=\"{0}\" title=\"" + ui.Text("sections", a.alias, base.getUser()) + "\" href=\"javascript:void(0);\">", appClass);
string iconElement = String.Format("<li><a class=\"{0}\" title=\"" + ui.Text("sections", a.alias, UmbracoUser) + "\" href=\"javascript:void(0);\">", appClass);
if (a.icon.StartsWith("."))
iconElement +=
"<img src=\"images/nada.gif\" class=\"trayHolder\" alt=\"\" /></a></li>";
else
iconElement += "<img src=\"images/tray/" + a.icon + "\" class=\"trayIcon\" alt=\"" + ui.Text("sections", a.alias, base.getUser()) + "\"></a></li>";
iconElement += "<img src=\"images/tray/" + a.icon + "\" class=\"trayIcon\" alt=\"" + ui.Text("sections", a.alias, UmbracoUser) + "\"></a></li>";
plcIcons.Text += iconElement;
}
//registers the jquery event handlers.
Page.ClientScript.RegisterStartupScript(this.GetType(), "AppIcons", "jQuery(document).ready(function() { " + JSEvents.ToString() + " } );", true);
Page.ClientScript.RegisterStartupScript(this.GetType(), "AppIcons", "jQuery(document).ready(function() { " + jsEvents.ToString() + " } );", true);
}
else
@@ -87,7 +87,7 @@ namespace umbraco.cms.presentation
// Load globalized labels
treeWindow.Text = ui.Text("main", "tree", base.getUser());
treeWindow.Text = ui.Text("main", "tree", UmbracoUser);
RenderActionJS();
@@ -97,13 +97,13 @@ namespace umbraco.cms.presentation
var updChkCookie = new umbraco.BusinessLogic.StateHelper.Cookies.Cookie("UMB_UPDCHK", GlobalSettings.VersionCheckPeriod); // was "updateCheck"
string updateCheckCookie = updChkCookie.HasValue ? updChkCookie.GetValue() : "";
if (GlobalSettings.VersionCheckPeriod > 0 && String.IsNullOrEmpty(updateCheckCookie) && base.getUser().UserType.Alias == "admin")
if (GlobalSettings.VersionCheckPeriod > 0 && String.IsNullOrEmpty(updateCheckCookie) && UmbracoUser.UserType.Alias == "admin")
{
// Add scriptmanager version check
ScriptManager sm = ScriptManager.GetCurrent(Page);
sm.Scripts.Add(new ScriptReference(SystemDirectories.Umbraco + "/js/umbracoUpgradeChecker.js"));
sm.Services.Add(new ServiceReference(SystemDirectories.Webservices + "/CheckForUpgrade.asmx"));
sm.Services.Add(new ServiceReference(SystemDirectories.WebServices + "/CheckForUpgrade.asmx"));
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "upgradeChecker", "jQuery(document).ready(function() {umbraco.presentation.webservices.CheckForUpgrade.CallUpgradeService(umbracoCheckUpgrade);});", true);
@@ -129,7 +129,7 @@ namespace umbraco.cms.presentation
IOHelper.ResolveUrl(SystemDirectories.Umbraco + "/images/pinnedIcons/umb.ico"),
HttpContext.Current.Request.Url.Host.ToLower().Replace("www.", ""));
var user = base.getUser();
var user = UmbracoUser;
if (user != null && user.Applications != null && user.Applications.Length > 0)
{
foreach (var app in user.Applications)