Agregar datos propietario
This commit is contained in:
@ -58,7 +58,17 @@ Editar Propietario
|
||||
<select class="ui search selection dropdown" name="comuna" id="comunas"></select>
|
||||
</div>
|
||||
</div>
|
||||
<button class="ui button" id="guardar_button">Guardar</button>
|
||||
<div class="fields">
|
||||
<div class="four wide field">
|
||||
<label>Email</label>
|
||||
<input type="email" name="email" value="{{$propietario->datos?->email}}" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Teléfono</label>
|
||||
<input type="text" name="telefono" value="{{$propietario->datos?->telefono}}" />
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="ui button" id="guardar_button">Guardar</button>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
@ -66,10 +76,10 @@ Editar Propietario
|
||||
@include('layout.body.scripts.rut')
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
class Propietario {
|
||||
props
|
||||
constructor({rut, digito, nombres, apellidos: {paterno, materno}, direccion: {calle, numero, extra, comuna, region}}) {
|
||||
constructor({rut, digito, nombres, apellidos: {paterno, materno}, direccion: {calle, numero, extra, comuna, region}, email, telefono}) {
|
||||
this.props = {
|
||||
rut,
|
||||
digito,
|
||||
@ -85,6 +95,8 @@ Editar Propietario
|
||||
comuna,
|
||||
region
|
||||
},
|
||||
email,
|
||||
telefono
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,6 +140,12 @@ Editar Propietario
|
||||
this.props.direccion.region = region
|
||||
}
|
||||
}
|
||||
},
|
||||
email: email => {
|
||||
this.props.email = email
|
||||
},
|
||||
telefono: telefono => {
|
||||
this.props.telefono = telefono
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -145,7 +163,9 @@ Editar Propietario
|
||||
numero: '{{$propietario->datos->direccion->numero}}',
|
||||
extra: '{{trim($propietario->datos->direccion->extra)}}',
|
||||
comuna: '{{$propietario->datos->direccion->comuna->id}}'
|
||||
}
|
||||
},
|
||||
email: '{{trim($propietario->datos?->email)}}',
|
||||
telefono: '{{trim($propietario->datos?->telefono)}}'
|
||||
}
|
||||
const data = {}
|
||||
const collator = new Intl.Collator('es')
|
||||
@ -299,6 +319,16 @@ Editar Propietario
|
||||
propietario.props.data.update().direccion().comuna(comuna_id)
|
||||
})
|
||||
}
|
||||
static email() {
|
||||
$("[name='email']").change(event => {
|
||||
propietario.props.data.update().email(event.currentTarget.value)
|
||||
})
|
||||
}
|
||||
static telefono() {
|
||||
$("[name='telefono']").change(event => {
|
||||
propietario.props.data.update().telefono($(event.currentTarget).val())
|
||||
})
|
||||
}
|
||||
|
||||
static run() {
|
||||
Watcher.rut()
|
||||
@ -307,6 +337,8 @@ Editar Propietario
|
||||
Watcher.direccion()
|
||||
Watcher.region()
|
||||
Watcher.comuna()
|
||||
Watcher.email()
|
||||
Watcher.telefono()
|
||||
}
|
||||
}
|
||||
class EventHandler {
|
||||
@ -381,6 +413,8 @@ Editar Propietario
|
||||
$("[name='numero']").val(this.props.data.props.direccion.numero)
|
||||
$("[name='extra']").val(this.props.data.props.direccion.extra)
|
||||
$('#region').val(this.props.data.props.direccion.region)
|
||||
$("[name='email']").val(this.props.data.props.email)
|
||||
$("[name='telefono']").val(this.props.data.props.telefono)
|
||||
this.update().region()
|
||||
},
|
||||
region: () => {
|
||||
@ -422,6 +456,8 @@ Editar Propietario
|
||||
this.props.data.update().direccion().extra(data.propietario.direccion.extra)
|
||||
this.props.data.update().direccion().comuna(data.propietario.direccion.comuna.id)
|
||||
this.props.data.update().direccion().region(data.propietario.direccion.comuna.provincia.region.id)
|
||||
this.props.data.update().email(data.propietario.email)
|
||||
this.props.data.update().telefono(data.propietario.telefono)
|
||||
this.update().propietario()
|
||||
})
|
||||
})
|
||||
@ -476,6 +512,8 @@ Editar Propietario
|
||||
$("[name='calle']").val('')
|
||||
$("[name='numero']").val('')
|
||||
$("[name='extra']").val('')
|
||||
$("[name='email']").val('')
|
||||
$("[name='telefono']").val('')
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -498,7 +536,8 @@ Editar Propietario
|
||||
})
|
||||
this.update().region()
|
||||
|
||||
$(this.props.ids.forms.edit).submit(Form.submit)
|
||||
document.getElementById(this.props.ids.forms.edit.replace('#', '')).addEventListener('submit', Form.submit)
|
||||
document.getElementById(this.props.ids.buttons.guardar.replace('#', '')).addEventListener('click', Form.submit)
|
||||
Watcher.run()
|
||||
}
|
||||
}
|
||||
@ -529,7 +568,9 @@ Editar Propietario
|
||||
extra: '{{$propietario->datos->direccion->extra}}',
|
||||
comuna: '{{$propietario->datos->direccion->comuna->id}}',
|
||||
region: '{{$propietario->datos->direccion->comuna->provincia->region->id}}',
|
||||
}
|
||||
},
|
||||
email: '{{$propietario->datos?->email}}',
|
||||
telefono: '{{$propietario->datos?->telefono}}'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user