demarches-normaliennes/app/javascript/new_design/administrateur/DraggableItem.vue

182 lines
6.2 KiB
Vue
Raw Normal View History

2018-11-14 16:26:00 +01:00
<template>
<div class="deleted" v-if="deleted">
<input type="hidden" :name="nameFor('id')" :value="id">
2018-11-14 16:26:00 +01:00
<input type="hidden" :name="nameFor('_destroy')" value="true">
</div>
<div class="draggable-item flex column justify-start" v-else :class="itemClassName">
<div class="flex justify-start section head" :class="{ hr: !isHeaderSection }">
2018-11-14 16:26:00 +01:00
<div class="handle">
<img :src="state.dragIconUrl" alt="">
</div>
<div class="cell">
<select
:id="elementIdFor('type_champ')"
:name="nameFor('type_champ')"
v-model="typeChamp"
@change="update"
class="small-margin small inline">
<option v-for="option in state.typesDeChampOptions" :key="option[1]" :value="option[1]">
{{ option[0] }}
</option>
2018-11-14 16:26:00 +01:00
</select>
</div>
<div class="flex justify-start delete">
<button class="button danger" @click.prevent="removeChamp">
2018-11-14 16:26:00 +01:00
Supprimer
</button>
</div>
</div>
<div class="flex justify-start section" :class="{ hr: isDropDown || isFile || isCarte }">
<div class="flex column justify-start shift-left">
2018-11-14 16:26:00 +01:00
<div class="cell libelle">
<label :for="elementIdFor('libelle')">
Libellé
</label>
<input
type="text"
:id="elementIdFor('libelle')"
:name="nameFor('libelle')"
v-model="libelle"
@change="update"
2018-11-14 16:26:00 +01:00
class="small-margin small"
:class="{ error: hasChanges && !isValid }">
2018-11-14 16:26:00 +01:00
</div>
<div class="cell" v-show="!isHeaderSection && !isExplication && !state.isAnnotation">
<label :for="elementIdFor('mandatory')">
Obligatoire
</label>
<input :name="nameFor('mandatory')" type="hidden" value="0">
<input
type="checkbox"
:id="elementIdFor('mandatory')"
:name="nameFor('mandatory')"
v-model="mandatory"
@change="update"
2018-11-14 16:26:00 +01:00
class="small-margin small"
value="1">
</div>
</div>
<div class="flex justify-start">
2018-11-14 16:26:00 +01:00
<div class="cell" v-show="!isHeaderSection">
<label :for="elementIdFor('description')">
Description
</label>
<textarea
:id="elementIdFor('description')"
:name="nameFor('description')"
v-model="description"
@change="update"
2018-11-14 16:26:00 +01:00
rows=3
cols=40
class="small-margin small">
</textarea>
</div>
</div>
</div>
<div class="flex justify-start section shift-left" v-show="!isHeaderSection">
2018-11-14 16:26:00 +01:00
<div class="cell" v-show="isDropDown">
<label :for="elementIdFor('drop_down_list')">
Liste déroulante
</label>
<textarea
:id="elementIdFor('drop_down_list')"
:name="nameFor('drop_down_list_attributes[value]')"
v-model="dropDownListValue"
@change="update"
2018-11-14 16:26:00 +01:00
rows=3
cols=40
placeholder="Ecrire une valeur par ligne et --valeur-- pour un séparateur."
class="small-margin small">
</textarea>
</div>
<div class="cell" v-show="isFile">
<label :for="elementIdFor('piece_justificative_template')">
Modèle
</label>
<template v-if="pieceJustificativeTemplateUrl">
<a :href="pieceJustificativeTemplateUrl" target="_blank">
{{pieceJustificativeTemplateFilename}}
2018-11-14 16:26:00 +01:00
</a>
<br> Modifier :
</template>
<input
type="file"
:id="elementIdFor('piece_justificative_template')"
:name="nameFor('piece_justificative_template')"
@change="upload"
2018-11-14 16:26:00 +01:00
class="small-margin small">
</div>
<div class="cell" v-show="isCarte">
<label>
Utilisation de la cartographie
</label>
<div class="carte-options">
<label :for="elementIdFor('quartiers_prioritaires')">
<input :name="nameFor('quartiers_prioritaires')" type="hidden" value="0">
<input
type="checkbox"
:id="elementIdFor('quartiers_prioritaires')"
:name="nameFor('quartiers_prioritaires')"
v-model="options.quartiers_prioritaires"
@change="update"
2018-11-14 16:26:00 +01:00
class="small-margin small"
value="1">
Quartiers prioritaires
</label>
<label :for="elementIdFor('cadastres')">
<input :name="nameFor('cadastres')" type="hidden" value="0">
<input
type="checkbox"
:id="elementIdFor('cadastres')"
:name="nameFor('cadastres')"
v-model="options.cadastres"
@change="update"
2018-11-14 16:26:00 +01:00
class="small-margin small"
value="1">
Cadastres
</label>
<label :for="elementIdFor('parcelles_agricoles')">
<input :name="nameFor('parcelles_agricoles')" type="hidden" value="0">
<input
type="checkbox"
:id="elementIdFor('parcelles_agricoles')"
:name="nameFor('parcelles_agricoles')"
v-model="options.parcelles_agricoles"
@change="update"
2018-11-14 16:26:00 +01:00
class="small-margin small"
value="1">
Parcelles Agricoles
</label>
</div>
</div>
<div class="flex-grow cell" v-show="isRepetition">
<Draggable :list="typesDeChamp" :options="{handle:'.handle'}">
<DraggableItem
v-for="(item, index) in typesDeChamp"
:state="stateForRepetition"
:index="index"
:item="item"
:key="item.id" />
</Draggable>
<button class="button" @click.prevent="addChamp">
<template v-if="state.isAnnotation">
Ajouter une annotation
</template>
<template v-else>
Ajouter un champ
</template>
</button>
</div>
2018-11-14 16:26:00 +01:00
</div>
<div class="meta">
<input type="hidden" :name="nameFor('order_place')" :value="index">
<input type="hidden" :name="nameFor('id')" :value="id">
2018-11-14 16:26:00 +01:00
</div>
</div>
</template>
<script src="./DraggableItem.js"></script>