From 88c1c584ade4d784fd49803d9572bba44c0af322 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Mon, 27 Apr 2015 09:11:20 +0200 Subject: [PATCH] Refactoring home page --- app/coffee/app.coffee | 4 +-- app/modules/home/home-directive.coffee | 9 +++++ app/modules/home/home-page.controller.coffee | 33 +++++++++++++++++++ app/modules/home/home-page.jade | 1 + app/{partials => modules}/home/home.jade | 5 ++- .../list.directive.coffee} | 2 +- .../list.jade} | 0 .../styles/list.scss} | 0 .../{projects.jade => projects-page.jade} | 0 9 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 app/modules/home/home-directive.coffee create mode 100644 app/modules/home/home-page.controller.coffee create mode 100644 app/modules/home/home-page.jade rename app/{partials => modules}/home/home.jade (97%) rename app/modules/home/{home-project-list.directive.coffee => projects/list.directive.coffee} (89%) rename app/modules/home/{home-project-list.jade => projects/list.jade} (100%) rename app/modules/home/{styles/home-project-list.scss => projects/styles/list.scss} (100%) rename app/modules/projects/{projects.jade => projects-page.jade} (100%) diff --git a/app/coffee/app.coffee b/app/coffee/app.coffee index 753ae33a..3c047ae7 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/app.coffee @@ -39,10 +39,10 @@ taiga.sessionId = taiga.generateUniqueSessionIdentifier() configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEventsProvider, tgLoaderProvider, $compileProvider, $translateProvider) -> $routeProvider.when("/", - {templateUrl: "home/home.html"}) + {templateUrl: "home/home-page.html"}) $routeProvider.when("/projects/", - {templateUrl: "projects/projects.html", resolve: {loader: tgLoaderProvider.add()}}) + {templateUrl: "projects/projects-page.html", resolve: {loader: tgLoaderProvider.add()}}) $routeProvider.when("/project/:pslug/", {templateUrl: "project/project.html"}) diff --git a/app/modules/home/home-directive.coffee b/app/modules/home/home-directive.coffee new file mode 100644 index 00000000..c5218db5 --- /dev/null +++ b/app/modules/home/home-directive.coffee @@ -0,0 +1,9 @@ +HomeDirective = -> + directive = { + templateUrl: "home/home.html" + scope: {} + } + + return directive + +angular.module("taigaProjects").directive("tgHome", HomeDirective) diff --git a/app/modules/home/home-page.controller.coffee b/app/modules/home/home-page.controller.coffee new file mode 100644 index 00000000..eddc1b65 --- /dev/null +++ b/app/modules/home/home-page.controller.coffee @@ -0,0 +1,33 @@ +class ProjectsPageController extends taiga.Controller + @.$inject = [ + "$scope", + "$q", + "$tgResources", + "$rootScope", + "$tgNavUrls", + "$tgAuth", + "$tgLocation", + "$appTitle", + "$projectUrl", + "$tgConfig", + "tgLoader", + "tgProjects", + "$translate" + + ] + + constructor: (@scope, @q, @rs, @rootscope, @navUrls, @auth, @location, + @appTitle, @projectUrl, @config, tgLoader, @projects, @translate) -> + @appTitle.set(@translate.instant("PROJECT.WELCOME")) + + if !@auth.isAuthenticated() + @location.path(@navUrls.resolve("login")) + + #Projects + promise = @projects.fetchProjects() + + # Finally + promise.finally tgLoader.pageLoaded + + +angular.module("taigaHome").controller("HomePage", ProjectsPageController) diff --git a/app/modules/home/home-page.jade b/app/modules/home/home-page.jade new file mode 100644 index 00000000..7bfe3e17 --- /dev/null +++ b/app/modules/home/home-page.jade @@ -0,0 +1 @@ +div(ng-controller="HomePage", tg-home) diff --git a/app/partials/home/home.jade b/app/modules/home/home.jade similarity index 97% rename from app/partials/home/home.jade rename to app/modules/home/home.jade index 74c9ab2c..de24aac1 100644 --- a/app/partials/home/home.jade +++ b/app/modules/home/home.jade @@ -1,7 +1,7 @@ doctype html -include ../includes/components/beta -div.home-wrapper.centered +include ../../partials/includes/components/beta +div.home-wrapper.centered(ng-controller="HomePage") div.duty-summary // TODO Hide if ASSIGNED TO ==== false div.title-bar.working-on-title Working on @@ -66,4 +66,3 @@ div.home-wrapper.centered div.duty-project Teletransportation hubs a.button-gray.see-more(href="#", title="See more Watching US") See more aside.project-list(tg-home-project-list) - diff --git a/app/modules/home/home-project-list.directive.coffee b/app/modules/home/projects/list.directive.coffee similarity index 89% rename from app/modules/home/home-project-list.directive.coffee rename to app/modules/home/projects/list.directive.coffee index ae0048b6..c5a81d84 100644 --- a/app/modules/home/home-project-list.directive.coffee +++ b/app/modules/home/projects/list.directive.coffee @@ -8,7 +8,7 @@ HomeProjectListDirective = (projectsService) -> projectsService.newProject() directive = { - templateUrl: "home/home-project-list.html" + templateUrl: "home/projects/list.html" scope: {} link: link } diff --git a/app/modules/home/home-project-list.jade b/app/modules/home/projects/list.jade similarity index 100% rename from app/modules/home/home-project-list.jade rename to app/modules/home/projects/list.jade diff --git a/app/modules/home/styles/home-project-list.scss b/app/modules/home/projects/styles/list.scss similarity index 100% rename from app/modules/home/styles/home-project-list.scss rename to app/modules/home/projects/styles/list.scss diff --git a/app/modules/projects/projects.jade b/app/modules/projects/projects-page.jade similarity index 100% rename from app/modules/projects/projects.jade rename to app/modules/projects/projects-page.jade