<commit_before>/**
 * This file is part of Superdesk.
 *
 * Copyright 2013, 2014 Sourcefabric z.u. and contributors.
 *
 * For the full copyright and license information, please see the
 * AUTHORS and LICENSE files distributed with this source code, or
 * at https://www.sourcefabric.org/superdesk/license
 */

 (function() {
    'use strict';

    DeskListController.$inject = ['$scope', 'desks', 'superdesk', 'privileges', 'tasks', 'api'];
    function DeskListController($scope, desks, superdesk, privileges, tasks, api) {

        var userDesks;

        desks.initialize()
        .then(function() {
            $scope.desks = desks.desks;
            $scope.deskStages = desks.deskStages;

            desks.fetchCurrentUserDesks().then(function (desk_list) {
                userDesks = desk_list._items;
            });
        });

        $scope.statuses = tasks.statuses;
        $scope.online_users = false;

        api('roles').query().then(function(result) {
            $scope.roles = result._items;
        });

        $scope.privileges = privileges.privileges;

        $scope.views = ['content', 'tasks', 'users'];

        $scope.view = $scope.views[0];

        $scope.setView = function(view) {
            $scope.view = view;
        };

        $scope.changeOnlineUsers = function(value) {
            $scope.online_users = value;
        };

        $scope.isMemberOf = function(desk) {
            return _.find(userDesks, {_id: desk._id});
        };

        $scope.openDeskView = function(desk, target) {
            desks.setCurrentDesk(desk);
            superdesk.intent('view', target);
        };

        $scope.$on('desks:refresh:stages', function(e, deskId) {
            desks.refreshStages().then(function() {
                $scope.deskStages[deskId] = desks.deskStages[deskId];
            });
        });
    }

    StageItemListDirective.$inject = ['search', 'api', 'superdesk', 'desks'];
    function StageItemListDirective(search, api, superdesk, desks) {
        return {
            templateUrl: 'scripts/superdesk-desks/views/stage-item-list.html',
            scope: {
                stage: '=',
                total: '=',
                allowed: '=',
                showEmpty: '=?',
                selected: '=?',
                action: '&',
                filter: '='
            },
            link: function(scope, elem) {

                scope.open = function(item) {
                    desks.setWorkspace(item.task.desk, item.task.stage);
                    superdesk.intent('read_only', 'content_article', item);
                };

                function queryItems(queryString) {
                    var query = search.query({});
                    query.filter({term: {'task.stage': scope.stage}});
                    query.size(10);

                    if (queryString) {
                        query.filter({query: {query_string: {
                            query: queryString,
                            lenient: false
                        }}});
                    }

                    var criteria = {source: query.getCriteria()};

                    scope.loading = true;
                    scope.items = scope.total = null;
                    api('archive').query(criteria).then(function(items) {
                        scope.items = items._items;
                        scope.total = items._meta.total;
                    })['finally'](function() {
                        scope.loading = false;
                    });

                }

                scope.$watch('filter', queryItems);
            }
        };
    }<commit_msg>feat(content): sync multi content view<commit_after>/**
 * This file is part of Superdesk.
 *
 * Copyright 2013, 2014 Sourcefabric z.u. and contributors.
 *
 * For the full copyright and license information, please see the
 * AUTHORS and LICENSE files distributed with this source code, or
 * at https://www.sourcefabric.org/superdesk/license
 */

 (function() {
    'use strict';

    DeskListController.$inject = ['$scope', 'desks', 'superdesk', 'privileges', 'tasks', 'api'];
    function DeskListController($scope, desks, superdesk, privileges, tasks, api) {

        var userDesks;

        desks.initialize()
        .then(function() {
            $scope.desks = desks.desks;
            $scope.deskStages = desks.deskStages;

            desks.fetchCurrentUserDesks().then(function (desk_list) {
                userDesks = desk_list._items;
            });
        });

        $scope.statuses = tasks.statuses;
        $scope.online_users = false;

        api('roles').query().then(function(result) {
            $scope.roles = result._items;
        });

        $scope.privileges = privileges.privileges;

        $scope.views = ['content', 'tasks', 'users'];

        $scope.view = $scope.views[0];

        $scope.setView = function(view) {
            $scope.view = view;
        };

        $scope.changeOnlineUsers = function(value) {
            $scope.online_users = value;
        };

        $scope.isMemberOf = function(desk) {
            return _.find(userDesks, {_id: desk._id});
        };

        $scope.openDeskView = function(desk, target) {
            desks.setCurrentDesk(desk);
            superdesk.intent('view', target);
        };

        $scope.$on('desks:refresh:stages', function(e, deskId) {
            desks.refreshStages().then(function() {
                $scope.deskStages[deskId] = desks.deskStages[deskId];
            });
        });
    }

    StageItemListDirective.$inject = ['search', 'api', 'superdesk', 'desks'];
    function StageItemListDirective(search, api, superdesk, desks) {
        return {
            templateUrl: 'scripts/superdesk-desks/views/stage-item-list.html',
            scope: {
                stage: '=',
                total: '=',
                allowed: '=',
                showEmpty: '=?',
                selected: '=?',
                action: '&',
                filter: '='
            },
            link: function(scope, elem) {

                scope.open = function(item) {
                    desks.setWorkspace(item.task.desk, item.task.stage);
                    superdesk.intent('read_only', 'content_article', item);
                };

                function queryItems(queryString) {
                    var query = search.query({});
                    query.filter({term: {'task.stage': scope.stage}});
                    query.size(10);

                    if (queryString) {
                        query.filter({query: {query_string: {
                            query: queryString,
                            lenient: false
                        }}});
                    }

                    var criteria = {source: query.getCriteria()};

                    scope.loading = true;
                    scope.items = scope.total = null;
                    api('archive').query(criteria).then(function(items) {
                        scope.items = items._items;
                        scope.total = items._meta.total;
                    })['finally'](function() {
                        scope.loading = false;
                    });

                }

                scope.$watch('filter', queryItems);
                scope.$on('task:stage', function(event, data) {
                    if (data.new_stage === scope.stage || data.old_stage === scope.stage) {
                        queryItems();
                    }
                });
            }
        };
    }
{'fraction_non_alphanumeric': 0.13182724252491695, 'fraction_numerical': 0.0029235880398671096, 'mean_word_length': 1.49867197875166, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '4615873', 'n_tokens_mistral': 2130, 'n_tokens_neox': 1985, 'n_words': 359}