diff --git a/app/coffee/app.coffee b/app/coffee/app.coffee index 55ae46d0..d7f34ada 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/app.coffee @@ -38,111 +38,111 @@ taiga.sessionId = taiga.generateUniqueSessionIdentifier() configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEventsProvider, tgLoaderProvider) -> $routeProvider.when("/", - {templateUrl: "/partials/projects.html", resolve: {loader: tgLoaderProvider.add()}}) + {templateUrl: "project/projects.html", resolve: {loader: tgLoaderProvider.add()}}) $routeProvider.when("/project/:pslug/", - {templateUrl: "/partials/project.html"}) + {templateUrl: "project/project.html"}) $routeProvider.when("/project/:pslug/backlog", - {templateUrl: "/partials/backlog.html", resolve: {loader: tgLoaderProvider.add()}}) + {templateUrl: "backlog/backlog.html", resolve: {loader: tgLoaderProvider.add()}}) $routeProvider.when("/project/:pslug/taskboard/:sslug", - {templateUrl: "/partials/taskboard.html", resolve: {loader: tgLoaderProvider.add()}}) + {templateUrl: "taskboard/taskboard.html", resolve: {loader: tgLoaderProvider.add()}}) $routeProvider.when("/project/:pslug/search", - {templateUrl: "/partials/search.html", reloadOnSearch: false}) + {templateUrl: "search/search.html", reloadOnSearch: false}) $routeProvider.when("/project/:pslug/kanban", - {templateUrl: "/partials/kanban.html", resolve: {loader: tgLoaderProvider.add()}}) + {templateUrl: "kanban/kanban.html", resolve: {loader: tgLoaderProvider.add()}}) # User stories $routeProvider.when("/project/:pslug/us/:usref", - {templateUrl: "/partials/us-detail.html", resolve: {loader: tgLoaderProvider.add()}}) + {templateUrl: "us/us-detail.html", resolve: {loader: tgLoaderProvider.add()}}) # Tasks $routeProvider.when("/project/:pslug/task/:taskref", - {templateUrl: "/partials/task-detail.html", resolve: {loader: tgLoaderProvider.add()}}) + {templateUrl: "task/task-detail.html", resolve: {loader: tgLoaderProvider.add()}}) # Wiki $routeProvider.when("/project/:pslug/wiki", {redirectTo: (params) -> "/project/#{params.pslug}/wiki/home"}, ) $routeProvider.when("/project/:pslug/wiki/:slug", - {templateUrl: "/partials/wiki.html", resolve: {loader: tgLoaderProvider.add()}}) + {templateUrl: "wiki/wiki.html", resolve: {loader: tgLoaderProvider.add()}}) # Team $routeProvider.when("/project/:pslug/team", - {templateUrl: "/partials/views/team/team.html", resolve: {loader: tgLoaderProvider.add()}}) + {templateUrl: "team/team.html", resolve: {loader: tgLoaderProvider.add()}}) # Issues $routeProvider.when("/project/:pslug/issues", - {templateUrl: "/partials/issues.html", resolve: {loader: tgLoaderProvider.add()}}) + {templateUrl: "issue/issues.html", resolve: {loader: tgLoaderProvider.add()}}) $routeProvider.when("/project/:pslug/issue/:issueref", - {templateUrl: "/partials/issues-detail.html", resolve: {loader: tgLoaderProvider.add()}}) + {templateUrl: "issue/issues-detail.html", resolve: {loader: tgLoaderProvider.add()}}) # Admin $routeProvider.when("/project/:pslug/admin/project-profile/details", - {templateUrl: "/partials/admin-project-profile.html"}) + {templateUrl: "admin/admin-project-profile.html"}) $routeProvider.when("/project/:pslug/admin/project-profile/default-values", - {templateUrl: "/partials/admin-project-default-values.html"}) + {templateUrl: "admin/admin-project-default-values.html"}) $routeProvider.when("/project/:pslug/admin/project-profile/modules", - {templateUrl: "/partials/admin-project-modules.html"}) + {templateUrl: "admin/admin-project-modules.html"}) $routeProvider.when("/project/:pslug/admin/project-values/us-status", - {templateUrl: "/partials/admin-project-values-us-status.html"}) + {templateUrl: "admin/admin-project-values-us-status.html"}) $routeProvider.when("/project/:pslug/admin/project-values/us-points", - {templateUrl: "/partials/admin-project-values-us-points.html"}) + {templateUrl: "admin/admin-project-values-us-points.html"}) $routeProvider.when("/project/:pslug/admin/project-values/task-status", - {templateUrl: "/partials/admin-project-values-task-status.html"}) + {templateUrl: "admin/admin-project-values-task-status.html"}) $routeProvider.when("/project/:pslug/admin/project-values/issue-status", - {templateUrl: "/partials/admin-project-values-issue-status.html"}) + {templateUrl: "admin/admin-project-values-issue-status.html"}) $routeProvider.when("/project/:pslug/admin/project-values/issue-types", - {templateUrl: "/partials/admin-project-values-issue-types.html"}) + {templateUrl: "admin/admin-project-values-issue-types.html"}) $routeProvider.when("/project/:pslug/admin/project-values/issue-priorities", - {templateUrl: "/partials/admin-project-values-issue-priorities.html"}) + {templateUrl: "admin/admin-project-values-issue-priorities.html"}) $routeProvider.when("/project/:pslug/admin/project-values/issue-severities", - {templateUrl: "/partials/admin-project-values-issue-severities.html"}) + {templateUrl: "admin/admin-project-values-issue-severities.html"}) $routeProvider.when("/project/:pslug/admin/memberships", - {templateUrl: "/partials/admin-memberships.html"}) + {templateUrl: "admin/admin-memberships.html"}) $routeProvider.when("/project/:pslug/admin/roles", - {templateUrl: "/partials/admin-roles.html"}) + {templateUrl: "admin/admin-roles.html"}) $routeProvider.when("/project/:pslug/admin/third-parties/github", - {templateUrl: "/partials/admin-third-parties-github.html"}) + {templateUrl: "admin/admin-third-parties-github.html"}) $routeProvider.when("/project/:pslug/admin/third-parties/gitlab", - {templateUrl: "/partials/admin-third-parties-gitlab.html"}) + {templateUrl: "admin/admin-third-parties-gitlab.html"}) $routeProvider.when("/project/:pslug/admin/third-parties/bitbucket", - {templateUrl: "/partials/admin-third-parties-bitbucket.html"}) + {templateUrl: "admin/admin-third-parties-bitbucket.html"}) $routeProvider.when("/project/:pslug/admin/contrib/:plugin", - {templateUrl: "/partials/contrib/main.html"}) + {templateUrl: "contrib/main.html"}) # User settings $routeProvider.when("/project/:pslug/user-settings/user-profile", - {templateUrl: "/partials/user-profile.html"}) + {templateUrl: "user/user-profile.html"}) $routeProvider.when("/project/:pslug/user-settings/user-change-password", - {templateUrl: "/partials/user-change-password.html"}) + {templateUrl: "user/user-change-password.html"}) $routeProvider.when("/project/:pslug/user-settings/user-avatar", - {templateUrl: "/partials/user-avatar.html"}) + {templateUrl: "user/user-avatar.html"}) $routeProvider.when("/project/:pslug/user-settings/mail-notifications", - {templateUrl: "/partials/mail-notifications.html"}) + {templateUrl: "user/mail-notifications.html"}) $routeProvider.when("/change-email/:email_token", - {templateUrl: "/partials/change-email.html"}) + {templateUrl: "user/change-email.html"}) $routeProvider.when("/cancel-account/:cancel_token", - {templateUrl: "/partials/cancel-account.html"}) + {templateUrl: "user/cancel-account.html"}) # Auth $routeProvider.when("/login", - {templateUrl: "/partials/login.html"}) + {templateUrl: "auth/login.html"}) $routeProvider.when("/register", - {templateUrl: "/partials/register.html"}) + {templateUrl: "auth/register.html"}) $routeProvider.when("/forgot-password", - {templateUrl: "/partials/forgot-password.html"}) + {templateUrl: "auth/forgot-password.html"}) $routeProvider.when("/change-password", - {templateUrl: "/partials/change-password-from-recovery.html"}) + {templateUrl: "auth/change-password-from-recovery.html"}) $routeProvider.when("/change-password/:token", - {templateUrl: "/partials/change-password-from-recovery.html"}) + {templateUrl: "auth/change-password-from-recovery.html"}) $routeProvider.when("/invitation/:token", - {templateUrl: "/partials/invitation.html"}) + {templateUrl: "auth/invitation.html"}) # Errors/Exceptions $routeProvider.when("/error", - {templateUrl: "/partials/error.html"}) + {templateUrl: "error/error.html"}) $routeProvider.when("/not-found", - {templateUrl: "/partials/not-found.html"}) + {templateUrl: "error/not-found.html"}) $routeProvider.when("/permission-denied", - {templateUrl: "/partials/permission-denied.html"}) + {templateUrl: "error/permission-denied.html"}) $routeProvider.otherwise({redirectTo: '/not-found'}) $locationProvider.html5Mode({enabled: true, requireBase: false}) @@ -257,6 +257,9 @@ modules = [ "taigaPlugins", "taigaIntegrations", + # template cache + "templates" + # Vendor modules "ngRoute", "ngAnimate", diff --git a/app/coffee/modules/admin/memberships.coffee b/app/coffee/modules/admin/memberships.coffee index 7a7f8988..dc21cfa3 100644 --- a/app/coffee/modules/admin/memberships.coffee +++ b/app/coffee/modules/admin/memberships.coffee @@ -105,40 +105,8 @@ module.controller("MembershipsController", MembershipsController) ## Member Avatar Directive ############################################################################# -paginatorTemplate = """ - -""" - -MembershipsDirective = -> - template = _.template(paginatorTemplate) +MembershipsDirective = ($template) -> + template = $template.get("admin/admin-membership-paginator.html", true) linkPagination = ($scope, $el, $attrs, $ctrl) -> # Constants @@ -215,6 +183,7 @@ MembershipsDirective = -> $ctrl.selectFilter("page", pagenum) $ctrl.loadMembers() + link = ($scope, $el, $attrs) -> $ctrl = $el.controller() linkPagination($scope, $el, $attrs, $ctrl) @@ -224,23 +193,15 @@ MembershipsDirective = -> return {link:link} -module.directive("tgMemberships", MembershipsDirective) +module.directive("tgMemberships", ["$tgTemplate", MembershipsDirective]) ############################################################################# ## Member Avatar Directive ############################################################################# -MembershipsRowAvatarDirective = ($log) -> - template = _.template(""" -
- <%- full_name %> -
- <%- full_name %> - -
-
- """) +MembershipsRowAvatarDirective = ($log, $template) -> + template = $template.get("admin/memberships-row-avatar.html", true) link = ($scope, $el, $attrs) -> render = (member) -> @@ -265,22 +226,15 @@ MembershipsRowAvatarDirective = ($log) -> return {link: link} -module.directive("tgMembershipsRowAvatar", ["$log", MembershipsRowAvatarDirective]) +module.directive("tgMembershipsRowAvatar", ["$log", "$tgTemplate", MembershipsRowAvatarDirective]) ############################################################################# ## Member IsAdminCheckbox Directive ############################################################################# -MembershipsRowAdminCheckboxDirective = ($log, $repo, $confirm) -> - template = _.template(""" -
- -
- Yes - No -
- """) # TODO: i18n +MembershipsRowAdminCheckboxDirective = ($log, $repo, $confirm, $template) -> + template = $template.get("admin/admin-memberships-row-checkbox.html", true) link = ($scope, $el, $attrs) -> render = (member) -> @@ -317,7 +271,7 @@ MembershipsRowAdminCheckboxDirective = ($log, $repo, $confirm) -> return {link: link} -module.directive("tgMembershipsRowAdminCheckbox", ["$log", "$tgRepo", "$tgConfirm", +module.directive("tgMembershipsRowAdminCheckbox", ["$log", "$tgRepo", "$tgConfirm", "$tgTemplate", MembershipsRowAdminCheckboxDirective]) diff --git a/app/coffee/modules/auth.coffee b/app/coffee/modules/auth.coffee index 173e38fd..9086f1eb 100644 --- a/app/coffee/modules/auth.coffee +++ b/app/coffee/modules/auth.coffee @@ -153,12 +153,8 @@ module.service("$tgAuth", AuthService) # Directive that manages the visualization of public register # message/link on login page. -PublicRegisterMessageDirective = ($config, $navUrls) -> - template = _.template(""" -

