From 1df1d972a0914925ba94dabc40590dbd73506ea3 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 24 Jun 2014 12:57:03 +0200 Subject: [PATCH] Add commons module. --- app/coffee/app.coffee | 30 ++++++++---- app/coffee/modules/backlog/main.coffee | 6 --- app/coffee/modules/common/directives.coffee | 54 +++++++++++++++++++++ app/coffee/modules/resources.coffee | 5 -- app/partials/views/modules/sprints.jade | 6 +-- gulpfile.coffee | 1 + 6 files changed, 79 insertions(+), 23 deletions(-) create mode 100644 app/coffee/modules/common/directives.coffee diff --git a/app/coffee/app.coffee b/app/coffee/app.coffee index 463532fb..c8e3e2bc 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/app.coffee @@ -53,18 +53,20 @@ init = ($log, $i18n, $config, $rootscope) -> $i18n.initialize($config.get("defaultLanguage")) $log.debug("Initialize application") +# Default Value for taiga local config module. +angular.module("taigaLocalConfig", []).value("localconfig", {}) -configure.$inject = ["$routeProvider", "$locationProvider", "$httpProvider"] -init.$inject = ["$log", "$tgI18n", "$tgConfig","$rootScope"] +# Default constructor for common module +angular.module("taigaCommon", []) modules = [ - # Main Modules + # Main Global Modules "taigaConfig", "taigaBase", "taigaResources", "taigaLocales", "taigaAuth", - + "taigaCommon", "taigaNavigation", # Specific Modules @@ -75,10 +77,20 @@ modules = [ "ngAnimate", ] -# Default Value for taiga local config module. -angular.module("taigaLocalConfig", []).value("localconfig", {}) - # Main module definition module = angular.module("taiga", modules) -module.config(configure) -module.run(init) + +module.config([ + "$routeProvider", + "$locationProvider", + "$httpProvider", + configure +]) + +module.run([ + "$log", + "$tgI18n", + "$tgConfig", + "$rootScope", + init +]) diff --git a/app/coffee/modules/backlog/main.coffee b/app/coffee/modules/backlog/main.coffee index 526dc597..9a5c911f 100644 --- a/app/coffee/modules/backlog/main.coffee +++ b/app/coffee/modules/backlog/main.coffee @@ -288,12 +288,6 @@ BacklogSprintDirective = ($repo) -> if not $scope.$first and not sprint.closed $el.addClass("sprint-old-open") - # Atatch formatted dates - initialDate = moment(sprint.estimated_start).format("YYYY/MM/DD") - finishDate = moment(sprint.estimated_finish).format("YYYY/MM/DD") - dates = "#{initialDate}-#{finishDate}" - $el.find(".sprint-date").html(dates) - # Update progress bars progressPercentage = Math.round(100 * (sprint.closed_points / sprint.total_points)) $el.find(".current-progress").css("width", "#{progressPercentage}%") diff --git a/app/coffee/modules/common/directives.coffee b/app/coffee/modules/common/directives.coffee new file mode 100644 index 00000000..f042cb03 --- /dev/null +++ b/app/coffee/modules/common/directives.coffee @@ -0,0 +1,54 @@ +### +# Copyright (C) 2014 Andrey Antukh +# Copyright (C) 2014 Jesús Espino Garcia +# Copyright (C) 2014 David Barragán Merino +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# File: modules/common/directives.coffee +### + +taiga = @.taiga +bindOnce = @.taiga.bindOnce + +DateRangeDirective = -> + renderRange = ($el, first, second) -> + initDate = moment(first).format("YYYY/MM/DD") + endDate = moment(second).format("YYYY/MM/DD") + $el.html("#{initDate}-#{endDate}") + + link = ($scope, $el, $attrs) -> + [first, second] = $attrs.tgDateRange.split(",") + + bindOnce $scope, first, (valFirst) -> + bindOnce $scope, second, (valSecond) -> + renderRange($el, valFirst, valSecond) + + return {link:link} + + +SprintProgressBarDirective = -> + link = ($scope, $el, $attrs) -> + bindOnce $scope, $attrs.tgSprintProgressbar, (sprint) -> + closedPoints = sprint.closed_points + totalPoints = sprint.total_points + percentage = Math.round(100 * (closedPoints/totalPoints)) + $el.css("width", "#{percentage}%") + + return {link: link} + + +module = angular.module("taigaCommon") +module.directive("tgDateRange", DateRangeDirective) +module.directive("tgSprintProgressbar", SprintProgressBarDirective) diff --git a/app/coffee/modules/resources.coffee b/app/coffee/modules/resources.coffee index 41471eaf..f809f697 100644 --- a/app/coffee/modules/resources.coffee +++ b/app/coffee/modules/resources.coffee @@ -21,13 +21,8 @@ taiga = @.taiga - - - - class ResourcesService extends taiga.Service - urls = { "auth": "/api/v1/auth" "auth-register": "/api/v1/auth/register" diff --git a/app/partials/views/modules/sprints.jade b/app/partials/views/modules/sprints.jade index c0aaaf8f..1b247abb 100644 --- a/app/partials/views/modules/sprints.jade +++ b/app/partials/views/modules/sprints.jade @@ -15,7 +15,7 @@ section.sprints div.sprint-summary a.icon.icon-arrow-up(href="", title="compact Sprint") span.sprint-name current sprint - span.sprint-date + span.sprint-date(tg-date-range="sprint.estimated_start,sprint.estimated_finish") ul li span.number(tg-bo-html="sprint.closed_points") -- @@ -24,7 +24,7 @@ section.sprints span.number(tg-bo-html="sprint.total_points") -- span.description total
points div.sprint-progress-bar - div.current-progress + div.current-progress(tg-sprint-progressbar="sprint") div.sprint-table div.row.milestone-us-item-row(ng-repeat="us in sprint.user_stories track by us.id") div.column-us.width-8 @@ -32,6 +32,6 @@ section.sprints span(tg-bo-ref="us.ref") span(tg-bo-html="us.subject") div.column-points.width-1(tg-bo-html="us.total_points") - a.button.button-gray(href="", tg-nav="project-taskboard:project=projectId,sprint=sprint.id", + a.button.button-gray(href="", tg-nav="project-taskboard:project=project.slug,sprint=sprint.id", title="Current Sprint Taskboard") span Sprint Taskboard diff --git a/gulpfile.coffee b/gulpfile.coffee index 62cde8be..248a4d8d 100644 --- a/gulpfile.coffee +++ b/gulpfile.coffee @@ -37,6 +37,7 @@ paths = { "app/coffee/*.coffee", "app/coffee/modules/controllerMixins.coffee", "app/coffee/modules/*.coffee", + "app/coffee/modules/common/*.coffee", "app/coffee/modules/backlog/*.coffee", "app/coffee/modules/locales/*.coffee", "app/coffee/modules/base/*.coffee",