Skip to content
This repository has been archived by the owner on Apr 3, 2021. It is now read-only.

Approve all / select all #157

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Approve all / select all #157

wants to merge 2 commits into from

Conversation

tomahock
Copy link
Collaborator

#96

Copy link
Member

@miguelantoniosantos miguelantoniosantos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Google ReCaptcha was disabled.
Can you implement a way to only select the visibles ones on datatables?

I think it is the following code:

datatable.rows({search: 'applied'});

@fbsoares
Copy link

Added "Deleted All" to checked entries. Also fixed a small bug on input array.
It was all ok on checking only the visible ones (tested with search query by keyword)

Copy link
Member

@quetzyg quetzyg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments.

@@ -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) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented code should be removed.

@@ -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)");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.log() calls should be removed. If you want to debug while developing, use the debugger construct, instead. And don't forget to remove it, once the code is ready for merging.

let data = {
"fuel_station": id,
"gasoline": gasoline,
"diesel": diesel,
"lpg": lpg,
"captcha": token
// "captcha": token
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented code should be removed.

@@ -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)");
}, "json");
});
// });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

$cacheController = new CacheController();
$cacheController->updateStations();

return redirect('/panel/entries/list')->with('status', 'Entrada Validada Manualmente!');
Copy link
Member

@quetzyg quetzyg Aug 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This route has a name set (entries.list). It's good practice to use those, instead of passing the URI.

You probably want to add a name to go along with the panel prefix in the routes, so the route name gets set to: panel.entries.list

@@ -79,16 +79,50 @@ public function add(Request $request)

public function push(Request $request)
{

Copy link
Member

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.

$fuel_station = $entry->fuelStation();
$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!');
Copy link
Member

Choose a reason for hiding this comment

The 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();
Copy link
Member

Choose a reason for hiding this comment

The 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 updateStations() method should be moved to a service class, which can then be called from the CacheController and other controllers, but not this way.


foreach(request()->get('id') as $id){
try {
$entry = Entry::findOrFail($id);
Copy link
Member

@quetzyg quetzyg Aug 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this logic to an EntryService, EntryRepository or whatever class name you want to use, then inject said class into this controller method and run the update() method from here.


foreach(request()->get('id') as $id){
try {
\Log::info("deleting ".json_encode($id));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments above, also apply in this method.

@@ -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) => {
let data = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we leaving IE users (among others) out on purpose?

https://caniuse.com/#search=let

let data = {
"fuel_station": id,
"gasoline": gasoline,
"diesel": diesel,
"lpg": lpg,
"captcha": token
// "captcha": token
}
$(obj).parent().parent().find('.popup_submit_text').html("VALIDADO");
Copy link
Member

Choose a reason for hiding this comment

The 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.
Instead we should use a selector to navigate up on the tree to grab the desired element.

https://api.jquery.com/parent/#parent-selector

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants