Skip to content

Commit aafe5bc

Browse files
author
Renato Marinho
authored
Merge pull request #273 from Te7a-Houdini/feature-createIssue-ajax
Feature - Button to keep add issues
2 parents 4b26b8c + c83b212 commit aafe5bc

File tree

7 files changed

+119
-19
lines changed

7 files changed

+119
-19
lines changed

app/Http/Controllers/Web/IssueController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use GitScrum\Models\ConfigStatus;
1818
use Carbon\Carbon;
1919
use Auth;
20+
use GitScrum\Http\Responses\Issue\Store as IssueStoreResponse;
2021

2122
class IssueController extends Controller
2223
{
@@ -76,10 +77,9 @@ public function create($scope, $slug, $parent_id = null)
7677

7778
public function store(IssueRequest $request)
7879
{
79-
$response = resolve('IssueService')->create($request);
80+
$issue = resolve('IssueService')->create($request);
8081

81-
return redirect()->route('issues.show', ['slug' => $response->slug])
82-
->with('success', trans('gitscrum.congratulations-the-issue-has-been-created-with-successfully'));
82+
return (new IssueStoreResponse())->response($request,$issue);
8383
}
8484

8585
public function show($slug)

app/Http/Responses/Issue/Store.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace GitScrum\Http\Responses\Issue;
4+
5+
use GitScrum\Classes\Helper;
6+
7+
class Store
8+
{
9+
public function response($request,$issue)
10+
{
11+
return $request->ajax() ? $this->toAjax($request,$issue) : $this->toHtml($issue);
12+
}
13+
14+
private function toHtml($issue)
15+
{
16+
return redirect()->route('issues.show', ['slug' => $issue->slug])
17+
->with('success', trans('gitscrum.congratulations-the-issue-has-been-created-with-successfully'));
18+
19+
}
20+
21+
private function toAjax($request,$issue)
22+
{
23+
$relation = $request->input('user_story_id') ? 'userStory' : 'sprint';
24+
25+
$data = $this->data($relation,$issue->{$relation});
26+
27+
return response()->json(['data' => $data , 'message' => trans('gitscrum.congratulations-the-issue-has-been-created-with-successfully') ]);
28+
}
29+
30+
private function data($relation,$relationModel)
31+
{
32+
$data = [
33+
'issueStatusChart' => view('partials.boxes.chart-donut', ['list' => $relationModel->issueStatus()])->render(),
34+
'issuesCount' => $relationModel->issues->count(),
35+
'issuesBox' => view('partials.boxes.issue', ['list' => $relationModel->issues, 'messageEmpty' => trans('gitscrum.this-does-not-have-any-issue-yet')])->render()
36+
];
37+
38+
return $relation == 'sprint' ? array_merge($data,$this->sprintData($relationModel)) : $data ;
39+
}
40+
41+
private function sprintData($sprint)
42+
{
43+
return [
44+
'issueTypes' => view('partials.boxes.issue-type', ['list' => $sprint->issueTypes()])->render(),
45+
'issueBurndownChart' => view('partials.boxes.burndown', ['title' => ('Burndown Chart'), 'list' => Helper::burndown($sprint)])->render()
46+
];
47+
}
48+
49+
50+
}

resources/lang/ar/gitscrum.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* The MIT License (MIT)
77
* Copyright (c) 2017 Renato Marinho <renato.marinho@s2move.com>
88
*/
9-
return array (
9+
10+
return array (
1011
'sprints' => 'السبرنتز',
1112
'issue-type' => 'نوع المسئله',
1213
'search-issue-type-by-name...' => 'ابحث عن نوع المسئله بالأسم ...',
@@ -187,4 +188,5 @@
187188
'congratulations-the-product-backlog-has-been-updated-with-successfully' => 'تهانينا ! لقد تم تعديل مهام المشروع بنجاح',
188189
'favorited-successfully' => 'تم الاضافة الى المفضلة بنجاح',
189190
'unfavorited-successfully' => 'تم الحذف من المفضلة بنجاح',
191+
'keep-adding' => 'أستمر بالإضافه'
190192
);

resources/lang/en/gitscrum.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
'congratulations-the-product-backlog-has-been-updated-with-successfully' => 'Congratulations! The Product Backlog has been successfully updated',
188188
'favorited-successfully' => 'Favorited',
189189
'unfavorited-successfully' => 'Unfavorited',
190+
'keep-adding' => 'Keep Adding'
190191
'private-sprint' => 'This sprint is private, only owner can access it',
191192
'save' => 'Save',
192193
'issue-status-updated' => '@:username updated the issue to: *:status*',

resources/views/partials/forms/issue.blade.php

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<form action="{{route($route, ['slug'=>@$issue->slug])}}" method="post" class="form-horizontal">
1+
<form id="storeIssueForm" action="{{route($route, ['slug'=>@$issue->slug])}}" method="post" class="form-horizontal">
22
{{ csrf_field() }}
33
<input type="hidden" name="product_backlog_id" value="{{$obj->productBacklog->id or $issue->productBacklog->id}}">
44

@@ -86,18 +86,65 @@
8686
</div>
8787
<div class="hr-line-dashed"></div>
8888
<div class="form-group">
89-
<label class="col-sm-3 control-label">{{trans('gitscrum.planning-pocker')}}</label>
90-
<div class="col-sm-9">
89+
<label class="col-sm-2">{{trans('gitscrum.planning-pocker')}}</label>
90+
<div class="col-sm-3">
9191
<div class="i-checks"><input type="checkbox" value="" checked=""> <i></i></div>
9292
<span class="help-block m-b-none">{{trans('gitscrum.collaborative-estimation')}}</span>
9393
</div>
94+
<div class="col-sm-3"></div>
95+
<label class="col-sm-2">{{trans('gitscrum.keep-adding')}}</label>
96+
<div class="col-sm-2">
97+
<div class="i-checks"><input id="keepAddingIssue" type="checkbox" value="" checked=""> <i></i></div>
98+
</div>
9499
</div>
95100
<div class="hr-line-dashed"></div>
101+
<div id="issueModalMessage" style="display: none;" class="alert alert-success">
102+
103+
</div>
96104
@include('partials.includes.form-btn-submit', ['action' => @$action])
97105
</form>
98106

99107
<script>
100108
$(function(){
101-
$('[data-provide="markdown"]').markdown({autofocus:false,savable:false})
102-
})
109+
$('[data-provide="markdown"]').markdown({autofocus:false,savable:false});
110+
111+
$( "#storeIssueForm" ).on('submit',function( event ) {
112+
113+
if (!$('#keepAddingIssue').is(':checked'))
114+
{
115+
$(this).submit();
116+
}
117+
118+
event.preventDefault();
119+
120+
$.ajax({
121+
'url' : $(this).attr('action'),
122+
'method' : 'POST',
123+
'data' : $(this).serialize(),
124+
'success' : function (response) {
125+
126+
for(classSelector in response.data)
127+
{
128+
$('.'+classSelector).html(response.data[classSelector]);
129+
}
130+
131+
$('#storeIssueForm').find("input[type=text], textarea").val("");
132+
133+
$('#issueModalMessage').show().text('').attr('class','alert alert-success').text(response.message);
134+
},
135+
'error' : function(response){
136+
137+
errorMessages = [];
138+
139+
for (errorKey in response.responseJSON)
140+
{
141+
errorMessages.push(response.responseJSON[errorKey]);
142+
}
143+
144+
$('#issueModalMessage').show().text('').attr('class','alert alert-danger').text(errorMessages.join(' , '));
145+
}
146+
});
147+
148+
});
149+
});
103150
</script>

