Skip to content
This repository was archived by the owner on May 10, 2022. It is now read-only.

Commit 00a4f22

Browse files
committed
hiding save report format button when showing existing report
1 parent 29bbb2b commit 00a4f22

File tree

6 files changed

+29
-12
lines changed

6 files changed

+29
-12
lines changed

Modules/ReportGenerator/Http/Controllers/ReportFormatController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public function update(Request $request)
134134

135135
$report_format->title = $request->title;
136136
$report_format->description = $request->description;
137+
$report_format->system_feature_id = $request->system_feature_id;
137138
$report_format->save();
138139

139140
if(!$report_format){ // If for some reason system feature isn't created, fire error message

Modules/ReportGenerator/Http/Controllers/ReportGeneratorController.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,20 @@ public function getComponents(Request $request)
6262

6363
$option_ids = serialize($option_ids);
6464
return response()->json([
65-
'redirecturl' => $protocol_host.'/reportgenerator/report/'.$option_ids,
65+
'option_ids' => $option_ids,
6666
'success' => 'Received Option IDs',
67-
'option_ids' => $option_ids
67+
'redirecturl' => $protocol_host.'/reportgenerator/report/'.$option_ids
6868
]);
6969
}
7070

7171
/**
7272
* Use option_ids from getComponents() above,
7373
* get data and show the generated report.
7474
* @param Array $option_ids : selected draggable_components
75+
* @param Boolean $hide: hide or show 'Save report format' button
7576
* @return Response $data : holds retrieved data
7677
*/
77-
public function showReport($option_ids)
78+
public function showReport($option_ids, $hide = False)
7879
{
7980
$option_ids = unserialize($option_ids);
8081
$notes = []; // store the notes for each dragged component.
@@ -99,14 +100,15 @@ public function showReport($option_ids)
99100
}
100101

101102
// These are used in menu and the select field in the form to add new report format
102-
$system_features = SystemFeature::all();
103103
$report_formats = ReportFormat::all();
104+
$system_features = SystemFeature::all();
104105

105106
return view('reportgenerator::report')->with([
106107
'data' => $data,
108+
'hide' => $hide,
107109
'column_names' => $column_names,
108-
'system_features' => $system_features,
109110
'report_formats' => $report_formats,
111+
'system_features' => $system_features,
110112
'option_ids' => serialize($option_ids)
111113
]);
112114
}
@@ -121,13 +123,13 @@ public function view($report_format_id)
121123
$draggable_components = ReportFormat::find($report_format_id)->draggable_components()->get();
122124

123125
$option_ids = [];
124-
foreach ($draggable_components as $draggable_component) {
126+
foreach ($draggable_components as $draggable_component) { // Get the option_ids of each $draggable_component
125127
$option_ids[] = $draggable_component->option_id;
126128
}
127129

128-
$option_ids = serialize($option_ids);
130+
$option_ids = serialize($option_ids); // serialize option_ids in preparation for showReport method
129131

130-
return ReportGeneratorController::showReport($option_ids); // call showReport method above
132+
return ReportGeneratorController::showReport($option_ids, True); // call showReport method above
131133

132134
}
133135

Modules/ReportGenerator/Resources/views/layouts/master.blade.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{ $system_feature->name }}</a>
4444
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
4545
@foreach($system_feature->report_formats as $report_format)
46-
<a class="dropdown-item" href="#">{{ $report_format->title }}</a>
46+
<a class="dropdown-item" href="{{ url('/reportgenerator/report_format/view/'.$report_format->id) }}">{{ $report_format->title }}</a>
4747
@endforeach
4848
</div>
4949
</li>
@@ -191,6 +191,14 @@
191191
{{ method_field('PATCH') }}
192192
<input type="hidden" name="_token" id="csrf-token" value="{{ Session::token() }}" />
193193
<div class="form-group"><input type="hidden" name="id" id="id"></div>
194+
<div class="form-group">
195+
<label for="system_feature_name">Select system feature</label>
196+
<select class="form-control" name="system_feature_id" id="system_feature_id">
197+
@foreach($system_features as $system_feature)
198+
<option value="{{ $system_feature->id }}">{{ $system_feature->name }}</option>
199+
@endforeach
200+
</select>
201+
</div>
194202
<div class="form-group">
195203
<label for="title">Title</label>
196204
<input type="text" name="title" class="form-control" id="title" placeholder="Enter title">
@@ -206,7 +214,7 @@
206214
</div>
207215
</div>
208216
</div>
209-
</div><!-- /#edit-system-feature -->
217+
</div><!-- /#edit-report-format -->
210218

211219
<!-- Delete report format modal-->
212220
<div class="modal fade" id="delete-report-format" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">

Modules/ReportGenerator/Resources/views/report.blade.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
</button>
1313
<div class="collapse navbar-collapse" id="navbarSupportedButtons">
1414
<ul class="navbar-nav mr-auto" style="margin-left: 500px !important">
15-
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#add-report-format">Save report as</button>&nbsp;
15+
@if(!$hide)
16+
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#add-report-format">Save report as</button>&nbsp;
17+
@endif
1618
<button type="button" class="btn btn-info" onclick="printReport('report_div')">Print</button>&nbsp;
1719
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#add-system-feature">PDF</button>&nbsp;
1820
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#add-system-feature">TXT</button>&nbsp;

Modules/ReportGenerator/Resources/views/report_formats.blade.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<th scope="col">#</th>
1111
<th scope="col">Title</th>
1212
<th scope="col">Description</th>
13+
<th scope="col">System Feature</th>
1314
<th scope="col">Actions</th>
1415
</tr>
1516
</thead>
@@ -19,9 +20,11 @@
1920
<th scope="row">{{ $report_format->id }}</th>
2021
<td>{{ $report_format->title }}</td>
2122
<td>{{ $report_format->description }}</td>
23+
<td>{{ $report_format->system_feature->name }}</td>
24+
2225
<td>
2326
<a class="btn btn-success btn-sm" href="{{ url('/reportgenerator/report_format/view/'.$report_format->id) }}" role="button"> View</a>
24-
<a class="btn btn-primary btn-sm" href="#" role="button" data-toggle="modal" data-target="#edit-report-format" data-id="{{ $report_format->id }}" data-title="{{ $report_format->title }}" data-description="{{ $report_format->description }}"> Edit</a>
27+
<a class="btn btn-primary btn-sm" href="#" role="button" data-toggle="modal" data-target="#edit-report-format" data-id="{{ $report_format->id }}" data-system-feature-name= "{{ $report_format->system_feature->name }}" data-title="{{ $report_format->title }}" data-description="{{ $report_format->description }}"> Edit</a>
2528
<a class="btn btn-danger btn-sm" href="#" role="button" data-toggle="modal" data-target="#delete-report-format" data-id="{{ $report_format->id }}" data-title="{{ $report_format->title }}"> Delete</a>
2629
</td>
2730
</tr>

public/assets/js/master.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ $(document).ready(function() {
128128
$('#edit-report-format').on('show.bs.modal', function(e){
129129
$('#edit-report-format #title').val($(e.relatedTarget).data('title'));
130130
$('#edit-report-format #description').val($(e.relatedTarget).data('description'));
131+
$('#edit-report-format #system_feature_id').select($(e.relatedTarget).data('system_feature_id'));
131132
$('#edit-report-format-form').submit(function(){
132133
var id = $('#edit-report-format #id').val($(e.relatedTarget).data('id'));
133134
$("#edit-report-format-form").attr("action", "report_format/" + id);

0 commit comments

Comments
 (0)