<commit_before>angular.module('order', ['ngResource','data']).
controller('order',['$resource', '$scope', '$q', '$http', '$filter', 'data', function($resource, $scope, $q, $http,  $filter, data) {
    $scope.date = new Date();
    $scope.date.setDate($scope.date.getDate()+1);
    $scope.groups=data.getGroups();
    $scope.group = 43;//= groups[0].id;
    $scope.items=data.getItems();
    $scope.fullOrderItems = {};
    $scope.orderStatus = {};

    $scope.loadOrder = function() {
        var frmtDate=$filter('date')($scope.date, 'dd.MM.yyyy');
        $scope.url="orders/orderitems?date="+frmtDate+"&group_id="+$scope.group;
        var FullOrderItems = $resource($scope.url);
        $scope.fullOrderItems = FullOrderItems.query();
        $scope.orderStatus = $resource("orders/orderstatus?date="+frmtDate).get();
    };
    $scope.loadOrder();

    $scope.getItemName = function(idItem){
        var item = $filter('filter')($scope.items, {id: idItem})
        return (item.length) ? item[0].itemName : "Не известно";
    };

    $scope.confirmOrder = function(){
        var frmtDate=$filter('date')($scope.date, 'dd.MM.yyyy');
        $http.post("orders/confirmorder?date="+frmtDate).then(
            function successCallback(response) {
                $scope.orderStatus = response.data;
            }, function errorCallback(err) {
                // unknown error
                alert(err.data.message);
        });
    };

    $scope.getOrderItem = function(idItem){
        var orderItems = $filter('filter')($scope.fullOrderItems, {item: {id: idItem}})
        if (orderItems.length === 0){
            //console.log("create empty orderItem");
            orderItem = {item: {id: idItem}};
            $scope.fullOrderItems.push(orderItem);
        }
        else
            orderItem = orderItems[0];
        return orderItem;
    };

    $scope.showGroup = function() {
        var selected = $filter('filter')($scope.groups, {id: $scope.group});
        return ($scope.group && selected.length) ? selected[0].groupName : 'Не задан';
    };

    $scope.saveColumn = function(formName) {
        console.log("----------FullOrderItems--------");
        console.log($scope.FullOrderItems);
        //here we can filter only not null rows or with id
        return $http.post($scope.url, $scope.fullOrderItems).then(
            function successCallback(response) {
                var frmtDate=$filter('date')($scope.date, 'dd.MM.yyyy');
                $scope.orderStatus = $resource("orders/orderstatus?date="+frmtDate).get();
            }, function errorCallback(err) {
                errCount = err.length;
                if(Array.isArray(err) && errCount>0) {
                    // err like {id: "id", msg: "Server-side error for this production!"}
                    var formNumber ='';
                    if (formName === 'count2form')
                        formNumber = 2;
                    if (err[0].id===0){
                        $scope[formName].$editables[0].setError(err[0].msg);
                    }
                    for (var i=0; i < errCount; i++){
                        $scope[formName].$setError('id'+err[i].id+'count'+formNumber, err[i].msg);
                    }
                } else {
                    // unknown error
                    $scope[formName].$editables[0].setError('Ошибка сохранения заказа!');
                }
            });
    };
}]);<commit_msg>bug fix - when use then method you must return text in error for x-editable to show errors. and json data is in data property of response<commit_after>angular.module('order', ['ngResource','data']).
controller('order',['$resource', '$scope', '$q', '$http', '$filter', 'data', function($resource, $scope, $q, $http,  $filter, data) {
    $scope.date = new Date();
    $scope.date.setDate($scope.date.getDate()+1);
    $scope.groups=data.getGroups();
    $scope.group = 43;//= groups[0].id;
    $scope.items=data.getItems();
    $scope.fullOrderItems = {};
    $scope.orderStatus = {};

    $scope.loadOrder = function() {
        var frmtDate=$filter('date')($scope.date, 'dd.MM.yyyy');
        $scope.url="orders/orderitems?date="+frmtDate+"&group_id="+$scope.group;
        var FullOrderItems = $resource($scope.url);
        $scope.fullOrderItems = FullOrderItems.query();
        $scope.orderStatus = $resource("orders/orderstatus?date="+frmtDate).get();
    };
    $scope.loadOrder();

    $scope.getItemName = function(idItem){
        var item = $filter('filter')($scope.items, {id: idItem});
        return (item.length) ? item[0].itemName : "Не известно";
    };

    $scope.confirmOrder = function(){
        var frmtDate=$filter('date')($scope.date, 'dd.MM.yyyy');
        $http.post("orders/confirmorder?date="+frmtDate).then(
            function successCallback(response) {
                $scope.orderStatus = response.data;
            }, function errorCallback(err) {
                // unknown error
                alert(err.data.message);
        });
    };

    $scope.getOrderItem = function(idItem){
        var orderItems = $filter('filter')($scope.fullOrderItems, {item: {id: idItem}});
        if (orderItems.length === 0){
            //console.log("create empty orderItem");
            orderItem = {item: {id: idItem}};
            $scope.fullOrderItems.push(orderItem);
        }
        else
            orderItem = orderItems[0];
        return orderItem;
    };

    $scope.showGroup = function() {
        var selected = $filter('filter')($scope.groups, {id: $scope.group});
        return ($scope.group && selected.length) ? selected[0].groupName : 'Не задан';
    };

    $scope.saveColumn = function(formName) {
        //console.log($scope.FullOrderItems);
        //here we can filter only not null rows or with id
        return $http.post($scope.url, $scope.fullOrderItems).then(
            function successCallback(response) {
                var frmtDate=$filter('date')($scope.date, 'dd.MM.yyyy');
                $scope.orderStatus = $resource("orders/orderstatus?date="+frmtDate).get();
            }, function errorCallback(response) {
                var err=response.data;
                errCount = err.length;
                if(Array.isArray(err) && errCount>0) {
                    // err like {id: "id", msg: "Server-side error for this production!"}
                    var formNumber ='';
                    if (formName === 'count2form')
                        formNumber = 2;
                    if (err[0].id===0){
                        $scope[formName].$editables[0].setError(err[0].msg);
                    }
                    for (var i=0; i < errCount; i++){
                        $scope[formName].$setError('id'+err[i].id+'count'+formNumber, err[i].msg);
                    }
                } else {
                    // unknown error
                    $scope[formName].$editables[0].setError('Ошибка сохранения заказа!');
                }
                return "error";
            });
    };
}]);
{'fraction_non_alphanumeric': 0.1675459860259518, 'fraction_numerical': 0.004848139170112648, 'mean_word_length': 2.127061970575123, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '923166', 'n_tokens_mistral': 2063, 'n_tokens_neox': 2037, 'n_words': 364}