Skip to content

Commit

Permalink
Models and services organization
Browse files Browse the repository at this point in the history
  • Loading branch information
renatopp committed Oct 3, 2015
1 parent ec2d82f commit ad8d1ef
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 34 deletions.
12 changes: 6 additions & 6 deletions src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ angular.module('app', [
}
])

.run(['$window', '$animate', '$location', '$document', '$timeout', 'settingsService', 'projectService',
.run(['$window', '$animate', '$location', '$document', '$timeout', 'settingsModel', 'projectModel',
function Execute($window,
$animate,
$location,
$document,
$timeout,
settingsService,
projectService) {
settingsModel,
projectModel) {

// reset path
$location.path('/');
Expand All @@ -33,8 +33,8 @@ angular.module('app', [
.attr('b3-drop-node', true);

// initialize editor
settingsService.getSettings();
projectService
settingsModel.getSettings();
projectModel
.getRecentProjects()
.then(function(projects) {

Expand All @@ -49,7 +49,7 @@ angular.module('app', [
}

if (projects.length > 0 && projects[0].isOpen) {
projectService
projectModel
.openProject(projects[0].path)
.then(function() {
closePreload();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

angular
.module('app')
.factory('projectService', projectService);
.factory('projectModel', projectModel);

projectService.$inject = [
projectModel.$inject = [
'$q',
'$rootScope',
'$window',
Expand All @@ -15,7 +15,7 @@
'editorService'
];

function projectService($q,
function projectModel($q,
$rootScope,
$window,
storageService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

angular
.module('app')
.factory('settingsService', settingsService);
.factory('settingsModel', settingsModel);

settingsService.$inject = [
settingsModel.$inject = [
'$q',
'storageService',
'systemService',
'editorService'
];

function settingsService($q,
function settingsModel($q,
storageService,
systemService,
editorService) {
Expand Down
6 changes: 3 additions & 3 deletions src/app/pages/dash/dash.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

DashController.$inject = [
'$scope',
'projectService'
'projectModel'
];

function DashController($scope, projectService) {
function DashController($scope, projectModel) {
var vm = this;
vm.project = null;
_activate();

function _activate() {
vm.project = projectService.getProject();
vm.project = projectModel.getProject();
}
$scope.$on('dash-projectchanged', function() {
_activate();
Expand Down
8 changes: 4 additions & 4 deletions src/app/pages/editor/components/menubar.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
'$window',
'$state',
'dialogService',
'projectService',
'projectModel',
'notificationService'
];

function MenubarController($scope,
$window,
$state,
dialogService,
projectService,
projectModel,
notificationService) {
var vm = this;
vm.onNewTree = onNewTree;
Expand Down Expand Up @@ -136,7 +136,7 @@

function onCloseProject() {
function doClose() {
projectService.closeProject();
projectModel.closeProject();
$state.go('dash.projects');
}

Expand All @@ -154,7 +154,7 @@
return false;
}
function onSaveProject() {
projectService
projectModel
.saveProject()
.then(function() {
notificationService.success(
Expand Down
20 changes: 10 additions & 10 deletions src/app/pages/projects/projects.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
'dialogService',
'systemService',
'notificationService',
'projectService'
'projectModel'
];

function ProjectsController($state,
$window,
dialogService,
systemService,
notificationService,
projectService) {
projectModel) {

// HEAD //
var vm = this;
Expand All @@ -38,15 +38,15 @@
// BODY //
function _activate() {
vm.isDesktop = systemService.isDesktop;
projectService
projectModel
.getRecentProjects()
.then(function(recents) {
vm.recentProjects = recents;
});
}

function _newProject(path, name) {
projectService
projectModel
.newProject(path, name)
.then(function() {
$state.go('editor');
Expand Down Expand Up @@ -97,7 +97,7 @@
}

function _openProject(path) {
projectService
projectModel
.openProject(path)
.then(function() {
$state.go('editor');
Expand Down Expand Up @@ -133,7 +133,7 @@
}

function editProject() {
var project = projectService.getProject();
var project = projectModel.getProject();

dialogService
.prompt('Rename project', null, 'input', project.name)
Expand All @@ -148,7 +148,7 @@
}

project.name = name;
projectService
projectModel
.saveProject(project)
.then(function() {
_activate();
Expand All @@ -161,7 +161,7 @@
}

function saveProject() {
projectService
projectModel
.saveProject()
.then(function() {
notificationService.success(
Expand All @@ -178,7 +178,7 @@

function closeProject() {
function doClose() {
projectService.closeProject();
projectModel.closeProject();
}

if ($window.editor.isDirty()) {
Expand All @@ -199,7 +199,7 @@
'Remove project?',
'Are you sure you want to remove this project?'
).then(function() {
projectService
projectModel
.removeProject(path)
.then(function() {
_activate();
Expand Down
10 changes: 5 additions & 5 deletions src/app/pages/settings/settings.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

SettingsController.$inject = [
'notificationService',
'settingsService',
'settingsModel',
'dialogService',
];

function SettingsController(notificationService,
settingsService,
settingsModel,
dialogService) {

// HEADER //
Expand All @@ -25,15 +25,15 @@

// BODY //
function _activate() {
settingsService
settingsModel
.getSettings()
.then(function(settings) {
vm.settings = settings;
});
}

function saveSettings() {
settingsService
settingsModel
.saveSettings(vm.settings)
.then(function() {
notificationService.success(
Expand All @@ -48,7 +48,7 @@
'Reset Settings?',
'Are you sure you want to reset to the default settings?'
).then(function() {
settingsService
settingsModel
.resetSettings()
.then(function() {
notificationService.success(
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit ad8d1ef

Please sign in to comment.