All files / app/features/picture/pages/picture-detail picture-detail.component.html

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 1661x                                                                                                                                                                                                                                                                                                                                          
@if (picture(); as pic) {
    <app-sidebar-action
        [order]="10"
        icon="content_copy"
        label="Копировать код вставки"
        priority="secondary"
        (activated)="copyInsertCode()"
    />
    @if (canEdit()) {
        <app-sidebar-action
            [order]="20"
            icon="edit"
            label="Изменить"
            priority="primary"
            (activated)="editPicture()"
        />
    }
    <div class="detail__card">
        <div
            class="detail__image"
            (click)="onImageClick()"
            (keydown.enter)="onImageClick()"
            (keydown.space)="onImageClick(); $event.preventDefault()"
            tabindex="0"
            role="button"
            data-testid="detail-image"
        >
            <img
                [src]="pic.imageUrl"
                [alt]="pic.title"
                loading="eager"
            />
        </div>
        <div class="detail__info">
            <div class="detail__section">
                <div class="detail__label">Описание</div>
                @if (isEditingTitle()) {
                    <div
                        class="detail__title-edit"
                        data-testid="detail-title-edit"
                    >
                        <textarea
                            #titleInput
                            class="detail__title-input"
                            rows="4"
                            [formControl]="titleControl"
                            [disabled]="isSavingTitle()"
                            (input)="autoResizeTextarea()"
                            (keydown.enter)="onTitleEnter($event)"
                            (keydown.escape)="cancelTitleEdit()"
                            (blur)="onTitleBlur()"
                            data-testid="detail-title-input"
                        ></textarea>
                        @if (titleControl.invalid && titleControl.dirty) {
                            <div
                                class="detail__title-error"
                                data-testid="detail-title-error"
                            >
                                @if (titleControl.hasError('required') || titleControl.hasError('minlength')) {
                                    Минимум 5 символов
                                } @else if (titleControl.hasError('maxlength')) {
                                    Максимум 500 символов
                                }
                            </div>
                        }
                        <div class="detail__title-hint">Enter — сохранить, Esc — отмена</div>
                    </div>
                } @else {
                    <div
                        class="detail__value"
                        [class.detail__value--editable]="canEdit()"
                        [attr.tabindex]="canEdit() ? 0 : null"
                        [attr.role]="canEdit() ? 'button' : null"
                        [attr.aria-label]="canEdit() ? 'Редактировать описание' : null"
                        (click)="startTitleEdit()"
                        (keydown.enter)="startTitleEdit()"
                        (keydown.space)="startTitleEdit(); $event.preventDefault()"
                        data-testid="detail-title"
                    >
                        {{ displayTitle() }}
                    </div>
                }
            </div>
            <div class="detail__section">
                <div class="detail__label">Кто разместил</div>
                <div
                    class="detail__value"
                    data-testid="detail-author"
                >
                    {{ pic.user }}
                </div>
            </div>
            <div class="detail__section">
                <div class="detail__label">Последнее обновление</div>
                <div class="detail__value">{{ pic.date | formatDate }}</div>
            </div>
            @if (pic.width && pic.height) {
                <div class="detail__section">
                    <div class="detail__label">Размер</div>
                    <div
                        class="detail__value"
                        data-testid="detail-dimensions"
                    >
                        {{ pic.width }} × {{ pic.height }} px
                    </div>
                </div>
            }
            <div class="detail__section">
                <div class="detail__label">Используется в статьях</div>
                @if (articlesLoading()) {
                    <ui-spinner
                        [diameter]="24"
                        [strokeWidth]="3"
                        data-testid="detail-articles-loading"
                    />
                } @else if (articles(); as articleList) {
                    @if (articleList.length > 0) {
                        <div
                            class="detail__articles"
                            data-testid="detail-articles"
                        >
                            @for (article of articleList; track article.id) {
                                <a
                                    class="detail__article-link"
                                    [routerLink]="['/articles', article.id]"
                                    data-testid="detail-article-link"
                                >
                                    {{ article.title }}
                                </a>
                            }
                        </div>
                    } @else {
                        <div
                            class="detail__value detail__value--muted"
                            data-testid="detail-articles-empty"
                        >
                            Нет
                        </div>
                    }
                } @else {
                    <div
                        class="detail__value detail__value--muted"
                        data-testid="detail-articles-error"
                    >
                        Не удалось загрузить
                    </div>
                }
            </div>
        </div>
    </div>
} @else if (isLoadError()) {
    <app-error
        title="Ошибка загрузки"
        message="Не удалось загрузить данные иллюстрации. Попробуйте обновить страницу."
        [showHomeButton]="true"
        data-testid="detail-load-error"
    />
} @else {
    <app-error
        title="Иллюстрация не найдена"
        message="Запрашиваемая иллюстрация не существует или была удалена."
        [showHomeButton]="true"
        data-testid="detail-error"
    />
}