<commit_before><template>
    <b-tab :title="langTabTitle">
        <b-card v-for="(row, index) in form.permissions.station.$each.$iter" :key="index" class="mb-3" no-body>
            <div class="card-header bg-primary-dark d-flex align-items-center">
                <div class="flex-fill">
                    <h2 class="card-title">
                        {{ getStationName(row.station_id.$model) }}
                    </h2>
                </div>
                <div class="flex-shrink-0">
                    <b-button size="sm" variant="outline-light" class="py-2 pr-0" @click.prevent="remove(index)">
                        <icon icon="remove"></icon>
                        <translate key="lang_btn_remove">Remove</translate>
                    </b-button>
                </div>
            </div>
            <b-card-body>
                <b-form-group>
                    <b-row>
                        <b-wrapped-form-group class="col-md-12" :id="'edit_form_station_permissions_'+row.station_id.$model"
                                              :field="row.permissions">
                            <template #label>
                                <translate key="lang_form_station_permission">Station Permissions</translate>
                            </template>
                            <template #description>
                                <translate key="lang_form_station_permission_desc">Users with this role will have these permissions for this single station.</translate>
                            </template>
                            <template #default="props">
                                <b-form-checkbox-group :id="props.id" :options="stationPermissionOptions"
                                                       v-model="props.field.$model">
                                </b-form-checkbox-group>
                            </template>
                        </b-wrapped-form-group>
                    </b-row>
                </b-form-group>
            </b-card-body>
        </b-card>

        <b-button-group v-if="hasRemainingStations">
            <b-dropdown size="sm" variant="outline-primary">
                <template #button-content>
                    <translate key="lang_btn_add_station">Add Station</translate>
                </template>
                <b-dropdown-item-button v-for="(stationName, stationId) in remainingStations" :key="stationId"
                    @click="add(stationId)">{{ stationName }}</b-dropdown-item-button>
            </b-dropdown>
        </b-button-group>
    </b-tab>
</template>

<script>
import BWrappedFormGroup from "~/components/Form/BWrappedFormGroup";
import Icon from "~/components/Common/Icon";
import _ from 'lodash';

export default {
    name: 'AdminPermissionsStationForm',
    components: {BWrappedFormGroup, Icon},
    props: {
        form: Object,
        stations: Object,
        stationPermissions: Object
    },
    computed: {
        langTabTitle() {
            return this.$gettext('Station Permissions');
        },
        stationPermissionOptions() {
            return _.map(this.stationPermissions, (permissionName, permissionKey) => {
                return {
                    text: permissionName,
                    value: permissionKey<commit_msg>Fixes #4666 -- Make station dropdown vertically scroll at certain height.<commit_after><template>
    <b-tab :title="langTabTitle">
        <b-card v-for="(row, index) in form.permissions.station.$each.$iter" :key="index" class="mb-3" no-body>
            <div class="card-header bg-primary-dark d-flex align-items-center">
                <div class="flex-fill">
                    <h2 class="card-title">
                        {{ getStationName(row.station_id.$model) }}
                    </h2>
                </div>
                <div class="flex-shrink-0">
                    <b-button size="sm" variant="outline-light" class="py-2 pr-0" @click.prevent="remove(index)">
                        <icon icon="remove"></icon>
                        <translate key="lang_btn_remove">Remove</translate>
                    </b-button>
                </div>
            </div>
            <b-card-body>
                <b-form-group>
                    <b-row>
                        <b-wrapped-form-group class="col-md-12" :id="'edit_form_station_permissions_'+row.station_id.$model"
                                              :field="row.permissions">
                            <template #label>
                                <translate key="lang_form_station_permission">Station Permissions</translate>
                            </template>
                            <template #description>
                                <translate key="lang_form_station_permission_desc">Users with this role will have these permissions for this single station.</translate>
                            </template>
                            <template #default="props">
                                <b-form-checkbox-group :id="props.id" :options="stationPermissionOptions"
                                                       v-model="props.field.$model">
                                </b-form-checkbox-group>
                            </template>
                        </b-wrapped-form-group>
                    </b-row>
                </b-form-group>
            </b-card-body>
        </b-card>

        <b-button-group v-if="hasRemainingStations">
            <b-dropdown size="sm" variant="outline-primary">
                <template #button-content>
                    <translate key="lang_btn_add_station">Add Station</translate>
                </template>
                <div style="max-height: 300px; overflow-y: auto;">
                    <b-dropdown-item-button v-for="(stationName, stationId) in remainingStations" :key="stationId"
                                            @click="add(stationId)">{{ stationName }}
                    </b-dropdown-item-button>
                </div>
            </b-dropdown>
        </b-button-group>
    </b-tab>
</template>

<script>
import BWrappedFormGroup from "~/components/Form/BWrappedFormGroup";
import Icon from "~/components/Common/Icon";
import _ from 'lodash';

export default {
    name: 'AdminPermissionsStationForm',
    components: {BWrappedFormGroup, Icon},
    props: {
        form: Object,
        stations: Object,
        stationPermissions: Object
    },
    computed: {
        langTabTitle() {
            return this.$gettext('Station Permissions');
        },
        stationPermissionOptions() {
            return _.map(this.stationPermissions, (permissionName, permissionKey) => {
                return {
                    text: permissionName,
                    value: permissionKey
{'fraction_non_alphanumeric': 0.12185430463576159, 'fraction_numerical': 0.003384841795437822, 'mean_word_length': 1.4202279202279202, 'pattern_counts': {'":': 0, '<': 107, '<?xml version=': 0, '>': 109, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4152671', 'n_tokens_mistral': 1745, 'n_tokens_neox': 1662, 'n_words': 304}