From 098b794d831e64b85d531fc70de518633be934d5 Mon Sep 17 00:00:00 2001 From: Juanfran Date: Wed, 26 Nov 2014 11:56:26 +0100 Subject: [PATCH] angular1.3 --- app/coffee/app.coffee | 28 +++++++++++-------- app/coffee/modules/admin/memberships.coffee | 3 +- app/coffee/modules/admin/roles.coffee | 3 +- app/coffee/modules/admin/third-parties.coffee | 3 +- app/coffee/modules/backlog/main.coffee | 4 ++- app/coffee/modules/base/repository.coffee | 1 + app/coffee/modules/common/attachments.coffee | 3 +- app/coffee/modules/common/confirm.coffee | 4 +-- app/coffee/modules/events.coffee | 3 +- app/coffee/modules/kanban/main.coffee | 5 +++- app/coffee/modules/taskboard/main.coffee | 3 +- app/coffee/utils.coffee | 11 ++++++++ app/partials/issues-detail.jade | 2 +- bower.json | 13 +++++---- 14 files changed, 57 insertions(+), 29 deletions(-) diff --git a/app/coffee/app.coffee b/app/coffee/app.coffee index 0b014ad3..76af3789 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/app.coffee @@ -134,7 +134,7 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEven {templateUrl: "/partials/permission-denied.html"}) $routeProvider.otherwise({redirectTo: '/not-found'}) - $locationProvider.html5Mode(true) + $locationProvider.html5Mode({enabled: true, requireBase: false}) defaultHeaders = { "Content-Type": "application/json" @@ -154,20 +154,24 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEven # Add next param when user try to access to a secction need auth permissions. authHttpIntercept = ($q, $location, $confirm, $navUrls, $lightboxService) -> - return (promise) -> - return promise.then null, (response) -> - if response.status == 0 - $lightboxService.closeAll() - $location.path($navUrls.resolve("error")) - $location.replace() - else if response.status == 401 - nextPath = $location.path() - $location.url($navUrls.resolve("login")).search("next=#{nextPath}") - return $q.reject(response) + httpResponseError = (response) -> + if response.status == 0 + $lightboxService.closeAll() + $location.path($navUrls.resolve("error")) + $location.replace() + else if response.status == 401 + nextPath = $location.path() + $location.url($navUrls.resolve("login")).search("next=#{nextPath}") + return $q.reject(response) + + return { + responseError: httpResponseError + } $provide.factory("authHttpIntercept", ["$q", "$location", "$tgConfirm", "$tgNavUrls", "lightboxService", authHttpIntercept]) - $httpProvider.responseInterceptors.push('authHttpIntercept') + + $httpProvider.interceptors.push('authHttpIntercept'); window.checksley.updateValidators({ linewidth: (val, width) -> diff --git a/app/coffee/modules/admin/memberships.coffee b/app/coffee/modules/admin/memberships.coffee index c337fbbe..631feb50 100644 --- a/app/coffee/modules/admin/memberships.coffee +++ b/app/coffee/modules/admin/memberships.coffee @@ -22,6 +22,7 @@ taiga = @.taiga mixOf = @.taiga.mixOf +bindMethods = @.taiga.bindMethods module = angular.module("taigaAdmin") @@ -47,7 +48,7 @@ class MembershipsController extends mixOf(taiga.Controller, taiga.PageMixin, tai constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @navUrls, @analytics, @appTitle) -> - _.bindAll(@) + bindMethods(@) @scope.sectionName = "Manage Members" #i18n @scope.project = {} diff --git a/app/coffee/modules/admin/roles.coffee b/app/coffee/modules/admin/roles.coffee index 99bae6e1..6174e69e 100644 --- a/app/coffee/modules/admin/roles.coffee +++ b/app/coffee/modules/admin/roles.coffee @@ -24,6 +24,7 @@ taiga = @.taiga mixOf = @.taiga.mixOf bindOnce = @.taiga.bindOnce debounce = @.taiga.debounce +bindMethods = @.taiga.bindMethods module = angular.module("taigaAdmin") @@ -47,7 +48,7 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil ] constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @navUrls, @appTitle) -> - _.bindAll(@) + bindMethods(@) @scope.sectionName = "Permissions" #i18n @scope.project = {} diff --git a/app/coffee/modules/admin/third-parties.coffee b/app/coffee/modules/admin/third-parties.coffee index 44c4782c..c8aa1b3d 100644 --- a/app/coffee/modules/admin/third-parties.coffee +++ b/app/coffee/modules/admin/third-parties.coffee @@ -22,6 +22,7 @@ taiga = @.taiga mixOf = @.taiga.mixOf +bindMethods = @.taiga.bindMethods module = angular.module("taigaAdmin") @@ -40,7 +41,7 @@ class GithubController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi ] constructor: (@scope, @repo, @rs, @params, @appTitle) -> - _.bindAll(@) + bindMethods(@) @scope.sectionName = "Github" #i18n @scope.project = {} diff --git a/app/coffee/modules/backlog/main.coffee b/app/coffee/modules/backlog/main.coffee index 87ae636a..2cca43de 100644 --- a/app/coffee/modules/backlog/main.coffee +++ b/app/coffee/modules/backlog/main.coffee @@ -27,6 +27,7 @@ scopeDefer = @.taiga.scopeDefer bindOnce = @.taiga.bindOnce groupBy = @.taiga.groupBy timeout = @.taiga.timeout +bindMethods = @.taiga.bindMethods module = angular.module("taigaBacklog") @@ -53,7 +54,7 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @appTitle, @navUrls, @events, @analytics, tgLoader) -> - _.bindAll(@) + bindMethods(@) @scope.sectionName = "Backlog" @showTags = false @@ -444,6 +445,7 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F return obj plainStatuses = _.map(@scope.userstories, "status") + plainStatuses = _.filter plainStatuses, (status) => if status return status diff --git a/app/coffee/modules/base/repository.coffee b/app/coffee/modules/base/repository.coffee index 9241975a..0cbf7348 100644 --- a/app/coffee/modules/base/repository.coffee +++ b/app/coffee/modules/base/repository.coffee @@ -143,6 +143,7 @@ class RepositoryService extends taiga.Service queryMany: (name, params, options={}) -> url = @urls.resolve(name) httpOptions = {headers: {}} + if not options.enablePagination httpOptions.headers["x-disable-pagination"] = "1" diff --git a/app/coffee/modules/common/attachments.coffee b/app/coffee/modules/common/attachments.coffee index 05951831..2a082259 100644 --- a/app/coffee/modules/common/attachments.coffee +++ b/app/coffee/modules/common/attachments.coffee @@ -22,6 +22,7 @@ taiga = @.taiga sizeFormat = @.taiga.sizeFormat bindOnce = @.taiga.bindOnce +bindMethods = @.taiga.bindMethods module = angular.module("taigaCommon") @@ -30,7 +31,7 @@ class AttachmentsController extends taiga.Controller @.$inject = ["$scope", "$rootScope", "$tgRepo", "$tgResources", "$tgConfirm", "$q"] constructor: (@scope, @rootscope, @repo, @rs, @confirm, @q) -> - _.bindAll(@) + bindMethods(@) @.type = null @.objectId = null @.projectId = null diff --git a/app/coffee/modules/common/confirm.coffee b/app/coffee/modules/common/confirm.coffee index 81679f42..ce93c707 100644 --- a/app/coffee/modules/common/confirm.coffee +++ b/app/coffee/modules/common/confirm.coffee @@ -23,7 +23,7 @@ taiga = @.taiga timeout = @.taiga.timeout cancelTimeout = @.taiga.cancelTimeout debounce = @.taiga.debounce - +bindMethods = @.taiga.bindMethods NOTIFICATION_MSG = { "success": @@ -42,7 +42,7 @@ class ConfirmService extends taiga.Service @.$inject = ["$q", "lightboxService", "$tgLoading"] constructor: (@q, @lightboxService, @loading) -> - _.bindAll(@) + bindMethods(@) hide: (el)-> if el diff --git a/app/coffee/modules/events.coffee b/app/coffee/modules/events.coffee index f167fcfe..bd8923c1 100644 --- a/app/coffee/modules/events.coffee +++ b/app/coffee/modules/events.coffee @@ -21,13 +21,14 @@ taiga = @.taiga startswith = @.taiga.startswith +bindMethods = @.taiga.bindMethods module = angular.module("taigaEvents", []) class EventsService constructor: (@win, @log, @config, @auth) -> - _.bindAll(@) + bindMethods(@) initialize: (sessionId) -> @.sessionId = sessionId diff --git a/app/coffee/modules/kanban/main.coffee b/app/coffee/modules/kanban/main.coffee index d8ba9db5..7f64a924 100644 --- a/app/coffee/modules/kanban/main.coffee +++ b/app/coffee/modules/kanban/main.coffee @@ -27,6 +27,7 @@ scopeDefer = @.taiga.scopeDefer bindOnce = @.taiga.bindOnce groupBy = @.taiga.groupBy timeout = @.taiga.timeout +bindMethods = @.taiga.bindMethods module = angular.module("taigaKanban") @@ -66,7 +67,9 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @appTitle, @navUrls, @events, @analytics, tgLoader) -> - _.bindAll(@) + + bindMethods(@) + @scope.sectionName = "Kanban" @scope.statusViewModes = {} @.initializeEventHandlers() diff --git a/app/coffee/modules/taskboard/main.coffee b/app/coffee/modules/taskboard/main.coffee index 331a69b2..f1b46ccc 100644 --- a/app/coffee/modules/taskboard/main.coffee +++ b/app/coffee/modules/taskboard/main.coffee @@ -26,6 +26,7 @@ groupBy = @.taiga.groupBy bindOnce = @.taiga.bindOnce scopeDefer = @.taiga.scopeDefer timeout = @.taiga.timeout +bindMethods = @.taiga.bindMethods module = angular.module("taigaTaskboard") @@ -53,7 +54,7 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin) constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @appTitle, @location, @navUrls, @events, @analytics, tgLoader) -> - _.bindAll(@) + bindMethods(@) @scope.sectionName = "Taskboard" @.initializeEventHandlers() diff --git a/app/coffee/utils.coffee b/app/coffee/utils.coffee index 455211bf..dc399ab8 100644 --- a/app/coffee/utils.coffee +++ b/app/coffee/utils.coffee @@ -23,6 +23,16 @@ nl2br = (str) => breakTag = '
' return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2') +bindMethods = (object) => + dependencies = _.keys(object) + + methods = [] + + _.forIn object, (value, key) => + if key not in dependencies + methods.push(key) + + _.bindAll(object, methods) bindOnce = (scope, attr, continuation) => val = scope.$eval(attr) @@ -133,6 +143,7 @@ sizeFormat = (input, precision=1) -> taiga = @.taiga taiga.nl2br = nl2br +taiga.bindMethods = bindMethods taiga.bindOnce = bindOnce taiga.mixOf = mixOf taiga.trim = trim diff --git a/app/partials/issues-detail.jade b/app/partials/issues-detail.jade index 971daecf..9fa95b0e 100644 --- a/app/partials/issues-detail.jade +++ b/app/partials/issues-detail.jade @@ -16,7 +16,7 @@ block content span.us-number(tg-bo-ref="issue.ref") span.us-name(tg-editable-subject, ng-model="issue", required-perm="modify_issue") - p.us-related-task(ng-if="issue.generated_user_stories") This issue has been promoted to US: + p.us-related-task(ng-if="issue.generated_user_stories.length") This issue has been promoted to US: a(ng-repeat="us in issue.generated_user_stories", tg-check-permission="view_us", href="", tg-bo-title="'#' + us.ref + ' ' + us.subject", diff --git a/bower.json b/bower.json index 10a70219..12d69091 100644 --- a/bower.json +++ b/bower.json @@ -50,11 +50,11 @@ "lodash": "~2.4.1", "emoticons": "~0.1.7", "jquery-flot": "~0.8.2", - "angular": "1.2.21", - "angular-route": "1.2.21", - "angular-animate": "1.2.21", - "angular-sanitize": "1.2.21", - "angular-mocks": "1.2.21", + "angular": "1.3.4", + "angular-route": "1.3.4", + "angular-animate": "1.3.4", + "angular-sanitize": "1.3.4", + "angular-mocks": "1.3.4", "kalendae": "~0.4.1", "checksley": "~0.6.0", "i18next": "~1.7.1", @@ -78,7 +78,8 @@ "resolutions": { "lodash": "~2.4.1", "moment": "~2.6.0", - "jquery": "~2.1.1" + "jquery": "~2.1.1", + "angular": "1.3.4" }, "private": true }