From 2661cc249e91c506a62f935ffb7c96403e997eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Barrag=C3=A1n=20Merino?= Date: Tue, 16 Sep 2014 12:58:11 +0200 Subject: [PATCH] Fix bug #1001 - Not list all attachments when a wiki page is created --- app/coffee/modules/common/attachments.coffee | 12 +++++++----- app/coffee/modules/resources/attachments.coffee | 4 ++-- app/partials/wiki-edit.jade | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/coffee/modules/common/attachments.coffee b/app/coffee/modules/common/attachments.coffee index 7a259bbb..8f36b9fb 100644 --- a/app/coffee/modules/common/attachments.coffee +++ b/app/coffee/modules/common/attachments.coffee @@ -33,6 +33,7 @@ class AttachmentsController extends taiga.Controller _.bindAll(@) @.type = null @.objectId = null + @.projectId = null @.uploadingAttachments = [] @.attachments = [] @@ -43,12 +44,14 @@ class AttachmentsController extends taiga.Controller initialize: (type, objectId) -> @.type = type @.objectId = objectId + @.projectId = @scope.projectId loadAttachments: -> - urlname = "attachments/#{@.type}" - id = @.objectId + return @.attachments if not @.objectId - return @rs.attachments.list(urlname, id).then (attachments) => + urlname = "attachments/#{@.type}" + + return @rs.attachments.list(urlname, @.objectId, @.projectId).then (attachments) => @.attachments = _.sortBy(attachments, "order") @.updateCounters() return attachments @@ -58,10 +61,9 @@ class AttachmentsController extends taiga.Controller @.deprecatedAttachmentsCount = _.filter(@.attachments, {is_deprecated: true}).length _createAttachment: (attachment) -> - projectId = @scope.projectId urlName = "attachments/#{@.type}" - promise = @rs.attachments.create(urlName, projectId, @.objectId, attachment) + promise = @rs.attachments.create(urlName, @.projectId, @.objectId, attachment) promise = promise.then (data) => data.isCreatedRightNow = true diff --git a/app/coffee/modules/resources/attachments.coffee b/app/coffee/modules/resources/attachments.coffee index 7ebc59ec..f56e82fd 100644 --- a/app/coffee/modules/resources/attachments.coffee +++ b/app/coffee/modules/resources/attachments.coffee @@ -27,8 +27,8 @@ sizeFormat = @.taiga.sizeFormat resourceProvider = ($rootScope, $urls, $model, $repo, $auth, $q) -> service = {} - service.list = (urlName, objectId) -> - params = {object_id: objectId} + service.list = (urlName, objectId, projectId) -> + params = {object_id: objectId, project: projectId} return $repo.queryMany(urlName, params) service.create = (urlName, projectId, objectId, file) -> diff --git a/app/partials/wiki-edit.jade b/app/partials/wiki-edit.jade index d714784f..2d1b04f6 100644 --- a/app/partials/wiki-edit.jade +++ b/app/partials/wiki-edit.jade @@ -21,4 +21,4 @@ block content section.wysiwyg textarea(placeholder="Write a your wiki page", ng-model="wiki.content", tg-markitup) - tg-attachments(ng-model="wiki", type="wiki_page") + tg-attachments(ng-model="wiki", type="wiki_page", ng-if="wiki.id")