- Not registered yet? - create your free account here -

""") +PublicRegisterMessageDirective = ($config, $navUrls, templates) -> + template = templates.get("auth/login-text.html", true) templateFn = -> publicRegisterEnabled = $config.get("publicRegisterEnabled") @@ -172,7 +168,7 @@ PublicRegisterMessageDirective = ($config, $navUrls) -> template: templateFn } -module.directive("tgPublicRegisterMessage", ["$tgConfig", "$tgNavUrls", PublicRegisterMessageDirective]) +module.directive("tgPublicRegisterMessage", ["$tgConfig", "$tgNavUrls", "$tgTemplate", PublicRegisterMessageDirective]) LoginDirective = ($auth, $confirm, $location, $config, $routeParams, $navUrls, $events) -> diff --git a/app/coffee/modules/backlog/filters.coffee b/app/coffee/modules/backlog/filters.coffee index d6445965..56199e3e 100644 --- a/app/coffee/modules/backlog/filters.coffee +++ b/app/coffee/modules/backlog/filters.coffee @@ -35,43 +35,9 @@ module = angular.module("taigaBacklog") ## Issues Filters Directive ############################################################################# -BacklogFiltersDirective = ($log, $location) -> - template = _.template(""" - <% _.each(filters, function(f) { %> - <% if (f.selected) { %> - - style="border-left: 3px solid <%- f.color %>;"<% } %>> - <%- f.name %> - - <%- f.count %> - - <% } else { %> - - style="border-left: 3px solid <%- f.color %>;"<% } %>> - <%- f.name %> - - <%- f.count %> - - <% } %> - <% }) %> - """) - - templateSelected = _.template(""" - <% _.each(filters, function(f) { %> - - style="border-left: 3px solid <%- f.color %>;"<% } %>> - <%- f.name %> - - - <% }) %> - """) - +BacklogFiltersDirective = ($log, $location, $templates) -> + template = $templates.get("backlog/filters.html", true) + templateSelected = $templates.get("backlog/filter-selected.html", true) link = ($scope, $el, $attrs) -> $ctrl = $el.closest(".wrapper").controller() @@ -100,10 +66,18 @@ BacklogFiltersDirective = ($log, $location) -> renderSelectedFilters() renderSelectedFilters = -> - html = templateSelected({filters:selectedFilters}) + _.map selectedFilters, (f) => + if f.color + f.style = "border-left: 3px solid #{f.color}" + + html = templateSelected({filters: selectedFilters}) $el.find(".filters-applied").html(html) renderFilters = (filters) -> + _.map filters, (f) => + if f.color + f.style = "border-left: 3px solid #{f.color}" + html = template({filters:filters}) $el.find(".filter-list").html(html) @@ -178,4 +152,4 @@ BacklogFiltersDirective = ($log, $location) -> return {link:link} -module.directive("tgBacklogFilters", ["$log", "$tgLocation", BacklogFiltersDirective]) +module.directive("tgBacklogFilters", ["$log", "$tgLocation", "$tgTemplate", BacklogFiltersDirective]) diff --git a/app/coffee/modules/backlog/main.coffee b/app/coffee/modules/backlog/main.coffee index 412c45ef..f6a0c353 100644 --- a/app/coffee/modules/backlog/main.coffee +++ b/app/coffee/modules/backlog/main.coffee @@ -686,19 +686,9 @@ module.directive("tgBacklog", ["$tgRepo", "$rootScope", BacklogDirective]) ## User story points directive ############################################################################# -UsRolePointsSelectorDirective = ($rootscope) -> +UsRolePointsSelectorDirective = ($rootscope, $template) -> #TODO: i18n - selectionTemplate = _.template(""" - - """) + selectionTemplate = $template.get("backlog/us-role-points-popover.html", true) link = ($scope, $el, $attrs) -> # Watchers @@ -747,39 +737,12 @@ UsRolePointsSelectorDirective = ($rootscope) -> return {link: link} -module.directive("tgUsRolePointsSelector", ["$rootScope", UsRolePointsSelectorDirective]) +module.directive("tgUsRolePointsSelector", ["$rootScope", "$tgTemplate", UsRolePointsSelectorDirective]) -UsPointsDirective = ($repo) -> - rolesTemplate = _.template(""" - - """) - - pointsTemplate = _.template(""" - - """) +UsPointsDirective = ($repo, $tgTemplate) -> + rolesTemplate = $tgTemplate.get("backlog/us-points-roles-popover.html", true) + pointsTemplate = $tgTemplate.get("backlog/us-points-popover.html", true) link = ($scope, $el, $attrs) -> $ctrl = $el.controller() @@ -940,7 +903,7 @@ UsPointsDirective = ($repo) -> return {link: link} -module.directive("tgBacklogUsPoints", ["$tgRepo", UsPointsDirective]) +module.directive("tgBacklogUsPoints", ["$tgRepo", "$tgTemplate", UsPointsDirective]) ############################################################################# ## Burndown graph directive @@ -1067,12 +1030,8 @@ module.directive("tgGmBacklogGraph", tgBacklogGraphDirective) ## Backlog progress bar directive ############################################################################# -TgBacklogProgressBarDirective = -> - template = _.template(""" -
-
-
- """) +TgBacklogProgressBarDirective = ($template) -> + template = $template.get("backlog/progress-bar.html", true) render = (el, projectPointsPercentaje, closedPointsPercentaje) -> el.html(template({ @@ -1109,4 +1068,4 @@ TgBacklogProgressBarDirective = -> return {link: link} -module.directive("tgBacklogProgressBar", TgBacklogProgressBarDirective) +module.directive("tgBacklogProgressBar", ["$tgTemplate", TgBacklogProgressBarDirective]) diff --git a/app/coffee/modules/backlog/sprints.coffee b/app/coffee/modules/backlog/sprints.coffee index acc40593..0c8c4479 100644 --- a/app/coffee/modules/backlog/sprints.coffee +++ b/app/coffee/modules/backlog/sprints.coffee @@ -84,36 +84,8 @@ module.directive("tgBacklogSprint", ["$tgRepo", "$rootScope", BacklogSprintDirec ## Sprint Header Directive ############################################################################# -BacklogSprintHeaderDirective = ($navUrls) -> - template = _.template(""" -
- - - <% if(isVisible){ %> - - <%- name %> - - <% } %> - - <% if(isEditable){ %> - - <% } %> -
- -
-
<%- estimatedDateRange %>
- -
- """) +BacklogSprintHeaderDirective = ($navUrls, $template) -> + template = $template.get("backlog/sprint-header.html", true) link = ($scope, $el, $attrs, $model) -> isEditable = -> @@ -157,7 +129,7 @@ BacklogSprintHeaderDirective = ($navUrls) -> require: "ngModel" } -module.directive("tgBacklogSprintHeader", ["$tgNavUrls", "$tgRepo", "$rootScope", BacklogSprintHeaderDirective]) +module.directive("tgBacklogSprintHeader", ["$tgNavUrls", "$tgTemplate", BacklogSprintHeaderDirective]) ############################################################################# ## Toggle Closed Sprints Directive diff --git a/app/coffee/modules/common.coffee b/app/coffee/modules/common.coffee index 06e01a56..bb11a405 100644 --- a/app/coffee/modules/common.coffee +++ b/app/coffee/modules/common.coffee @@ -187,3 +187,20 @@ Qqueue = ($q) -> return qqueue module.factory("$tgQqueue", ["$q", Qqueue]) + +############################################################################# +## Templates +############################################################################# + +Template = ($templateCache) -> + return { + get: (name, lodash = false) => + tmp = $templateCache.get(name) + + if lodash + tmp = _.template(tmp) + + return tmp + } + +module.factory("$tgTemplate", ["$templateCache", Template]) diff --git a/app/coffee/modules/common/attachments.coffee b/app/coffee/modules/common/attachments.coffee index 9fbe6504..15a0ec6a 100644 --- a/app/coffee/modules/common/attachments.coffee +++ b/app/coffee/modules/common/attachments.coffee @@ -155,53 +155,8 @@ class AttachmentsController extends taiga.Controller return not item.is_deprecated -AttachmentsDirective = ($config, $confirm) -> - template = _.template(""" -
-
-

