Merge pull request #1370 from taigaio/add-us-to-epics-improvement

Add userstories to epics performance improvement
stable
Alejandro 2017-09-19 13:52:46 +02:00 committed by GitHub
commit 94c9a00052
7 changed files with 31 additions and 22 deletions

View File

@ -1122,6 +1122,7 @@
"CHOOSE_PROJECT_FROM": "What's the project?", "CHOOSE_PROJECT_FROM": "What's the project?",
"CHOOSE_USERSTORY": "What's the user story?", "CHOOSE_USERSTORY": "What's the user story?",
"NO_USERSTORIES": "This project has no User Stories yet. Please select another project.", "NO_USERSTORIES": "This project has no User Stories yet. Please select another project.",
"NO_USERSTORIES_FOUND": "It looks like nothing was found with your search criteria",
"FILTER_USERSTORIES": "Filter user stories", "FILTER_USERSTORIES": "Filter user stories",
"LIGHTBOX_TITLE_BLOKING_EPIC": "Blocking epic", "LIGHTBOX_TITLE_BLOKING_EPIC": "Blocking epic",
"ACTION_DELETE": "Delete epic" "ACTION_DELETE": "Delete epic"

View File

@ -28,17 +28,19 @@ class RelatedUserstoriesCreateController
] ]
constructor: (@currentUserService, @rs, @confirm, @analytics) -> constructor: (@currentUserService, @rs, @confirm, @analytics) ->
@.projects = @currentUserService.projects.get("all") @.projects = null
@.projectUserstories = Immutable.List() @.projectUserstories = Immutable.List()
@.loading = false @.loading = false
selectProject: (selectedProjectId, onSelectedProject) -> loadProjects: () ->
@rs.userstories.listAllInProject(selectedProjectId).then (data) => if @.projects == null
@.projects = @currentUserService.projects.get("all")
filterUss: (selectedProjectId, filterText) ->
@rs.userstories.listInAllProjects({project: selectedProjectId, q: filterText}, true).then (data) =>
excludeIds = @.epicUserstories.map((us) -> us.get('id')) excludeIds = @.epicUserstories.map((us) -> us.get('id'))
filteredData = data.filter((us) -> excludeIds.indexOf(us.get('id')) == -1) filteredData = data.filter((us) -> excludeIds.indexOf(us.get('id')) == -1)
@.projectUserstories = filteredData @.projectUserstories = filteredData
if onSelectedProject
onSelectedProject()
saveRelatedUserStory: (selectedUserstoryId, onSavedRelatedUserstory) -> saveRelatedUserStory: (selectedUserstoryId, onSavedRelatedUserstory) ->
# This method assumes the following methods are binded to the controller: # This method assumes the following methods are binded to the controller:

View File

