Resolve all endpoint

This commit is contained in:
Phil Hughes 2016-07-05 17:27:07 +01:00 committed by Douwe Maan
parent 50e0728cc9
commit a55c1232b5
6 changed files with 19 additions and 15 deletions

View File

@ -2,6 +2,8 @@
data: ->
comments: CommentsStore.state
loading: false
props:
endpoint: String
computed:
resolved: ->
resolvedCount = 0
@ -19,9 +21,8 @@
ids = CommentsStore.getAllForState(this.allResolved)
this.$set('loading', true)
promise = if this.allResolved then ResolveService.resolveAll(ids) else ResolveService.resolveAll(ids)
promise
ResolveService
.resolveAll(this.endpoint, ids, !this.allResolved)
.done =>
CommentsStore.updateAll(!this.allResolved)
.always =>

View File

@ -5,15 +5,10 @@
resolved: resolve
type: 'post'
url: endpoint
resolveAll: (ids) ->
resolveAll: (endpoint, ids, resolve) ->
$.ajax
data:
id: ids
type: 'get'
url: '/'
unResolveAll: (ids) ->
$.ajax
data:
id: ids
type: 'get'
url: '/'
resolve: resolve
type: 'post'
url: endpoint

View File

@ -71,6 +71,11 @@ class Projects::NotesController < Projects::ApplicationController
render nothing: true, status: 200
end
def resolve_all
sleep 2
render nothing: true, status: 200
end
private
def note

View File

@ -46,7 +46,7 @@
- if current_user
#resolve-all-app{ "v-cloak" => true }
%resolve-all{ "inline-template" => true }
%resolve-all{ ":endpoint" => "'#{resolve_all_namespace_project_notes_path(@project.namespace, @project)}'", "inline-template" => true }
.line-resolve-all{ "v-show" => "commentsCount > 0" }
%button.btn.btn-gray{ type: "button", "aria-label" => "Resolve all", "@click" => "updateAll", ":disabled" => "loading" }
= icon("spinner spin", "v-show" => "loading")
@ -54,7 +54,7 @@
%span.line-resolve-text
{{ resolved }}/{{ commentsCount }} comments resolved
- if @commits.nonzero?
- if @commits_count.nonzero?
%ul.merge-request-tabs.nav-links.no-top.no-bottom
%li.notes-tab
= link_to namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: {target: 'div#notes', action: 'notes', toggle: 'tab'} do

View File

@ -825,6 +825,10 @@ Rails.application.routes.draw do
resources :group_links, only: [:index, :create, :destroy], constraints: { id: /\d+/ }
resources :notes, only: [:index, :create, :destroy, :update], constraints: { id: /\d+/ } do
collection do
post :resolve_all
end
member do
post :toggle_award_emoji
delete :delete_attachment

File diff suppressed because one or more lines are too long