-
Notifications
You must be signed in to change notification settings - Fork 7
Approve all / select all #157
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,16 +79,50 @@ public function add(Request $request) | |
|
||
public function push(Request $request) | ||
{ | ||
|
||
$validatedData = $request->validate([ | ||
'id' => 'required|exists:entries', | ||
'id' => 'required|array', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is better:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it better? Genuinely asking. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because, reasons. On a more serious note, the current validation is only checking if the value passed is an array. We can force that by using |
||
]); | ||
try { | ||
$entry = Entry::findOrFail($validatedData['id']); | ||
$entry->push(); | ||
return redirect('/panel/entries/list')->with('status', 'Entrada Validada Manualmente!'); | ||
} catch (Exception $e) { | ||
return redirect('/panel/entries/list')->with('status', 'Erro ao validar entrada!'); | ||
|
||
foreach(request()->get('id') as $id){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the injected request (i.e. |
||
try { | ||
$entry = Entry::findOrFail($id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move this logic to an |
||
$entry->update(['used' => 1]); | ||
|
||
$fuel_station = $entry->fuelStation(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't use |
||
$fuel_station->update(['has_gasoline' => $entry->has_gasoline,'has_diesel' => $entry->has_diesel, 'has_lpg' => $entry->has_lpg]); | ||
} catch (Exception $e) { | ||
return redirect('/panel/entries/list')->with('status', 'Erro ao validar entrada!'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Show the invalid id in the error message, when redirecting. Otherwise the user has no idea what entry failed. |
||
} | ||
} | ||
|
||
$cacheController = new CacheController(); | ||
$cacheController->updateStations(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, refactor this. Controllers shouldn't be used this way. The logic in the |
||
|
||
return redirect('/panel/entries/list')->with('status', 'Entrada Validada Manualmente!'); | ||
} | ||
|
||
public function delete(Request $request) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A |
||
{ | ||
$validatedData = $request->validate([ | ||
'id' => 'required|array', | ||
]); | ||
|
||
foreach(request()->get('id') as $id){ | ||
try { | ||
\Log::info("deleting ".json_encode($id)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comments above, also apply in this method. |
||
$entry = Entry::findOrFail($id); | ||
$entry->update(['used' => 1]); | ||
|
||
} catch (Exception $e) { | ||
return redirect('/panel/entries/list')->with('status', 'Erro ao validar entrada!'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you're making use of translations here, for consistency and better organisation, do the same when passing the status message on redirect. |
||
} | ||
} | ||
|
||
$cacheController = new CacheController(); | ||
$cacheController->updateStations(); | ||
|
||
return redirect('/panel/entries/list')->with('status', 'Entrada Validada Manualmente!'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This route has a name set ( You probably want to add a name to go along with the |
||
} | ||
|
||
public function fetch_pending() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,13 +59,13 @@ function submitEntry(obj, id) { | |
let gasoline = Number(!($(".mapboxgl-popup-content").find('.gasoline img').hasClass('no-gas'))); | ||
let diesel = Number(!($(".mapboxgl-popup-content").find('.diesel img').hasClass('no-gas'))); | ||
let lpg = Number(!($(".mapboxgl-popup-content").find('.lpg img').hasClass('no-gas'))); | ||
validateCaptcha((token) => { | ||
// validateCaptcha((token) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commented code should be removed. |
||
let data = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we leaving IE users (among others) out on purpose? |
||
"fuel_station": id, | ||
"gasoline": gasoline, | ||
"diesel": diesel, | ||
"lpg": lpg, | ||
"captcha": token | ||
// "captcha": token | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commented code should be removed. |
||
} | ||
$(obj).parent().parent().find('.popup_submit_text').html("VALIDADO"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This approach is very dangerous. It is too bounded to markup. If a new layer is added/removed it will break. |
||
setTimeout(function() { | ||
|
@@ -75,7 +75,7 @@ function submitEntry(obj, id) { | |
$.post("/panel/entries/add", data, function (reply) { | ||
console.log("Entrada adicionada: " + reply.success + " (0 -> falha, 1 -> sucesso)"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, "json"); | ||
}); | ||
// }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
} | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This blank line can be removed.