<template>
  <div class="text-center">
    <div class="row items-center justify-center q-gutter-md q-ma-xs">

      <q-list bordered class="rounded-borders">
        <q-expansion-item v-for="(rec, index) in shared_consts.TypeNotifs_Arr"
                          :key="index"
                          expand-separator
                          :icon="rec.icon"
                          default-opened
                          :label="t(rec.labeltrans)"
        >
          <q-card>
            <q-card-section v-if="!!rec">
              <div>{{ t(rec.descr) }}</div>

              <CMyFieldDb
                title=""
                table="users"
                mykey="profile"
                mysubkey="notifs"
                :specialField="{
                  findsubkey: (myrec) => myrec.dir === rec.value,
                  paramtosetsubkey: 'value',
                  paramdef: rec.value,
                  defaultnewrec: { dir: rec.value},
                }"
                jointable="usernotifs"
                tablesel="usernotifs"
                :filter="(myrec) => myrec.directory === rec.value"
                :type="costanti.FieldType.binary">
              </CMyFieldDb>

              <div v-if="rec.value === shared_consts.TypeNotifs.TYPEDIR_BACHECA">
                <div
                  v-if="tools.isBitActive(getnotifbydir(shared_consts.TypeNotifs.TYPEDIR_BACHECA), shared_consts.UsersNotif.NEW_ADV_SECTOR)">
                  {{$t('sectors.sector_select_details')}}
                  <br>
                  <CMyFieldDb
                    :title="$t('sectors.sector_goods_select')"
                    table="users"
                    mykey="profile"
                    mysubkey="notif_sector_goods"
                    :jointable="toolsext.TABSECTORGOODS"
                    :type="costanti.FieldType.multiselect">
                  </CMyFieldDb>
                  <CMyFieldDb
                    :title="$t('sectors.sector_select')"
                    table="users"
                    mykey="profile"
                    mysubkey="notif_sectors"
                    :jointable="toolsext.TABSECTORS"
                    :type="costanti.FieldType.multiselect">
                  </CMyFieldDb>
                </div>
                <div
                  v-if="tools.isBitActive(getnotifbydir(shared_consts.TypeNotifs.TYPEDIR_BACHECA), shared_consts.UsersNotif.NEW_ADV_REGION)">
                  <CMyFieldDb
                    :title="$t('notifs.select_regions')"
                    table="users"
                    mykey="profile"
                    mysubkey="notif_regions"
                    :jointable="toolsext.TABREGIONS"
                    :type="costanti.FieldType.multiselect">
                  </CMyFieldDb>
                </div>
                <div
                  v-if="tools.isBitActive(getnotifbydir(shared_consts.TypeNotifs.TYPEDIR_BACHECA), shared_consts.UsersNotif.NEW_ADV_PROVINCE)">
                  <CMyFieldDb
                    :title="$t('notifs.select_provinces')"
                    table="users"
                    mykey="profile"
                    mysubkey="notif_provinces"
                    :jointable="toolsext.TABPROVINCE"
                    :type="costanti.FieldType.multiselect">
                  </CMyFieldDb>
                </div>

                <!--<CMyFieldDb
                  :title="$t('notification.cities')"
                  table="users"
                  mykey="profile"
                  mysubkey="notif_cities"
                  :jointable="shared_consts.TAB_CITIES"
                  :type="costanti.FieldType.multiselect_by_server">
                </CMyFieldDb>-->


              </div>

            </q-card-section>
          </q-card>
        </q-expansion-item>
      </q-list>
    </div>
  </div>
</template>

<script lang="ts" src="./CNotifSettings.ts">
</script>

<style lang="scss" scoped>
@import './CNotifSettings.scss';
</style>
