<commit_before>Ext.define('devilry.extjshelpers.studentsmanager.StudentsManager', {
    extend: 'Ext.panel.Panel',
    //alias: 'widget.studentsmanager',
    cls: 'studentsmanager',
    frame: false,
    border: false,

    requires: [
        'devilry.extjshelpers.studentsmanager.FilterSelector',
        'devilry.extjshelpers.studentsmanager.StudentsGrid',
        'devilry.extjshelpers.assignmentgroup.MultiCreateNewDeadlineWindow',
        'devilry.extjshelpers.SearchField',
        'devilry.extjshelpers.SetListOfUsers',
        'devilry.gradeeditors.EditManyDraftEditorWindow'
    ],

    mixins: {
        createFeedback: 'devilry.extjshelpers.studentsmanager.StudentsManagerCreateFeedback',
        manageDeadlines: 'devilry.extjshelpers.studentsmanager.StudentsManagerManageDeadlines',
        closeOpen: 'devilry.extjshelpers.studentsmanager.StudentsManagerCloseOpen'
    },

    config: {
        /**
         * @cfg
         * Use the administrator RESTful interface to store drafts? If this is
         * ``false``, we use the examiner RESTful interface.
         */
        isAdministrator: false,

        deadlinemodel: undefined,
        assignmentgroupstore: undefined,
        assignmentid: undefined,
        gradeeditor_config_model: undefined,
        periodid: undefined
    },

    constructor: function(config) {
        this.callParent([config]);
        this.initConfig(config);

        this.gradeeditor_config_recordcontainer = Ext.create('devilry.extjshelpers.SingleRecordContainer');
        this.registryitem_recordcontainer = Ext.create('devilry.extjshelpers.SingleRecordContainer');
        this.registryitem_recordcontainer.addListener('setRecord', this.onLoadRegistryItem, this);
    },

    initComponent: function() {
        this.giveFeedbackButton = Ext.widget('button', {
            scale: 'large',
            text: 'Give feedback to selected',
            listeners: {
                scope: this,
                click: this.onGiveFeedbackToSelected,
                render: function(button) {
                    if(!this.registryitem_recordcontainer.record) {
                        button.getEl().mask('Loading'); // TODO: Only mask the affected buttons
                    }
                }
            }
        });

        this.addStudentsButton = Ext.widget('button', {
            text: 'Create groups',
            iconCls: 'icon-add-32',
            scale: 'large',
            menu: [{
                text: Ext.String.format('One group for each student registered in {0}', DevilrySettings.DEVILRY_SYNCSYSTEM),
                listeners: {
                    scope: this,
                    click: this.onOneGroupForEachRelatedStudent
                }
            }, {
                text: 'Manually',
                listeners: {
                    scope: this,
                    click: this.onManuallyCreateUsers
                }
            }]
        });

        Ext.apply(this, {
            layout: {
                type: 'vbox',
                align: 'stretch'
            },
            items: [{
                xtype: 'searchfield',
                emptyText: 'Search...',
                margin: 10,
                flex: 0,
            }, {
                xtype: 'panel',
                flex: 1,
                layout: 'fit',
                frame: true,
                border: false,
                items: [{
                    xtype: 'studentsmanager_studentsgrid',
                    store: this.assignmentgroupstore,
                    assignmentid: this.assignmentid
                }],

                dockedItems: [{
                    xtype: 'toolbar',
                    dock: 'bottom',
                    ui: 'footer',
                    items: [this.addStudentsButton, '->', {
                        xtype: 'button',
                        text: 'Actions on selected',
                        scale: 'large',
                        menu: [{
                            text: 'Close/open selected',
                            menu: [{
                                text: 'Close',
                                listeners: {
                                    scope: this,
                                    click: this.onCloseGroups
                                }
                            }, {
                                text: 'Open',
                                listeners: {
                                    scope: this,
                                    click: this.onOpenGroups
                                }
                            }]
                        }, {
                            text: 'Add deadline to selected',
                            listeners: {
                                scope: this,
                                click: this.onAddDeadline
                            }
                        }, {
                            text: 'Change examiners on selected',
                            menu: [{
                                text: 'Replace',
                                iconCls: 'icon-edit-16',
                                listeners: {
                                    scope: this,
                                    click: this.onReplaceExaminers
                                }
                            }, {
                                text: 'Add',
                                iconCls: 'icon-add-16',
                                listeners: {
                                    scope: this,
                                    click: this.onAddExaminers
                                }
                            }, {
                                text: 'Random distribute',
                                listeners: {
                                    scope: this,
                                    click: this.onRandomDistributeExaminers
                                }
                            }, {
                                text: 'Clear',
                                iconCls: 'icon-delete-16',
                                listeners: {
                                    scope: this,
                                    click: this.onClearExaminers
                                }
                            }]
                        }]
                    }, this.giveFeedbackButton]
                }]
            }],

        });
        this.callParent(arguments);
        this.setSearchfieldAttributes();

        this.addListener('render', function() {
            //this.up('window').addListener('show', this.onManuallyCreateUsers, this);
            //this.up('window').addListener('show', this.onOneGroupForEachRelatedStudent, this);
        }, this);
        this.loadGradeEditorConfigModel();
    },

    /**
     * @private
     */
    onSelectNone: function() {
        Ext.MessageBox.alert('No element(s) selected', 'You must select at least one group to use the selected action.');
    },

    /**
     * @private
     */
    noneSelected: function() {
        return this.down('studentsmanager_studentsgrid').selModel.getSelection().length == 0;
    },

    /**
     * @private
     */
    loadFirstPage: function() {
        this.assignmentgroupstore.currentPage = 1;<commit_msg>apps.extjshelpers: Started decoupling toolbar in StudentsManager.<commit_after>Ext.define('devilry.extjshelpers.studentsmanager.StudentsManager', {
    extend: 'Ext.panel.Panel',
    //alias: 'widget.studentsmanager',
    cls: 'studentsmanager',
    frame: false,
    border: false,

    requires: [
        'devilry.extjshelpers.studentsmanager.FilterSelector',
        'devilry.extjshelpers.studentsmanager.StudentsGrid',
        'devilry.extjshelpers.assignmentgroup.MultiCreateNewDeadlineWindow',
        'devilry.extjshelpers.SearchField',
        'devilry.extjshelpers.SetListOfUsers',
        'devilry.gradeeditors.EditManyDraftEditorWindow'
    ],

    mixins: {
        createFeedback: 'devilry.extjshelpers.studentsmanager.StudentsManagerCreateFeedback',
        manageDeadlines: 'devilry.extjshelpers.studentsmanager.StudentsManagerManageDeadlines',
        closeOpen: 'devilry.extjshelpers.studentsmanager.StudentsManagerCloseOpen'
    },

    config: {
        /**
         * @cfg
         * Use the administrator RESTful interface to store drafts? If this is
         * ``false``, we use the examiner RESTful interface.
         */
        isAdministrator: false,

        deadlinemodel: undefined,
        assignmentgroupstore: undefined,
        assignmentid: undefined,
        gradeeditor_config_model: undefined,
        periodid: undefined
    },

    constructor: function(config) {
        this.callParent([config]);
        this.initConfig(config);

        this.gradeeditor_config_recordcontainer = Ext.create('devilry.extjshelpers.SingleRecordContainer');
        this.registryitem_recordcontainer = Ext.create('devilry.extjshelpers.SingleRecordContainer');
        this.registryitem_recordcontainer.addListener('setRecord', this.onLoadRegistryItem, this);
    },

    initComponent: function() {
        this.giveFeedbackButton = Ext.widget('button', {
            scale: 'large',
            text: 'Give feedback to selected',
            listeners: {
                scope: this,
                click: this.onGiveFeedbackToSelected,
                render: function(button) {
                    if(!this.registryitem_recordcontainer.record) {
                        button.getEl().mask('Loading'); // TODO: Only mask the affected buttons
                    }
                }
            }
        });

        this.addStudentsButton = Ext.widget('button', {
            text: 'Create groups',
            iconCls: 'icon-add-32',
            scale: 'large',
            menu: [{
                text: Ext.String.format('One group for each student registered in {0}', DevilrySettings.DEVILRY_SYNCSYSTEM),
                listeners: {
                    scope: this,
                    click: this.onOneGroupForEachRelatedStudent
                }
            }, {
                text: 'Manually',
                listeners: {
                    scope: this,
                    click: this.onManuallyCreateUsers
                }
            }]
        });

        Ext.apply(this, {
            layout: {
                type: 'vbox',
                align: 'stretch'
            },
            items: [{
                xtype: 'searchfield',
                emptyText: 'Search...',
                margin: 10,
                flex: 0,
            }, {
                xtype: 'panel',
                flex: 1,
                layout: 'fit',
                frame: true,
                border: false,
                items: [{
                    xtype: 'studentsmanager_studentsgrid',
                    store: this.assignmentgroupstore,
                    assignmentid: this.assignmentid
                }],

                dockedItems: [{
                    xtype: 'toolbar',
                    dock: 'bottom',
                    ui: 'footer',
                    items: this.getToolbarItems()
                }]
            }],

        });
        this.callParent(arguments);
        this.setSearchfieldAttributes();

        this.addListener('render', function() {
            //this.up('window').addListener('show', this.onManuallyCreateUsers, this);
            //this.up('window').addListener('show', this.onOneGroupForEachRelatedStudent, this);
        }, this);
        this.loadGradeEditorConfigModel();
    },

    getToolbarItems: function() {
        return [this.addStudentsButton, '->', {
            xtype: 'button',
            text: 'Actions on selected',
            scale: 'large',
            menu: [{
                text: 'Close/open selected',
                menu: [{
                    text: 'Close',
                    listeners: {
                        scope: this,
                        click: this.onCloseGroups
                    }
                }, {
                    text: 'Open',
                    listeners: {
                        scope: this,
                        click: this.onOpenGroups
                    }
                }]
            }, {
                text: 'Add deadline to selected',
                listeners: {
                    scope: this,
                    click: this.onAddDeadline
                }
            }, {
                text: 'Change examiners on selected',
                menu: [{
                    text: 'Replace',
                    iconCls: 'icon-edit-16',
                    listeners: {
                        scope: this,
                        click: this.onReplaceExaminers
                    }
                }, {
                    text: 'Add',
                    iconCls: 'icon-add-16',
                    listeners: {
                        scope: this,
                        click: this.onAddExaminers
                    }
                }, {
                    text: 'Random distribute',
                    listeners: {
                        scope: this,
                        click: this.onRandomDistributeExaminers
                    }
                }, {
                    text: 'Clear',
                    iconCls: 'icon-delete-16',
                    listeners: {
                        scope: this,
                        click: this.onClearExaminers
                    }
                }]
            }]
        }, this.giveFeedbackButton];
    },

    /**
     * @private
     */
    onSelectNone: function() {
        Ext.MessageBox.alert('No element(s) selected', 'You must select at least one group to use the selected action.');
    },

    /**
     * @private
     */
    noneSelected: function() {
        return this.down('studentsmanager_studentsgrid').selModel.getSelection().length == 0;
    },

    /**
     * @private
     */
    loadFirstPage: function() {
        this.assignmentgroupstore.currentPage = 1;
{'fraction_non_alphanumeric': 0.09603953305163647, 'fraction_numerical': 0.002148535415025424, 'mean_word_length': 1.1483076923076923, 'pattern_counts': {'":': 0, '<': 3, '<?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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '264406', 'n_tokens_mistral': 3461, 'n_tokens_neox': 3226, 'n_words': 582}