import {Component} from '@angular/core';

import {TransactionService} from 'm2-core';
import {CdDemoComponent} from '../../../abstract/CdDemoComponent';


@Component({
    template: `
        <section class="cd-content-section">
            <h4 i18n>Кнопка управления пакетами изменений</h4>

            <div class="mt-3 d-flex align-items-center">
                <transaction-button-group 
                        [formTxNameFn]="formTxNameFn"
                >
                </transaction-button-group>
                
                <div *ngIf="activeTx$ | async as activeTx" class="ml-4">
                    <i class="sdi-status online">{{activeTx.displayName | noName}}</i>
                </div>
            </div>
        </section>
    `
})
export class CdTransactionButtonDemoComponent extends CdDemoComponent {

    constructor(
        private txService: TransactionService
    ) {
        super();
    }

    formTxNameFn = () => $localize`Пакет изменений, созданный в демо-плагине`;

    activeTx$ = this.txService.activeTx$;

}