@ -90,7 +90,6 @@ describe "RelatedUserstoriesCreate", ->
} }
]) ])
onSelectedProjectCallback = sinon.stub()
userstories = Immutable.fromJS([ userstories = Immutable.fromJS([
{ {
id: 11 id: 11
@ -108,7 +107,7 @@ describe "RelatedUserstoriesCreate", ->
]) ])
promise = mocks.tgResources.userstories.listAllInProject.withArgs(1).promise().resolve(userstories) promise = mocks.tgResources.userstories.listAllInProject.withArgs(1).promise().resolve(userstories)
RelatedUserstoriesCreateCtrl.selectProject(1, onSelectedProjectCallback).then () -> RelatedUserstoriesCreateCtrl.filterUss(1, "").then () ->
expect(RelatedUserstoriesCreateCtrl.projectUserstories.toJS()).to.eql(filteredUserstories.toJS()) expect(RelatedUserstoriesCreateCtrl.projectUserstories.toJS()).to.eql(filteredUserstories.toJS())
done() done()

View File

@ -18,6 +18,7 @@
### ###
module = angular.module('taigaEpics') module = angular.module('taigaEpics')
debounceLeading = @.taiga.debounceLeading
RelatedUserstoriesCreateDirective = (@lightboxService) -> RelatedUserstoriesCreateDirective = (@lightboxService) ->
link = (scope, el, attrs, ctrl) -> link = (scope, el, attrs, ctrl) ->
@ -37,6 +38,7 @@ RelatedUserstoriesCreateDirective = (@lightboxService) ->
existingUserstoryForm.setErrors(errors) existingUserstoryForm.setErrors(errors)
scope.showLightbox = (selectedProjectId) -> scope.showLightbox = (selectedProjectId) ->
ctrl.loadProjects()
scope.selectProject(selectedProjectId).then () => scope.selectProject(selectedProjectId).then () =>
lightboxService.open(el.find(".lightbox-create-related-user-stories")) lightboxService.open(el.find(".lightbox-create-related-user-stories"))
@ -53,10 +55,11 @@ RelatedUserstoriesCreateDirective = (@lightboxService) ->
scope.selectProject = (selectedProjectId) -> scope.selectProject = (selectedProjectId) ->
scope.selectedUserstory = null scope.selectedUserstory = null
scope.searchUserstory = "" scope.searchUserstory = ""
ctrl.selectProject(selectedProjectId) ctrl.filterUss(selectedProjectId, scope.searchUserstory)
scope.onUpdateSearchUserstory = () -> scope.onUpdateSearchUserstory = debounceLeading 300, () ->
scope.selectedUserstory = null scope.selectedUserstory = null
ctrl.filterUss(scope.selectedProject, scope.searchUserstory)
return { return {
link: link, link: link,

View File

@ -110,13 +110,8 @@ a.add-button.e2e-add-userstory-button(
translate="COMMON.SAVE" translate="COMMON.SAVE"
ng-show="relatedWithSelector=='new-user-story'" ng-show="relatedWithSelector=='new-user-story'"
) )
p(
ng-show="relatedWithSelector=='existing-user-story' && !vm.projectUserstories.size"
translate="EPIC.NO_USERSTORIES"
)
fieldset.existing-user-story(ng-show="relatedWithSelector=='existing-user-story' && vm.projectUserstories.size") fieldset.existing-user-story(ng-show="relatedWithSelector=='existing-user-story'")
label( label(
translate="EPIC.CHOOSE_USERSTORY" translate="EPIC.CHOOSE_USERSTORY"
for="userstory-filter" for="userstory-filter"
@ -129,7 +124,7 @@ a.add-button.e2e-add-userstory-button(
ng-change="onUpdateSearchUserstory()" ng-change="onUpdateSearchUserstory()"
) )
form.existing-user-story-form form.existing-user-story-form(ng-show="relatedWithSelector=='existing-user-story' && vm.projectUserstories.size")
select.userstory.e2e-userstories-select( select.userstory.e2e-userstories-select(
size="5" size="5"
ng-model="selectedUserstory" ng-model="selectedUserstory"
@ -140,10 +135,15 @@ a.add-button.e2e-add-userstory-button(
value="" value=""
) )
option( option(
ng-repeat="us in vm.projectUserstories | toMutable | byRef:searchUserstory track by us.id" ng-repeat="us in vm.projectUserstories | toMutable track by us.id"
value="{{ ::us.id }}" value="{{ ::us.id }}"
) #{hash}{{::us.ref}} {{::us.subject}} ) #{hash}{{::us.ref}} {{::us.subject}}
p.no-stories-found(
ng-show="relatedWithSelector=='existing-user-story' && !vm.projectUserstories.size"
translate="EPIC.NO_USERSTORIES_FOUND"
)
button.button-green.e2e-select-related-userstory-button( button.button-green.e2e-select-related-userstory-button(
href="" href=""
ng-click="vm.saveRelatedUserStory(selectedUserstory, closeLightbox)" ng-click="vm.saveRelatedUserStory(selectedUserstory, closeLightbox)"

View File

@ -51,6 +51,9 @@
.new-user-story-form { .new-user-story-form {
margin-bottom: 1rem; margin-bottom: 1rem;
} }
.no-stories-found {
padding: 1rem 0 0 0;
}
.new-user-story-options { .new-user-story-options {
display: flex; display: flex;
margin-left: auto; margin-left: auto;

View File

@ -20,14 +20,15 @@
Resource = (urlsService, http) -> Resource = (urlsService, http) ->
service = {} service = {}
service.listInAllProjects = (params) -> service.listInAllProjects = (params, pagination=false) ->
url = urlsService.resolve("userstories") url = urlsService.resolve("userstories")
httpOptions = { if !pagination
headers: { httpOptions = {
"x-disable-pagination": "1" headers: {
"x-disable-pagination": "1"
}
} }
}
return http.get(url, params, httpOptions) return http.get(url, params, httpOptions)
.then (result) -> .then (result) ->