<vdr-action-bar>
    <vdr-ab-left>
        <vdr-language-selector
            [disabled]="isNew$ | async"
            [availableLanguageCodes]="availableLanguages$ | async"
            [currentLanguageCode]="languageCode$ | async"
            (languageCodeChange)="setLanguage($event)"
        ></vdr-language-selector>
    </vdr-ab-left>
    <vdr-ab-right>
        <button
            class="btn btn-primary"
            *ngIf="(isNew$ | async); else: updateButton"
            (click)="create()"
            [disabled]="detailForm.invalid || detailForm.pristine"
        >
            {{ 'common.create' | translate }}
        </button>
        <ng-template #updateButton>
            <button
                class="btn btn-primary"
                (click)="save()"
                [disabled]="detailForm.invalid || detailForm.pristine"
            >
                {{ 'common.update' | translate }}
            </button>
        </ng-template>
    </vdr-ab-right>
</vdr-action-bar>

<form class="form" [formGroup]="detailForm">
    <section class="form-block">
        <vdr-form-field [label]="'common.code' | translate" for="code">
            <input id="code" type="text" formControlName="code" />
        </vdr-form-field>
        <vdr-form-field [label]="'common.name' | translate" for="name">
            <input id="name" type="text" formControlName="name" />
        </vdr-form-field>
        <vdr-form-field [label]="'common.enabled' | translate" for="enabled">
            <div class="toggle-switch">
                <input type="checkbox" id="enabled" formControlName="enabled" />
                <label for="enabled"></label>
            </div>
        </vdr-form-field>
    </section>
</form>
