From d1499ad541fb9b259dd823b709affafa07f824fe Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 17 Jun 2014 09:48:49 +0200 Subject: [PATCH] Next iteration over backlog. --- app/coffee/app.coffee | 6 +- app/coffee/modules/backlog.coffee | 81 ++++++++---- app/coffee/modules/resources.coffee | 10 +- app/coffee/modules/resources/http.coffee | 8 +- app/partials/backlog.jade | 4 - .../views/components/backlog-row.jade | 8 +- app/partials/views/modules/backlog-table.jade | 105 ++++++++-------- app/partials/views/modules/sprints.jade | 116 +++++++++++------- bower.json | 2 + gulpfile.coffee | 3 +- 10 files changed, 195 insertions(+), 148 deletions(-) diff --git a/app/coffee/app.coffee b/app/coffee/app.coffee index 7e75d6ca..f5f1dc07 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/app.coffee @@ -46,7 +46,7 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $compil init = ($log, $rootScope) -> $log.debug("Initialize application") -configure.$inject = ["$routeProvider", "$locationProvider","$httpProvider"] +configure.$inject = ["$routeProvider", "$locationProvider", "$httpProvider"] init.$inject = ["$log", "$rootScope"] modules = [ @@ -55,8 +55,10 @@ modules = [ "taigaConfig", "taigaResources", - "taigaBacklog", + + # Vendor modules + "pasvaz.bindonce", ] angular.module("taigaLocalConfig", []).value("localconfig", {}) diff --git a/app/coffee/modules/backlog.coffee b/app/coffee/modules/backlog.coffee index 27b090cc..a7d04a7f 100644 --- a/app/coffee/modules/backlog.coffee +++ b/app/coffee/modules/backlog.coffee @@ -18,7 +18,29 @@ taiga = @.taiga class BacklogController extends taiga.TaigaController - constructor: (@scope, @repo, @params, @rs) -> + constructor: (@scope, @repo, @params, @rs, @q) -> + promise = @.loadInitialData() + # Obviously fail condition + promise.then null, => + console.log "FAIL" + + loadSprints: -> + return @rs.getSprints(@scope.projectId).then (sprints) => + @scope.sprints = sprints + return sprints + + loadUserstories: -> + return @rs.getUnassignedUserstories(@scope.projectId).then (userstories) => + @scope.userstories = userstories + return userstories + + loadBacklog: -> + return @q.all([ + @.loadSprints(), + @.loadUserstories() + ]) + + loadInitialData: -> # Resolve project slug promise = @repo.resolve({pslug: @params.pslug}).then (data) => console.log "resolve", data.project @@ -28,36 +50,43 @@ class BacklogController extends taiga.TaigaController # Load project promise = promise.then (project) => @scope.project = project - console.log project - return @rs.getMilestones(@scope.projectId) + return @.loadBacklog() - # Load milestones - promise = promise.then (milestones) => - @scope.milestones = milestones - return @rs.getBacklog(@scope.projectId) - - # Load unassigned userstories - promise = promise.then (userstories) => - @scope.userstories = userstories - - # Obviously fail condition - promise.then null, => - console.log "FAIL" + return promise -BacklogDirective = ($compile) -> - controller: ["$scope", "$tgRepo", "$routeParams", "$tgResources", BacklogController] - link: (scope, element, attrs, ctrl) -> +BacklogDirective = ($compile, $templateCache) -> + backlogLink = ($scope, $element, $attrs, $ctrl) -> + # UserStories renderin + dom = angular.element.parseHTML($templateCache.get("backlog-row.html")) + scope = null + $scope.$watch "userstories", (userstories) => + return if not userstories -BacklogTableDirective = ($compile, $templateCache) -> - require: "^tgBacklog" - link: (scope, element, attrs, ctrl) -> - content = $templateCache.get("backlog-row.html") - scope.$watch "userstories", (userstories) => - console.log "ready to render", userstories + if scope != null + scope.$destroy() + + scope = $scope.$new() + dom = $compile(dom)(scope) + $element.append(dom) + + link = ($scope, $element, $attrs, $ctrl) -> + backlogTableDom = $element.find("section.backlog-table") + backlogLink($scope, backlogTableDom, $attrs, $ctrl) + + return { + controller: [ + "$scope", + "$tgRepo", + "$routeParams", + "$tgResources", + "$q", + BacklogController + ] + link: link + } module = angular.module("taigaBacklog", []) -module.directive("tgBacklog", ["$compile", BacklogDirective]) -module.directive("tgBacklogTable", ["$compile", "$templateCache", BacklogTableDirective]) +module.directive("tgBacklog", ["$compile", "$templateCache", BacklogDirective]) diff --git a/app/coffee/modules/resources.coffee b/app/coffee/modules/resources.coffee index fc1e76fa..e0e2c69a 100644 --- a/app/coffee/modules/resources.coffee +++ b/app/coffee/modules/resources.coffee @@ -30,19 +30,23 @@ class ResourcesService extends taiga.TaigaService getProject: (projectId) -> return @repo.queryOne("projects", projectId) + getProjects: -> + return @repo.queryMany("projects") + ############################################################################# # Backlog ############################################################################# - getMilestones: (projectId) -> - return @repo.queryMany("milestones", {project:projectId}).then (milestones) => + getSprints: (projectId) -> + params = {"project": projectId} + return @repo.queryMany("milestones", params).then (milestones) => for m in milestones uses = m.user_stories uses = _.map(uses, (u) => @model.make_model("userstories", u)) m._attrs.user_stories = uses return milestones - getBacklog: (projectId) -> + getUnassignedUserstories: (projectId) -> params = {"project": projectId, "milestone": "null"} return @repo.queryMany("userstories", params) diff --git a/app/coffee/modules/resources/http.coffee b/app/coffee/modules/resources/http.coffee index befffefa..45d05c71 100644 --- a/app/coffee/modules/resources/http.coffee +++ b/app/coffee/modules/resources/http.coffee @@ -37,11 +37,9 @@ class HttpService extends taiga.TaigaService return @http(options) get: (url, params) -> - return @.request({ - method: "GET", - url: url, - params: params - }) + options = {method: "GET", url: url} + options.params = params if params + return @.request(options) post: (url, data, params) -> options = {method: "POST", url: url} diff --git a/app/partials/backlog.jade b/app/partials/backlog.jade index f2a641de..614d4d3a 100644 --- a/app/partials/backlog.jade +++ b/app/partials/backlog.jade @@ -31,7 +31,3 @@ block content div.lightbox.lightbox_add-sprint include views/modules/lightbox_add-sprint - // Preloading angular templates parts - script(type="text/ng-template" id="backlog-row.html") - include views/components/backlog-row - diff --git a/app/partials/views/components/backlog-row.jade b/app/partials/views/components/backlog-row.jade index 57c00e51..dc943f78 100644 --- a/app/partials/views/components/backlog-row.jade +++ b/app/partials/views/components/backlog-row.jade @@ -1,14 +1,14 @@ -div.row.table-main +div.row.table-main(ng-repeat="us in userstories") div.user-stories div.user-story-name input(type="checkbox", name="") - a(href="") Crear el perfil de usuario Senior en el admin + a(href="") {{ us.subject }} span.us-settings a.icon.icon-edit(href="", title="Edit") a.icon.icon-delete(href="", title="Delete") div.user-story-tags - - for(var y = 0; y < 3; y++) - include ../components/tag + span.tag Tag name + span.tag Tag name div.status Status div.points 12 div.points 54 diff --git a/app/partials/views/modules/backlog-table.jade b/app/partials/views/modules/backlog-table.jade index 75381651..eedb212e 100644 --- a/app/partials/views/modules/backlog-table.jade +++ b/app/partials/views/modules/backlog-table.jade @@ -1,4 +1,4 @@ -section.backlog-table(tg-backlog-table) +section.backlog-table div.row.backlog-table-header div.user-stories User Stories div.status Status @@ -9,61 +9,52 @@ section.backlog-table(tg-backlog-table) div.status.width-2 div.points.width-1 Front div.points.width-1 Total - div.row.table-main.blocked - div.user-stories - div.user-story-name - input(type="checkbox", name="") - a(href="") Crear el perfil de usuario Senior en el admin - span.us-settings - a.icon.icon-edit(href="", title="Edit") - a.icon.icon-delete(href="", title="Delete") - div.user-story-tags - - for(var y = 0; y < 3; y++) - include ../components/tag - div.status.width-2 - a(href="", title="Status Name") Status Name - ul.popover.pop-status - li - a(href="", title="Status 1") Status 1 - li - a(href="", title="Status 2") Status 2 - li - a(href="", title="Status 3") Status 3 - div.points - a(href="", title="Front") 24 - ul.popover.pop-points-open - li - a(href="", title="0") 0 - li - a(href="", title="1/2") 1/2 - li - a(href="", title="1") 1 - li - a(href="", title="2") 2 - li - a(href="", title="3") 3 - li - a(href="", title="4") 4 - li - a(href="", title="8") 8 - li - a(href="", title="13") 13 - li - a(href="", title="20") 20 - li - a(href="", title="40") 40 - li - a(href="", title="100") 100 - li - a(href="", title="?") ? - div.points - a(href="", title="Total Points") 43 - ul.popover.pop-status - li - a(href="", title="Status 1") Status 1 - li - a(href="", title="Status 2") Status 2 - li - a(href="", title="Status 3") Status 3 +section.backlog-table + // div.row.table-main.blocked + // div.user-stories + // div.user-story-name + // input(type="checkbox", name="") + // a(href="") Crear el perfil de usuario Senior en el admin + // span.us-settings + // a.icon.icon-edit(href="", title="Edit") + // a.icon.icon-delete(href="", title="Delete") + // div.user-story-tags + // - for(var y = 0; y < 3; y++) + // include ../components/tag + // div.status.width-2 + // a(href="", title="Status Name") Status Name + // ul.popover.pop-status + // li + // a(href="", title="Status 1") Status 1 + // li + // a(href="", title="Status 2") Status 2 + // li + // a(href="", title="Status 3") Status 3 + // div.points + // a(href="", title="Front") 24 + // ul.popover.pop-points-open + // li: a(href="", title="0") 0 + // li: a(href="", title="1/2") 1/2 + // li: a(href="", title="1") 1 + // li: a(href="", title="2") 2 + // li: a(href="", title="3") 3 + // li: a(href="", title="4") 4 + // li: a(href="", title="8") 8 + // li: a(href="", title="13") 13 + // li: a(href="", title="20") 20 + // li: a(href="", title="40") 40 + // li: a(href="", title="100") 100 + // li: a(href="", title="?") ? + // div.points + // a(href="", title="Total Points") 43 + // ul.popover.pop-status + // li + // a(href="", title="Status 1") Status 1 + // li + // a(href="", title="Status 2") Status 2 + // li + // a(href="", title="Status 3") Status 3 hr.doom-line +script(type="text/ng-template" id="backlog-row.html") + include ../components/backlog-row diff --git a/app/partials/views/modules/sprints.jade b/app/partials/views/modules/sprints.jade index e05c6d91..2154d641 100644 --- a/app/partials/views/modules/sprints.jade +++ b/app/partials/views/modules/sprints.jade @@ -10,8 +10,7 @@ section.sprints a.button-green(href="", title="Add New US") span.text + New sprint - // If is current sprint - section.sprint.sprint-current + section.sprint(ng-repeat="sprint in sprints track by sprint.id", tg-backlog-sprint) header div.sprint-summary a.icon.icon-arrow-up(href="", title="compact Sprint") @@ -35,48 +34,73 @@ section.sprints a.button.button-gray(href="", title="Current Sprint Taksboard") span Sprint Taskboard - // If Sprint is open but date is old - section.sprint.sprint-old-open - header - div.sprint-summary - a.icon.icon-arrow-up(href="", title="compact Sprint") - span.sprint-name old open sprint - span.sprint-date 04/05/14-03/06/14 - ul - li - span.number 20 - span.description closed
points - li - span.number 24 - span.description total
points - div.sprint-progress-bar - div.current-progress - div.sprint-table - - for (var x = 0; x < 10; x++) - div.row - div.column-us.width-8 - a(href="", title="") #125 Crear el perfil de usuario Senior en el admin - div.column-points.width-1 45 + // If is current sprint + // section.sprint.sprint-current + // header + // div.sprint-summary + // a.icon.icon-arrow-up(href="", title="compact Sprint") + // span.sprint-name current sprint + // span.sprint-date 04/06/14-20/06/14 + // ul + // li + // span.number 12 + // span.description closed
points + // li + // span.number 24 + // span.description total
points + // div.sprint-progress-bar + // div.current-progress + // div.sprint-table + // - for (var x = 0; x < 10; x++) + // div.row + // div.column-us.width-8 + // a.us-name(href="", title="") #125 Crear el perfil de usuario Senior en el admin + // div.column-points.width-1 45 + // a.button.button-gray(href="", title="Current Sprint Taksboard") + // span Sprint Taskboard - // If Sprint is closed and date is old - section.sprint.sprint-closed - header - div.sprint-summary - a.icon.icon-arrow-up(href="", title="compact Sprint") - span.sprint-name old sprint - span.sprint-date 04/04/14-03/05/14 - ul - li - span.number 24 - span.description closed
points - li - span.number 24 - span.description total
points - div.sprint-progress-bar - div.current-progress - div.sprint-table - - for (var x = 0; x < 10; x++) - div.row - div.column-us.width-8 - a(href="", title="") #125 Crear el perfil de usuario Senior en el admin - div.column-points.width-1 45 + // // If Sprint is open but date is old + // section.sprint.sprint-old-open + // header + // div.sprint-summary + // a.icon.icon-arrow-up(href="", title="compact Sprint") + // span.sprint-name old open sprint + // span.sprint-date 04/05/14-03/06/14 + // ul + // li + // span.number 20 + // span.description closed
points + // li + // span.number 24 + // span.description total
points + // div.sprint-progress-bar + // div.current-progress + // div.sprint-table + // - for (var x = 0; x < 10; x++) + // div.row + // div.column-us.width-8 + // a(href="", title="") #125 Crear el perfil de usuario Senior en el admin + // div.column-points.width-1 45 + + // // If Sprint is closed and date is old + // section.sprint.sprint-closed + // header + // div.sprint-summary + // a.icon.icon-arrow-up(href="", title="compact Sprint") + // span.sprint-name old sprint + // span.sprint-date 04/04/14-03/05/14 + // ul + // li + // span.number 24 + // span.description closed
points + // li + // span.number 24 + // span.description total
points + // div.sprint-progress-bar + // div.current-progress + // div.sprint-table + // - for (var x = 0; x < 10; x++) + // div.row + // div.column-us.width-8 + // a(href="", title="") #125 Crear el perfil de usuario Senior en el admin + // div.column-points.width-1 45 diff --git a/bower.json b/bower.json index 8e687d07..20cea1c5 100644 --- a/bower.json +++ b/bower.json @@ -36,6 +36,7 @@ ], "dependencies": { "lodash": "~2.4.1", + "jade": "~1.3.1", "emoticons": "~0.1.7", "jquery-flot": "~0.8.2", "angular": "1.2.17", @@ -48,6 +49,7 @@ "i18next": "~1.7.1", "jquery": "~2.1.1", "select2": "~3.4.5", + "angular-bindonce": "~0.3.1", "angular-ui-select2": "~0.0.5", "google-diff-match-patch-js": "~1.0.0", "underscore.string": "~2.3.3", diff --git a/gulpfile.coffee b/gulpfile.coffee index 403f5173..d6c8f7a3 100644 --- a/gulpfile.coffee +++ b/gulpfile.coffee @@ -51,7 +51,8 @@ vendorJsLibs = [ "app/vendor/angular/angular.js", "app/vendor/angular-route/angular-route.js", "app/vendor/angular-sanitize/angular-sanitize.js", - "app/vendor/angular-animate/angular-animate.js" + "app/vendor/angular-animate/angular-animate.js", + "app/vendor/angular-bindonce/bindonce.js" ]