<commit_before>// noinspection JSUnresolvedVariable: Ext4 provided by LabKey
(function (Ext) {
    // noinspection JSUnusedGlobalSymbols: Ext.Component.initComponent (1.1.0)
    Ext.define('WNPRC.breeding.PregnancyDetailPanel', {
        alias: 'widget.wnprc-breeding-pregnancy',
        extend: 'LDK.panel.WebpartPanel',

        initComponent: function () {
            // creates a scoped helper object to co-ordinate the async functions from each of the children. essentially
            // a poor-man's 'promise' library, which will only work in-so-far as all the calls to 'promise' happen
            // before any of the calls to 'resolve' (which--in this instance--they _should_, but still be advised that
            // there is no protection currently for an instance where they do interleave)
            const onLoad = function (callback) {
                var promises = 0;
                return {
                    promise: function () {
                        promises++;
                        return this.resolve;
                    },
                    resolve: function () {
                        if ((--promises) === 0) callback();
                    }
                };
            };

            // create the loader instance to turn off the 'loading' mask and resume
            // rendering of the components (to make it a more pleasing visual experience)
            const loader = onLoad(function () {
                Ext.defer(this.table.unmask, 500, this.table);
                // noinspection JSUnresolvedFunction: Ext.resumeLayouts (4.1.0)
                Ext.resumeLayouts(true);
            }.bind(this));

            // define the handler for loading the child records after the initial loading is complete
            const DETAIL_PANEL_XTYPE = 'wnprc-detailpanel';
            const CHILD_RECORD_XTYPE = 'wnprc-childrecordspanel';
            const onStoreLoad = function (store) {
                // noinspection JSUnresolvedFunction: Ext.suspendLayouts (4.1.1)
                Ext.suspendLayouts();
                this.down(DETAIL_PANEL_XTYPE + ', ' + CHILD_RECORD_XTYPE).forEach(function (i) {
                    i.loadFromStore(store);
                }, this);
            };

            // configure the queries for the child records. these are all assumed to be
            // parameterized queries that take the id of the 'parent' record (in this
            // case a pregnancy.objectid) as the PARENT_RECORD_ID parameter
            const children = [{
                queryName: '_UltrasoundInfoByParentRecordId',
                schemaName: 'study',
                title: 'Ultrasounds'
            }, {
                queryName: '_PregnancyInfoByParentRecordId',
                schemaName: 'study',
                title: 'Pregnancy History'
            }];

            // noinspection JSUnresolvedExtXType: Ext.panel.Panel (2.3.0)
            Ext.apply(this, {
                items: [{
                    border: false,
                    items: [{
                        bodyStyle: 'padding: 5px;',
                        border: false,
                        columnWidth: 0.25,
                        xtype: DETAIL_PANEL_XTYPE<commit_msg>the ExtJS "down" function only returns the first descendant. switching to "query"<commit_after>// noinspection JSUnresolvedVariable: Ext4 provided by LabKey
(function (Ext) {
    // noinspection JSUnusedGlobalSymbols: Ext.Component.initComponent (1.1.0)
    Ext.define('WNPRC.breeding.PregnancyDetailPanel', {
        alias: 'widget.wnprc-breeding-pregnancy',
        extend: 'LDK.panel.WebpartPanel',

        initComponent: function () {
            // creates a scoped helper object to co-ordinate the async functions from each of the children. essentially
            // a poor-man's 'promise' library, which will only work in-so-far as all the calls to 'promise' happen
            // before any of the calls to 'resolve' (which--in this instance--they _should_, but still be advised that
            // there is no protection currently for an instance where they do interleave)
            const onLoad = function (callback) {
                var promises = 0;
                return {
                    promise: function () {
                        promises++;
                        return this.resolve;
                    },
                    resolve: function () {
                        if ((--promises) === 0) callback();
                    }
                };
            };

            // create the loader instance to turn off the 'loading' mask and resume
            // rendering of the components (to make it a more pleasing visual experience)
            const loader = onLoad(function () {
                Ext.defer(this.table.unmask, 500, this.table);
                // noinspection JSUnresolvedFunction: Ext.resumeLayouts (4.1.0)
                Ext.resumeLayouts(true);
            }.bind(this));

            // define the handler for loading the child records after the initial loading is complete
            const DETAIL_PANEL_XTYPE = 'wnprc-detailpanel';
            const CHILD_RECORD_XTYPE = 'wnprc-childrecordspanel';
            const onStoreLoad = function (store) {
                // noinspection JSUnresolvedFunction: Ext.suspendLayouts (4.1.1)
                Ext.suspendLayouts();
                this.query(DETAIL_PANEL_XTYPE + ', ' + CHILD_RECORD_XTYPE).forEach(function (i) {
                    i.loadFromStore(store);
                }, this);
            };

            // configure the queries for the child records. these are all assumed to be
            // parameterized queries that take the id of the 'parent' record (in this
            // case a pregnancy.objectid) as the PARENT_RECORD_ID parameter
            const children = [{
                queryName: '_UltrasoundInfoByParentRecordId',
                schemaName: 'study',
                title: 'Ultrasounds'
            }, {
                queryName: '_PregnancyInfoByParentRecordId',
                schemaName: 'study',
                title: 'Pregnancy History'
            }];

            // noinspection JSUnresolvedExtXType: Ext.panel.Panel (2.3.0)
            Ext.apply(this, {
                items: [{
                    border: false,
                    items: [{
                        bodyStyle: 'padding: 5px;',
                        border: false,
                        columnWidth: 0.25,
                        xtype: DETAIL_PANEL_XTYPE
{'fraction_non_alphanumeric': 0.08626787636475473, 'fraction_numerical': 0.006766107950176841, 'mean_word_length': 1.5697352824970368, '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': '4228675', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1572, 'n_words': 478}