Fixes login and tree
Adds tree loader, fixes icons, fixes toggle arrows Refactors httpbackend into nicer system Testing of promises are broken :( TODO: update docs
This commit is contained in:
@@ -19,7 +19,7 @@ module.exports = function (grunt) {
|
||||
grunt.registerTask('dev', ['jshint:dev', 'build', 'webserver', 'open:dev', 'watch']);
|
||||
|
||||
//run by the watch task
|
||||
grunt.registerTask('watch-build', ['jshint:dev','recess:build','karma:unit','concat','copy']);
|
||||
grunt.registerTask('watch-build', ['jshint:dev','recess:build','concat','copy','karma:unit']);
|
||||
|
||||
//triggered from grunt dev or grunt
|
||||
grunt.registerTask('build', ['clean','concat','recess:build','copy']);
|
||||
@@ -152,9 +152,9 @@ module.exports = function (grunt) {
|
||||
src:['src/common/resources/*.js'],
|
||||
dest: '<%= distdir %>/js/umbraco.resources.js'
|
||||
},
|
||||
mocks: {
|
||||
src:['src/common/mocks/**/*.js'],
|
||||
dest: '<%= distdir %>/js/umbraco.mocks.js'
|
||||
testing: {
|
||||
src:['src/common/mocks/resources/*.js'],
|
||||
dest: '<%= distdir %>/js/umbraco.testing.js'
|
||||
},
|
||||
directives: {
|
||||
src:['src/common/directives/*.js'],
|
||||
|
||||
+1885
-1845
File diff suppressed because it is too large
Load Diff
-14733
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,41 @@
|
||||
angular.module('umbraco.mocks.resources')
|
||||
.factory('contentTypeResource', function () {
|
||||
return {
|
||||
|
||||
//return a content type with a given ID
|
||||
getContentType: function(id){
|
||||
|
||||
return {
|
||||
name: "News Article",
|
||||
alias: "newsArticle",
|
||||
id: id,
|
||||
tabs:[]
|
||||
};
|
||||
|
||||
},
|
||||
//return all availabel types
|
||||
all: function(){
|
||||
return [];
|
||||
},
|
||||
|
||||
//return children inheriting a given type
|
||||
children: function(id){
|
||||
return [];
|
||||
},
|
||||
|
||||
//return all content types a type inherite from
|
||||
parents: function(id){
|
||||
return [];
|
||||
},
|
||||
|
||||
//return all types allowed under given document
|
||||
getAllowedTypes: function(documentId){
|
||||
return [
|
||||
{name: "News Article", description: "Standard news article", alias: "newsArticle", id: 1234, cssClass:"file"},
|
||||
{name: "News Area", description: "Area to hold all news articles, there should be only one", alias: "newsArea", id: 1234, cssClass:"suitcase"},
|
||||
{name: "Employee", description: "Employee profile information page", alias: "employee", id: 1234, cssClass:"user"}
|
||||
];
|
||||
}
|
||||
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* @ngdoc factory
|
||||
* @name umbraco.resources.treeResource
|
||||
* @description Loads in data for trees
|
||||
**/
|
||||
function _getChildren(options){
|
||||
if(options === undefined){
|
||||
options = {};
|
||||
}
|
||||
var section = options.section || 'content';
|
||||
var treeItem = options.node;
|
||||
|
||||
var iLevel = treeItem.level + 1;
|
||||
|
||||
//hack to have create as default content action
|
||||
var action;
|
||||
if(section === "content"){
|
||||
action = "create";
|
||||
}
|
||||
|
||||
return [
|
||||
{ name: "child-of-" + treeItem.name, id: iLevel + "" + 1234, icon: "icon-file-alt", view: section + "/edit/" + iLevel + "" + 1234, children: [], expanded: false, hasChildren: true, level: iLevel, defaultAction: action, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: iLevel + "" + 1235, icon: "icon-file-alt", view: section + "/edit/" + iLevel + "" + 1235, children: [], expanded: false, hasChildren: true, level: iLevel, defaultAction: action, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: iLevel + "" + 1236, icon: "icon-file-alt", view: section + "/edit/" + iLevel + "" + 1236, children: [], expanded: false, hasChildren: true, level: iLevel, defaultAction: action, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: iLevel + "" + 1237, icon: "icon-file-alt", view: "common/legacy/1237?p=" + encodeURI("developer/contentType.aspx?idequal1234"), children: [], expanded: false, hasChildren: true, level: iLevel, defaultAction: action, menu: getMenuItems() }
|
||||
];
|
||||
}
|
||||
|
||||
function _getMenuItems() {
|
||||
return [
|
||||
{ name: "Create", cssclass: "plus", alias: "create" },
|
||||
|
||||
{ seperator: true, name: "Delete", cssclass: "remove", alias: "delete" },
|
||||
{ name: "Move", cssclass: "move", alias: "move" },
|
||||
{ name: "Copy", cssclass: "copy", alias: "copy" },
|
||||
{ name: "Sort", cssclass: "sort", alias: "sort" },
|
||||
|
||||
{ seperator: true, name: "Publish", cssclass: "globe", alias: "publish" },
|
||||
{ name: "Rollback", cssclass: "undo", alias: "rollback" },
|
||||
|
||||
{ seperator: true, name: "Permissions", cssclass: "lock", alias: "permissions" },
|
||||
{ name: "Audit Trail", cssclass: "time", alias: "audittrail" },
|
||||
{ name: "Notifications", cssclass: "envelope", alias: "notifications" },
|
||||
|
||||
{ seperator: true, name: "Hostnames", cssclass: "home", alias: "hostnames" },
|
||||
{ name: "Public Access", cssclass: "group", alias: "publicaccess" },
|
||||
|
||||
{ seperator: true, name: "Reload", cssclass: "refresh", alias: "users" }
|
||||
];
|
||||
}
|
||||
|
||||
var treeArray = [];
|
||||
function _getApplication(section){
|
||||
|
||||
var t;
|
||||
switch(section){
|
||||
|
||||
case "content":
|
||||
t = [
|
||||
{ name: "My website", id: 1234, icon: "icon-home", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menu: getMenuItems() },
|
||||
{ name: "Components", id: 1235, icon: "icon-cogs", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menu: getMenuItems() },
|
||||
{ name: "Archieve", id: 1236, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menu: getMenuItems() },
|
||||
{ name: "Recycle Bin", id: 1237, icon: "icon-trash", view: section + "/trash/view/", children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menu: getMenuItems() }
|
||||
];
|
||||
break;
|
||||
|
||||
case "developer":
|
||||
t = [
|
||||
{ name: "Data types", id: 1234, icon: "icon-folder-close", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Macros", id: 1235, icon: "icon-folder-close", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Pacakges", id: 1236, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "XSLT Files", id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Razor Files", id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() }
|
||||
];
|
||||
break;
|
||||
case "settings":
|
||||
t = [
|
||||
{ name: "Stylesheets", id: 1234, icon: "icon-folder-close", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Templates", id: 1235, icon: "icon-folder-close", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Dictionary", id: 1236, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Media types", id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Document types", id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() }
|
||||
];
|
||||
break;
|
||||
default:
|
||||
t = [
|
||||
{ name: "random-name-" + section, id: 1234, icon: "icon-home", defaultAction: "create", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: 1235, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: 1236, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: 1237, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() }
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
//treeArray[cacheKey] = t;
|
||||
return t;
|
||||
}
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 769 KiB |
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
angular.module("umbraco.directives")
|
||||
.directive('umbTreeItem', function($compile, $http, $templateCache, $interpolate, $log, $location, treeService) {
|
||||
.directive('umbTreeItem', function($compile, $http, $templateCache, $interpolate, $log, $location, treeService, notificationsService) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
@@ -10,14 +10,15 @@ angular.module("umbraco.directives")
|
||||
node:'='
|
||||
},
|
||||
|
||||
template: '<li><div ng-style="setTreePadding(node)">' +
|
||||
template: '<li><div ng-style="setTreePadding(node)" ng-class="{\'loading\': node.loading}">' +
|
||||
'<ins ng-hide="node.hasChildren" style="background:none;width:18px;"></ins>' +
|
||||
'<ins ng-show="node.hasChildren" ng-class="{\'icon-caret-right\': !node.expanded, \'icon-caret-down\': node.expanded}" ng-click="load(node)"></ins>' +
|
||||
'<i class="{{node | umbTreeIconClass:\'icon umb-tree-icon sprTree\'}}" style="{{node | umbTreeIconStyle}}"></i>' +
|
||||
'<a ng-click="select(this, node, $event)" >{{node.name}}</a>' +
|
||||
'<i class="umb-options" ng-click="options(this, node, $event)"><i></i><i></i><i></i></i>' +
|
||||
'</div>'+
|
||||
'</li>',
|
||||
'<ins ng-show="node.hasChildren" ng-class="{\'icon-caret-right\': !node.expanded, \'icon-caret-down\': node.expanded}" ng-click="load(this, node)"></ins>' +
|
||||
'<i class="{{node | umbTreeIconClass:\'icon umb-tree-icon sprTree\'}}" style="{{node | umbTreeIconStyle}}"></i>' +
|
||||
'<a ng-click="select(this, node, $event)" >{{node.name}}</a>' +
|
||||
'<i class="umb-options" ng-click="options(this, node, $event)"><i></i><i></i><i></i></i>' +
|
||||
'<div ng-show="node.loading" class="l"><div></div></div>' +
|
||||
'</div>' +
|
||||
'</li>',
|
||||
|
||||
link: function (scope, element, attrs) {
|
||||
|
||||
@@ -68,18 +69,29 @@ angular.module("umbraco.directives")
|
||||
scope.$emit("treeNodeSelect", { element: e, node: n, event: ev });
|
||||
};
|
||||
|
||||
scope.load = function (node) {
|
||||
scope.load = function (arrow, node) {
|
||||
|
||||
if (node.expanded){
|
||||
node.expanded = false;
|
||||
node.children = [];
|
||||
node.children = [];
|
||||
|
||||
}else {
|
||||
|
||||
node.loading = true;
|
||||
|
||||
treeService.getChildren( { node: node, section: scope.section } )
|
||||
.then(function (data) {
|
||||
node.loading = false;
|
||||
// $(arrow).parent().remove(loader);
|
||||
|
||||
node.children = data;
|
||||
node.expanded = true;
|
||||
}, function (reason) {
|
||||
alert(reason);
|
||||
}, function (reason) {
|
||||
// $(arrow).parent().remove(loader);
|
||||
node.loading = false;
|
||||
notificationsService.error(reason);
|
||||
|
||||
//alert(reason);
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function treeIconStyleFilter(treeIconHelper) {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
return "background-image: url('" + treeNode.iconFilePath + "');height:16px;background-position:2px 0px";
|
||||
return "background-image: url('" + treeNode.iconFilePath + "');height:16px; background-position:2px 0px; background-repeat: no-repeat";
|
||||
};
|
||||
}
|
||||
angular.module('umbraco.filters').filter("umbTreeIconStyle", treeIconStyleFilter);
|
||||
@@ -0,0 +1 @@
|
||||
angular.module("umbraco.mocks", ['ngMockE2E']);
|
||||
@@ -0,0 +1,18 @@
|
||||
angular.module('umbraco.mocks').
|
||||
factory('mocksUtills', function () {
|
||||
'use strict';
|
||||
|
||||
return {
|
||||
urlRegex: function(url) {
|
||||
url = url.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||
return new RegExp("^" + url);
|
||||
},
|
||||
|
||||
getParameterByName: function(url, name) {
|
||||
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
|
||||
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
|
||||
results = regex.exec(url);
|
||||
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -1,160 +1,91 @@
|
||||
function _getNode(id){
|
||||
return {
|
||||
name: "My content with id: " + id,
|
||||
updateDate: new Date(),
|
||||
publishDate: new Date(),
|
||||
id: id,
|
||||
parentId: 1234,
|
||||
icon: "icon-file-alt",
|
||||
owner: {name: "Administrator", id: 0},
|
||||
updater: {name: "Per Ploug Krogslund", id: 1},
|
||||
angular.module('umbraco.mocks').
|
||||
factory('contentMocks', ['$httpBackend', 'mocksUtills', function ($httpBackend, mocksUtills) {
|
||||
'use strict';
|
||||
|
||||
function returnNodebyId(status, data, headers) {
|
||||
var id = mocksUtills.getParameterByName(data, "id") || 1234;
|
||||
|
||||
var node = {
|
||||
name: "My content with id: " + id,
|
||||
updateDate: new Date(),
|
||||
publishDate: new Date(),
|
||||
id: id,
|
||||
parentId: 1234,
|
||||
icon: "icon-file-alt",
|
||||
owner: {name: "Administrator", id: 0},
|
||||
updater: {name: "Per Ploug Krogslund", id: 1},
|
||||
|
||||
tabs: [
|
||||
{
|
||||
label: "Child documents",
|
||||
alias: "tab00",
|
||||
id: 0,
|
||||
active: true,
|
||||
properties: [
|
||||
{ alias: "list", label: "List", view: "listview", value: "", hideLabel: true }
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "Content",
|
||||
alias: "tab01",
|
||||
id: 1,
|
||||
properties: [
|
||||
{ alias: "bodyText", label: "Body Text", description:"Here you enter the primary article contents", view: "rte", value: "<p>askjdkasj lasjd</p>" },
|
||||
{ alias: "textarea", label: "textarea", view: "textarea", value: "ajsdka sdjkds", config: { rows: 4 } },
|
||||
{ alias: "map", label: "Map", view: "googlemaps", value: "37.4419,-122.1419", config: { mapType: "ROADMAP", zoom: 4 } },
|
||||
{ alias: "media", label: "Media picker", view: "mediapicker", value: "" },
|
||||
{ alias: "content", label: "Content picker", view: "contentpicker", value: "" }
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "Sample Editor",
|
||||
alias: "tab02",
|
||||
id: 2,
|
||||
properties: [
|
||||
{ alias: "datepicker", label: "Datepicker", view: "datepicker", config: { rows: 7 } },
|
||||
{ alias: "tags", label: "Tags", view: "tags", value: ""}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "Grid",
|
||||
alias: "tab03",
|
||||
id: 3,
|
||||
properties: [
|
||||
{ alias: "grid", label: "Grid", view: "grid", controller: "umbraco.grid", value: "test", hideLabel: true }
|
||||
]
|
||||
},{
|
||||
label: "WIP",
|
||||
alias: "tab04",
|
||||
id: 4,
|
||||
properties: [
|
||||
{ alias: "tes", label: "Stuff", view: "test", controller: "umbraco.embeddedcontent", value: "",
|
||||
tabs: [
|
||||
{
|
||||
label: "Child documents",
|
||||
alias: "tab00",
|
||||
id: 0,
|
||||
active: true,
|
||||
properties: [
|
||||
{ alias: "list", label: "List", view: "listview", value: "", hideLabel: true }
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "Content",
|
||||
alias: "tab01",
|
||||
id: 1,
|
||||
properties: [
|
||||
{ alias: "bodyText", label: "Body Text", description:"Here you enter the primary article contents", view: "rte", value: "<p>askjdkasj lasjd</p>" },
|
||||
{ alias: "textarea", label: "textarea", view: "textarea", value: "ajsdka sdjkds", config: { rows: 4 } },
|
||||
{ alias: "map", label: "Map", view: "googlemaps", value: "37.4419,-122.1419", config: { mapType: "ROADMAP", zoom: 4 } },
|
||||
{ alias: "media", label: "Media picker", view: "mediapicker", value: "" },
|
||||
{ alias: "content", label: "Content picker", view: "contentpicker", value: "" }
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "Sample Editor",
|
||||
alias: "tab02",
|
||||
id: 2,
|
||||
properties: [
|
||||
{ alias: "datepicker", label: "Datepicker", view: "datepicker", config: { rows: 7 } },
|
||||
{ alias: "tags", label: "Tags", view: "tags", value: ""}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "Grid",
|
||||
alias: "tab03",
|
||||
id: 3,
|
||||
properties: [
|
||||
{ alias: "grid", label: "Grid", view: "grid", controller: "umbraco.grid", value: "test", hideLabel: true }
|
||||
]
|
||||
},{
|
||||
label: "WIP",
|
||||
alias: "tab04",
|
||||
id: 4,
|
||||
properties: [
|
||||
{ alias: "tes", label: "Stuff", view: "test", controller: "umbraco.embeddedcontent", value: "",
|
||||
|
||||
config: {
|
||||
fields: [
|
||||
{ alias: "embedded", label: "Embbeded", view: "textstring", value: ""},
|
||||
{ alias: "embedded2", label: "Embbeded 2", view: "contentpicker", value: ""},
|
||||
{ alias: "embedded3", label: "Embbeded 3", view: "textarea", value: ""},
|
||||
{ alias: "embedded4", label: "Embbeded 4", view: "datepicker", value: ""}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
angular.module('umbraco.mocks.resources')
|
||||
.factory('contentResource', function ($q) {
|
||||
var contentArray = [];
|
||||
var factory = {
|
||||
getById: function (id) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
if (contentArray[id] !== undefined){
|
||||
deferred.resolve(contentArray[id]);
|
||||
}else{
|
||||
deferred.resolve(_getNode(id));
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
//returns an empty content object which can be persistent on the content service
|
||||
//requires the parent id and the alias of the content type to base the scaffold on
|
||||
getContentScaffold: function(parentId, alias){
|
||||
|
||||
//use temp storage for now...
|
||||
|
||||
var c = this.getContent(parentId);
|
||||
c.name = "empty name";
|
||||
|
||||
$.each(c.tabs, function(index, tab){
|
||||
$.each(tab.properties,function(index, property){
|
||||
property.value = "";
|
||||
});
|
||||
});
|
||||
|
||||
return c;
|
||||
},
|
||||
|
||||
getChildren: function(parentId, options){
|
||||
|
||||
if(options === undefined){
|
||||
options = {
|
||||
take: 10,
|
||||
offset: 0,
|
||||
filter: ''
|
||||
};
|
||||
}
|
||||
|
||||
var collection = {take: 10, total: 68, pages: 7, currentPage: options.offset, filter: options.filter};
|
||||
collection.total = 56 - (options.filter.length);
|
||||
collection.pages = Math.round(collection.total / collection.take);
|
||||
collection.resultSet = [];
|
||||
|
||||
if(collection.total < options.take){
|
||||
collection.take = collection.total;
|
||||
}else{
|
||||
collection.take = options.take;
|
||||
}
|
||||
|
||||
|
||||
var _id = 0;
|
||||
for (var i = 0; i < collection.take; i++) {
|
||||
_id = (parentId + i) * options.offset;
|
||||
var cnt = this.getById(_id);
|
||||
|
||||
//here we fake filtering
|
||||
if(options.filter !== ''){
|
||||
cnt.name = options.filter + cnt.name;
|
||||
}
|
||||
|
||||
collection.resultSet.push(cnt);
|
||||
}
|
||||
|
||||
return collection;
|
||||
},
|
||||
|
||||
//saves or updates a content object
|
||||
saveContent: function (content) {
|
||||
contentArray[content.id] = content;
|
||||
//alert("Saved: " + JSON.stringify(content));
|
||||
},
|
||||
|
||||
publishContent: function (content) {
|
||||
contentArray[content.id] = content;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return factory;
|
||||
});
|
||||
config: {
|
||||
fields: [
|
||||
{ alias: "embedded", label: "Embbeded", view: "textstring", value: ""},
|
||||
{ alias: "embedded2", label: "Embbeded 2", view: "contentpicker", value: ""},
|
||||
{ alias: "embedded3", label: "Embbeded 3", view: "textarea", value: ""},
|
||||
{ alias: "embedded4", label: "Embbeded 4", view: "datepicker", value: ""}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
return [200, node, null];
|
||||
}
|
||||
|
||||
|
||||
|
||||
return {
|
||||
register: function() {
|
||||
|
||||
$httpBackend
|
||||
.whenGET(mocksUtills.urlRegex('/umbraco/UmbracoApi/Content/GetById'))
|
||||
.respond(returnNodebyId);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
}]);
|
||||
@@ -1,41 +1,24 @@
|
||||
angular.module('umbraco.mocks.resources')
|
||||
.factory('contentTypeResource', function () {
|
||||
return {
|
||||
|
||||
//return a content type with a given ID
|
||||
getContentType: function(id){
|
||||
|
||||
return {
|
||||
name: "News Article",
|
||||
alias: "newsArticle",
|
||||
id: id,
|
||||
tabs:[]
|
||||
};
|
||||
|
||||
},
|
||||
//return all availabel types
|
||||
all: function(){
|
||||
return [];
|
||||
},
|
||||
|
||||
//return children inheriting a given type
|
||||
children: function(id){
|
||||
return [];
|
||||
},
|
||||
|
||||
//return all content types a type inherite from
|
||||
parents: function(id){
|
||||
return [];
|
||||
},
|
||||
|
||||
//return all types allowed under given document
|
||||
getAllowedTypes: function(documentId){
|
||||
return [
|
||||
{name: "News Article", description: "Standard news article", alias: "newsArticle", id: 1234, cssClass:"file"},
|
||||
{name: "News Area", description: "Area to hold all news articles, there should be only one", alias: "newsArea", id: 1234, cssClass:"suitcase"},
|
||||
{name: "Employee", description: "Employee profile information page", alias: "employee", id: 1234, cssClass:"user"}
|
||||
angular.module('umbraco.mocks').
|
||||
factory('contentTypeMocks', ['$httpBackend', 'mocksUtills', function ($httpBackend, mocksUtills) {
|
||||
'use strict';
|
||||
|
||||
function returnAllowedChildren(status, data, headers) {
|
||||
var types = [
|
||||
{ name: "News Article", description: "Standard news article", alias: "newsArticle", id: 1234, cssClass: "file" },
|
||||
{ name: "News Area", description: "Area to hold all news articles, there should be only one", alias: "newsArea", id: 1234, cssClass: "suitcase" },
|
||||
{ name: "Employee", description: "Employee profile information page", alias: "employee", id: 1234, cssClass: "user" }
|
||||
];
|
||||
}
|
||||
|
||||
};
|
||||
});
|
||||
return [200, types, null];
|
||||
}
|
||||
|
||||
return {
|
||||
register: function() {
|
||||
|
||||
$httpBackend
|
||||
.whenGET(mocksUtills.urlRegex('/umbraco/Api/'))
|
||||
.respond(returnAllowedChildren);
|
||||
|
||||
}
|
||||
};
|
||||
}]);
|
||||
@@ -1,97 +1,109 @@
|
||||
/**
|
||||
* @ngdoc factory
|
||||
* @name umbraco.resources.treeResource
|
||||
* @description Loads in data for trees
|
||||
**/
|
||||
function _getChildren(options){
|
||||
if(options === undefined){
|
||||
options = {};
|
||||
}
|
||||
var section = options.section || 'content';
|
||||
var treeItem = options.node;
|
||||
angular.module('umbraco.mocks').
|
||||
factory('treeMocks', ['$httpBackend', 'mocksUtills', function ($httpBackend, mocksUtills) {
|
||||
'use strict';
|
||||
|
||||
function getMenuItems() {
|
||||
return [
|
||||
{ name: "Create", cssclass: "plus", alias: "create" },
|
||||
|
||||
var iLevel = treeItem.level + 1;
|
||||
{ seperator: true, name: "Delete", cssclass: "remove", alias: "delete" },
|
||||
{ name: "Move", cssclass: "move", alias: "move" },
|
||||
{ name: "Copy", cssclass: "copy", alias: "copy" },
|
||||
{ name: "Sort", cssclass: "sort", alias: "sort" },
|
||||
|
||||
//hack to have create as default content action
|
||||
var action;
|
||||
if(section === "content"){
|
||||
action = "create";
|
||||
}
|
||||
{ seperator: true, name: "Publish", cssclass: "globe", alias: "publish" },
|
||||
{ name: "Rollback", cssclass: "undo", alias: "rollback" },
|
||||
|
||||
return [
|
||||
{ name: "child-of-" + treeItem.name, id: iLevel + "" + 1234, icon: "icon-file-alt", view: section + "/edit/" + iLevel + "" + 1234, children: [], expanded: false, hasChildren: true, level: iLevel, defaultAction: action, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: iLevel + "" + 1235, icon: "icon-file-alt", view: section + "/edit/" + iLevel + "" + 1235, children: [], expanded: false, hasChildren: true, level: iLevel, defaultAction: action, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: iLevel + "" + 1236, icon: "icon-file-alt", view: section + "/edit/" + iLevel + "" + 1236, children: [], expanded: false, hasChildren: true, level: iLevel, defaultAction: action, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: iLevel + "" + 1237, icon: "icon-file-alt", view: "common/legacy/1237?p=" + encodeURI("developer/contentType.aspx?idequal1234"), children: [], expanded: false, hasChildren: true, level: iLevel, defaultAction: action, menu: getMenuItems() }
|
||||
];
|
||||
}
|
||||
|
||||
function _getMenuItems() {
|
||||
return [
|
||||
{ name: "Create", cssclass: "plus", alias: "create" },
|
||||
{ seperator: true, name: "Permissions", cssclass: "lock", alias: "permissions" },
|
||||
{ name: "Audit Trail", cssclass: "time", alias: "audittrail" },
|
||||
{ name: "Notifications", cssclass: "envelope", alias: "notifications" },
|
||||
|
||||
{ seperator: true, name: "Delete", cssclass: "remove", alias: "delete" },
|
||||
{ name: "Move", cssclass: "move", alias: "move" },
|
||||
{ name: "Copy", cssclass: "copy", alias: "copy" },
|
||||
{ name: "Sort", cssclass: "sort", alias: "sort" },
|
||||
{ seperator: true, name: "Hostnames", cssclass: "home", alias: "hostnames" },
|
||||
{ name: "Public Access", cssclass: "group", alias: "publicaccess" },
|
||||
|
||||
{ seperator: true, name: "Publish", cssclass: "globe", alias: "publish" },
|
||||
{ name: "Rollback", cssclass: "undo", alias: "rollback" },
|
||||
{ seperator: true, name: "Reload", cssclass: "refresh", alias: "users" }
|
||||
];
|
||||
}
|
||||
|
||||
{ seperator: true, name: "Permissions", cssclass: "lock", alias: "permissions" },
|
||||
{ name: "Audit Trail", cssclass: "time", alias: "audittrail" },
|
||||
{ name: "Notifications", cssclass: "envelope", alias: "notifications" },
|
||||
function _getChildren(options) {
|
||||
if (options === undefined) {
|
||||
options = {};
|
||||
}
|
||||
var section = options.section || 'content';
|
||||
var treeItem = options.node;
|
||||
|
||||
{ seperator: true, name: "Hostnames", cssclass: "home", alias: "hostnames" },
|
||||
{ name: "Public Access", cssclass: "group", alias: "publicaccess" },
|
||||
var iLevel = treeItem.level + 1;
|
||||
|
||||
{ seperator: true, name: "Reload", cssclass: "refresh", alias: "users" }
|
||||
];
|
||||
}
|
||||
//hack to have create as default content action
|
||||
var action;
|
||||
if (section === "content") {
|
||||
action = "create";
|
||||
}
|
||||
|
||||
var treeArray = [];
|
||||
function _getApplication(section){
|
||||
|
||||
var t;
|
||||
switch(section){
|
||||
return [
|
||||
{ name: "child-of-" + treeItem.name, id: iLevel + "" + 1234, icon: "icon-file-alt", view: section + "/edit/" + iLevel + "" + 1234, children: [], expanded: false, hasChildren: true, level: iLevel, defaultAction: action, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: iLevel + "" + 1235, icon: "icon-file-alt", view: section + "/edit/" + iLevel + "" + 1235, children: [], expanded: false, hasChildren: true, level: iLevel, defaultAction: action, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: iLevel + "" + 1236, icon: "icon-file-alt", view: section + "/edit/" + iLevel + "" + 1236, children: [], expanded: false, hasChildren: true, level: iLevel, defaultAction: action, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: iLevel + "" + 1237, icon: "icon-file-alt", view: "common/legacy/1237?p=" + encodeURI("developer/contentType.aspx?idequal1234"), children: [], expanded: false, hasChildren: true, level: iLevel, defaultAction: action, menu: getMenuItems() }
|
||||
];
|
||||
}
|
||||
|
||||
case "content":
|
||||
t = [
|
||||
{ name: "My website", id: 1234, icon: "icon-home", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menu: getMenuItems() },
|
||||
{ name: "Components", id: 1235, icon: "icon-cogs", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menu: getMenuItems() },
|
||||
{ name: "Archieve", id: 1236, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menu: getMenuItems() },
|
||||
{ name: "Recycle Bin", id: 1237, icon: "icon-trash", view: section + "/trash/view/", children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menu: getMenuItems() }
|
||||
];
|
||||
break;
|
||||
function returnApplicationTrees(status, data, headers) {
|
||||
var section = mocksUtills.getParameterByName(data, "application");
|
||||
|
||||
case "developer":
|
||||
t = [
|
||||
{ name: "Data types", id: 1234, icon: "icon-folder-close", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Macros", id: 1235, icon: "icon-folder-close", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Pacakges", id: 1236, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "XSLT Files", id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Razor Files", id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() }
|
||||
];
|
||||
break;
|
||||
case "settings":
|
||||
t = [
|
||||
{ name: "Stylesheets", id: 1234, icon: "icon-folder-close", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Templates", id: 1235, icon: "icon-folder-close", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Dictionary", id: 1236, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Media types", id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Document types", id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() }
|
||||
];
|
||||
break;
|
||||
default:
|
||||
t = [
|
||||
{ name: "random-name-" + section, id: 1234, icon: "icon-home", defaultAction: "create", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: 1235, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: 1236, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: 1237, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() }
|
||||
];
|
||||
break;
|
||||
}
|
||||
var t;
|
||||
switch (section) {
|
||||
|
||||
//treeArray[cacheKey] = t;
|
||||
return t;
|
||||
}
|
||||
case "content":
|
||||
t = [
|
||||
{ name: "My website", id: 1234, icon: "icon-home", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menu: getMenuItems() },
|
||||
{ name: "Components", id: 1235, icon: "icon-cogs", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menu: getMenuItems() },
|
||||
{ name: "Archieve", id: 1236, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menu: getMenuItems() },
|
||||
{ name: "Recycle Bin", id: 1237, icon: "icon-trash", view: section + "/trash/view/", children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menu: getMenuItems() }
|
||||
];
|
||||
break;
|
||||
|
||||
case "developer":
|
||||
t = [
|
||||
{ name: "Data types", id: 1234, icon: "icon-folder-close", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Macros", id: 1235, icon: "icon-folder-close", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Pacakges", id: 1236, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "XSLT Files", id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Razor Files", id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() }
|
||||
];
|
||||
break;
|
||||
case "settings":
|
||||
t = [
|
||||
{ name: "Stylesheets", id: 1234, icon: "icon-folder-close", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Templates", id: 1235, icon: "icon-folder-close", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Dictionary", id: 1236, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Media types", id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Document types", id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() }
|
||||
];
|
||||
break;
|
||||
default:
|
||||
t = [
|
||||
{ name: "random-name-" + section, id: 1234, icon: "icon-home", defaultAction: "create", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: 1235, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: 1236, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: 1237, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() }
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return [200, t, null];
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
register: function() {
|
||||
|
||||
$httpBackend
|
||||
.whenGET(mocksUtills.urlRegex('/umbraco/UmbracoTrees/ApplicationTreeApi/GetApplicationTrees'))
|
||||
.respond(returnApplicationTrees);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
}]);
|
||||
@@ -0,0 +1,40 @@
|
||||
angular.module('umbraco.mocks').
|
||||
factory('userMocks', ['$httpBackend', 'mocksUtills', function ($httpBackend, mocksUtills) {
|
||||
'use strict';
|
||||
|
||||
var firsttry = true;
|
||||
function returnUser(status, data, headers) {
|
||||
var app = mocksUtills.getParameterByName(data, "application");
|
||||
|
||||
var mocked = {
|
||||
name: "Per Ploug",
|
||||
email: "test@test.com",
|
||||
emailHash: "f9879d71855b5ff21e4963273a886bfc",
|
||||
id: 0,
|
||||
locale: 'da-DK'
|
||||
};
|
||||
|
||||
if (firsttry) {
|
||||
firsttry = false;
|
||||
return [200, mocked, null];
|
||||
} else {
|
||||
return [200, mocked, null];
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
register: function() {
|
||||
|
||||
$httpBackend
|
||||
.whenPOST(mocksUtills.urlRegex('/umbraco/UmbracoApi/Authentication/PostLogin'))
|
||||
.respond(returnUser);
|
||||
|
||||
|
||||
$httpBackend
|
||||
.whenGET('/umbraco/UmbracoApi/Authentication/GetCurrentUser')
|
||||
.respond(returnUser);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
}]);
|
||||
@@ -1,108 +0,0 @@
|
||||
function getMenuItems() {
|
||||
return [
|
||||
{ name: "Create", cssclass: "plus", alias: "create" },
|
||||
|
||||
{ seperator: true, name: "Delete", cssclass: "remove", alias: "delete" },
|
||||
{ name: "Move", cssclass: "move", alias: "move" },
|
||||
{ name: "Copy", cssclass: "copy", alias: "copy" },
|
||||
{ name: "Sort", cssclass: "sort", alias: "sort" },
|
||||
|
||||
{ seperator: true, name: "Publish", cssclass: "globe", alias: "publish" },
|
||||
{ name: "Rollback", cssclass: "undo", alias: "rollback" },
|
||||
|
||||
{ seperator: true, name: "Permissions", cssclass: "lock", alias: "permissions" },
|
||||
{ name: "Audit Trail", cssclass: "time", alias: "audittrail" },
|
||||
{ name: "Notifications", cssclass: "envelope", alias: "notifications" },
|
||||
|
||||
{ seperator: true, name: "Hostnames", cssclass: "home", alias: "hostnames" },
|
||||
{ name: "Public Access", cssclass: "group", alias: "publicaccess" },
|
||||
|
||||
{ seperator: true, name: "Reload", cssclass: "refresh", alias: "users" }
|
||||
];
|
||||
}
|
||||
|
||||
function _getChildren(options){
|
||||
if(options === undefined){
|
||||
options = {};
|
||||
}
|
||||
var section = options.section || 'content';
|
||||
var treeItem = options.node;
|
||||
|
||||
var iLevel = treeItem.level + 1;
|
||||
|
||||
//hack to have create as default content action
|
||||
var action;
|
||||
if(section === "content"){
|
||||
action = "create";
|
||||
}
|
||||
|
||||
return [
|
||||
{ name: "child-of-" + treeItem.name, id: iLevel + "" + 1234, icon: "icon-file-alt", view: section + "/edit/" + iLevel + "" + 1234, children: [], expanded: false, hasChildren: true, level: iLevel, defaultAction: action, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: iLevel + "" + 1235, icon: "icon-file-alt", view: section + "/edit/" + iLevel + "" + 1235, children: [], expanded: false, hasChildren: true, level: iLevel, defaultAction: action, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: iLevel + "" + 1236, icon: "icon-file-alt", view: section + "/edit/" + iLevel + "" + 1236, children: [], expanded: false, hasChildren: true, level: iLevel, defaultAction: action, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: iLevel + "" + 1237, icon: "icon-file-alt", view: "common/legacy/1237?p=" + encodeURI("developer/contentType.aspx?idequal1234"), children: [], expanded: false, hasChildren: true, level: iLevel, defaultAction: action, menu: getMenuItems() }
|
||||
];
|
||||
}
|
||||
|
||||
var treeArray = [];
|
||||
function _getApplication(section){
|
||||
|
||||
var t;
|
||||
switch(section){
|
||||
|
||||
case "content":
|
||||
t = [
|
||||
{ name: "My website", id: 1234, icon: "icon-home", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menu: getMenuItems() },
|
||||
{ name: "Components", id: 1235, icon: "icon-cogs", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menu: getMenuItems() },
|
||||
{ name: "Archieve", id: 1236, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menu: getMenuItems() },
|
||||
{ name: "Recycle Bin", id: 1237, icon: "icon-trash", view: section + "/trash/view/", children: [], expanded: false, hasChildren: true, level: 1, defaultAction: "create", menu: getMenuItems() }
|
||||
];
|
||||
break;
|
||||
|
||||
case "developer":
|
||||
t = [
|
||||
{ name: "Data types", id: 1234, icon: "icon-folder-close", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Macros", id: 1235, icon: "icon-folder-close", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Pacakges", id: 1236, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "XSLT Files", id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Razor Files", id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() }
|
||||
];
|
||||
break;
|
||||
case "settings":
|
||||
t = [
|
||||
{ name: "Stylesheets", id: 1234, icon: "icon-folder-close", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Templates", id: 1235, icon: "icon-folder-close", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Dictionary", id: 1236, icon: "icon-folder-close", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Media types", id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "Document types", id: 1237, icon: "icon-folder-close", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() }
|
||||
];
|
||||
break;
|
||||
default:
|
||||
t = [
|
||||
{ name: "random-name-" + section, id: 1234, icon: "icon-home", defaultAction: "create", view: section + "/edit/" + 1234, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: 1235, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1235, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: 1236, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1236, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() },
|
||||
{ name: "random-name-" + section, id: 1237, icon: "icon-folder-close", defaultAction: "create", view: section + "/edit/" + 1237, children: [], expanded: false, hasChildren: true, level: 1, menu: getMenuItems() }
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
//treeArray[cacheKey] = t;
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var _backendData = {
|
||||
tree:{
|
||||
getApplication: _getApplication,
|
||||
getChildren: _getChildren
|
||||
},
|
||||
content: {
|
||||
getNode: function(){return null;}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,77 +1,17 @@
|
||||
var umbracoAppDev = angular.module('umbraco.httpbackend', ['umbraco', 'ngMockE2E']);
|
||||
var umbracoAppDev = angular.module('umbraco.httpbackend', ['umbraco', 'ngMockE2E', 'umbraco.mocks']);
|
||||
|
||||
function urlRegex(url) {
|
||||
url = url.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||
return new RegExp("^" + url);
|
||||
}
|
||||
|
||||
function getParameterByName(url, name) {
|
||||
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
|
||||
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
|
||||
results = regex.exec(url);
|
||||
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
|
||||
}
|
||||
|
||||
var firsttry = true;
|
||||
function returnUser(status, data, headers){
|
||||
var app = getParameterByName(data, "application");
|
||||
|
||||
var mocked = {
|
||||
name: "Per Ploug",
|
||||
email: "test@test.com",
|
||||
emailHash: "f9879d71855b5ff21e4963273a886bfc",
|
||||
id: 0,
|
||||
locale: 'da-DK'
|
||||
};
|
||||
|
||||
if(firsttry){
|
||||
firsttry = false;
|
||||
return [200, mocked, null];
|
||||
}else{
|
||||
return [200, mocked, null];
|
||||
}
|
||||
}
|
||||
|
||||
function returnApplicationTrees(status, data, headers){
|
||||
var app = getParameterByName(data, "application");
|
||||
var tree = _backendData.tree.getApplication(app);
|
||||
return [200, tree, null];
|
||||
}
|
||||
|
||||
function returnAllowedChildren(status, data, headers){
|
||||
var types = [
|
||||
{name: "News Article", description: "Standard news article", alias: "newsArticle", id: 1234, cssClass:"file"},
|
||||
{name: "News Area", description: "Area to hold all news articles, there should be only one", alias: "newsArea", id: 1234, cssClass:"suitcase"},
|
||||
{name: "Employee", description: "Employee profile information page", alias: "employee", id: 1234, cssClass:"user"}
|
||||
];
|
||||
|
||||
return [200, types, null];
|
||||
}
|
||||
|
||||
function initBackEnd($httpBackend) {
|
||||
|
||||
// returns the current list of phones
|
||||
$httpBackend
|
||||
.whenGET( urlRegex('/umbraco/Api/ContentType/GetAllowedChildren'))
|
||||
.respond( returnAllowedChildren);
|
||||
|
||||
$httpBackend
|
||||
.whenPOST(urlRegex('/umbraco/UmbracoApi/Authentication/PostLogin'))
|
||||
.respond(returnUser);
|
||||
|
||||
$httpBackend
|
||||
.whenGET('/umbraco/UmbracoApi/Authentication/GetCurrentUser')
|
||||
.respond(returnUser);
|
||||
|
||||
$httpBackend
|
||||
.whenGET( urlRegex('/umbraco/UmbracoTrees/ApplicationTreeApi/GetApplicationTrees') )
|
||||
.respond(returnApplicationTrees);
|
||||
|
||||
// adds a new phone to the phones array
|
||||
$httpBackend.whenPOST('/phones').respond(function(method, url, data) {
|
||||
//phones.push(angular.fromJSON(data));
|
||||
});
|
||||
|
||||
function initBackEnd($httpBackend, contentMocks, treeMocks, userMocks, contentTypeMocks) {
|
||||
|
||||
//Register mocked http responses
|
||||
contentMocks.register();
|
||||
|
||||
treeMocks.register();
|
||||
|
||||
userMocks.register();
|
||||
|
||||
contentTypeMocks.register();
|
||||
|
||||
$httpBackend.whenGET(/^views\//).passThrough();
|
||||
$httpBackend.whenGET(/^js\//).passThrough();
|
||||
$httpBackend.whenGET(/^lib\//).passThrough();
|
||||
|
||||
@@ -35,9 +35,14 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
|
||||
|
||||
var deferred = $q.defer();
|
||||
|
||||
|
||||
|
||||
//go and get the data
|
||||
$http.get(getContentUrl(id)).
|
||||
success(function (data, status, headers, config) {
|
||||
|
||||
console.log("getting by id success");
|
||||
|
||||
//set the first tab to active
|
||||
_.each(data.tabs, function (item) {
|
||||
item.active = false;
|
||||
@@ -49,6 +54,7 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
|
||||
deferred.resolve(data);
|
||||
}).
|
||||
error(function (data, status, headers, config) {
|
||||
console.log("getting by id - error");
|
||||
deferred.reject('Failed to retreive data for content id ' + id);
|
||||
});
|
||||
|
||||
|
||||
@@ -15,13 +15,16 @@ function contentTypeResource($q, $http) {
|
||||
//return a content type with a given ID
|
||||
getContentType: function (id) {
|
||||
|
||||
return {
|
||||
var deferred = $q.defer();
|
||||
var data = {
|
||||
name: "News Article",
|
||||
alias: "newsArticle",
|
||||
id: id,
|
||||
tabs: []
|
||||
};
|
||||
|
||||
|
||||
deferred.resolve(data);
|
||||
return deferred.promise;
|
||||
},
|
||||
//return all available types
|
||||
all: function () {
|
||||
@@ -41,14 +44,19 @@ function contentTypeResource($q, $http) {
|
||||
//return all types allowed under given document
|
||||
getAllowedTypes: function (contentId) {
|
||||
|
||||
|
||||
var deferred = $q.defer();
|
||||
|
||||
//go and get the tree data
|
||||
$http.get(getChildContentTypesUrl(contentId)).
|
||||
success(function (data, status, headers, config) {
|
||||
|
||||
console.log("success");
|
||||
|
||||
deferred.resolve(data);
|
||||
}).
|
||||
error(function (data, status, headers, config) {
|
||||
console.log("wrong");
|
||||
deferred.reject('Failed to retreive data for content id ' + contentId);
|
||||
});
|
||||
|
||||
@@ -56,5 +64,5 @@ function contentTypeResource($q, $http) {
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
angular.module('umbraco.resources').factory('contentTypeResource', contentTypeResource);
|
||||
@@ -31,4 +31,4 @@ function sectionResource($q, $http) {
|
||||
};
|
||||
}
|
||||
|
||||
angular.module('umbraco.resources').factory('treeResource', treeResource);
|
||||
angular.module('umbraco.resources').factory('sectionResource', sectionResource);
|
||||
@@ -45,6 +45,7 @@ angular.module('umbraco.security.service', [
|
||||
|
||||
function onLoginDialogClose(success) {
|
||||
loginDialog = null;
|
||||
|
||||
if ( success ) {
|
||||
queue.retryAll();
|
||||
} else {
|
||||
@@ -108,11 +109,6 @@ angular.module('umbraco.security.service', [
|
||||
// Is the current user authenticated?
|
||||
isAuthenticated: function(){
|
||||
return !!service.currentUser;
|
||||
},
|
||||
|
||||
// Is the current user an adminstrator?
|
||||
isAdmin: function() {
|
||||
return !!(service.currentUser && service.currentUser.admin);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ angular.module('umbraco.services')
|
||||
};
|
||||
|
||||
scope.hide = function() {
|
||||
$modal.modal('hide');
|
||||
$modal.modal('hide');
|
||||
$('body').remove($modal);
|
||||
};
|
||||
|
||||
scope.show = function() {
|
||||
@@ -51,8 +52,10 @@ angular.module('umbraco.services')
|
||||
};
|
||||
|
||||
scope.submit = function(data){
|
||||
callback(data);
|
||||
$modal.modal('hide');
|
||||
$modal.modal('hide');
|
||||
$('body').remove($modal);
|
||||
|
||||
callback(data);
|
||||
};
|
||||
|
||||
scope.select = function(item){
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -75,7 +75,6 @@
|
||||
|
||||
.umb-tree ins {
|
||||
vertical-align: middle;
|
||||
background: url(../img/applicationIcons/tree-arrow.png) no-repeat center center;
|
||||
margin-left: -16px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
@@ -297,6 +296,97 @@ i.umb-options i {
|
||||
color: @red;
|
||||
}
|
||||
|
||||
|
||||
.umb-tree li div.l{
|
||||
width:100%;
|
||||
height:1px;
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
.umb-tree li div.l div{
|
||||
background-color: @blue;
|
||||
margin-top:0;
|
||||
margin-left:-100%;
|
||||
-moz-animation-name:bounce_loadingProgressG;
|
||||
-moz-animation-duration:1s;
|
||||
-moz-animation-iteration-count:infinite;
|
||||
-moz-animation-timing-function:linear;
|
||||
-webkit-animation-name:bounce_loadingProgressG;
|
||||
-webkit-animation-duration:1s;
|
||||
-webkit-animation-iteration-count:infinite;
|
||||
-webkit-animation-timing-function:linear;
|
||||
-ms-animation-name:bounce_loadingProgressG;
|
||||
-ms-animation-duration:1s;
|
||||
-ms-animation-iteration-count:infinite;
|
||||
-ms-animation-timing-function:linear;
|
||||
-o-animation-name:bounce_loadingProgressG;
|
||||
-o-animation-duration:1s;
|
||||
-o-animation-iteration-count:infinite;
|
||||
-o-animation-timing-function:linear;
|
||||
animation-name:bounce_loadingProgressG;
|
||||
animation-duration:1s;
|
||||
animation-iteration-count:infinite;
|
||||
animation-timing-function:linear;
|
||||
width:100%;
|
||||
height:1px;
|
||||
}
|
||||
|
||||
@-moz-keyframes bounce_loadingProgressG{
|
||||
0%{
|
||||
margin-left:-100%;
|
||||
}
|
||||
|
||||
100%{
|
||||
margin-left:100%;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@-webkit-keyframes bounce_loadingProgressG{
|
||||
0%{
|
||||
margin-left:-100%;
|
||||
}
|
||||
|
||||
100%{
|
||||
margin-left:100%;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@-ms-keyframes bounce_loadingProgressG{
|
||||
0%{
|
||||
margin-left:-100%;
|
||||
}
|
||||
|
||||
100%{
|
||||
margin-left:100%;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@-o-keyframes bounce_loadingProgressG{
|
||||
0%{
|
||||
margin-left:-100%;
|
||||
}
|
||||
|
||||
100%{
|
||||
margin-left:100%;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@keyframes bounce_loadingProgressG{
|
||||
0%{
|
||||
margin-left:-100%;
|
||||
}
|
||||
|
||||
100%{
|
||||
margin-left:100%;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Search
|
||||
// -------------------------
|
||||
/*
|
||||
|
||||
@@ -11,8 +11,8 @@ yepnope({
|
||||
|
||||
'js/umbraco.servervariables.js',
|
||||
'js/app_dev.js',
|
||||
'js/umbraco.httpbackend.helper.js',
|
||||
'js/umbraco.httpbackend.js',
|
||||
'js/umbraco.testing.js',
|
||||
|
||||
'js/umbraco.directives.js',
|
||||
'js/umbraco.filters.js',
|
||||
|
||||
@@ -13,9 +13,7 @@
|
||||
|
||||
userService.authenticate(login, password)
|
||||
.then(function (data) {
|
||||
$scope.authenticated = data.authenticated;
|
||||
$scope.user = data.user;
|
||||
$scope.submit(null);
|
||||
$scope.submit(data);
|
||||
}, function (reason) {
|
||||
alert(reason);
|
||||
});
|
||||
|
||||
@@ -9,14 +9,15 @@ module.exports = function(karma) {
|
||||
files: [
|
||||
'lib/jquery/jquery-1.8.2.min.js',
|
||||
'lib/angular/angular.min.js',
|
||||
'lib/underscore/underscore.js',
|
||||
'test/lib/angular/angular-mocks.js',
|
||||
'src/app.js',
|
||||
'src/app_dev.js',
|
||||
'src/common/directives/*.js',
|
||||
'src/common/filters/*.js',
|
||||
'src/common/services/*.js',
|
||||
'src/common/security/*.js',
|
||||
'src/common/mocks/*.js',
|
||||
'src/common/resources/*.js',
|
||||
'src/common/mocks/**/*.js',
|
||||
'src/views/**/*.controller.js',
|
||||
'test/unit/**/*.spec.js'
|
||||
],
|
||||
@@ -44,7 +45,7 @@ module.exports = function(karma) {
|
||||
// level of logging
|
||||
// possible values: karma.LOG_DISABLE || karma.LOG_ERROR || karma.LOG_WARN || karma.LOG_INFO || karma.LOG_DEBUG
|
||||
// CLI --log-level debug
|
||||
logLevel: karma.LOG_INFO,
|
||||
logLevel: karma.LOG_DEBUG,
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
// CLI --auto-watch --no-auto-watch
|
||||
|
||||
+1885
-1845
File diff suppressed because it is too large
Load Diff
@@ -1,21 +1,42 @@
|
||||
describe('content factory tests', function () {
|
||||
var $scope, contentFactory;
|
||||
var $rootScope, $httpBackend, contentFactory;
|
||||
|
||||
beforeEach(module('umbraco.services'));
|
||||
beforeEach(module('umbraco.resources'));
|
||||
beforeEach(module('umbraco.httpbackend'));
|
||||
|
||||
beforeEach(inject(function($injector) {
|
||||
$scope = $injector.get('$rootScope');
|
||||
contentFactory = $injector.get('contentResource');
|
||||
beforeEach(inject(function ($injector) {
|
||||
$rootScope = $injector.get('$rootScope');
|
||||
$httpBackend = $injector.get('$httpBackend');
|
||||
contentFactory = $injector.get('contentResource');
|
||||
}));
|
||||
|
||||
describe('global content factory crud', function () {
|
||||
afterEach(function () {
|
||||
$httpBackend.verifyNoOutstandingExpectation();
|
||||
$httpBackend.verifyNoOutstandingRequest();
|
||||
});
|
||||
|
||||
it('should return a content object, given an id', function () {
|
||||
var doc1 = contentFactory.getById(1234).then(function(doc1){
|
||||
expect(doc1).toNotBe(undefined);
|
||||
expect(doc1.id).toBe(1234);
|
||||
});
|
||||
|
||||
describe('global content factory crud', function () {
|
||||
it('should return a content object, given an id', function () {
|
||||
var doc = "meh";
|
||||
contentFactory.getById(1234).then(function (result) {
|
||||
doc = result;
|
||||
});
|
||||
|
||||
console.log("doc:", doc);
|
||||
$rootScope.$root.$digest();
|
||||
|
||||
|
||||
//$scope.$apply();
|
||||
|
||||
//.then(function (doc1) {
|
||||
console.log("doc:", doc);
|
||||
|
||||
expect(doc).toNotBe(undefined);
|
||||
expect(doc.id).toBe(1234);
|
||||
//});
|
||||
|
||||
});
|
||||
|
||||
it('should return a content children collection given an id', function () {
|
||||
|
||||
@@ -1,30 +1,34 @@
|
||||
describe('content type factory tests', function () {
|
||||
var $scope, contentTypeFactory;
|
||||
var $rootScope, contentTypeResource;
|
||||
|
||||
beforeEach(module('umbraco.services'));
|
||||
beforeEach(module('umbraco.resources'));
|
||||
|
||||
beforeEach(inject(function($injector) {
|
||||
$scope = $injector.get('$rootScope');
|
||||
contentTypeFactory = $injector.get('contentTypeResource');
|
||||
beforeEach(module('umbraco.httpbackend'));
|
||||
|
||||
beforeEach(inject(function ($injector) {
|
||||
$rootScope = $injector.get('$rootScope');
|
||||
contentTypeResource = $injector.get('contentTypeResource');
|
||||
}));
|
||||
|
||||
describe('global content type factory crud', function () {
|
||||
|
||||
it('should return a content type object, given an id', function () {
|
||||
var ct1 = contentTypeFactory.getContentType(1234);
|
||||
|
||||
var ct1 = contentTypeResource.getContentType(1234);
|
||||
|
||||
$rootScope.$digest();
|
||||
|
||||
console.log("ct1:", ct1);
|
||||
|
||||
expect(ct1).toNotBe(undefined);
|
||||
expect(ct1.id).toBe(1234);
|
||||
});
|
||||
|
||||
|
||||
it('should return a allowed content type collection given a document id', function () {
|
||||
var collection = contentTypeFactory.getAllowedTypes(1234);
|
||||
|
||||
console.log("running test", angular.toJson(collection));
|
||||
it('should return a allowed content type collection given a document id', function(){
|
||||
// var collection = contentTypeResource.getAllowedTypes(1234);
|
||||
// $rootScope.$apply();
|
||||
|
||||
//expect(collection.length).toBe(3);
|
||||
// console.log("running test", angular.toJson(collection));
|
||||
// expect(collection.length).toBe(3);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,30 +1,30 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<base href="/belle/" />
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Umbraco</title>
|
||||
<link rel="stylesheet" href="assets/css/umbraco.css" />
|
||||
</head>
|
||||
<body ng-controller="MainController" id="umbracoMainPageBody">
|
||||
|
||||
<div ng-hide="!authenticated" ng-cloak ng-animate="'fade'" id="Div1" class="clearfix" ng-click="closeDialogs($event)">
|
||||
|
||||
<umb-left-column></umb-left-column>
|
||||
|
||||
<section id="contentwrapper">
|
||||
<div id="contentcolumn">
|
||||
<div ng-view></div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<umb-notifications></umb-notifications>
|
||||
|
||||
|
||||
<script src="lib/yepnope/yepnope.min.js"></script>
|
||||
<script src="js/loader.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<base href="/belle/" />
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Umbraco</title>
|
||||
<link rel="stylesheet" href="assets/css/umbraco.css" />
|
||||
</head>
|
||||
<body ng-controller="MainController" id="umbracoMainPageBody">
|
||||
|
||||
<div ng-hide="!authenticated" ng-cloak ng-animate="'fade'" id="Div1" class="clearfix" ng-click="closeDialogs($event)">
|
||||
|
||||
<umb-left-column></umb-left-column>
|
||||
|
||||
<section id="contentwrapper">
|
||||
<div id="contentcolumn">
|
||||
<div ng-view></div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<umb-notifications></umb-notifications>
|
||||
|
||||
|
||||
<script src="lib/yepnope/yepnope.min.js"></script>
|
||||
<script src="js/loader.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -11,8 +11,8 @@ yepnope({
|
||||
|
||||
'js/umbraco.servervariables.js',
|
||||
'js/app_dev.js',
|
||||
'js/umbraco.httpbackend.helper.js',
|
||||
'js/umbraco.httpbackend.js',
|
||||
'js/umbraco.testing.js',
|
||||
|
||||
'js/umbraco.directives.js',
|
||||
'js/umbraco.filters.js',
|
||||
|
||||
Reference in New Issue
Block a user