update
This commit is contained in:
7
assets/static/appico/Notepad.svg
Normal file
7
assets/static/appico/Notepad.svg
Normal file
@@ -0,0 +1,7 @@
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 493.474 493.474" xml:space="preserve" width="256px" height="256px" fill="#000000">
|
||||
|
||||
<g id="SVGRepo_bgCarrier" stroke-width="0"/>
|
||||
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
@@ -124,6 +124,7 @@
|
||||
<script src="page/supercafe.js"></script>
|
||||
<script src="page/avisos.js"></script>
|
||||
<script src="page/comedor.js"></script>
|
||||
<script src="page/notas.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
141
src/page/notas.js
Normal file
141
src/page/notas.js
Normal file
@@ -0,0 +1,141 @@
|
||||
PAGES.notas = {
|
||||
navcss: "btn5",
|
||||
icon: "static/appico/Notepad.svg",
|
||||
AccessControl: true,
|
||||
Title: "Notas",
|
||||
edit: function (mid) {
|
||||
if (!checkRole("notas:edit")) {setUrlHash("notas");return}
|
||||
var nameh1 = safeuuid();
|
||||
var field_asunto = safeuuid();
|
||||
var field_contenido = safeuuid();
|
||||
var field_autor = safeuuid();
|
||||
var btn_guardar = safeuuid();
|
||||
var btn_borrar = safeuuid();
|
||||
var div_actions = safeuuid();
|
||||
container.innerHTML = `
|
||||
<h1>Nota <code id="${nameh1}"></code></h1>
|
||||
<fieldset style="float: left;">
|
||||
<legend>Valores</legend>
|
||||
<label>
|
||||
Asunto<br>
|
||||
<input type="text" id="${field_asunto}" value=""><br><br>
|
||||
</label>
|
||||
<input type="hidden" id="${field_autor}">
|
||||
<div id="${div_actions}"></div>
|
||||
<label>
|
||||
Contenido<br>
|
||||
<textarea id="${field_contenido}"></textarea><br><br>
|
||||
</label>
|
||||
<hr>
|
||||
<button class="btn5" id="${btn_guardar}">Guardar</button>
|
||||
<button class="rojo" id="${btn_borrar}">Borrar</button>
|
||||
</fieldset>
|
||||
`;
|
||||
var divact = document.getElementById(div_actions);
|
||||
addCategory_Personas(
|
||||
divact,
|
||||
SC_Personas,
|
||||
"",
|
||||
(value) => {
|
||||
document.getElementById(field_autor).value = value;
|
||||
},
|
||||
"Autor"
|
||||
);
|
||||
gun
|
||||
.get(TABLE)
|
||||
.get("notas")
|
||||
.get(mid)
|
||||
.once((data, key) => {
|
||||
function load_data(data, ENC = "") {
|
||||
document.getElementById(nameh1).innerText = key;
|
||||
document.getElementById(field_asunto).value = data["Asunto"] || "";
|
||||
document.getElementById(field_contenido).value =
|
||||
data["Contenido"] || "";
|
||||
document.getElementById(field_autor).value = data["Autor"] || "";
|
||||
|
||||
// Persona select
|
||||
divact.innerHTML = "";
|
||||
addCategory_Personas(
|
||||
divact,
|
||||
SC_Personas,
|
||||
data["Autor"] || "",
|
||||
(value) => {
|
||||
document.getElementById(field_autor).value = value;
|
||||
},
|
||||
"Autor"
|
||||
);
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
SEA.decrypt(data, SECRET, (data) => {
|
||||
load_data(data, "%E");
|
||||
});
|
||||
} else {
|
||||
load_data(data);
|
||||
}
|
||||
});
|
||||
document.getElementById(btn_guardar).onclick = () => {
|
||||
var data = {
|
||||
Autor: document.getElementById(field_autor).value,
|
||||
Contenido: document.getElementById(field_contenido).value,
|
||||
Asunto: document.getElementById(field_asunto).value,
|
||||
};
|
||||
var enc = SEA.encrypt(data, SECRET, (encrypted) => {
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
betterGunPut(
|
||||
gun.get(TABLE).get("notas").get(mid),
|
||||
encrypted
|
||||
);
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("notas");
|
||||
}, 1500);
|
||||
});
|
||||
};
|
||||
document.getElementById(btn_borrar).onclick = () => {
|
||||
if (confirm("¿Quieres borrar esta nota?") == true) {
|
||||
betterGunPut(gun.get(TABLE).get("notas").get(mid), null);
|
||||
toastr.error("Borrado!");
|
||||
setTimeout(() => {
|
||||
setUrlHash("notas");
|
||||
}, 1500);
|
||||
}
|
||||
};
|
||||
},
|
||||
index: function () {
|
||||
if (!checkRole("notas")) {setUrlHash("index");return}
|
||||
const tablebody = safeuuid();
|
||||
var btn_new = safeuuid();
|
||||
container.innerHTML = `
|
||||
<h1>Notas</h1>
|
||||
<button id="${btn_new}">Nueva nota</button>
|
||||
<div id="cont"></div>
|
||||
`;
|
||||
TS_IndexElement(
|
||||
"notas",
|
||||
[
|
||||
{
|
||||
key: "Autor",
|
||||
type: "persona",
|
||||
default: "",
|
||||
label: "Autor",
|
||||
},
|
||||
{
|
||||
key: "Asunto",
|
||||
type: "raw",
|
||||
default: "",
|
||||
label: "Asunto",
|
||||
},
|
||||
],
|
||||
gun.get(TABLE).get("notas"),
|
||||
document.querySelector("#cont"),
|
||||
);
|
||||
if (!checkRole("notas:edit")) {
|
||||
document.getElementById(btn_new).style.display = "none"
|
||||
} else {
|
||||
document.getElementById(btn_new).onclick = () => {
|
||||
setUrlHash("notas," + safeuuid(""));
|
||||
};
|
||||
}
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user