Merge pull request #987 from umbraco/temp-U4-7590

Fixes: U4-7590 List view layout cookie: Change to use local storage a…
This commit is contained in:
Claus
2016-01-05 09:43:54 +01:00
5 changed files with 51 additions and 44 deletions

View File

@@ -1,30 +1,31 @@
{
"name": "Umbraco",
"version": "7",
"homepage": "https://github.com/umbraco/Umbraco-CMS",
"authors": [
"Shannon <shannon@umbraco.com>"
],
"description": "Umbraco CMS",
"license": "MIT",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"typeahead.js": "~0.10.5",
"underscore": "~1.7.0",
"rgrove-lazyload": "*",
"bootstrap-social": "~4.8.0",
"jquery": "2.0.3",
"jquery-ui": "1.11.4",
"angular-dynamic-locale": "0.1.28",
"ng-file-upload": "~7.3.8",
"tinymce": "~4.1.10",
"codemirror": "~5.3.0"
}
"name": "Umbraco",
"version": "7",
"homepage": "https://github.com/umbraco/Umbraco-CMS",
"authors": [
"Shannon <shannon@umbraco.com>"
],
"description": "Umbraco CMS",
"license": "MIT",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"typeahead.js": "~0.10.5",
"underscore": "~1.7.0",
"rgrove-lazyload": "*",
"bootstrap-social": "~4.8.0",
"jquery": "2.0.3",
"jquery-ui": "1.11.4",
"angular-dynamic-locale": "0.1.28",
"ng-file-upload": "~7.3.8",
"tinymce": "~4.1.10",
"codemirror": "~5.3.0",
"angular-local-storage": "~0.2.3"
}
}

View File

@@ -492,6 +492,10 @@ module.exports = function (grunt) {
keepExpandedHierarchy: false,
files: ['ng-file-upload.min.js']
},
'angular-local-storage': {
keepExpandedHierarchy: false,
files: ['dist/angular-local-storage.min.js']
},
'codemirror': {
files: [
'lib/codemirror.js',

View File

@@ -10,7 +10,8 @@ var app = angular.module('umbraco', [
'ngSanitize',
'ngMobile',
'tmh.dynamicLocale',
'ngFileUpload'
'ngFileUpload',
'LocalStorageModule'
]);
var packages = angular.module("umbraco.packages", []);

View File

@@ -1,16 +1,17 @@
(function() {
'use strict';
function listViewHelper($cookieStore) {
function listViewHelper(localStorageService) {
var firstSelectedIndex = 0;
var localStorageKey = "umblistViewLayout";
function getLayout(nodeId, availableLayouts) {
var storedLayouts = [];
if ($cookieStore.get("umblistViewLayout")) {
storedLayouts = $cookieStore.get("umblistViewLayout");
if(localStorageService.get(localStorageKey)) {
storedLayouts = localStorageService.get(localStorageKey);
}
if (storedLayouts && storedLayouts.length > 0) {
@@ -47,19 +48,18 @@
activeLayout = getFirstAllowedLayout(availableLayouts);
}
setLayoutCookie(nodeId, activeLayout);
saveLayoutInLocalStorage(nodeId, activeLayout);
return activeLayout;
}
function setLayoutCookie(nodeId, selectedLayout) {
function saveLayoutInLocalStorage(nodeId, selectedLayout) {
var layoutFound = false;
var storedLayouts = [];
if($cookieStore.get("umblistViewLayout")) {
storedLayouts = $cookieStore.get("umblistViewLayout");
if(localStorageService.get(localStorageKey)) {
storedLayouts = localStorageService.get(localStorageKey);
}
if(storedLayouts.length > 0) {
@@ -73,14 +73,14 @@
}
if(!layoutFound) {
var cookieObject = {
var storageObject = {
"nodeId": nodeId,
"path": selectedLayout.path
};
storedLayouts.push(cookieObject);
storedLayouts.push(storageObject);
}
document.cookie="umblistViewLayout=" + JSON.stringify(storedLayouts);
localStorageService.set(localStorageKey, storedLayouts);
}
@@ -106,7 +106,7 @@
var item = null;
if ($event.shiftKey === true) {
if(selectedIndex > firstSelectedIndex) {
start = firstSelectedIndex;
@@ -266,7 +266,7 @@
getLayout: getLayout,
getFirstAllowedLayout: getFirstAllowedLayout,
setLayout: setLayout,
setLayoutCookie: setLayoutCookie,
saveLayoutInLocalStorage: saveLayoutInLocalStorage,
selectHandler: selectHandler,
selectItem: selectItem,
deselectItem: deselectItem,

View File

@@ -9,16 +9,17 @@
'lib/angular/1.1.5/angular-cookies.min.js',
'lib/angular/1.1.5/angular-mobile.js',
'lib/angular/1.1.5/angular-sanitize.min.js',
'lib/angular/angular-ui-sortable.js',
'lib/angular-dynamic-locale/tmhDynamicLocale.min.js',
'lib/ng-file-upload/ng-file-upload.min.js',
'lib/angular-local-storage/angular-local-storage.min.js',
'lib/bootstrap/js/bootstrap.2.3.2.min.js',
'lib/bootstrap-tabdrop/bootstrap-tabdrop.js',
'lib/umbraco/Extensions.js',
'lib/umbraco/NamespaceManager.js',
'lib/umbraco/LegacyUmbClientMgr.js',
'lib/umbraco/LegacySpeechBubble.js',