<commit_before>Ext.require(['Ext.data.*', 'Ext.grid.*']);

Ext.define('PrepItemCategory', {
    extend: 'Ext.data.Model',
    fields: [{
        name: 'id',
        type: 'int',
        useNull: true
    }, 'title'],
    validations: [{
        type: 'length',
        field: 'title',
        min: 1
    }]
});

Ext.define('Project', {
    extend: 'Ext.data.Model',
    fields: [{
        name: 'id',
        type: 'int',
        useNull: true
    }, 'title']
});

Ext.define('PrepItem', {
    extend: 'Ext.data.Model',
    fields: [{
        name: 'id',
        type: 'int',
        useNull: true
      }, {
        name: 'deadline',
        type: 'date',
      }, {
        name: 'deadline_optional',
        type: 'boolean',
      }, {
        name: 'individual',
        type: 'boolean'
      }, {
        name: 'paperwork',
        type: 'boolean'
      }, 'title', 'description', 'prep_item_category_id', 'project_ids'
    ], validations: [{
      type: 'length',
      field: 'title',
      min: 1
    }, {
      type: 'length',
      field: 'description',
      min: 1
    }]
});

Ext.onReady(function() {

    function formatDate(value) {
        return value ? Ext.Date.dateFormat(value, 'M d, Y') : '';
    }

    var categoriesStore = Ext.create('Ext.data.Store', {
        autoLoad: true,
        autoSync: true,
        model: 'PrepItemCategory',
        proxy: {
            type: 'rest',
            url: '/prep_item_categories',
            reader: {
                type: 'json',
                root: 'data'
            },
            writer: {
                type: 'json'
            },
        }
    });

    var prepItemsStore = Ext.create('Ext.data.Store', {
        autoLoad: true,
        autoSync: true,
        model: 'PrepItem',
        proxy: {
            type: 'rest',
            url: '/prep_items',
            reader: {
                type: 'json',
                root: 'data'
            },
            writer: {
                type: 'json'
            }
        }
    });

    var projectsStore = Ext.create('Ext.data.ArrayStore', {
        model: "Project",
        data: projectsData
    });

    var categoriesRowEditing = Ext.create('Ext.grid.plugin.RowEditing');
    
    var categoriesGrid = Ext.create('Ext.grid.Panel', {
        plugins: [categoriesRowEditing],
        width: 200,
        height: 400,
        frame: true,
        title: 'Categories',
        store: categoriesStore,
        columns: [{
            text: 'ID',
            width: 40,
            sortable: true,
            dataIndex: 'id',
            renderer: function(v){
                if (Ext.isEmpty(v)) {
                    v = '&#160;';
                }
                return v;
            }
        }, {
            text: 'Title',
            flex: 1,
            sortable: true,
            dataIndex: 'title',
            field: {
                xtype: 'textfield',
                allowBlank: false
            }
        }],
        dockedItems: [{
            xtype: 'toolbar',
            items: [{
                text: 'Add',
                handler: function() {
                    // empty record
                    categoriesStore.insert(0, new PrepItemCategory());
                    categoriesRowEditing.startEdit(0, 0);
                }
            }, '-', {
                text: 'Delete',
                handler: function() {
                    var selection = categoriesGrid.getView().getSelectionModel().getSelection()[0];
                    if (selection) {
                        categoriesStore.remove(selection);
                    }
                }
            }]
        }]
    });

    var prepItemRowEditing = Ext.create('Ext.grid.plugin.RowEditing');

    var prepItemGrid = Ext.create('Ext.grid.Panel', {
        plugins: [prepItemRowEditing],
        width: 700,
        height: 400,
        frame: true,
        title: 'Todos',
        store: prepItemsStore,
        columns: [{
            text: 'ID',
            width: 40,
            sortable: true,
            dataIndex: 'id',
            renderer: function(v){
                if (Ext.isEmpty(v)) {
                    v = '&#160;';
                }
                return v;
            }
        }, {
            text: 'Category',
            flex: 1,
            sortable: true,
            dataIndex: 'prep_item_category_id',
            editor: {
                  xtype: 'combobox',
                  store: categoriesStore,
                  queryMode: 'local',
                  displayField: 'title',
                  valueField: 'id',
                  editable: false,
                  multiSelect: false
           }, 
           renderer: function(value) {
             if (value != 0 && value != "") {
               record = categoriesStore.findRecord("id", value);
               if (record != null) {
                 return record.get('title');
               } else {
                 return value;
               }
             } else {
               return "";<commit_msg>don't use local for categories because it broke using categories that were just added<commit_after>Ext.require(['Ext.data.*', 'Ext.grid.*']);

Ext.define('PrepItemCategory', {
    extend: 'Ext.data.Model',
    fields: [{
        name: 'id',
        type: 'int',
        useNull: true
    }, 'title'],
    validations: [{
        type: 'length',
        field: 'title',
        min: 1
    }]
});

Ext.define('Project', {
    extend: 'Ext.data.Model',
    fields: [{
        name: 'id',
        type: 'int',
        useNull: true
    }, 'title']
});

Ext.define('PrepItem', {
    extend: 'Ext.data.Model',
    fields: [{
        name: 'id',
        type: 'int',
        useNull: true
      }, {
        name: 'deadline',
        type: 'date',
      }, {
        name: 'deadline_optional',
        type: 'boolean',
      }, {
        name: 'individual',
        type: 'boolean'
      }, {
        name: 'paperwork',
        type: 'boolean'
      }, 'title', 'description', 'prep_item_category_id', 'project_ids'
    ], validations: [{
      type: 'length',
      field: 'title',
      min: 1
    }, {
      type: 'length',
      field: 'description',
      min: 1
    }]
});

Ext.onReady(function() {

    function formatDate(value) {
        return value ? Ext.Date.dateFormat(value, 'M d, Y') : '';
    }

    var categoriesStore = Ext.create('Ext.data.Store', {
        autoLoad: true,
        autoSync: true,
        model: 'PrepItemCategory',
        proxy: {
            type: 'rest',
            url: '/prep_item_categories',
            reader: {
                type: 'json',
                root: 'data'
            },
            writer: {
                type: 'json'
            },
        }
    });

    var prepItemsStore = Ext.create('Ext.data.Store', {
        autoLoad: true,
        autoSync: true,
        model: 'PrepItem',
        proxy: {
            type: 'rest',
            url: '/prep_items',
            reader: {
                type: 'json',
                root: 'data'
            },
            writer: {
                type: 'json'
            }
        }
    });

    var projectsStore = Ext.create('Ext.data.ArrayStore', {
        model: "Project",
        data: projectsData
    });

    var categoriesRowEditing = Ext.create('Ext.grid.plugin.RowEditing');
    
    var categoriesGrid = Ext.create('Ext.grid.Panel', {
        plugins: [categoriesRowEditing],
        width: 200,
        height: 400,
        frame: true,
        title: 'Categories',
        store: categoriesStore,
        columns: [{
            text: 'ID',
            width: 40,
            sortable: true,
            dataIndex: 'id',
            renderer: function(v){
                if (Ext.isEmpty(v)) {
                    v = '&#160;';
                }
                return v;
            }
        }, {
            text: 'Title',
            flex: 1,
            sortable: true,
            dataIndex: 'title',
            field: {
                xtype: 'textfield',
                allowBlank: false
            }
        }],
        dockedItems: [{
            xtype: 'toolbar',
            items: [{
                text: 'Add',
                handler: function() {
                    // empty record
                    categoriesStore.insert(0, new PrepItemCategory());
                    categoriesRowEditing.startEdit(0, 0);
                }
            }, '-', {
                text: 'Delete',
                handler: function() {
                    var selection = categoriesGrid.getView().getSelectionModel().getSelection()[0];
                    if (selection) {
                        categoriesStore.remove(selection);
                    }
                }
            }]
        }]
    });

    var prepItemRowEditing = Ext.create('Ext.grid.plugin.RowEditing');

    var prepItemGrid = Ext.create('Ext.grid.Panel', {
        plugins: [prepItemRowEditing],
        width: 700,
        height: 400,
        frame: true,
        title: 'Todos',
        store: prepItemsStore,
        columns: [{
            text: 'ID',
            width: 40,
            sortable: true,
            dataIndex: 'id',
            renderer: function(v){
                if (Ext.isEmpty(v)) {
                    v = '&#160;';
                }
                return v;
            }
        }, {
            text: 'Category',
            flex: 1,
            sortable: true,
            dataIndex: 'prep_item_category_id',
            editor: {
                  xtype: 'combobox',
                  store: categoriesStore,
                  displayField: 'title',
                  valueField: 'id',
                  editable: false,
                  multiSelect: false
           }, 
           renderer: function(value) {
             if (value != 0 && value != "") {
               record = categoriesStore.findRecord("id", value);
               if (record != null) {
                 return record.get('title');
               } else {
                 return value;
               }
             } else {
               return "";
{'fraction_non_alphanumeric': 0.1331548681340472, 'fraction_numerical': 0.006345429307951616, 'mean_word_length': 1.1899696048632218, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3910142', 'n_tokens_mistral': 2861, 'n_tokens_neox': 2684, 'n_words': 579}