- - attachments -

-
- <% if (maxFileSize){ %> - - <% }; %> - - -
-
- -
-
-
- -
-
- -
-
- -
-
- -
-
-
- - - + show deprecated atachments - - - ({{ctrl.deprecatedAttachmentsCount }} deprecated) - - -
-
""") +AttachmentsDirective = ($config, $confirm, $templates) -> + template = $templates.get("attachment/attachments.html", true) link = ($scope, $el, $attrs, $ctrls) -> $ctrl = $ctrls[0] @@ -283,56 +238,12 @@ AttachmentsDirective = ($config, $confirm) -> template: templateFn } -module.directive("tgAttachments", ["$tgConfig", "$tgConfirm", AttachmentsDirective]) +module.directive("tgAttachments", ["$tgConfig", "$tgConfirm", "$tgTemplate", AttachmentsDirective]) -AttachmentDirective = -> - template = _.template(""" -
- - - <%- name %> - -
-
- <%- size %> -
-
- <% if (isDeprecated){ %> (deprecated) <% } %> - <%- description %> -
- <% if (modifyPermission) {%> -
- - - -
- <% } %> - """) - - templateEdit = _.template(""" -
- - <%- name %> -
-
- <%- size %> -
-
- -
-
- checked<% } %> /> - -
-
- - -
- """) +AttachmentDirective = ($template) -> + template = $template.get("attachment/attachment.html", true) + templateEdit = $template.get("attachment/attachment-edit.html", true) link = ($scope, $el, $attrs, $ctrl) -> render = (attachment, edit=false) -> @@ -356,8 +267,10 @@ AttachmentDirective = -> html = template(ctx) $el.html(html) + if attachment.is_deprecated $el.addClass("deprecated") + $el.find("input:checkbox").prop('checked', true) saveAttachment = -> attachment.description = $el.find("input[name='description']").val() @@ -408,4 +321,4 @@ AttachmentDirective = -> restrict: "AE" } -module.directive("tgAttachment", AttachmentDirective) +module.directive("tgAttachment", ["$tgTemplate", AttachmentDirective]) diff --git a/app/coffee/modules/common/components.coffee b/app/coffee/modules/common/components.coffee index b439c2b0..9b5ea62e 100644 --- a/app/coffee/modules/common/components.coffee +++ b/app/coffee/modules/common/components.coffee @@ -107,7 +107,7 @@ module.directive("tgSprintProgressbar", SprintProgressBarDirective) ## Created-by display directive ############################################################################# -CreatedByDisplayDirective = -> +CreatedByDisplayDirective = ($template)-> # Display the owner information (full name and photo) and the date of # creation of an object (like USs, tasks and issues). # @@ -119,16 +119,7 @@ CreatedByDisplayDirective = -> # 'owner'(ng-model) # - scope.usersById object is required. - template = _.template(""" -
- <%- owner.full_name_display %> -
- -
- Created by <%- owner.full_name_display %> - <%- date %> -
- """) # TODO: i18n + template = $template.get("common/components/created-by.html", true) # TODO: i18n link = ($scope, $el, $attrs) -> render = (model) -> @@ -154,51 +145,19 @@ CreatedByDisplayDirective = -> require: "ngModel" } -module.directive("tgCreatedByDisplay", CreatedByDisplayDirective) +module.directive("tgCreatedByDisplay", ["$tgTemplate", CreatedByDisplayDirective]) ############################################################################# ## Watchers directive ############################################################################# -WatchersDirective = ($rootscope, $confirm, $repo, $qqueue) -> +WatchersDirective = ($rootscope, $confirm, $repo, $qqueue, $template) -> # You have to include a div with the tg-lb-watchers directive in the page # where use this directive # # TODO: i18n - template = _.template(""" - <% if(isEditable){ %> -
- watchers - -
- <% } else if(watchers.length > 0){ %> -
- watchers -
- <% }; %> - - <% _.each(watchers, function(watcher) { %> - <% if(watcher) { %> -
-
- - <%- watcher.full_name_display %> - -
-
- <%- watcher.full_name_display %> - - <% if(isEditable){ %> - - - <% }; %> -
-
- <% } %> - <% }); %> - """) + template = $template.get("common/components/watchers.html", true) link = ($scope, $el, $attrs, $model) -> isEditable = -> @@ -288,43 +247,19 @@ WatchersDirective = ($rootscope, $confirm, $repo, $qqueue) -> return {link:link, require:"ngModel"} -module.directive("tgWatchers", ["$rootScope", "$tgConfirm", "$tgRepo", "$tgQqueue", WatchersDirective]) +module.directive("tgWatchers", ["$rootScope", "$tgConfirm", "$tgRepo", "$tgQqueue", "$tgTemplate", WatchersDirective]) ############################################################################# ## Assigned to directive ############################################################################# -AssignedToDirective = ($rootscope, $confirm, $repo, $loading, $qqueue) -> +AssignedToDirective = ($rootscope, $confirm, $repo, $loading, $qqueue, $template) -> # You have to include a div with the tg-lb-assignedto directive in the page # where use this directive # # TODO: i18n - template = _.template(""" - <% if (assignedTo) { %> -
- <%- assignedTo.full_name_display %> -
- <% } %> - -
- Assigned to - - - - <% if (assignedTo) { %> - <%- assignedTo.full_name_display %> - <% } else { %> - Not assigned - <% } %> - - <% if(isEditable){ %><% }; %> - - <% if (assignedTo!==null && isEditable) { %> - - <% } %> -
- """) # TODO: i18n + template = $template.get("common/components/assigned-to.html", true) link = ($scope, $el, $attrs, $model) -> isEditable = -> @@ -391,18 +326,15 @@ AssignedToDirective = ($rootscope, $confirm, $repo, $loading, $qqueue) -> require:"ngModel" } -module.directive("tgAssignedTo", ["$rootScope", "$tgConfirm", "$tgRepo", "$tgLoading", "$tgQqueue", AssignedToDirective]) +module.directive("tgAssignedTo", ["$rootScope", "$tgConfirm", "$tgRepo", "$tgLoading", "$tgQqueue", "$tgTemplate", AssignedToDirective]) ############################################################################# ## Block Button directive ############################################################################# -BlockButtonDirective = ($rootscope, $loading) -> - template = """ - Block - Unblock - """ +BlockButtonDirective = ($rootscope, $loading, $template) -> + template = $template.get("common/components/block-button.html") link = ($scope, $el, $attrs, $model) -> isEditable = -> @@ -443,17 +375,15 @@ BlockButtonDirective = ($rootscope, $loading) -> template: template } -module.directive("tgBlockButton", ["$rootScope", "$tgLoading", BlockButtonDirective]) +module.directive("tgBlockButton", ["$rootScope", "$tgLoading", "$tgTemplate", BlockButtonDirective]) ############################################################################# ## Delete Button directive ############################################################################# -DeleteButtonDirective = ($log, $repo, $confirm, $location) -> - template = """ - Delete - """ #TODO: i18n +DeleteButtonDirective = ($log, $repo, $confirm, $location, $template) -> + template = $template.get("common/components/delete-button.html") link = ($scope, $el, $attrs, $model) -> if not $attrs.onDeleteGoToUrl @@ -485,26 +415,15 @@ DeleteButtonDirective = ($log, $repo, $confirm, $location) -> template: template } -module.directive("tgDeleteButton", ["$log", "$tgRepo", "$tgConfirm", "$tgLocation", DeleteButtonDirective]) +module.directive("tgDeleteButton", ["$log", "$tgRepo", "$tgConfirm", "$tgLocation", "$tgTemplate", DeleteButtonDirective]) ############################################################################# ## Editable subject directive ############################################################################# -EditableSubjectDirective = ($rootscope, $repo, $confirm, $loading, $qqueue) -> - template = """ -
- {{ item.subject }} - -
-
- - - - -
- """ +EditableSubjectDirective = ($rootscope, $repo, $confirm, $loading, $qqueue, $template) -> + template = $template.get("common/components/editable-subject.html") link = ($scope, $el, $attrs, $model) -> @@ -571,46 +490,17 @@ EditableSubjectDirective = ($rootscope, $repo, $confirm, $loading, $qqueue) -> template: template } -module.directive("tgEditableSubject", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", - EditableSubjectDirective]) +module.directive("tgEditableSubject", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", "$tgTemplate", EditableSubjectDirective]) ############################################################################# ## Editable subject directive ############################################################################# -EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading, $selectedText, $qqueue) -> - template = """ -
-
- -
-
- - - - Markdown syntax help - - - - -
- """ # TODO: i18n - noDescriptionMegEditMode = """ -

