<commit_before>/*
 * Squidex Headless CMS
 *
 * @license
 * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
 */

import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { onErrorResumeNext } from 'rxjs/operators';

import {
    fadeAnimation,
    ImmutableArray,
    LocalStoreService,
    SchemaDetailsDto,
    SchemaDto,
    SchemasState,
    Types
} from '@app/shared/internal';

@Component({
    selector: 'sqx-schema-category',
    styleUrls: ['./schema-category.component.scss'],
    templateUrl: './schema-category.component.html',
    animations: [
        fadeAnimation
    ]
})
export class SchemaCategoryComponent implements OnInit, OnChanges {
    @Output()
    public removing = new EventEmitter();

    @Input()
    public name: string;

    @Input()
    public isReadonly: boolean;

    @Input()
    public schemasFilter: string;

    @Input()
    public schemas: ImmutableArray<SchemaDto>;

    public displayName: string;

    public schemasFiltered: ImmutableArray<SchemaDto>;
    public schemasForCategory: ImmutableArray<SchemaDto>;

    public isOpen = true;

    public allowDrop = (schema: any) => {
        return (Types.is(schema, SchemaDto) || Types.is(schema, SchemaDetailsDto)) && !this.isSameCategory(schema);
    }

    constructor(
        private readonly localStore: LocalStoreService,
        private readonly schemasState: SchemasState
    ) {
    }

    public ngOnInit() {
        this.isOpen = this.localStore.get(`schema-category.${name}`) !== 'false';
    }

    public toggle() {
        this.isOpen = !this.isOpen;

        this.localStore.set(`schema-category.${name}`, this.isOpen + '');
    }

    public ngOnChanges(changes: SimpleChanges): void {
        if (changes['schemas'] || changes['schemasFilter']) {
            const query = this.schemasFilter;

            this.schemasForCategory = this.schemas.filter(x => this.isSameCategory(x));
            this.schemasFiltered = this.schemasForCategory.filter(x => !query || x.name.indexOf(query) >= 0);
        }

        if (changes['name']) {
            if (!this.name || this.name.length === 0) {
                this.displayName = 'Schemas';
            } else {
                this.displayName = this.name;
            }
        }
    }
<commit_msg>Fixing call into local store to use category name<commit_after>/*
 * Squidex Headless CMS
 *
 * @license
 * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
 */

import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { onErrorResumeNext } from 'rxjs/operators';

import {
    fadeAnimation,
    ImmutableArray,
    LocalStoreService,
    SchemaDetailsDto,
    SchemaDto,
    SchemasState,
    Types
} from '@app/shared/internal';

@Component({
    selector: 'sqx-schema-category',
    styleUrls: ['./schema-category.component.scss'],
    templateUrl: './schema-category.component.html',
    animations: [
        fadeAnimation
    ]
})
export class SchemaCategoryComponent implements OnInit, OnChanges {
    @Output()
    public removing = new EventEmitter();

    @Input()
    public name: string;

    @Input()
    public isReadonly: boolean;

    @Input()
    public schemasFilter: string;

    @Input()
    public schemas: ImmutableArray<SchemaDto>;

    public displayName: string;

    public schemasFiltered: ImmutableArray<SchemaDto>;
    public schemasForCategory: ImmutableArray<SchemaDto>;

    public isOpen = true;

    public allowDrop = (schema: any) => {
        return (Types.is(schema, SchemaDto) || Types.is(schema, SchemaDetailsDto)) && !this.isSameCategory(schema);
    }

    constructor(
        private readonly localStore: LocalStoreService,
        private readonly schemasState: SchemasState
    ) {
    }

    public ngOnInit() {
        this.isOpen = this.localStore.get(`schema-category.${this.name}`) !== 'false';
    }

    public toggle() {
        this.isOpen = !this.isOpen;

        this.localStore.set(`schema-category.${this.name}`, this.isOpen + '');
    }

    public ngOnChanges(changes: SimpleChanges): void {
        if (changes['schemas'] || changes['schemasFilter']) {
            const query = this.schemasFilter;

            this.schemasForCategory = this.schemas.filter(x => this.isSameCategory(x));
            this.schemasFiltered = this.schemasForCategory.filter(x => !query || x.name.indexOf(query) >= 0);
        }

        if (changes['name']) {
            if (!this.name || this.name.length === 0) {
                this.displayName = 'Schemas';
            } else {
                this.displayName = this.name;
            }
        }
    }

{'fraction_non_alphanumeric': 0.1261682242990654, 'fraction_numerical': 0.0008496176720475786, 'mean_word_length': 2.7945205479452055, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '3833795', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1367, 'n_words': 296}