<template>
  <div class="ButtonsBlock" v-if="selected.length">
    <r-selection-filter
      v-if="
        $AC.haveOneOfScope([
          $AC.scopes.MILITARY_RECRUIT_SPECIALIST,
        ])
      "
      :selected="selected"
      :filter="checkStatuses(['15'])"
    >
      <template #default="props">
        <multi-add-to-list
          :model="props.filtred"
          :sign="false"
          class="DopButton-Button"
          process-key="milBaseMassSignProcess"
          action-type="addToSummonList"
          label="Добавить в список на вызов"
          default-time="09:00"
          :personRegistryListFilter="personRegistryListFilter"
          :disabled="selected.length > 50"
          @done="onReload"
        />
      </template>
    </r-selection-filter>
  </div>
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import MultiInit from '@/recruits/components/dialogs/MultiInit.vue';
import MultiAddToList from '@/recruits/components/dialogs/MultiAddToList.vue';
import { SearchRecruitResponse } from '@/recruits/openapi/person-registry';
import RSelectionFilter from '@/recruits/components/common/r-selection-filter.vue';

@Component({
  components: {
    MultiInit,
    MultiAddToList,
    RSelectionFilter,
  },
})
export default class ListButtons extends Vue {
  @Prop({ default: () => [] }) selected: SearchRecruitResponse[];

  personRegistryListFilter = {
    statuses: ['1'],
    summonObjectiveNotAll: ['101'],
  };

  public onReload(): void {
    this.$emit('onReload');
  }

  public checkStatuses(
    currentStatuses: string[]
  ): { (selected: SearchRecruitResponse): boolean } {
    return (selected) => currentStatuses.includes(selected.status);
  }
}
</script>

<style lang="scss">
.ButtonsBlock {
  display: flex;
  flex-flow: row;
  align-items: flex-start;
  gap: 16px;
}
.DopButton {
  box-sizing: border-box;
  background-color: rgba(15, 32, 160, 0.08);
  border-radius: 20px;
  padding: 4px;
  margin-top: -5px;
  margin-bottom: -5px;
  &-TextFiled {
    margin-left: 8px;
    margin-right: 8px;
    font-family: 'Golos UI', sans-serif;
    font-style: normal;
    font-weight: 400;
    font-size: 14px;
    line-height: 16px;
    color: rgba(2, 12, 18, 0.58);
  }
}
</style>
