From ab03bb9effd2a4e956c1157319c4d8285dcde477 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 11 Jun 2014 18:24:33 +0200 Subject: [PATCH] Initial js layout for backlog. --- app/coffee/base.coffee | 3 +- app/coffee/modules/backlog.coffee | 46 ++++++++++++++++ app/coffee/modules/resources/http.coffee | 13 +++-- .../modules/resources/repository.coffee | 17 +++--- app/partials/backlog.jade | 53 ++++++++++--------- .../views/components/backlog-row.jade | 15 ++++++ app/partials/views/modules/backlog-table.jade | 22 ++------ gulpfile.js | 9 +++- 8 files changed, 119 insertions(+), 59 deletions(-) create mode 100644 app/partials/views/components/backlog-row.jade diff --git a/app/coffee/base.coffee b/app/coffee/base.coffee index 04e2d303..99de96df 100644 --- a/app/coffee/base.coffee +++ b/app/coffee/base.coffee @@ -16,8 +16,9 @@ # along with this program. If not, see . class TaigaBase - class TaigaService extends TaigaBase +class TaigaController extends TaigaBase @.taiga.TaigaBase = TaigaBase @.taiga.TaigaService = TaigaService +@.taiga.TaigaController = TaigaController diff --git a/app/coffee/modules/backlog.coffee b/app/coffee/modules/backlog.coffee index e69de29b..7bea08ce 100644 --- a/app/coffee/modules/backlog.coffee +++ b/app/coffee/modules/backlog.coffee @@ -0,0 +1,46 @@ +# 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 . + +taiga = @.taiga + +class BacklogController extends taiga.TaigaController + constructor: (@repo) -> + console.log "foo" + + getMilestones: -> + projectId = 1 + return @repo.queryMany("milestones", {project:projectId}).then (milestones) -> + console.log milestones + return milestones + + +BacklogDirective = ($compile) -> + controller: ["$tgRepo", BacklogController] + link: (scope, element, attrs, ctrl) -> + ctrl.getMilestones().then => + console.log "kaka" + + +BacklogTableDirective = ($compile, $templateCache) -> + require: "^tgBacklog" + link: (scope, element, attrs, ctrl) -> + content = $templateCache.get("backlog-row.html") + + +module = angular.module("taiga") +module.directive("tgBacklog", ["$compile", BacklogDirective]) +module.directive("tgBacklogTable", ["$compile", "$templateCache", BacklogTableDirective]) diff --git a/app/coffee/modules/resources/http.coffee b/app/coffee/modules/resources/http.coffee index 4f0c691f..befffefa 100644 --- a/app/coffee/modules/resources/http.coffee +++ b/app/coffee/modules/resources/http.coffee @@ -39,29 +39,34 @@ class HttpService extends taiga.TaigaService get: (url, params) -> return @.request({ method: "GET", + url: url, params: params }) post: (url, data, params) -> - options = {method: "POST"} + options = {method: "POST", url: url} options.data = data if data options.params = params if params return @.request(options) put: (url, data, params) -> - options = {method: "PUT"} + options = {method: "PUT", url: url} options.data = data if data options.params = params if params return @.request(options) patch: (url, data, params) -> - options = {method: "PATCH"} + options = {method: "PATCH", url: url} options.data = data if data options.params = params if params return @.request(options) delete: (url, data, params) -> - options = {method: "DELETE"} + options = {method: "DELETE", url: url} options.data = data if data options.params = params if params return @.request(options) + + +module = angular.module("taigaResources") +module.service("$tgHttp", HttpService) diff --git a/app/coffee/modules/resources/repository.coffee b/app/coffee/modules/resources/repository.coffee index f6a3a50f..cb9f93b4 100644 --- a/app/coffee/modules/resources/repository.coffee +++ b/app/coffee/modules/resources/repository.coffee @@ -18,9 +18,9 @@ taiga = @.taiga class RepositoryService extends taiga.TaigaService - @.$inject = ["$q", "$tgModel", "$tgStorage", "$tgHttp"] + @.$inject = ["$q", "$tgModel", "$tgStorage", "$tgHttp", "$tgUrls"] - constructor: (@q, @model, @storage, @http) -> + constructor: (@q, @model, @storage, @http, @urls) -> super() resolveUrlForModel: (model) -> @@ -98,25 +98,24 @@ class RepositoryService extends taiga.TaigaService return defered.promise - queryMany: (name, params) -> url = @urls.resolve(name) - return @http.get(url, params).then (data, status) -> - return _.map(data, (x) -> @model.make_model(name, x)) + return @http.get(url, params).then (data) => + return _.map(data.data, (x) => @model.make_model(name, x)) queryOne: (name, id, params) -> url = @urls.resolve(name) url = "#{url}/#{id}" if id - return @http.get(url, params).then (data, status) -> + return @http.get(url, params).then (data) => return @model.make_model(name, data) queryPaginated: (name, params) -> url = @urls.resolve(name) - return @http.get(url, params).then (data, status, headers) -> - headers = headers() + return @http.get(url, params).then (data) => + headers = data.headers() result = {} - result.models = _.map(data, (x) -> @model.make_model(name, x)) + result.models = _.map(data.data, (x) => @model.make_model(name, x)) result.count = parseInt(headers["x-pagination-count"], 10) result.current = parseInt(headers["x-pagination-current"] or 1, 10) result.paginatedBy = parseInt(headers["x-paginated-by"], 10) diff --git a/app/partials/backlog.jade b/app/partials/backlog.jade index 2b70d612..21487f80 100644 --- a/app/partials/backlog.jade +++ b/app/partials/backlog.jade @@ -4,30 +4,31 @@ block head title Taiga Project management web application with scrum in mind! block content - sidebar.menu-secondary.extrabar.filters-bar - include views/modules/filters - section.main.backlog - include views/components/mainTitle - include views/components/summary - include views/modules/burndown - div.backlog-menu - a.trans-button(href="", title="Move to Current Sprint") - span.icon.icon-move - span.text Move to current Sprint - a.trans-button(href="", title="Show Filters") - span.icon.icon-filter - span.text Show Filters - a.trans-button(href="", title="Show Tags") - span.icon.icon-tag - span.text Show Tags - include views/components/addnewus - include views/modules/backlog-table - sidebar.menu-secondary.sidebar - include views/modules/sprints - div.lightbox.lightbox_add-new-us - include views/modules/lightbox_add-new-us - div.lightbox.lightbox_add-bulk - include views/modules/lightbox_add-bulk - div.lightbox.lightbox_add-sprint - include views/modules/lightbox_add-sprint + div(tg-backlog) + sidebar.menu-secondary.extrabar.filters-bar + include views/modules/filters + section.main.backlog + include views/components/mainTitle + include views/components/summary + include views/modules/burndown + div.backlog-menu + a.trans-button(href="", title="Move to Current Sprint") + span.icon.icon-move + span.text Move to current Sprint + a.trans-button(href="", title="Show Filters") + span.icon.icon-filter + span.text Show Filters + a.trans-button(href="", title="Show Tags") + span.icon.icon-tag + span.text Show Tags + include views/components/addnewus + include views/modules/backlog-table + sidebar.menu-secondary.sidebar + include views/modules/sprints + div.lightbox.lightbox_add-new-us + include views/modules/lightbox_add-new-us + div.lightbox.lightbox_add-bulk + include views/modules/lightbox_add-bulk + div.lightbox.lightbox_add-sprint + include views/modules/lightbox_add-sprint diff --git a/app/partials/views/components/backlog-row.jade b/app/partials/views/components/backlog-row.jade new file mode 100644 index 00000000..57c00e51 --- /dev/null +++ b/app/partials/views/components/backlog-row.jade @@ -0,0 +1,15 @@ +div.row.table-main + 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 Status + div.points 12 + div.points 54 + a.icon.icon-drag-v(href="", title="Drag") diff --git a/app/partials/views/modules/backlog-table.jade b/app/partials/views/modules/backlog-table.jade index b0ade700..a3a12cbf 100644 --- a/app/partials/views/modules/backlog-table.jade +++ b/app/partials/views/modules/backlog-table.jade @@ -1,4 +1,4 @@ -section.backlog-table +section.backlog-table(tg-backlog-table) div.row.backlog-table-header div.user-stories User Stories div.status Status @@ -66,19 +66,7 @@ section.backlog-table li a(href="", title="Status 3") Status 3 hr.doom-line - - for (var x = 0; x < 50; x++) - div.row.table-main - 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 Status - div.points 12 - div.points 54 - a.icon.icon-drag-v(href="", title="Drag") + +// Preloading angular templates parts +script(type="text/ng-template" id="backlog-row.html") + include ../components/backlog-row diff --git a/gulpfile.js b/gulpfile.js index 881ffcc6..678d442f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -32,8 +32,13 @@ var paths = { sassMain: "app/styles/main.scss", css: "dist/styles/**/*.css", images: "app/images/**/*", - coffee: ["app/coffee/**/*.coffee", - "config/main.coffee"] + coffee: ["app/coffee/app.coffee", + "config/main.coffee", + "app/coffee/*.coffee", + "app/coffee/modules/*.coffee", + "app/coffee/modules/resources/init.coffee", + "app/coffee/modules/resources/*.coffee", + "app/coffee/**/*.coffee"] }; // Ordered list of vendor/external libraries.