Liberacion
This commit is contained in:
32
Templates/IMMEX/modulos/add_SistemaXCliente_Script.html
Normal file
32
Templates/IMMEX/modulos/add_SistemaXCliente_Script.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", ()=>{
|
||||
document.querySelector('#add-sistema-cliente').addEventListener('click', function() {
|
||||
let parentWidth = window.innerWidth;
|
||||
let parentHeight = window.innerHeight;
|
||||
|
||||
let childWidth = 800;
|
||||
let childHeight = 600;
|
||||
let left =(parentWidth - childWidth);
|
||||
let top = (parentHeight - childHeight);
|
||||
|
||||
let popupWin = window.open("{% url 'create_sistemaIMMEX' %}", "createSistemaXCliente_popup", "width=" + childWidth + ",height=" + childHeight + ",left=" + left + ",top=" + top);
|
||||
popupWin.focus();
|
||||
});
|
||||
|
||||
|
||||
window.addEventListener('message', (event)=>{
|
||||
let response = event.data.data;
|
||||
let windowName = event.data.windowName;
|
||||
|
||||
if(windowName==='createSistemaXCliente'){
|
||||
|
||||
let option = '<option value="' + response.id + '" selected>'+response.cliente+', ' + response.nombre + '</option>';
|
||||
document.querySelector('#id_sistema_cliente').insertAdjacentHTML('beforeend', option);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
@@ -4,7 +4,9 @@
|
||||
{% block title %}Add Cliente IMMEX {% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Crear Módulo/Permisos</h2>
|
||||
<h2>Editar Módulo/Permisos</h2>
|
||||
<p><strong>Cliente:</strong>{{object.sistema_cliente}}</p>
|
||||
<hr>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
@@ -36,4 +38,7 @@
|
||||
|
||||
<button type="submit" class="btn btn-outline-success">Guardar</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
{% include 'IMMEX/modulos/add_SistemaXCliente_Script.html' %}
|
||||
{% endblock %}
|
||||
@@ -33,4 +33,11 @@
|
||||
|
||||
<button type="submit" class="btn btn-outline-success">Guardar</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
{% include 'IMMEX/modulos/add_SistemaXCliente_Script.html' %}
|
||||
|
||||
{% endblock scripts %}
|
||||
@@ -31,6 +31,7 @@
|
||||
{% block scripts %}
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", ()=>{
|
||||
console.log('edit_cliente.html',window.name)
|
||||
if(window.name ==='popupWin')
|
||||
{
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
{% block content %}
|
||||
<h1>Create a new Sistema IMMEX por cliente</h1>
|
||||
<form method="post">
|
||||
<form method="post" id="sistemaXCliente-form">
|
||||
|
||||
{% csrf_token %}
|
||||
{% if form.non_field_errors %}
|
||||
@@ -63,6 +63,43 @@
|
||||
{% block scripts %}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
console.log('SISTEMA X CLIENTE', window.name);
|
||||
|
||||
if(window.name==='createSistemaXCliente_popup'){
|
||||
document.querySelector('#sistemaXCliente-form').addEventListener('submit',(event)=>{
|
||||
event.preventDefault();
|
||||
let form = event.target;
|
||||
let url = `{% url 'create_sistemaIMMEX' %}`;
|
||||
let data = new FormData(form);
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open('POST',url);
|
||||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
xhr.onreadystatechange = ()=>{
|
||||
if(xhr.readyState===XMLHttpRequest.DONE){
|
||||
if(xhr.status===200){
|
||||
let response = JSON.parse(xhr.responseText);
|
||||
if(response.errors){
|
||||
alert(response.errors);
|
||||
|
||||
}else{
|
||||
window.opener.postMessage({data:response, windowName:'createSistemaXCliente'}, window.location.origin);
|
||||
|
||||
window.close();
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
console.error('Request error', xhr.statusText);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
xhr.send(data);
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/*add Sistema*/
|
||||
document.querySelector('#add-sistema-btn').addEventListener('click', function() {
|
||||
let parentWidth = window.innerWidth;
|
||||
@@ -92,11 +129,12 @@
|
||||
popupWin.focus();
|
||||
});
|
||||
|
||||
|
||||
|
||||
window.addEventListener('message', function(event) {
|
||||
let response = event.data.data;
|
||||
|
||||
|
||||
let windowName = event.data.windowName;
|
||||
|
||||
if(windowName==='clientWindow'){
|
||||
let id_cliente = response.id;
|
||||
let Nombre = response.Nombre;
|
||||
|
||||
Reference in New Issue
Block a user