From 3e5ab894a650f35609b142028ce3e460853238bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Juli=C3=A1n?= Date: Mon, 1 Aug 2016 13:37:53 +0200 Subject: [PATCH] Create Assigned to component --- .../assigned-to-selector.directive.coffee | 40 +++++++++++++++++++ .../assigned-to-selector.jade | 4 ++ .../assigned-to/assigned-to.controller.coffee | 37 +++++++++++++++++ .../assigned-to/assigned-to.directive.coffee | 35 ++++++++++++++++ .../components/assigned-to/assigned-to.jade | 13 ++++++ .../epics/create-epic/create-epic.jade | 2 + .../epic-row/epic-row.controller.coffee | 1 - .../epics/dashboard/epic-row/epic-row.jade | 20 ++-------- .../epics-dashboard.controller.coffee | 6 +-- .../epics/dashboard/epics-dashboard.jade | 1 + .../epics-table/epics-table.directive.coffee | 5 ++- .../dashboard/epics-table/epics-table.jade | 2 +- 12 files changed, 143 insertions(+), 23 deletions(-) create mode 100644 app/modules/components/assigned-to/assigned-to-selector/assigned-to-selector.directive.coffee create mode 100644 app/modules/components/assigned-to/assigned-to-selector/assigned-to-selector.jade create mode 100644 app/modules/components/assigned-to/assigned-to.controller.coffee create mode 100644 app/modules/components/assigned-to/assigned-to.directive.coffee create mode 100644 app/modules/components/assigned-to/assigned-to.jade diff --git a/app/modules/components/assigned-to/assigned-to-selector/assigned-to-selector.directive.coffee b/app/modules/components/assigned-to/assigned-to-selector/assigned-to-selector.directive.coffee new file mode 100644 index 00000000..b13be4d0 --- /dev/null +++ b/app/modules/components/assigned-to/assigned-to-selector/assigned-to-selector.directive.coffee @@ -0,0 +1,40 @@ +### +# Copyright (C) 2014-2016 Taiga Agile LLC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# File: assigned-to-selector.directive.coffee +### + +AssignedToSelectorDirective = () -> + + link = (scope, el, attrs) -> + console.log scope.assigned.toJS() + console.log scope.project.toJS() + + return { + # controller: "AssignedToSelectorCtrl", + # controllerAs: "vm", + # bindToController: true, + templateUrl: "components/assigned-to/assigned-to-selector/assigned-to-selector.html", + scope: { + assigned: "=", + project: "=" + }, + link: link + } + +AssignedToSelectorDirective.$inject = [] + +angular.module("taigaComponents").directive("tgAssignedToSelector", AssignedToSelectorDirective) diff --git a/app/modules/components/assigned-to/assigned-to-selector/assigned-to-selector.jade b/app/modules/components/assigned-to/assigned-to-selector/assigned-to-selector.jade new file mode 100644 index 00000000..29de6158 --- /dev/null +++ b/app/modules/components/assigned-to/assigned-to-selector/assigned-to-selector.jade @@ -0,0 +1,4 @@ +tg-lightbox-close + +.assigned-to-container + h2.title(translate="COMMON.ASSIGNED_TO.TITLE_ACTION_EDIT_ASSIGNMENT") diff --git a/app/modules/components/assigned-to/assigned-to.controller.coffee b/app/modules/components/assigned-to/assigned-to.controller.coffee new file mode 100644 index 00000000..d7b76bc4 --- /dev/null +++ b/app/modules/components/assigned-to/assigned-to.controller.coffee @@ -0,0 +1,37 @@ +### +# Copyright (C) 2014-2015 Taiga Agile LLC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# File: attchment.controller.coffee +### + +class AssignedToController + @.$inject = [ + "tgLightboxFactory" + ] + + constructor: (@lightboxFactory) -> + + onSelectAssignedTo: (assigned, project) -> + @lightboxFactory.create('tg-assigned-to-selector', { + "class": "lightbox lightbox-assigned-to-selector open" + "assigned": "assigned" + "project": "project" + }, { + "assigned": assigned + "project": project + }) + +angular.module('taigaComponents').controller('AssignedToCtrl', AssignedToController) diff --git a/app/modules/components/assigned-to/assigned-to.directive.coffee b/app/modules/components/assigned-to/assigned-to.directive.coffee new file mode 100644 index 00000000..bc596b3c --- /dev/null +++ b/app/modules/components/assigned-to/assigned-to.directive.coffee @@ -0,0 +1,35 @@ +### +# Copyright (C) 2014-2016 Taiga Agile LLC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# File: assigned-to.directive.coffee +### + +AssignedToDirective = () -> + + return { + controller: "AssignedToCtrl", + controllerAs: "vm", + bindToController: true, + templateUrl: "components/assigned-to/assigned-to.html", + scope: { + assignedTo: "=" + project: "=" + } + } + +AssignedToDirective.$inject = [] + +angular.module("taigaComponents").directive("tgAssignedToComponent", AssignedToDirective) diff --git a/app/modules/components/assigned-to/assigned-to.jade b/app/modules/components/assigned-to/assigned-to.jade new file mode 100644 index 00000000..e1570c69 --- /dev/null +++ b/app/modules/components/assigned-to/assigned-to.jade @@ -0,0 +1,13 @@ +img.assigned-to( + ng-if="vm.assignedTo" + tg-avatar="vm.assignedTo" + alt="{{vm.assignedTo.get('full_name_display')}}" + title="{{vm.assignedTo.get('full_name_display')}}" + ng-click="vm.onSelectAssignedTo(vm.assignedTo, vm.project)" +) +img.assigned-to( + ng-if="!vm.assignedTo" + src="/#{v}/images/unnamed.png" + alt="{{EPICS.DASHBOARD.UNASSIGNED | translate}}" + ng-click="vm.onSelectAssignedTo(vm.assignedTo, vm.project)" +) diff --git a/app/modules/epics/create-epic/create-epic.jade b/app/modules/epics/create-epic/create-epic.jade index 44367e04..c7ccf9c2 100644 --- a/app/modules/epics/create-epic/create-epic.jade +++ b/app/modules/epics/create-epic/create-epic.jade @@ -6,6 +6,8 @@ tg-lightbox-close ng-submit="vm.createEpic()" ) fieldset + // TODO ADD COLOR SELECTOR + //- tg-color-selector(on-select-dropdown-color="vm.newEpic.color = color") input( type="text" name="subject" diff --git a/app/modules/epics/dashboard/epic-row/epic-row.controller.coffee b/app/modules/epics/dashboard/epic-row/epic-row.controller.coffee index d840e567..ffe2898a 100644 --- a/app/modules/epics/dashboard/epic-row/epic-row.controller.coffee +++ b/app/modules/epics/dashboard/epic-row/epic-row.controller.coffee @@ -54,7 +54,6 @@ class EpicRowController @.onUpdateEpicStatus() onError = (data) => - console.log data @confirm.notify('error') return @rs.epics.patch(id, patch).then(onSuccess, onError) diff --git a/app/modules/epics/dashboard/epic-row/epic-row.jade b/app/modules/epics/dashboard/epic-row/epic-row.jade index c7c9d94a..627579ce 100644 --- a/app/modules/epics/dashboard/epic-row/epic-row.jade +++ b/app/modules/epics/dashboard/epic-row/epic-row.jade @@ -31,22 +31,10 @@ .sprint( ng-if="vm.column.sprint" ) - .assigned( - ng-if="vm.column.assigned && vm.epic.get('assigned_to')" - ng-click="vm.onSelectAssignedTo()" - ) - img( - tg-avatar="vm.epic.get('assigned_to_extra_info')" - alt="{{::vm.epic.getIn(['assigned_to_extra_info', 'full_name_display'])}}" - ) - .assigned( - ng-if="vm.column.assigned && !vm.epic.get('assigned_to')" - ng-class="{'is-unassigned': !vm.epic.get('assigned_to')}" - ng-click="vm.onSelectAssignedTo()" - ) - img( - src="/#{v}/images/unnamed.png" - alt="{{EPICS.DASHBOARD.UNASSIGNED | translate}}" + .assigned + tg-assigned-to-component( + assigned-to="vm.epic.get('assigned_to_extra_info')" + project="vm.project" ) .status( ng-if="vm.column.status && !vm.permissions.canEdit" diff --git a/app/modules/epics/dashboard/epics-dashboard.controller.coffee b/app/modules/epics/dashboard/epics-dashboard.controller.coffee index 1c9d8b6e..39c94575 100644 --- a/app/modules/epics/dashboard/epics-dashboard.controller.coffee +++ b/app/modules/epics/dashboard/epics-dashboard.controller.coffee @@ -40,9 +40,9 @@ class EpicsDashboardController if not project.is_epics_activated @errorHandlingService.permissionDenied() @.project = project - @._loadEpics() + @.loadEpics() - _loadEpics: () -> + loadEpics: () -> projectId = @.project.id return @resources.epics.list(projectId).then (epics) => @.epics = epics @@ -50,7 +50,7 @@ class EpicsDashboardController _onCreateEpic: () -> @lightboxService.closeAll() @confirm.notify("success") - @._loadEpics() + @.loadEpics() onCreateEpic: () -> @lightboxFactory.create('tg-create-epic', { diff --git a/app/modules/epics/dashboard/epics-dashboard.jade b/app/modules/epics/dashboard/epics-dashboard.jade index c2f22f05..3657a406 100644 --- a/app/modules/epics/dashboard/epics-dashboard.jade +++ b/app/modules/epics/dashboard/epics-dashboard.jade @@ -18,6 +18,7 @@ ng-if="vm.project && vm.epics.size" project="vm.project" epics="vm.epics" + on-update-epic-status="vm.loadEpics()" ) section.empty-epics(ng-if="!vm.epics.size") diff --git a/app/modules/epics/dashboard/epics-table/epics-table.directive.coffee b/app/modules/epics/dashboard/epics-table/epics-table.directive.coffee index bc4793cb..e6b273d3 100644 --- a/app/modules/epics/dashboard/epics-table/epics-table.directive.coffee +++ b/app/modules/epics/dashboard/epics-table/epics-table.directive.coffee @@ -27,8 +27,9 @@ EpicsTableDirective = () -> controllerAs: "vm", bindToController: true, scope: { - epics: "=" - project: "=" + epics: "=", + project: "=", + onUpdateEpicStatus: "&" } } diff --git a/app/modules/epics/dashboard/epics-table/epics-table.jade b/app/modules/epics/dashboard/epics-table/epics-table.jade index ef17423b..8dec9f2d 100644 --- a/app/modules/epics/dashboard/epics-table/epics-table.jade +++ b/app/modules/epics/dashboard/epics-table/epics-table.jade @@ -94,6 +94,6 @@ mixin epicSwitch(name, model) epic="epic" project="vm.project" column="vm.column" - on-update-epic-status="vm.loadEpics()" + on-update-epic-status="vm.onUpdateEpicStatus()" permissions="vm.permissions" )