<template>
  <div
    v-if="myel"
    :class="
      (editOn ? ` clEditDiv` : ``) +
      `` +
      (!myel.active ? ` clEditNotActive` : ``)
    "
  >
    <div v-if="!!myel.type">
      <div class="row justify-evenly q-gutter-sm">
        <q-btn
          class="q-ma-sm"
          dense
          @click="toggleSize"
          label="Espandi"
          icon="chevron_left"
          color="primary"
        />
        <q-btn
          v-if="enableAdd"
          class="q-ma-sm"
          label="Aggiungi"
          icon-right="arrow_upward"
          color="positive"
          dense
          @click="
            direzadd = -1;
            visuadd = true;
          "
        >
        </q-btn>
        <q-btn
          v-if="enableAdd"
          class="q-ma-sm"
          label="Aggiungi"
          icon-right="arrow_downward"
          color="positive"
          dense
          @click="
            direzadd = 1;
            visuadd = true;
          "
        >
        </q-btn>
      </div>
      <q-bar v-if="enableEdit" class="q-pa-md bg-light-blue text-white">
        <!--<q-toggle v-if="tools.isManager()"
                v-model="enableAdd"
                icon="fas fa-plus"
      </q-toggle>
      >-->
        &nbsp;

        <q-space />
        <q-btn
          icon="fas fa-trash-alt"
          color="negative"
          label="Elimina"
          dense
          size="sm"
          @click="delElem"
        >
        </q-btn>
        <q-btn
          icon="far fa-copy"
          label="Duplica"
          dense
          size="sm"
          @click="dupElem(myel.order + 10 * direzadd)"
        >
        </q-btn>
      </q-bar>
      <div class="fixed-button">
        <div class="justify-center row q-ma-xs">
          <q-btn
            dense
            v-if="enableEdit && !disableSave"
            icon="fas fa-check"
            color="positive"
            label="Salva Modifiche"
            :disable="disableSave"
            @click="saveElem"
          >
          </q-btn>
          <!--<q-btn
            dense
            v-if="enableEdit && !disableSave"
            icon="fas fa-check"
            color="positive"
            label="Salva"
            :disable="disableSave"
            @click="saveElem(true)"
          >
          </q-btn>-->
        </div>
      </div>
      <q-list padding bordered class="rounded-borders">
        <q-expansion-item
          dense
          dense-toggle
          expand-separator
          label="Visualizzazione"
          icon="fas fa-eye"
        >
          <div class="row q-gutter-sm q-pa-sm">
            <q-toggle
              v-model="myel.active"
              color="positive"
              icon="fas fa-eye"
              label="Attiva"
            >
            </q-toggle>
            <q-select
              v-model="neworder"
              :options="orderOptions"
              label="Posizionamento"
              options-dense
              dense
              emit-value
              map-options
              style="width: 100px"
              @update:model-value="modifElem"
              use-input
              hide-selected
              fill-input
              text-color="white"
              @new-value="addOrder"
            >
            </q-select>
          </div>
        </q-expansion-item>
        <q-btn
          v-if="enableAdd"
          class="q-ma-sm"
          label="Sposta in SU"
          icon-right="arrow_upward"
          color="positive"
          dense
          @click="moveElem(-1)"
        >
        </q-btn>
        <q-btn
          v-if="enableAdd"
          class="q-ma-sm"
          label="Sposta in GIU"
          icon-right="arrow_downward"
          color="positive"
          dense
          @click="moveElem(1)"
        >
        </q-btn>

        <q-expansion-item
          dense
          dense-toggle
          expand-separator
          label="Dimensioni"
          icon="fas fa-expand-alt"
        >
          <div class="row">
            <q-select
              label="Lunghezza:"
              v-model="myel.widthimg"
              emit-value
              map-options
              :options="generateSizeOptions()"
              use-input
              use-chips
              @input="modifElem"
              @new-value="updateSizeWidth"
              filled
              dense
              style="width: 150px"
            />
            <q-select
              label="Altezza:"
              v-model="myel.heightimg"
              emit-value
              map-options
              :options="generateSizeOptions()"
              use-input
              use-chips
              @input="saveElem"
              filled
              dense
              @new-value="updateSizeHeight"
              style="width: 150px"
            />
            <q-select
              label="Altezza Carosello:"
              v-if="
                myel.type === shared_consts.ELEMTYPE.CARD ||
                myel.type === shared_consts.ELEMTYPE.GRID_ORIZ
              "
              v-model="myel.heightcarousel"
              emit-value
              map-options
              :options="generateSizeOptions()"
              use-input
              use-chips
              @input="saveElem"
              filled
              dense
              @new-value="updateSizeHeight"
              style="width: 150px"
            />
          </div>
        </q-expansion-item>

        <q-expansion-item
          dense
          dense-toggle
          expand-separator
          label="Allineamento"
          icon="fas fa-align-center"
        >
          <div class="row">
            <q-select
              :behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'"
              v-if="enableEdit"
              rounded
              outlined
              v-model="myel.align"
              :options="tools.SelectListAlign"
              @update:model-value="modifElem"
              dense
              label="Allinea"
              style="width: 100px"
              emit-value
              map-options
              @save="saveCard"
            >
            </q-select>
            <q-select
              :behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'"
              v-if="enableEdit"
              rounded
              outlined
              v-model="myel.vertalign"
              :options="tools.SelectListVertAlign"
              @update:model-value="modifElem"
              dense
              label="Vert Allinea"
              style="min-width: 150px"
              emit-value
              map-options
            >
            </q-select>
            <q-select
              :behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'"
              v-if="enableEdit"
              rounded
              style="min-width: 150px"
              outlined
              v-model="myel.class"
              :options="tools.SelectListClass"
              @update:model-value="modifElem"
              dense
              label="Classe"
              emit-value
              map-options
            >
            </q-select>
            <q-select
              :behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'"
              v-if="enableEdit && showFit"
              rounded
              style="width: 100px"
              outlined
              v-model="myel.fit"
              :options="tools.SelectListFit"
              @update:model-value="modifElem"
              dense
              label="Adatta:"
              emit-value
              map-options
            >
            </q-select>
          </div>
          <div class="row">
            <q-input
              dense
              label="Classe:"
              @update:model-value="modifElem"
              v-model="myel.class2"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
          </div>
        </q-expansion-item>
        <q-expansion-item
          dense
          dense-toggle
          expand-separator
          label="Animazione"
          icon="fas fa-play-circle"
        >
          <CSelectAnimation
            v-if="enableEdit && showAnimation"
            v-model="myel.anim"
            @update:model-value="modifElem"
          >
          </CSelectAnimation>
        </q-expansion-item>
        <q-expansion-item
          dense
          dense-toggle
          expand-separator
          label="Banner Iniziale"
          icon="fas fa-play-circle"
        >
          <div>Banner:</div>

          <q-input
            dense
            label="Titolo Banner:"
            @update:model-value="modifElem"
            v-model="myel.titleBanner"
            filled
            v-on:keyup.enter="saveElem"
          >
          </q-input>
          <q-input
            dense
            label="Classe Banner:"
            @update:model-value="modifElem"
            v-model="myel.classBanner"
            filled
            v-on:keyup.enter="saveElem"
          >
          </q-input>
          <CSelectColor
            v-if="enableEdit"
            style="min-width: 150px"
            v-model="myel.color"
            @update:model-value="modifElem"
            title="Colore Titolo"
          >
          </CSelectColor>
        </q-expansion-item>
        <div v-if="myel.type === shared_consts.ELEMTYPE.TEXT">
          <div v-if="enableEdit">
            <q-input
              class="fa-border"
              @update:model-value="modifElem"
              v-model="myel.container"
              dense
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
          </div>
        </div>
        <div
          v-else-if="myel.type === shared_consts.ELEMTYPE.CARD"
          :class="myel.span ? '' : ''"
        >
          <q-select
            v-model="myel.num2"
            :options="[
              { label: '1', value: 1 },
              { label: '2', value: 2 },
              { label: '3', value: 3 },
              { label: '4', value: 4 },
            ]"
            label="Cards per Slide"
            emit-value
            map-options
            style="min-width: 120px"
            @input="saveElem"
          >
          </q-select>
          <q-expansion-item
            dense
            dense-toggle
            expand-separator
            label="Classi per l'Immagine"
            icon="fas fa-expand-alt"
          >
            <q-select
              label="Classi:"
              v-model="selectedClasses"
              emit-value
              map-options
              :options="classiImmagineOptions()"
              use-chips
              multiple
              @update:model-value="updateClass4"
              filled
              dense
              style="width: 350px"
            />
          </q-expansion-item>
          <div class="row">
            <q-input
              dense
              label="Classe Schede:"
              @update:model-value="modifElem"
              v-model="myel.class3"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
          </div>
          <q-btn
            rounded
            dense
            color="primary"
            label="Scheda"
            icon="fas fa-plus"
            @click="addNewCard"
          >
          </q-btn>
          <q-btn
            rounded
            dense
            color="primary"
            label="Scheda"
            icon="fas fa-copy"
            @click="dupNewCard"
          >
          </q-btn>

          <q-tabs
            v-model="tabCard"
            dense
            class="text-grey"
            active-color="primary"
            indicator-color="primary"
            align="justify"
            narrow-indicator
          >
            <q-tab
              v-for="(rec, ind) in myel.listcards"
              :key="ind"
              :name="ind"
              :label="`Scheda ` + (ind + 1)"
              icon="fas fa-pencil-alt"
            />
          </q-tabs>

          <q-tab-panels v-model="tabCard" animated>
            <q-tab-panel
              v-for="(rec, ind) in myel.listcards"
              :key="ind"
              :name="ind"
            >
              <div v-if="enableEdit" class="column bordered q-ma-xs">
                <q-bar class="bg-primary text-white">
                  Scheda {{ ind + 1 }}
                  <q-space />
                  <q-btn
                    icon="fas fa-trash-alt"
                    color="negative"
                    dense
                    size="sm"
                    @click="delRecCard(rec._id, myel)"
                  >
                  </q-btn>
                </q-bar>

                <CMyFieldRec
                  title="Immagine:"
                  table="imgcards"
                  :id="rec._id"
                  :rec="rec"
                  field="imagefile"
                  @update:model-value="modifElem"
                  :canEdit="true"
                  :canModify="true"
                  :nosaveToDb="true"
                  :path="myel.path"
                  :fieldtype="costanti.FieldType.imgcard"
                  @save="saveCard"
                >
                </CMyFieldRec>

                <div v-if="enableEdit" class="row">
                  <q-input
                    dense
                    style="min-width: 150px"
                    label="Titolo:"
                    class="fa-border"
                    @update:model-value="modifElem"
                    v-model="rec.alt"
                    filled
                    v-on:keyup.enter="saveElem"
                  >
                  </q-input>
                  <q-input
                    dense
                    style="min-width: 150px"
                    label="Style:"
                    class="fa-border"
                    @update:model-value="modifElem"
                    v-model="rec.style"
                    filled
                    v-on:keyup.enter="saveElem"
                  >
                  </q-input>
                  <q-input
                    dense
                    style="min-width: 450px"
                    label="Link:"
                    class="fa-border"
                    @update:model-value="modifElem"
                    v-model="rec.link"
                    filled
                    v-on:keyup.enter="saveElem"
                  >
                  </q-input>
                  <CSelectColor
                    v-if="enableEdit"
                    style="min-width: 150px"
                    v-model="rec.color"
                    @update:model-value="modifElem"
                    title="Col Titolo"
                  >
                  </CSelectColor>
                  <CSelectFontSize
                    v-if="enableEdit"
                    style="min-width: 200px"
                    v-model="rec.size"
                    @update:model-value="modifElem"
                    title="Font Titolo"
                  >
                  </CSelectFontSize>
                </div>
                <CMyEditor
                  v-model:value="rec.content"
                  title="Contenuto:"
                  @keyup.enter.stop
                  :showButtons="false"
                  :canModify="true"
                  @update:value="modifElem"
                  @showandsave="saveElem"
                >
                </CMyEditor>

                <q-input
                  label="Sottotitolo:"
                  class="fa-border"
                  dense
                  @update:model-value="modifElem"
                  v-model="rec.description"
                  filled
                  v-on:keyup.enter="saveElem"
                >
                </q-input>
              </div>
              <div v-if="enableEdit" class="row">
                <CSelectColor
                  v-if="enableEdit"
                  v-model="rec.colorsub"
                  @update:model-value="modifElem"
                  title="Col Sottotitolo"
                >
                </CSelectColor>
              </div>
            </q-tab-panel>
          </q-tab-panels>
        </div>

        <div v-else-if="myel.type === shared_consts.ELEMTYPE.MARGINI">
          <div v-if="enableEdit">
            <q-input
              dense
              label="Margine:"
              class="fa-border"
              @update:model-value="modifElem"
              v-model="myel.size"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
          </div>
        </div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.TITLE">
          <div v-if="enableEdit">
            <q-input
              dense
              label="Titolo"
              class="fa-border"
              @update:model-value="modifElem"
              v-model="myel.title"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
            <q-input
              dense
              label="Style"
              class="fa-border"
              @update:model-value="modifElem"
              v-model="myel.styleadd"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
            <q-input
              dense
              label="Immagine:"
              class="fa-border"
              @update:model-value="modifElem"
              v-model="myel.imgback"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
          </div>
        </div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.IMGTITLE">
          <div v-if="enableEdit">
            <CMyFieldRec
              title="Immagine:"
              table="myelems"
              :id="myel._id"
              :rec="myel"
              field="image"
              @update:model-value="modifElem"
              :canEdit="true"
              :canModify="true"
              :fieldtype="costanti.FieldType.image"
            >
            </CMyFieldRec>

            <q-input
              dense
              label="Title"
              class="fa-border"
              @update:model-value="modifElem"
              v-model="myel.container"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
            <q-input
              dense
              label="Sottotitolo"
              class="fa-border"
              @update:model-value="modifElem"
              v-model="myel.container2"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
          </div>
        </div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.IMGPOSTER">
          <div v-if="enableEdit">
            <q-input
              dense
              label="Velocità"
              style="max-width: 100px"
              class="fa-border"
              @update:model-value="modifElem"
              v-model="myel.speed"
              type="number"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
            <CMyFieldRec
              title="Immagine:"
              table="myelems"
              :id="myel._id"
              :rec="myel"
              field="image"
              @update:model-value="modifElem"
              :canEdit="true"
              :canModify="true"
              :fieldtype="costanti.FieldType.image"
            >
            </CMyFieldRec>
            <CMyFieldRec
              title="Logo:"
              table="myelems"
              :id="myel._id"
              :rec="myel"
              field="img"
              @update:model-value="modifElem"
              :canEdit="true"
              :canModify="true"
              :fieldtype="costanti.FieldType.image"
            >
            </CMyFieldRec>
            <div class="row">
              <q-select
                label="Lunghezza Logo:"
                v-model="myel.widthimg"
                emit-value
                map-options
                :options="generateSizeOptions()"
                use-input
                use-chips
                @input="saveElem"
                filled
                dense
                @new-value="updateSizeWidth"
                style="width: 150px"
              />

              <q-select
                label="Altezza Logo:"
                v-model="myel.heightimg"
                emit-value
                map-options
                :options="generateSizeOptions()"
                use-input
                use-chips
                @input="saveElem"
                filled
                dense
                @new-value="updateSizeHeight"
                style="width: 150px"
              />
            </div>

            <q-btn
              rounded
              dense
              color="primary"
              label="Testo"
              icon="fas fa-plus"
              @click="addNewElemText"
            >
            </q-btn>

            <q-tabs
              v-model="tabElemsText"
              dense
              class="text-grey"
              active-color="primary"
              indicator-color="primary"
              align="justify"
              narrow-indicator
            >
              <q-tab
                v-for="(rec, ind) in myel.elemsText"
                :key="ind"
                :name="`elem` + ind"
                :label="`Testo ` + (ind + 1)"
                icon="fas fa-pencil-alt"
              />
            </q-tabs>

            <q-tab-panels v-model="tabElemsText" animated>
              <q-tab-panel
                v-for="(rec, ind) in myel.elemsText"
                :key="ind"
                :name="`elem` + ind"
              >
                <div v-if="enableEdit" class="column bordered q-ma-xs">
                  <q-bar class="bg-primary text-white">
                    Elem {{ ind + 1 }}
                    <q-space />
                    <q-btn
                      icon="fas fa-trash-alt"
                      color="negative"
                      dense
                      size="sm"
                      @click="delRecCard(rec._id, myel)"
                    >
                    </q-btn>
                  </q-bar>
                  <div v-if="enableEdit" class="row">
                    <CSelectColor
                      v-if="enableEdit"
                      style="min-width: 150px"
                      v-model="rec.color"
                      @update:model-value="modifElem"
                      title="Col Titolo"
                    >
                    </CSelectColor>
                    <CSelectFontSize
                      v-if="enableEdit"
                      style="min-width: 200px"
                      v-model="rec.size"
                      @update:model-value="modifElem"
                      title="Font Titolo"
                    >
                    </CSelectFontSize>
                  </div>
                  <q-input
                    dense
                    label="Classe:"
                    @update:model-value="modifElem"
                    v-model="rec.class"
                    filled
                    v-on:keyup.enter="saveElem"
                  >
                  </q-input>
                  <CMyEditor
                    v-model:value="rec.text"
                    title="Contenuto:"
                    @keyup.enter.stop
                    :showButtons="false"
                    :canModify="true"
                    @update:value="modifElem"
                    @showandsave="saveElem"
                  >
                  </CMyEditor>
                  <CSelectAnimation
                    v-if="enableEdit && showAnimation"
                    v-model="rec.anim"
                    @update:model-value="modifElem"
                    label="Animazione"
                  >
                  </CSelectAnimation>
                </div>
              </q-tab-panel>
            </q-tab-panels>
          </div>
        </div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.HTML">
          <div v-if="enableEdit">
            <CMyEditor
              v-model:value="myel.containerHtml"
              title=""
              @keyup.enter.stop
              :showButtons="false"
              :canModify="true"
              @update:value="modifElem"
              @showandsave="saveElem"
            >
            </CMyEditor>
          </div>
        </div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.IMAGE">
          <div v-if="enableEdit">
            <q-input
              label="NomeFile Img:"
              @update:model-value="modifElem"
              v-model="myel.image"
              filled
              dense
              v-on:keyup.enter="saveElem"
            >
            </q-input>
            <CMyFieldRec
              title="NomeFile Img:"
              table="myelems"
              :id="myel._id"
              :rec="myel"
              field="image"
              @update:model-value="modifElem"
              :canEdit="true"
              :canModify="true"
              :fieldtype="costanti.FieldType.image"
            >
            </CMyFieldRec>
            <CMyFieldRec
              title="Versione Img:"
              table="myelems"
              :id="myel._id"
              :rec="myel"
              field="vers_img"
              @update:model-value="modifElem"
              :canEdit="true"
              :canModify="true"
              :fieldtype="costanti.FieldType.number"
            >
            </CMyFieldRec>
          </div>
        </div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.QRCODE">
          <div v-if="enableEdit">
            <q-input
              dense
              label="Link:"
              @update:model-value="modifElem"
              v-model="myel.container"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
            <q-input
              dense
              label="Testo Link:"
              @update:model-value="modifElem"
              v-model="myel.container2"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
            <q-toggle
              v-model="myel.parambool"
              color="positive"
              label="Leggi"
              @update:model-value="modifElem"
            ></q-toggle>
            <q-input
              label="NomeFile Img:"
              @update:model-value="modifElem"
              v-model="myel.image"
              filled
              dense
              v-on:keyup.enter="saveElem"
            >
            </q-input>
            <CMyFieldRec
              title="NomeFile Img:"
              table="myelems"
              :id="myel._id"
              :rec="myel"
              field="image"
              @update:model-value="modifElem"
              :canEdit="true"
              :canModify="true"
              :path="myel.path"
              :fieldtype="costanti.FieldType.image"
            >
            </CMyFieldRec>
          </div>
        </div>

        <div v-else-if="myel.type === shared_consts.ELEMTYPE.IMAGEUPLOAD">
          <div v-if="enableEdit">
            <q-input
              dense
              label="NomeFile Img:"
              @update:model-value="modifElem"
              v-model="myel.image"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
            <CMyFieldRec
              title="NomeFile Img:"
              table="myelems"
              :id="myel._id"
              :rec="myel"
              field="image"
              @update:model-value="modifElem"
              :canEdit="true"
              :canModify="true"
              :fieldtype="costanti.FieldType.image"
            >
            </CMyFieldRec>
            <div class="">
              <!--<div
                class="col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6 col-sticky"
              >
                <q-select
                  label="Lunghezza:"
                  v-model="myel.widthimg"
                  emit-value
                  map-options
                  :options="generateSizeOptions()"
                  @input="modifElem"
                  filled
                  dense
                  use-input
                  use-chips
                  @new-value="updateSizeWidth"
                  style="width: 150px"
                />
                <q-input
                  dense
                  label="Altezza:"
                  @update:model-value="modifElem"
                  v-model="myel.heightimg"
                  filled
                  v-on:keyup.enter="saveElem"
                >
                </q-input>
                
              </div>-->
            </div>
          </div>
        </div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.VIDEO">
          <div v-if="enableEdit" class="row">
            <q-input
              dense
              label="NomeFile Video:"
              @update:model-value="modifElem"
              v-model="myel.container"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
            <q-input
              dense
              label="Ratio:"
              type="number"
              @update:model-value="modifElem"
              v-model="myel.ratio"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
          </div>
        </div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.FOOTER"></div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.PAGE">
          <div v-if="enableEdit" class="row">
            <q-select
              :behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'"
              rounded
              outlined
              v-model="myel.container"
              :options="arrPages"
              label="Pagina"
              emit-value
              map-options
              @change="saveElem"
            >
            </q-select>
          </div>
        </div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.PAGEINTRO">
          <div v-if="enableEdit" class="row">
            <q-input
              dense
              label="NomeFile Img:"
              @update:model-value="modifElem"
              v-model="myel.container"
              debounce="1000"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
            <div class="col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6 col-sticky">
              <q-select
                label="Lunghezza:"
                v-model="myel.widthimg"
                emit-value
                map-options
                :options="generateSizeOptions()"
                use-input
                use-chips
                @input="saveElem"
                filled
                dense
                @new-value="updateSizeWidth"
                style="width: 150px"
              />
              <q-select
                label="Altezza:"
                v-model="myel.heightimg"
                emit-value
                map-options
                :options="generateSizeOptions()"
                use-input
                use-chips
                @input="saveElem"
                filled
                dense
                @new-value="updateSizeHeight"
                style="width: 150px"
              />
              <q-input
                dense
                label="Link:"
                @update:model-value="modifElem"
                debounce="1000"
                v-model="myel.link"
                filled
                v-on:keyup.enter="saveElem"
              >
              </q-input>
            </div>
          </div>
        </div>
        <div
          v-else-if="myel.type === shared_consts.ELEMTYPE.CAROUSEL_IDISCIPLINE"
        >
          <CCardCarousel :myarr="getArrDisciplines()"> </CCardCarousel>
        </div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.OPENSTREETMAP">
          <div v-if="enableEdit" class="row">
            <q-input
              dense
              label="ImgMap:"
              @update:model-value="modifElem"
              v-model="myel.container"
              debounce="1000"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
            <q-input
              dense
              label="UrlMap:"
              @update:model-value="modifElem"
              v-model="myel.container2"
              debounce="1000"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
            <q-input
              dense
              label="Title:"
              @update:model-value="modifElem"
              v-model="myel.container3"
              debounce="1000"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
            <q-input
              dense
              label="Coordinata Mappa 1:"
              @update:model-value="modifElem"
              v-model="myel.containerHtml"
              debounce="1000"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
            <q-input
              dense
              label="Coordinata Mappa Big:"
              @update:model-value="modifElem"
              v-model="myel.link"
              debounce="1000"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
          </div>
        </div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.CAROUSEL_IMGS">
          <div v-if="enableEdit" class="row">
            <CMyFieldRec
              title="Lista Immagini:"
              table="myelems"
              :id="myel._id"
              :rec="myel"
              field="list"
              @update:model-value="modifElem"
              :canEdit="true"
              :canModify="true"
            >
            </CMyFieldRec>

            <!--sss
          -->

            <q-input
              dense
              label="Secondi tra un'immagine e l'altra:"
              @update:model-value="modifElem"
              debounce="1000"
              v-model="myel.container2"
              type="number"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
            <q-toggle
              label="Sottotitoli"
              v-model="myel.parambool"
              color="positive"
              icon="far fa-eye"
            >
            </q-toggle>

            <q-toggle
              label="Miniature"
              v-model="myel.parambool2"
              color="positive"
              icon="far fa-eye"
            >
            </q-toggle>
          </div>
        </div>
        <div
          v-else-if="myel.type === shared_consts.ELEMTYPE.CAROUSEL_HOME"
        ></div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.BUTTON">
          <q-input
            dense
            label="Colore:"
            @update:model-value="modifElem"
            debounce="1000"
            v-model="myel.color"
            v-on:keyup.enter="saveElem"
          >
          </q-input>
          <q-input
            dense
            label="Colore Testo:"
            @update:model-value="modifElem"
            debounce="1000"
            v-model="myel.containerHtml"
            v-on:keyup.enter="saveElem"
          >
          </q-input>
          <q-input
            dense
            label="Link:"
            @update:model-value="modifElem"
            debounce="1000"
            v-model="myel.link"
            filled
            v-on:keyup.enter="saveElem"
          >
          </q-input>
          <q-input
            dense
            label="Testo Bottone:"
            @update:model-value="modifElem"
            debounce="1000"
            v-model="myel.container"
            filled
            v-on:keyup.enter="saveElem"
          >
          </q-input>
          <q-input
            dense
            label="Icona:"
            @update:model-value="modifElem"
            debounce="1000"
            v-model="myel.container2"
            filled
            v-on:keyup.enter="saveElem"
          >
          </q-input>
          <q-input
            dense
            label="Dimensione"
            @update:model-value="modifElem"
            debounce="1000"
            v-model="myel.size"
            filled
            v-on:keyup.enter="saveElem"
          >
          </q-input>
          <q-input
            dense
            label="Target:"
            @update:model-value="modifElem"
            debounce="1000"
            v-model="myel.container3"
            filled
            v-on:keyup.enter="saveElem"
          >
          </q-input>
        </div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.GRID_ORIZ">
          <div v-if="enableEdit" class="row">
            <q-select
              v-model="myel.container"
              :options="[
                { label: 'Eventi', value: 'mybachecas' },
                { label: 'Servizi', value: 'myskills' },
              ]"
              label="Tabella"
              emit-value
              map-options
              @input="saveElem"
              style="min-width: 120px"
            >
            </q-select>
            <br />
            <q-select
              v-model="myel.number"
              :options="[
                { label: 'Orizzontale', value: costanti.VISUTABLE_GRID_ORIZ },
                { label: 'Griglia', value: costanti.VISUTABLE_LISTA },
                { label: 'Scheda User', value: costanti.VISUTABLE_SCHEDA_USER },
                { label: 'User Info', value: costanti.SHOW_USERINFO },
              ]"
              label="Visualizzazione"
              emit-value
              map-options
              style="min-width: 120px"
              @input="saveElem"
            >
            </q-select>
            <q-toggle
              v-model="myel.parambool"
              color="positive"
              label="Search"
              @update:model-value="modifElem"
            ></q-toggle>
            <q-toggle
              v-model="myel.parambool2"
              color="positive"
              label="Finder"
              @update:model-value="modifElem"
            ></q-toggle>
            <q-toggle
              v-model="myel.parambool3"
              color="positive"
              label="Mostra Mappa"
              @update:model-value="modifElem"
            ></q-toggle>
          </div>
        </div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.CALENDAR">
          <div v-if="enableEdit" class="row">
            <q-input
              dense
              label="Visualizza ultimi N eventi:"
              @update:model-value="modifElem"
              debounce="1000"
              v-model="myel.number"
              filled
              v-on:keyup.enter="saveElem"
            >
            </q-input>
          </div>
        </div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.CHECK_EMAIL"></div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.CHECKIFISLOGGED">
          <q-select
            v-model="myel.container"
            :options="[
              { label: 'Mostra Sempre', value: true },
              { label: 'Solo se Offline', value: false },
            ]"
            label="Quando mostrarlo"
            emit-value
            map-options
          >
          </q-select>
        </div>
        <div v-else-if="myel.type === shared_consts.ELEMTYPE.CATALOGO">
          <div v-if="enableEdit" class="row">
            <div>Cataloghi:</div>
            <br />
            <q-toggle
              v-model="myel.catalogo.pdf"
              color="positive"
              icon="fas fa-file-pdf"
              label="Versione PDF"
              @update:model-value="modifElem"
            >
            </q-toggle>
            <br>

            <!--++AddCATALOGO_FIELDS-->
            <q-select
              :behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'"
              v-if="enableEdit && myel.catalogo && myel.catalogo.productTypes"
              rounded
              outlined
              v-model="myel.catalogo.productTypes"
              :options="shared_consts.VERSIONI_PRODOTTO"
              @update:model-value="modifElem"
              multiple
              dense
              label="Includi"
              style="width: 150px"
              emit-value
              map-options
            >
            </q-select>

            <q-select
              :behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'"
              v-if="
                enableEdit && myel.catalogo && myel.catalogo.excludeproductTypes
              "
              rounded
              outlined
              v-model="myel.catalogo.excludeproductTypes"
              :options="shared_consts.VERSIONI_PRODOTTO"
              @update:model-value="modifElem"
              multiple
              dense
              label="Escludi"
              style="width: 150px"
              emit-value
              map-options
            >
            </q-select>
            <q-select
              :behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'"
              v-if="enableEdit"
              rounded
              outlined
              v-model="myel.catalogo.Editore"
              :options="Products.publishers"
              @update:model-value="modifElem"
              multiple
              dense
              label="Editori"
              style="width: 150px"
              emit-value
              map-options
              option-value="_id"
              option-label="name"
            >
            </q-select>

            <q-select
              label="Largh. Schede:"
              v-model="myel.catalogo.widthscheda"
              emit-value
              map-options
              :options="generateSizeOptions()"
              use-input
              use-chips
              @input="modifElem"
              @new-value="updateCatalogoSizeWidthScheda"
              filled
              dense
              style="width: 150px"
            />
            <q-select
              label="Largh. Pagina:"
              v-model="myel.catalogo.widthpag"
              emit-value
              map-options
              :options="generateSizeOptions(false)"
              use-input
              use-chips
              @input="modifElem"
              @new-value="updateCatalogoSizeWidthPag"
              filled
              dense
              style="width: 180px"
            />
            <q-select
              label="Largh. Immagini:"
              v-model="myel.catalogo.width"
              emit-value
              map-options
              :options="generateSizeOptions()"
              use-input
              use-chips
              @input="modifElem"
              @new-value="updateCatalogoSizeWidth"
              filled
              dense
              style="width: 180px"
            />
            <q-select
              label="Altezza Schede:"
              v-model="myel.catalogo.height"
              emit-value
              map-options
              :options="generateSizeOptions()"
              use-input
              use-chips
              @input="modifElem"
              @new-value="updateCatalogoSizeHeight"
              filled
              dense
              style="width: 180px"
            />
          </div>
          <div class="sfondo_margine">
            Margini:<br />
            <q-select
              label="Schede per Riga"
              v-model="myel.catalogo.numschede_perRiga"
              emit-value
              map-options
              :options="[
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
              ]"
              use-input
              use-chips
              @input="modifElem"
              @new-value="updateCatalogoNumSchedePerRiga"
              filled
              dense
              style="width: 180px"
            />
            <q-select
              label="Schede per Colonna"
              v-model="myel.catalogo.numschede_perCol"
              emit-value
              map-options
              :options="[
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
              ]"
              use-input
              use-chips
              @input="modifElem"
              @new-value="updateCatalogoNumSchedePerCol"
              filled
              dense
              style="width: 180px"
            />
            <q-input
              dense
              label="Margine per Pagina:"
              @update:model-value="modifElem"
              v-model="myel.catalogo.margine_pagina"
              filled
              v-on:keyup.enter="saveFieldElem"
            >
            </q-input>
            <q-input
              dense
              label="Margine per Riga:"
              @update:model-value="modifElem"
              v-model="myel.catalogo.margine_riga"
              filled
              v-on:keyup.enter="saveFieldElem"
            >
            </q-input>
          </div>
          <div>Sfondo:</div>
          <div v-if="enableEdit">
            Nome File Web: {{ myel.catalogo.backgroundimage }}<br />
            <CMyFieldRec
              title="Per Web:"
              table="catalogo"
              :rec="myel.catalogo"
              field="backgroundimage"
              @update:model-value="modifElem"
              :canEdit="true"
              :canModify="true"
              :fieldtype="costanti.FieldType.image"
              @save="saveFieldElem"
            >
            </CMyFieldRec>
            <br />
            <div class="sfondo_print">
              Per Stampa:
              <q-toggle
                v-model="myel.catalogo.printable"
                color="positive"
                icon="fas fa-file-pdf"
                label="Versione Stampabile"
                @update:model-value="modifElem"
              >
              </q-toggle>

              <q-input
                dense
                label="Margine per Pagina:"
                @update:model-value="modifElem"
                v-model="myel.catalogo.margine_paginaPrintable"
                filled
                v-on:keyup.enter="saveFieldElem"
              >
              </q-input>
              <q-input
                dense
                label="Margine per Riga:"
                @update:model-value="modifElem"
                v-model="myel.catalogo.margine_rigaPrintable"
                filled
                v-on:keyup.enter="saveFieldElem"
              >
              </q-input>

              Nome File Printable: {{ myel.catalogo.backgroundimage_printable }}
              <CMyFieldRec
                title="Sfondo:"
                table="catalogo"
                :rec="myel.catalogo"
                field="backgroundimage_printable"
                @update:model-value="modifElem"
                :canEdit="true"
                :canModify="true"
                :fieldtype="costanti.FieldType.image"
                @save="saveFieldElem"
              >
              </CMyFieldRec>
              <q-select
                label="Largh. Pag. Stampa:"
                v-model="myel.catalogo.widthpagPrintable"
                emit-value
                map-options
                :options="generateSizeOptions(false)"
                use-input
                use-chips
                @input="modifElem"
                @new-value="updateCatalogoSizeWidthPagPrintable"
                filled
                dense
                style="width: 180px"
              />
            </div>
          </div>
        </div>
      </q-list>
    </div>
    <br /><br /><br />
  </div>
  <div>
    <q-dialog
      v-model="visuadd"
      style="
        width: 600px;
        max-width: 100%;
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
      "
      transition-show="slide-up"
      transition-hide="slide-down"
    >
      <q-card class="">
        <q-bar dense class="bg-primary text-white">
          Aggiungi Elemento:
          <q-space />
          <q-btn flat round color="white" icon="close" v-close-popup></q-btn>
        </q-bar>

        <div class="q-pa-md row justify-center">
          <div style="width: 100%; max-width: 600px">
            <q-list padding bordered class="rounded-borders">
              <q-expansion-item
                label="Principali"
                icon="fas fa-eye"
                dense
                dense-toggle
                expand-separator
                default-opened
              >
                <div class="row q-pa-sm">
                  <div
                    v-for="(rec, index) in shared_consts.TypesElem"
                    :key="index"
                    class="col-6 q-pa-xs"
                  >
                    <q-btn
                      v-if="enableAdd"
                      :label="rec.label"
                      color="primary"
                      class="full-width uniform-button q-px-sm"
                      @click="
                        newtype = rec.value;
                        addNewElem(myel, direzadd);
                      "
                    >
                    </q-btn>
                  </div>
                </div>
              </q-expansion-item>
              <q-expansion-item
                dense
                dense-toggle
                expand-separator
                label="Gestione"
                icon="fas fa-cog"
              >
                <div class="row q-pa-sm">
                  <div
                    v-for="(rec, index) in shared_consts.TypesElemAdmin"
                    :key="index"
                    class="col-6 q-pa-xs"
                  >
                    <q-btn
                      v-if="enableAdd"
                      :label="rec.label"
                      color="primary"
                      class="full-width uniform-button q-px-sm"
                      @click="
                        newtype = rec.value;
                        addNewElem(myel, direzadd);
                      "
                    >
                    </q-btn>
                  </div>
                </div>
              </q-expansion-item>
              <q-expansion-item
                dense
                dense-toggle
                expand-separator
                label="Avanzati"
                icon="fas fa-star"
              >
                <div class="row q-pa-sm">
                  <div
                    v-for="(rec, index) in shared_consts.TypesElemAdminTools"
                    :key="index"
                    class="col-6 q-pa-sm"
                  >
                    <q-btn
                      v-if="enableAdd"
                      :label="rec.label"
                      color="primary"
                      class="full-width uniform-button q-px-sm"
                      @click="
                        newtype = rec.value;
                        addNewElem(myel, direzadd);
                      "
                    >
                    </q-btn>
                  </div>
                </div>
              </q-expansion-item>
            </q-list>
          </div>
        </div>
      </q-card>
    </q-dialog>
  </div>
</template>

<script lang="ts" src="./CMyEditElem.ts">
</script>
<style lang="scss" scoped>
@import './CMyEditElem.scss';
</style>