- Empty space is so boring... - go on be descriptive... - A rose by any other name would smell as sweet... -

- """ # TODO: i18n - noDescriptionMegReadMode = """ -

- No description yet. -

- """ # TODO: i18n +EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading, $selectedText, $qqueue, $template) -> + template = $template.get("common/components/editable-description.html") # TODO: i18n + noDescriptionMegEditMode = $template.get("common/components/editable-description-msg-edit-mode.html") # TODO: i18n + noDescriptionMegReadMode = $template.get("common/components/editable-description-msg-read-mode.html") # TODO: i18n link = ($scope, $el, $attrs, $model) -> $el.find('.edit-description').hide() @@ -678,7 +568,7 @@ EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading, } module.directive("tgEditableDescription", ["$rootScope", "$tgRepo", "$tgConfirm", - "$compile", "$tgLoading", "$selectedText", "$tgQqueue", EditableDescriptionDirective]) + "$compile", "$tgLoading", "$selectedText", "$tgQqueue", "$tgTemplate", EditableDescriptionDirective]) ############################################################################# @@ -715,13 +605,8 @@ ListItemUsStatusDirective = -> return {link:link} -ListItemAssignedtoDirective = -> - template = _.template(""" -
- <%- name %> -
<%- name %>
-
- """) +ListItemAssignedtoDirective = ($template) -> + template = $template.get("common/components/list-item-assigned-to-avatar.html", true) link = ($scope, $el, $attrs) -> bindOnce $scope, "membersById", (membersById) -> @@ -737,12 +622,9 @@ ListItemAssignedtoDirective = -> return {link:link} +module.directive("tgListitemAssignedto", ["$tgTemplate", ListItemAssignedtoDirective]) ListItemPriorityDirective = -> - template = """ -
- """ - link = ($scope, $el, $attrs) -> render = (priorityById, issue) -> priority = priorityById[issue.priority] @@ -759,15 +641,12 @@ ListItemPriorityDirective = -> return { link: link - template: template + templateUrl: "common/components/level.html" } +module.directive("tgListitemPriority", ListItemPriorityDirective) ListItemSeverityDirective = -> - template = """ -
- """ - link = ($scope, $el, $attrs) -> render = (severityById, issue) -> severity = severityById[issue.severity] @@ -784,15 +663,11 @@ ListItemSeverityDirective = -> return { link: link - template: template + templateUrl: "common/components/level.html" } ListItemTypeDirective = -> - template = """ -
- """ - link = ($scope, $el, $attrs) -> render = (issueTypeById, issue) -> type = issueTypeById[issue.type] @@ -809,7 +684,7 @@ ListItemTypeDirective = -> return { link: link - template: template + templateUrl: "common/components/level.html" } @@ -817,10 +692,8 @@ ListItemTypeDirective = -> ## Progress bar directive ############################################################################# -TgProgressBarDirective = -> - template = _.template(""" -
- """) +TgProgressBarDirective = ($template) -> + template = $template.get("common/components/progress-bar.html", true) render = (el, percentage) -> el.html(template({percentage: percentage})) @@ -838,16 +711,14 @@ TgProgressBarDirective = -> return {link: link} +module.directive("tgProgressBar", ["$tgTemplate", TgProgressBarDirective]) ############################################################################# ## Main title directive ############################################################################# -TgMainTitleDirective = -> - template = _.template(""" - <%- projectName %> - <%- sectionName %> - """) +TgMainTitleDirective = ($template) -> + template = $template.get("common/components/main-title.html", true) render = (el, projectName, sectionName) -> el.html(template({ @@ -867,13 +738,10 @@ TgMainTitleDirective = -> return {link: link} +module.directive("tgMainTitle", ["$tgTemplate", TgMainTitleDirective]) module.directive("tgListitemType", ListItemTypeDirective) module.directive("tgListitemIssueStatus", ListItemIssueStatusDirective) -module.directive("tgListitemAssignedto", ListItemAssignedtoDirective) -module.directive("tgListitemPriority", ListItemPriorityDirective) module.directive("tgListitemSeverity", ListItemSeverityDirective) module.directive("tgListitemTaskStatus", ListItemTaskStatusDirective) module.directive("tgListitemUsStatus", ListItemUsStatusDirective) -module.directive("tgProgressBar", TgProgressBarDirective) -module.directive("tgMainTitle", TgMainTitleDirective) diff --git a/app/coffee/modules/common/estimation.coffee b/app/coffee/modules/common/estimation.coffee index 6dcf4a9b..6965bd24 100644 --- a/app/coffee/modules/common/estimation.coffee +++ b/app/coffee/modules/common/estimation.coffee @@ -27,7 +27,7 @@ module = angular.module("taigaCommon") ## User story estimation directive (for Lightboxes) ############################################################################# -LbUsEstimationDirective = ($rootScope, $repo, $confirm) -> +LbUsEstimationDirective = ($rootScope, $repo, $confirm, $template) -> # Display the points of a US and you can edit it. # # Example: @@ -37,35 +37,8 @@ LbUsEstimationDirective = ($rootScope, $repo, $confirm) -> # - Us object (ng-model) # - scope.project object - mainTemplate = _.template(""" - - """) - - pointsTemplate = _.template(""" -
- """) + mainTemplate = $template.get("common/estimation/lb-us-estimation-points-per-role.html", true) + pointsTemplate = $template.get("common/estimation/lb-us-estimation-points.html", true) link = ($scope, $el, $attrs, $model) -> render = (points) -> @@ -158,14 +131,14 @@ LbUsEstimationDirective = ($rootScope, $repo, $confirm) -> require: "ngModel" } -module.directive("tgLbUsEstimation", ["$rootScope", "$tgRepo", "$tgConfirm", LbUsEstimationDirective]) +module.directive("tgLbUsEstimation", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgTemplate", LbUsEstimationDirective]) ############################################################################# ## User story estimation directive ############################################################################# -UsEstimationDirective = ($rootScope, $repo, $confirm, $qqueue) -> +UsEstimationDirective = ($rootScope, $repo, $confirm, $qqueue, $template) -> # Display the points of a US and you can edit it. # # Example: @@ -175,35 +148,8 @@ UsEstimationDirective = ($rootScope, $repo, $confirm, $qqueue) -> # - Us object (ng-model) # - scope.project object - mainTemplate = _.template(""" - - """) - - pointsTemplate = _.template(""" - - """) + mainTemplate = $template.get("common/estimation/us-estimation-points-per-role.html", true) + pointsTemplate = $template.get("common/estimation/us-estimation-points.html", true) link = ($scope, $el, $attrs, $model) -> isEditable = -> @@ -329,4 +275,4 @@ UsEstimationDirective = ($rootScope, $repo, $confirm, $qqueue) -> require: "ngModel" } -module.directive("tgUsEstimation", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgQqueue", UsEstimationDirective]) +module.directive("tgUsEstimation", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgQqueue", "$tgTemplate", UsEstimationDirective]) diff --git a/app/coffee/modules/common/history.coffee b/app/coffee/modules/common/history.coffee index 679b9d90..5e017226 100644 --- a/app/coffee/modules/common/history.coffee +++ b/app/coffee/modules/common/history.coffee @@ -61,191 +61,15 @@ class HistoryController extends taiga.Controller return @rs.history.undeleteComment(type, objectId, activityId).then => @.loadHistory(type, objectId) -HistoryDirective = ($log, $loading, $qqueue) -> - templateChangeDiff = _.template(""" -
-
- <%- name %> -
-
-

