From 79005262a0a8bf2bdcc1b9a46d9437f9cc5fc0c4 Mon Sep 17 00:00:00 2001 From: Kevin Giszewski Date: Wed, 5 Feb 2014 15:00:25 -0500 Subject: [PATCH] Use User.locale in lieu of Settings.js --- Gruntfile.js | 2 +- app/config/en-GB.js | 34 ++++++++++++++++++++++++ app/controllers/config.controller.js | 39 ++++++++++++++++------------ app/resources/propertyeditor.js | 7 +---- 4 files changed, 58 insertions(+), 24 deletions(-) create mode 100644 app/config/en-GB.js diff --git a/Gruntfile.js b/Gruntfile.js index 2532d09..c08c6ba 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -107,7 +107,7 @@ module.exports = function(grunt) { {expand: true, cwd: 'app/', src: ['package.manifest'], dest: '<%= dest %>', flatten: true}, {expand: true, cwd: 'app/views/', src: ['archetype.html', 'archetype.config.html'], dest: '<%= dest %>/views', flatten: true}, {expand: true, cwd: 'app/config/', src: ['propertyEditors.views.js'], dest: '<%= dest %>/js', flatten: true}, - {expand: true, cwd: 'app/config/', src: ['settings.js'], dest: '<%= dest %>/js', flatten: true}, + {expand: true, cwd: 'app/config/', src: ['en-gb.js'], dest: '<%= dest %>/js', flatten: true}, {expand: true, cwd: 'app/config/', src: ['en-us.js'], dest: '<%= dest %>/js', flatten: true}, {expand: true, cwd: 'app/config/', src: ['fr-fr.js'], dest: '<%= dest %>/js', flatten: true}, {expand: true, cwd: 'app/Umbraco/Umbraco.Archetype/bin/Debug/', src: ['Archetype.dll'], dest: '<%= dest %>/bin', flatten: true} diff --git a/app/config/en-GB.js b/app/config/en-GB.js new file mode 100644 index 0000000..7f0fe80 --- /dev/null +++ b/app/config/en-GB.js @@ -0,0 +1,34 @@ +{ + "label": "Label", + "alias": "Alias", + "hideFieldsetControls": "Hide Fieldset Controls?", + "hideFieldsetControlsDescription": "Hides the fieldset add/remove/sort controls.", + "toggleAdvanced": "Toggle Advanced Options", + "toggleAdvancedDescription": "Show advanced options.", + "hidePropertyLabels": "Hide Property Labels?", + "hidePropertyLabelsDescription": "Hides the property labels.", + "maxFieldsets": "Max Fieldsets", + "maxFieldsetsDescription": "How many Fieldsets are allowed? Entering '1' will disable the controls. Default is unlimited.", + "enableMultipleFieldsets": "Enable Multiple Fieldsets?", + "enableMultipleFieldsetsDescription": "Allows multiple types of fieldsets within this archetype.", + "hideFieldsetToolbar": "Hide Fieldset Toolbar?", + "hideFieldsetToolbarDescription": "Hides the fieldset toolbar that appears when more than one fieldset model appears.", + "customWrapperClass": "Custom Wrapper Class", + "customWrapperClassDescription": "(Optional) Enter a custom CSS class that will be applied to the wrapper div.", + "cssFile": "CSS File", + "cssFileDescription": "(Optional) Enter a path for a custom CSS file to be included on the page.", + "jsFile": "JS File", + "jsFileDescription": "(Optional) Enter a path for a custom JS file to be included on the page.", + "toggleDeveloperMode": "Toggle Developer Mode", + "toggleDeveloperModeDescription": "Turn on for developer options.", + "configModel": "Config Model", + "configModelDescription": "Be careful editing the text below, it controls the schema for this archetype.", + "helpText": "Help Text", + "defaultValue": "Default Value", + "dataType": "DataType", + "required": "Required", + "properties": "Properties", + "labelTemplate": "Label Template", + "select": "Select", + "icon": "Icon" +} diff --git a/app/controllers/config.controller.js b/app/controllers/config.controller.js index 2f58468..80e31dc 100644 --- a/app/controllers/config.controller.js +++ b/app/controllers/config.controller.js @@ -1,4 +1,4 @@ -angular.module("umbraco").controller("Imulus.ArchetypeConfigController", function ($scope, $http, assetsService, dialogService, archetypePropertyEditorResource) { +angular.module("umbraco").controller("Imulus.ArchetypeConfigController", function ($scope, $http, assetsService, dialogService, archetypePropertyEditorResource, userService) { //$scope.model.value = ""; //console.log($scope.model.value); @@ -19,25 +19,30 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio $scope.availableDataTypes = data; }); + //get the current user + + userService.getCurrentUser().then(function (user) { + $scope.model.language = user.locale; + console.log($scope.model.language); + }); + //load the localization info - archetypePropertyEditorResource.getSettings() - .then(function(settings) { - $scope.settings = settings; - return settings.langIso; + userService.getCurrentUser() + .then(function (user) { + $scope.model.langIso = user.locale; + return user.locale; }) - .then(function(langIso){ - archetypePropertyEditorResource.getLocale(langIso) - .then(function(locale) { - return locale; - }).then(function(locale){ - archetypePropertyEditorResource.getDefaultLocale(locale) - .then(function(defaultLocale) { - $scope.locales = {} - $scope.locales.locale = locale; - $scope.locales.defaultLocale = defaultLocale; + .then(function(langIso){ + archetypePropertyEditorResource.getLocale(langIso) + .then(function(locale){ + archetypePropertyEditorResource.getDefaultLocale(locale) + .then(function(defaultLocale) { + $scope.locales = {} + $scope.locales.locale = locale; + $scope.locales.defaultLocale = defaultLocale; + }); }); - }); - }); + }); $scope.getLocales = function(){ if($scope.locales){ diff --git a/app/resources/propertyeditor.js b/app/resources/propertyeditor.js index 129edb8..a55d7dc 100644 --- a/app/resources/propertyeditor.js +++ b/app/resources/propertyeditor.js @@ -29,14 +29,9 @@ angular.module('umbraco.resources').factory('archetypePropertyEditorResource', f return ""; }); }, - getSettings: function() { - return umbRequestHelper.resourcePromise( - $http.get("/App_plugins/Archetype/js/settings.js"), 'Failed to retrieve config' - ); - }, getLocale: function(langIso) { return umbRequestHelper.resourcePromise( - $http.get("/App_plugins/Archetype/js/" + langIso + ".js"), 'Failed to retrieve locale' + $http.get("/App_plugins/Archetype/js/" + langIso.toLowerCase() + ".js"), 'Failed to retrieve locale' ); }, getDefaultLocale: function() {