Hello.
I have 2 lists being assembled in javascript, based on the rule:
- Do you have flag Automatically DispatchedNotes as true in the database? Then it stays in the Array: clientsDownloadTrue
- Do you have flag queryNotesAddressed Automatically as false in the database? Then it stays in the Array: clientsDownloadFalse
The screen is this:
Whensending,doIwanttoknowexactlywhichrecordwenttoonesideortheother?
Followmyjavascript:
app.controller("ConfiguraDownloadAutomatico",
function($scope, $http,$filter,dialogMessage) {
$scope.clientes = [];
$scope.clientesDownloadFalse= [];
$scope.clientesDownloadTrue =[];
// picklist
$scope.selectedA = [];
$scope.selectedB = [];
$scope.items = [];
$scope.checkedA = false;
$scope.checkedB = false;
/**
* Obter sessão
*/
$scope.loadSession = function() {
$http({
method : 'GET',
url : 'session'
}).then(function successCallback(response) {
$scope.idUsuario = response.data.result.id_usuario;
$scope.iniciar();
}, function errorCallback(response) {
console.log(response.data);
});
};
$scope.loadSession();
$scope.iniciar = function() {
$http.post('obterEmpresasDownload', $scope.idUsuario).success(function(response) {
$scope.clientes = response;
$scope.items = response;
angular.forEach($scope.clientes, function(value, key){
if(value.consultaNotasDestinadasAutomaticamente == true){
$scope.clientesDownloadTrue.push(value);
}else{
$scope.clientesDownloadFalse.push(value);
}
});
});
};
$scope.preparaInsercao = function(clientesDownloadFalse, clientesDownloadTrue) {
var dados = {
clientesDownloadFalse : $scope.clientesDownloadFalse,
clientesDownloadTrue : $scope.clientesDownloadTrue
};
$http.post(
'configuradownload/salvarEmpresasDownloadAutomatico',
dados).then(
function(response) {
if (response.data.codReturn == 0) {
dialogMessage("Configura Download Automático",
response.data.descReturn, "success");
} else {
dialogMessage("Configura Download Automático",
response.data.descReturn, "erro");
}
}, function(response) {
});
};
function arrayObjectIndexOf(myArray, searchTerm, property) {
for(var i = 0, len = myArray.length; i < len; i++) {
if (myArray[i][property] === searchTerm) return i;
}
return -1;
}
$scope.aToB = function() {
for (i in $scope.selectedA) {
var moveId = arrayObjectIndexOf($scope.items, $scope.selectedA[i], "idCliente");
$scope.clientesDownloadTrue.push($scope.items[moveId]);
var delId = arrayObjectIndexOf($scope.clientesDownloadFalse, $scope.selectedA[i], "idCliente");
$scope.clientesDownloadFalse.splice(delId,1);
}
reset();
};
$scope.bToA = function() {
for (i in $scope.selectedB) {
var moveId = arrayObjectIndexOf($scope.items, $scope.selectedB[i], "idCliente");
$scope.clientesDownloadFalse.push($scope.items[moveId]);
var delId = arrayObjectIndexOf($scope.clientesDownloadTrue, $scope.selectedB[i], "idCliente");
$scope.clientesDownloadTrue.splice(delId,1);
}
reset();
};
function reset(){
$scope.selectedA=[];
$scope.selectedB=[];
$scope.toggle=0;
}
$scope.toggleA = function() {
if ($scope.selectedA.length>0) {
$scope.selectedA=[];
}
else {
for (i in $scope.clientesDownloadFalse) {
$scope.selectedA.push($scope.clientesDownloadFalse[i].idCliente);
}
}
}
$scope.toggleB = function() {
if ($scope.selectedB.length>0) {
$scope.selectedB=[];
}
else {
for (i in $scope.clientesDownloadTrue) {
$scope.selectedB.push($scope.clientesDownloadTrue[i].idCliente);
}
}
}
$scope.selectA = function(i) {
$scope.selectedA.push(i);
};
$scope.selectB = function(i) {
$scope.selectedB.push(i);
};
});
When saving, call the prepareInserca function that picks up the lists, send it to my java controller and there save the object.
If you need more information, please put it on time. Thank you.