<commit_before>/*
 * Copyright 2015-2016 OpenCB
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import {LitElement, html} from "lit";
import UtilsNew from "../../../core/utilsNew.js";
import "../forms/select-field-filter.js";

export default class ClinicalPriorityFilter extends LitElement {

    constructor() {
        super();

        // Set status and init private properties
        this._init();
    }

    createRenderRoot() {
        return this;
    }

    static get properties() {
        return {
            priorities: {
                type: Array
            },
            priority: {
                type: String
            },
            placeholder: {
                type: String
            },
            config: {
                type: Object
            }
        };
    }

    _init() {
        this._prefix = UtilsNew.randomString(6) + "_";
    }

    connectedCallback() {
        super.connectedCallback();
        this._config = {...this.getDefaultConfig(), ...this.config};
    }

    // update(changedProperties) {
    //     if (changedProperties.has("priority")) {
    //     }
    //     super.update(changedProperties);
    // }

    filterChange(e) {
        const event = new CustomEvent("filterChange", {
            detail: {
                value: e.detail.value
            }
        });
        this.dispatchEvent(event);
    }

    getDefaultConfig() {
        return {
            priorities: ["URGENT", "HIGH", "MEDIUM", "LOW"],
            multiple: true
        };
    }

    render() {
        return html`
            <select-field-filter
                .placeholder="${this.placeholder}"
                ?multiple="${this._config.multiple}"
                .data="${this.priorities?.length ? this.priorities : this._config.priorities}"
                .value=${this.priority}
                multiple
                @filterChange="${e => this.filterChange(e)}">
            </select-field-filter>
        `;
    }

}

customElements.define("clinical-priority-filter", ClinicalPriorityFilter);<commit_msg>wc: code fixes and improvements in clinical-priority-filter<commit_after>/*
 * Copyright 2015-2016 OpenCB
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import {LitElement, html} from "lit";
import "../forms/select-field-filter.js";

export default class ClinicalPriorityFilter extends LitElement {

    constructor() {
        super();

        // Set status and init private properties
        this._init();
    }

    createRenderRoot() {
        return this;
    }

    static get properties() {
        return {
            priority: {
                type: String
            },
            priorities: {
                type: Array
            },
            placeholder: {
                type: String
            },
            multiple: {
                type: Boolean
            },
            classes: {
                type: String
            },
            disabled: {
                type: Boolean
            },
        };
    }

    _init() {
        this.priorities = ["URGENT", "HIGH", "MEDIUM", "LOW"];
        this.multiple = true;
        this.disabled = false;
    }

    filterChange(e) {
        const event = new CustomEvent("filterChange", {
            detail: {
                value: e.detail.value,
                query: {
                    priority: e.detail.value
                }
            }
        });
        this.dispatchEvent(event);
    }

    render() {
        return html`
            <select-field-filter
                .data="${this.priorities}"
                .value=${this.priority}
                .placeholder="${this.placeholder}"
                ?multiple="${this.multiple}"
                .classes="${this.classes}"
                .disabled="${this.disabled}"
                @filterChange="${e => this.filterChange(e)}">
            </select-field-filter>
        `;
    }

}

customElements.define("clinical-priority-filter", ClinicalPriorityFilter);
{'fraction_non_alphanumeric': 0.11301916932907348, 'fraction_numerical': 0.0049920127795527154, 'mean_word_length': 1.6872317596566524, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '5010878', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1226, 'n_words': 344}