<commit_before>module Vidyano.WebComponents.Attributes {
    @PersistentObjectAttribute.register({
        properties: {
            href: String,
            canClear: {
                type: Boolean,
                readOnly: true
            },
            canAddNewReference: {
                type: Boolean,
                readOnly: true
            },
            canBrowseReference: {
                type: Boolean,
                readOnly: true
            },
            filter: {
                type: String,
                notify: true
            },
            objectId: {
                type: String,
                observer: "_objectIdChanged",
                value: null
            },
            selectInPlace: {
                type: Boolean,
                reflectToAttribute: true,
                computed: "attribute.selectInPlace"
            }
        },
        observers: [
            "_update(attribute.isReadOnly)"
        ]
    })
    export class PersistentObjectAttributeReference extends WebComponents.Attributes.PersistentObjectAttribute {
        objectId: string;
        attribute: Vidyano.PersistentObjectAttributeWithReference;
        href: string;
        filter: string;

        private _setCanClear: (val: boolean) => void;
        private _setCanAddNewReference: (val: boolean) => void;
        private _setCanBrowseReference: (val: boolean) => void;

        attached() {
            super.attached();
            this._update();
        }

        protected _attributeChanged() {
            super._attributeChanged();

            this._update();
        }

        protected _valueChanged(newValue: any) {
            this._update();

            if (this.attribute && newValue !== this.attribute.value) {
                this.attribute.setValue(newValue, true);
            }
        }

        private _objectIdChanged() {
            if (this.attribute && this.attribute.objectId !== this.objectId)
                this.attribute.changeReference(this.objectId ? [this.objectId] : []);
        }

        private _filterBlur() {
            if (!this.attribute)
                return;

            if (!StringEx.isNullOrEmpty(this.filter) && this.filter != this.attribute.value) {
                this.attribute.lookup.textSearch = 'vi-breadcrumb:"' + this.filter + '"';
                this.attribute.lookup.search().then(result => {
                    if (result.length == 0)
                        this.filter = this.attribute.value;
                    else if (result.length == 1)
                        this.attribute.changeReference([result[0]]).then(() => this._update());
                    else {
                        this.attribute.lookup.textSearch = this.filter;

                        this._browseReference(true).catch(() => {
                            this.filter = this.attribute.value;
                        });
                    }
                });
            }
            else
                this.filter = this.attribute.value;<commit_msg>Hide 'vi-breadcrumb' on reference attributes after finding a result<commit_after>module Vidyano.WebComponents.Attributes {
    @PersistentObjectAttribute.register({
        properties: {
            href: String,
            canClear: {
                type: Boolean,
                readOnly: true
            },
            canAddNewReference: {
                type: Boolean,
                readOnly: true
            },
            canBrowseReference: {
                type: Boolean,
                readOnly: true
            },
            filter: {
                type: String,
                notify: true
            },
            objectId: {
                type: String,
                observer: "_objectIdChanged",
                value: null
            },
            selectInPlace: {
                type: Boolean,
                reflectToAttribute: true,
                computed: "attribute.selectInPlace"
            }
        },
        observers: [
            "_update(attribute.isReadOnly)"
        ]
    })
    export class PersistentObjectAttributeReference extends WebComponents.Attributes.PersistentObjectAttribute {
        objectId: string;
        attribute: Vidyano.PersistentObjectAttributeWithReference;
        href: string;
        filter: string;

        private _setCanClear: (val: boolean) => void;
        private _setCanAddNewReference: (val: boolean) => void;
        private _setCanBrowseReference: (val: boolean) => void;

        attached() {
            super.attached();
            this._update();
        }

        protected _attributeChanged() {
            super._attributeChanged();

            this._update();
        }

        protected _valueChanged(newValue: any) {
            this._update();

            if (this.attribute && newValue !== this.attribute.value) {
                this.attribute.setValue(newValue, true);
            }
        }

        private _objectIdChanged() {
            if (this.attribute && this.attribute.objectId !== this.objectId)
                this.attribute.changeReference(this.objectId ? [this.objectId] : []);
        }

        private _filterBlur() {
            if (!this.attribute)
                return;

            if (!StringEx.isNullOrEmpty(this.filter) && this.filter != this.attribute.value) {
                this.attribute.lookup.textSearch = 'vi-breadcrumb:"' + this.filter + '"';
                this.attribute.lookup.search().then(result => {
                    this.attribute.lookup.textSearch = null;

                    if (result.length == 0)
                        this.filter = this.attribute.value;
                    else if (result.length == 1)
                        this.attribute.changeReference([result[0]]).then(() => this._update());
                    else {
                        this.attribute.lookup.textSearch = this.filter;

                        this._browseReference(true).catch(() => {
                            this.filter = this.attribute.value;
                        });
                    }
                });
            }
            else
                this.filter = this.attribute.value;
{'fraction_non_alphanumeric': 0.10009686793671295, 'fraction_numerical': 0.0009686793671294801, 'mean_word_length': 1.3315769665035755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '7493340', 'n_tokens_mistral': 1506, 'n_tokens_neox': 1426, 'n_words': 265}