- <%= diff %> -

-
-
- """) - - templateChangePoints = _.template(""" - <% _.each(points, function(point, name) { %> -
-
- US points (<%- name.toLowerCase() %>) -
-
-

- from
- <%- point[0] %> -

-

- to
- <%- point[1] %> -

-
-
- <% }); %> - """) - - templateChangeGeneric = _.template(""" -
-
- <%- name %> -
-
-

- from
- <%- from %> -

-

- to
- <%- to %> -

-
-
- """) - templateChangeAttachment = _.template(""" -
-
- <%- name %> -
-
- <% _.each(diff, function(change) { %> -

- <%- change.name %> from
- <%- change.from %> -

-

- <%- change.name %> to
- <%- change.to %> -

- <% }) %> -
-
- """) - - templateDeletedComment = _.template(""" -
-
- Comment deleted by <%- deleteCommentUser %> on <%- deleteCommentDate %> - (Show deleted comment) - -
<%= deleteComment %>
-
- <% if (canRestoreComment) { %> - - - Restore comment - - <% } %> -
- """) - - templateActivity = _.template(""" -
-
- - <%- userFullName %> - -
-
-
- - <%- userFullName %> - - - <%- creationDate %> - -
- - <% if (comment.length > 0) { %> - <% if ((deleteCommentDate || deleteCommentUser)) { %> -
- Comment deleted by <%- deleteCommentUser %> on <%- deleteCommentDate %> -
- <% } %> -
- <%= comment %> -
- <% if (!deleteCommentDate && mode !== "activity" && canDeleteComment) { %> - - <% } %> - <% } %> - - <% if(changes.length > 0) { %> -
- <% if (mode != "activity") { %> - - <%- changesText %> - - - <% } %> - - <% _.each(changes, function(change) { %> - <%= change %> - <% }) %> -
- <% } %> -
-
- """) - - templateBaseEntries = _.template(""" - - <% if (showMore > 0) { %> - - + Show previous entries (<%- showMore %> more) - - <% } %> - <% _.each(entries, function(entry) { %> - <%= entry %> - <% }) %> - """) - - templateBase = _.template(""" -
- -
-
-
- - <% if (mode !== "edit") { %> - - - Markdown syntax help - - Comment - <% } %> -
-
- -
- """) +HistoryDirective = ($log, $loading, $qqueue, $template) -> + templateChangeDiff = $template.get("common/history/history-change-diff.html", true) + templateChangePoints = $template.get("common/history/history-change-points.html", true) + templateChangeGeneric = $template.get("common/history/history-change-generic.html", true) + templateChangeAttachment = $template.get("common/history/history-change-attachment.html", true) + templateDeletedComment = $template.get("common/history/history-deleted-comment.html", true) + templateActivity = $template.get("common/history/history-activity.html", true) + templateBaseEntries = $template.get("common/history/history-base-entries.html", true) + templateBase = $template.get("common/history/history-base.html", true) link = ($scope, $el, $attrs, $ctrl) -> # Bootstraping @@ -332,7 +156,8 @@ HistoryDirective = ($log, $loading, $qqueue) -> name: getHumanizedFieldName(name) from: formatChange(values[0]) to: formatChange(values[1]) - } + } + return templateChangeAttachment({name: name, diff: diff}) return _.flatten(attachments).join("\n") @@ -532,4 +357,4 @@ HistoryDirective = ($log, $loading, $qqueue) -> } -module.directive("tgHistory", ["$log", "$tgLoading", "$tgQqueue", HistoryDirective]) +module.directive("tgHistory", ["$log", "$tgLoading", "$tgQqueue", "$tgTemplate", HistoryDirective]) diff --git a/app/coffee/modules/common/lightboxes.coffee b/app/coffee/modules/common/lightboxes.coffee index 09f4dc5e..7352c902 100644 --- a/app/coffee/modules/common/lightboxes.coffee +++ b/app/coffee/modules/common/lightboxes.coffee @@ -201,7 +201,7 @@ BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loadi block(item) return { - templateUrl: "/partials/views/modules/lightbox-block.html" + templateUrl: "common/lightbox/lightbox-block.html" link: link require: "ngModel" } @@ -213,15 +213,8 @@ module.directive("tgLbBlock", ["$rootScope", "$tgRepo", "$tgConfirm", "lightboxS ## Generic Lightbox Blocking-Message Input Directive ############################################################################# -BlockingMessageInputDirective = ($log) -> - template = _.template(""" - - """) +BlockingMessageInputDirective = ($log, $template) -> + template = $template.get("common/lightbox/lightbox-blocking-message-input.html", true) link = ($scope, $el, $attrs, $model) -> if not $attrs.watch @@ -243,7 +236,7 @@ BlockingMessageInputDirective = ($log) -> restrict: "EA" } -module.directive("tgBlockingMessageInput", ["$log", BlockingMessageInputDirective]) +module.directive("tgBlockingMessageInput", ["$log", "$tgTemplate", BlockingMessageInputDirective]) ############################################################################# @@ -426,45 +419,11 @@ module.directive("tgLbCreateBulkUserstories", [ ## AssignedTo Lightbox Directive ############################################################################# -usersTemplate = _.template(""" -<% if (selected) { %> -
-
- - - -
- - <%-selected.full_name_display %> - - -
-<% } %> - -<% _.each(users, function(user) { %> -
-
- - - -
- - <%- user.full_name_display %> - -
-<% }) %> - -<% if (showMore) { %> -
- ...too many users, keep filtering -
-<% } %> -""") - -AssignedToLightboxDirective = (lightboxService, lightboxKeyboardNavigationService) -> +AssignedToLightboxDirective = (lightboxService, lightboxKeyboardNavigationService, $template) -> link = ($scope, $el, $attrs) -> selectedUser = null selectedItem = null + usersTemplate = $template.get("common/lightbox/lightbox-assigned-to-users.html", true) normalizeString = (string) -> normalizedString = string @@ -547,12 +506,12 @@ AssignedToLightboxDirective = (lightboxService, lightboxKeyboardNavigationServic $el.off() return { - templateUrl: "/partials/views/modules/lightbox-assigned-to.html" + templateUrl: "common/lightbox/lightbox-assigned-to.html" link:link } -module.directive("tgLbAssignedto", ["lightboxService", "lightboxKeyboardNavigationService", AssignedToLightboxDirective]) +module.directive("tgLbAssignedto", ["lightboxService", "lightboxKeyboardNavigationService", "$tgTemplate", AssignedToLightboxDirective]) ############################################################################# @@ -632,7 +591,7 @@ WatchersLightboxDirective = ($repo, lightboxService, lightboxKeyboardNavigationS $el.off() return { - templateUrl: "/partials/views/modules/lightbox-users.html" + templateUrl: "common/lightbox/lightbox-users.html" link:link } diff --git a/app/coffee/modules/common/popovers.coffee b/app/coffee/modules/common/popovers.coffee index 39e6a954..329b661e 100644 --- a/app/coffee/modules/common/popovers.coffee +++ b/app/coffee/modules/common/popovers.coffee @@ -29,7 +29,7 @@ module = angular.module("taigaCommon") ## UserStory status Directive (popover for change status) ############################################################################# -UsStatusDirective = ($repo, popoverService) -> +UsStatusDirective = ($repo, $template) -> ### Print the status of a US and a popover to change it. - tg-us-status: The user story @@ -42,16 +42,7 @@ UsStatusDirective = ($repo, popoverService) -> NOTE: This directive need 'usStatusById' and 'project'. ### - template = _.template(""" - """) + template = $template.get("common/popover/popover-us-status.html", true) link = ($scope, $el, $attrs) -> $ctrl = $el.controller() @@ -106,13 +97,13 @@ UsStatusDirective = ($repo, popoverService) -> return {link: link} -module.directive("tgUsStatus", ["$tgRepo", UsStatusDirective]) +module.directive("tgUsStatus", ["$tgRepo", "$tgTemplate", UsStatusDirective]) ############################################################################# ## Related Task Status Directive ############################################################################# -RelatedTaskStatusDirective = ($repo, popoverService) -> +RelatedTaskStatusDirective = ($repo, $template) -> ### Print the status of a related task and a popover to change it. - tg-related-task-status: The related task @@ -125,16 +116,7 @@ RelatedTaskStatusDirective = ($repo, popoverService) -> NOTE: This directive need 'taskStatusById' and 'project'. ### - selectionTemplate = _.template(""" - """) + selectionTemplate = $template.get("common/popover/popover-related-task-status.html", true) updateTaskStatus = ($el, task, taskStatusById) -> taskStatusDomParent = $el.find(".us-status") @@ -187,7 +169,7 @@ RelatedTaskStatusDirective = ($repo, popoverService) -> return {link: link} -module.directive("tgRelatedTaskStatus", ["$tgRepo", RelatedTaskStatusDirective]) +module.directive("tgRelatedTaskStatus", ["$tgRepo", "$tgTemplate", RelatedTaskStatusDirective]) ############################################################################# ## jQuery plugin for Popover diff --git a/app/coffee/modules/common/tags.coffee b/app/coffee/modules/common/tags.coffee index afcaee76..6ff2f700 100644 --- a/app/coffee/modules/common/tags.coffee +++ b/app/coffee/modules/common/tags.coffee @@ -99,25 +99,11 @@ module.directive("tgColorizeTags", ColorizeTagsDirective) ## TagLine Directive (for Lightboxes) ############################################################################# -LbTagLineDirective = ($rs) -> +LbTagLineDirective = ($rs, $template) -> ENTER_KEY = 13 COMMA_KEY = 188 - template = """ -
- - - """ # TODO: i18n - - # Tags template (rendered manually using lodash) - templateTags = _.template(""" - <% _.each(tags, function(tag) { %> - style="border-left: 5px solid <%- tag.color %>;"<% } %>> - <%- tag.name %> - - - <% }); %> - """) # TODO: i18n + templateTags = $template.get("common/tag/lb-tag-line-tags.html", true) link = ($scope, $el, $attrs, $model) -> ## Render @@ -125,6 +111,11 @@ LbTagLineDirective = ($rs) -> ctx = { tags: _.map(tags, (t) -> {name: t, color: tagsColors[t]}) } + + _.map ctx.tags, (tag) => + if tag.color + tag.style = "border-left: 5px solid #{tag.color}" + html = templateTags(ctx) $el.find("div.tags-container").html(html) @@ -226,42 +217,22 @@ LbTagLineDirective = ($rs) -> return { link:link, require:"ngModel" - template: template + templateUrl: "common/tag/lb-tag-line.html" } -module.directive("tgLbTagLine", ["$tgResources", LbTagLineDirective]) +module.directive("tgLbTagLine", ["$tgResources", "$tgTemplate", LbTagLineDirective]) ############################################################################# ## TagLine Directive (for detail pages) ############################################################################# -TagLineDirective = ($rootScope, $repo, $rs, $confirm, $qqueue) -> +TagLineDirective = ($rootScope, $repo, $rs, $confirm, $qqueue, $template) -> ENTER_KEY = 13 ESC_KEY = 27 COMMA_KEY = 188 - template = """ -
- - - - """ # TODO: i18n - - # Tags template (rendered manually using lodash) - templateTags = _.template(""" - <% _.each(tags, function(tag) { %> - - <%- tag.name %> - <% if (isEditable) { %> - - <% } %> - - <% }); %> - """) # TODO: i18n + templateTags = $template.get("common/tag/tags-line-tags.html", true) link = ($scope, $el, $attrs, $model) -> isEditable = -> @@ -430,7 +401,7 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm, $qqueue) -> return { link:link, require:"ngModel" - template: template + templateUrl: "common/tag/tag-line.html" } -module.directive("tgTagLine", ["$rootScope", "$tgRepo", "$tgResources", "$tgConfirm", "$tgQqueue", TagLineDirective]) +module.directive("tgTagLine", ["$rootScope", "$tgRepo", "$tgResources", "$tgConfirm", "$tgQqueue", "$tgTemplate", TagLineDirective]) diff --git a/app/coffee/modules/common/wisiwyg.coffee b/app/coffee/modules/common/wisiwyg.coffee index e1ceeae2..96ffcf77 100644 --- a/app/coffee/modules/common/wisiwyg.coffee +++ b/app/coffee/modules/common/wisiwyg.coffee @@ -28,17 +28,8 @@ module = angular.module("taigaCommon") ############################################################################# ## WYSIWYG markitup editor directive ############################################################################# -tgMarkitupDirective = ($rootscope, $rs, $tr, $selectedText) -> - previewTemplate = _.template(""" -
-
- -
-
- <%= data %> -
-
- """) +tgMarkitupDirective = ($rootscope, $rs, $tr, $selectedText, $template) -> + previewTemplate = $template.get("common/wysiwyg/wysiwyg-markitup-preview.html", true) link = ($scope, $el, $attrs, $model) -> element = angular.element($el) @@ -283,4 +274,4 @@ tgMarkitupDirective = ($rootscope, $rs, $tr, $selectedText) -> return {link:link, require:"ngModel"} -module.directive("tgMarkitup", ["$rootScope", "$tgResources", "$tgI18n", "$selectedText", tgMarkitupDirective]) +module.directive("tgMarkitup", ["$rootScope", "$tgResources", "$tgI18n", "$selectedText", "$tgTemplate", tgMarkitupDirective]) diff --git a/app/coffee/modules/issues/detail.coffee b/app/coffee/modules/issues/detail.coffee index b0590326..56ada2c9 100644 --- a/app/coffee/modules/issues/detail.coffee +++ b/app/coffee/modules/issues/detail.coffee @@ -142,7 +142,7 @@ module.controller("IssueDetailController", IssueDetailController) ## Issue status display directive ############################################################################# -IssueStatusDisplayDirective = -> +IssueStatusDisplayDirective = ($template)-> # Display if a Issue is open or closed and its issueboard status. # # Example: @@ -152,18 +152,7 @@ IssueStatusDisplayDirective = -> # - Issue object (ng-model) # - scope.statusById object - template = _.template(""" - - <% if (status.is_closed) { %> - Closed - <% } else { %> - Open - <% } %> - - - <%- status.name %> - - """) # TODO: i18n + template = $template.get("common/components/status-display.html", true) link = ($scope, $el, $attrs) -> render = (issue) -> @@ -184,14 +173,14 @@ IssueStatusDisplayDirective = -> require: "ngModel" } -module.directive("tgIssueStatusDisplay", IssueStatusDisplayDirective) +module.directive("tgIssueStatusDisplay", ["$tgTemplate", IssueStatusDisplayDirective]) ############################################################################# ## Issue status button directive ############################################################################# -IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) -> +IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $template) -> # Display the status of Issue and you can edit it. # # Example: @@ -202,21 +191,7 @@ IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) -> # - scope.statusById object # - $scope.project.my_permissions - template = _.template(""" -
- - <%- status.name %> - <% if(editable){ %><% }%> - status - - -
- """) #TODO: i18n + template = $template.get("issue/issues-status-button.html", true) link = ($scope, $el, $attrs, $model) -> isEditable = -> @@ -281,13 +256,13 @@ IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) -> require: "ngModel" } -module.directive("tgIssueStatusButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", IssueStatusButtonDirective]) +module.directive("tgIssueStatusButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", "$tgTemplate", IssueStatusButtonDirective]) ############################################################################# ## Issue type button directive ############################################################################# -IssueTypeButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) -> +IssueTypeButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $template) -> # Display the type of Issue and you can edit it. # # Example: @@ -298,21 +273,7 @@ IssueTypeButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) -> # - scope.typeById object # - $scope.project.my_permissions - template = _.template(""" -
- - <%- type.name %> - <% if(editable){ %><% }%> - type - - -
- """) #TODO: i18n + template = $template.get("issue/issue-type-button.html", true) link = ($scope, $el, $attrs, $model) -> isEditable = -> @@ -376,14 +337,14 @@ IssueTypeButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) -> require: "ngModel" } -module.directive("tgIssueTypeButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", IssueTypeButtonDirective]) +module.directive("tgIssueTypeButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", "$tgTemplate", IssueTypeButtonDirective]) ############################################################################# ## Issue severity button directive ############################################################################# -IssueSeverityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) -> +IssueSeverityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $template) -> # Display the severity of Issue and you can edit it. # # Example: @@ -394,21 +355,7 @@ IssueSeverityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) # - scope.severityById object # - $scope.project.my_permissions - template = _.template(""" -
- - <%- severity.name %> - <% if(editable){ %><% }%> - severity - - -
- """) #TODO: i18n + template = $template.get("issue/issue-severity-button.html", true) link = ($scope, $el, $attrs, $model) -> isEditable = -> @@ -473,14 +420,14 @@ IssueSeverityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) require: "ngModel" } -module.directive("tgIssueSeverityButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", IssueSeverityButtonDirective]) +module.directive("tgIssueSeverityButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", "$tgTemplate", IssueSeverityButtonDirective]) ############################################################################# ## Issue priority button directive ############################################################################# -IssuePriorityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) -> +IssuePriorityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $template) -> # Display the priority of Issue and you can edit it. # # Example: @@ -491,21 +438,7 @@ IssuePriorityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) # - scope.priorityById object # - $scope.project.my_permissions - template = _.template(""" -
- - <%- priority.name %> - <% if(editable){ %><% }%> - priority - - -
- """) #TODO: i18n + template = $template.get("issue/issue-priority-button.html", true) link = ($scope, $el, $attrs, $model) -> isEditable = -> @@ -570,7 +503,7 @@ IssuePriorityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue) require: "ngModel" } -module.directive("tgIssuePriorityButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", IssuePriorityButtonDirective]) +module.directive("tgIssuePriorityButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", "$tgTemplate", IssuePriorityButtonDirective]) ############################################################################# @@ -578,12 +511,6 @@ module.directive("tgIssuePriorityButton", ["$rootScope", "$tgRepo", "$tgConfirm" ############################################################################# PromoteIssueToUsButtonDirective = ($rootScope, $repo, $confirm, $qqueue) -> - template = _.template(""" - - Promote to User Story - - """) # TODO: i18n - link = ($scope, $el, $attrs, $model) -> save = $qqueue.bindAdd (issue, finish) => @@ -627,7 +554,7 @@ PromoteIssueToUsButtonDirective = ($rootScope, $repo, $confirm, $qqueue) -> return { restrict: "AE" require: "ngModel" - template: template + templateUrl: "issue/promote-issue-to-us-button.html" link: link } diff --git a/app/coffee/modules/issues/list.coffee b/app/coffee/modules/issues/list.coffee index 1b186bf4..273c3e74 100644 --- a/app/coffee/modules/issues/list.coffee +++ b/app/coffee/modules/issues/list.coffee @@ -307,41 +307,9 @@ module.controller("IssuesController", IssuesController) ## Issues Directive ############################################################################# -paginatorTemplate = """ - -""" - -IssuesDirective = ($log, $location) -> +IssuesDirective = ($log, $location, $template) -> ## Issues Pagination - template = _.template(paginatorTemplate) + template = $template.get("issue/issue-paginator.html", true) linkPagination = ($scope, $el, $attrs, $ctrl) -> # Constants @@ -456,51 +424,16 @@ IssuesDirective = ($log, $location) -> return {link:link} -module.directive("tgIssues", ["$log", "$tgLocation", IssuesDirective]) +module.directive("tgIssues", ["$log", "$tgLocation", "$tgTemplate", IssuesDirective]) ############################################################################# ## Issues Filters Directive ############################################################################# -IssuesFiltersDirective = ($log, $location, $rs, $confirm, $loading) -> - template = _.template(""" - <% _.each(filters, function(f) { %> - <% if (!f.selected) { %> - - style="border-left: 3px solid <%- f.color %>;"<% } %>> - <%- f.name %> - - <% if (f.count){ %> - <%- f.count %> - <% } %> - <% if (f.type == "myFilters"){ %> - - <% } %> - - <% } %> - <% }) %> - - - - """) - - templateSelected = _.template(""" - <% _.each(filters, function(f) { %> - - style="border-left: 3px solid <%- f.color %>;"<% } %>> - <%- f.name %> - - - - <% }) %> - """) - +IssuesFiltersDirective = ($log, $location, $rs, $confirm, $loading, $template) -> + template = $template.get("issue/issues-filters.html", true) + templateSelected = $template.get("issue/issues-filters-selected.html", true) link = ($scope, $el, $attrs) -> $ctrl = $el.closest(".wrapper").controller() @@ -527,14 +460,23 @@ IssuesFiltersDirective = ($log, $location, $rs, $confirm, $loading) -> renderSelectedFilters(selectedFilters) renderSelectedFilters = (selectedFilters) -> + _.filter selectedFilters, (f) => + if f.color + f.style = "border-left: 3px solid #{f.color}" + html = templateSelected({filters:selectedFilters}) $el.find(".filters-applied").html(html) + if selectedFilters.length > 0 $el.find(".save-filters").show() else $el.find(".save-filters").hide() renderFilters = (filters) -> + _.filter filters, (f) => + if f.color + f.style = "border-left: 3px solid #{f.color}" + html = template({filters:filters}) $el.find(".filter-list").html(html) @@ -700,7 +642,7 @@ IssuesFiltersDirective = ($log, $location, $rs, $confirm, $loading) -> return {link:link} -module.directive("tgIssuesFilters", ["$log", "$tgLocation", "$tgResources", "$tgConfirm", "$tgLoading", +module.directive("tgIssuesFilters", ["$log", "$tgLocation", "$tgResources", "$tgConfirm", "$tgLoading", "$tgTemplate", IssuesFiltersDirective]) @@ -708,7 +650,7 @@ module.directive("tgIssuesFilters", ["$log", "$tgLocation", "$tgResources", "$tg ## Issue status Directive (popover for change status) ############################################################################# -IssueStatusInlineEditionDirective = ($repo, popoverService) -> +IssueStatusInlineEditionDirective = ($repo, $template) -> ### Print the status of an Issue and a popover to change it. - tg-issue-status-inline-edition: The issue @@ -720,16 +662,7 @@ IssueStatusInlineEditionDirective = ($repo, popoverService) -> NOTE: This directive need 'issueStatusById' and 'project'. ### - selectionTemplate = _.template(""" - """) + selectionTemplate = $template.get("issue/issue-status-inline-edition-selection.html", true) updateIssueStatus = ($el, issue, issueStatusById) -> issueStatusDomParent = $el.find(".issue-status") @@ -779,7 +712,7 @@ IssueStatusInlineEditionDirective = ($repo, popoverService) -> return {link: link} -module.directive("tgIssueStatusInlineEdition", ["$tgRepo", IssueStatusInlineEditionDirective]) +module.directive("tgIssueStatusInlineEdition", ["$tgRepo", "$tgTemplate", IssueStatusInlineEditionDirective]) ############################################################################# diff --git a/app/coffee/modules/kanban/main.coffee b/app/coffee/modules/kanban/main.coffee index f687b002..d82a8065 100644 --- a/app/coffee/modules/kanban/main.coffee +++ b/app/coffee/modules/kanban/main.coffee @@ -445,7 +445,7 @@ KanbanUserstoryDirective = ($rootscope) -> $el.off() return { - templateUrl: "/partials/views/components/kanban-task.html" + templateUrl: "kanban/kanban-task.html" link: link require: "ngModel" } diff --git a/app/coffee/modules/nav.coffee b/app/coffee/modules/nav.coffee index ad8c19c3..29740c50 100644 --- a/app/coffee/modules/nav.coffee +++ b/app/coffee/modules/nav.coffee @@ -71,42 +71,9 @@ class ProjectsNavigationController extends taiga.Controller module.controller("ProjectsNavigationController", ProjectsNavigationController) -ProjectsNavigationDirective = ($rootscope, animationFrame, $timeout, tgLoader, $location, $compile) -> - baseTemplate = _.template(""" -