resources/views/sprints/show.blade.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class="btn btn-lg btn-block btn-warning"><strong>{{trans('gitscrum.sprint-planni
6262
class="btn btn-block btn-primary"
6363
data-toggle="modal" data-target="#modalLarge"><strong>{{trans('gitscrum.create-issue')}}</strong></a>
6464

65-
@include('partials.boxes.chart-donut', ['list' => $sprint->issueStatus()])
65+
<div class="issueStatusChart">@include('partials.boxes.chart-donut', ['list' => $sprint->issueStatus()])</div>
6666

6767
<div class="">
6868
@include('partials.boxes.progress-bar', [ 'percentage' => Helper::percentage($sprint, 'issues')])
@@ -80,14 +80,14 @@ class="btn btn-block btn-primary"
8080
</tr>
8181
<tr>
8282
<td width="50%">
83-
<h6>{{$sprint->issues->count()}} {{trans('gitscrum.issues')}}</h6>
83+
<h6><div class="issuesCount">{{$sprint->issues->count()}}</div> {{trans('gitscrum.issues')}}</h6>
8484
</td>
8585
<td width="50%"></td>
8686
</tr>
8787
</tbody>
8888
</table>
8989

90-
@include('partials.boxes.issue-type', ['list' => $sprint->issueTypes()])
90+
<div class="issueTypes">@include('partials.boxes.issue-type', ['list' => $sprint->issueTypes()])</div>
9191

9292
@include('partials.boxes.note', [ 'list' => $sprint,
9393
'type'=> 'sprints', 'title' => trans('gitscrum.definition-of-done-checklist'),
@@ -124,7 +124,7 @@ class="btn btn-block btn-primary"
124124
</p>
125125
@endif
126126

127-
@include('partials.boxes.burndown', ['title' => ('Burndown Chart'), 'list' => Helper::burndown($sprint)])
127+
<div class="issueBurndownChart">@include('partials.boxes.burndown', ['title' => ('Burndown Chart'), 'list' => Helper::burndown($sprint)])</div>
128128

129129
<div class="clearfix"></div>
130130

@@ -133,7 +133,7 @@ class="btn btn-block btn-primary"
133133
<ul class="nav nav-tabs">
134134
<li class="active"><a data-toggle="tab" href="#tab-issues">
135135
<i class="fa fa-list-alt" aria-hidden="true"></i>
136-
{{trans('gitscrum.issues')}} ({{$sprint->issues->count()}})</a></li>
136+
{{trans('gitscrum.issues')}} (<div class="issuesCount">{{$sprint->issues->count()}}</div>)</a></li>
137137
<li class=""><a data-toggle="tab" href="#tab-comments">
138138
<i class="fa fa-comments" aria-hidden="true"></i>
139139
{{trans('gitscrum.comments')}} ({{$sprint->comments->count()}})</a></li>
@@ -146,7 +146,7 @@ class="btn btn-block btn-primary"
146146
<div id="tab-issues" class="tab-pane active">
147147
<div class="panel-body">
148148
@include('partials.boxes.search-min')
149-
@include('partials.boxes.issue', ['list' => $sprint->issues, 'messageEmpty' => trans('gitscrum.this-does-not-have-any-issue-yet')])
149+
<div class="issuesBox">@include('partials.boxes.issue', ['list' => $sprint->issues, 'messageEmpty' => trans('gitscrum.this-does-not-have-any-issue-yet')])</div>
150150
</div>
151151
</div>
152152
<div id="tab-comments" class="tab-pane">

resources/views/user_stories/show.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class="btn btn-block btn-primary"
4848
{{trans('gitscrum.create-issue')}}</a>
4949
</div>
5050

51-
<div class="">
51+
<div class="issueStatusChart">
5252
@include('partials.boxes.chart-donut', ['list'=>$userStory->issueStatus()])
5353
</div>
5454

@@ -95,7 +95,7 @@ class="btn btn-block btn-primary"
9595

9696
<ul class="nav nav-tabs">
9797
<li class="active"><a data-toggle="tab" href="#tab-issues"> {{trans('gitscrum.issues')}}
98-
({{$userStory->issues->count()}}) </a></li>
98+
(<div class="issuesCount">{{$userStory->issues->count()}}</div>) </a></li>
9999
<li class=""><a data-toggle="tab" href="#tab-comments"> {{trans('gitscrum.comments')}}
100100
({{$userStory->comments->count()}}) </a></li>
101101
<li class=""><a data-toggle="tab" href="#tab-activities"> {{trans('gitscrum.activities')}} </a></li>
@@ -104,8 +104,8 @@ class="btn btn-block btn-primary"
104104
<div class="tab-content">
105105
<div id="tab-issues" class="tab-pane active">
106106
<div class="panel-body">
107-
@include('partials.boxes.issue', ['list' => $userStory->issues, 'messageEmpty' => trans('gitscrum
108-
.gitscrum.this-does-not-have-any-issue-yet')])
107+
<div class="issuesBox">@include('partials.boxes.issue', ['list' => $userStory->issues, 'messageEmpty' => trans('gitscrum
108+
.gitscrum.this-does-not-have-any-issue-yet')])</div>
109109
</div>
110110
</div>
111111
<div id="tab-comments" class="tab-pane">

0 commit comments

Comments
 (0)