Your projects

-
-
- - -
-
- -
- - Create project - -
- -
- -
- -
- -
- """) # TODO: i18n - - projectsTemplate = _.template(""" - <% _.each(projects, function(project) { %> -
  • - - <%- project.name %> - - -
  • - <% }) %> - """) # TODO: i18n +ProjectsNavigationDirective = ($rootscope, animationFrame, $timeout, tgLoader, $location, $compile, $template) -> + baseTemplate = $template.get("project/project-navigation-base.html", true) + projectsTemplate = $template.get("project/project-navigation-list.html", true) overlay = $(".projects-nav-overlay") loadingStart = 0 @@ -201,93 +168,15 @@ ProjectsNavigationDirective = ($rootscope, animationFrame, $timeout, tgLoader, $ } -module.directive("tgProjectsNav", ["$rootScope", "animationFrame", "$timeout", "tgLoader", "$tgLocation", "$compile", ProjectsNavigationDirective]) +module.directive("tgProjectsNav", ["$rootScope", "animationFrame", "$timeout", "tgLoader", "$tgLocation", "$compile", "$tgTemplate", ProjectsNavigationDirective]) ############################################################################# ## Project ############################################################################# -ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $navUrls, $config) -> - menuEntriesTemplate = _.template(""" - - """) +ProjectMenuDirective = ($log, $compile, $auth, $rootscope, $tgAuth, $location, $navUrls, $config, $template) -> + menuEntriesTemplate = $template.get("project/project-menu.html", true) mainTemplate = _.template("""