local authorship is now stored
This commit is contained in:
		@@ -1,3 +1,5 @@
 | 
				
			|||||||
 | 
					import Dataset from "./dataset.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const form = document.forms[0];
 | 
					const form = document.forms[0];
 | 
				
			||||||
const {
 | 
					const {
 | 
				
			||||||
    title: titleEntry,
 | 
					    title: titleEntry,
 | 
				
			||||||
@@ -23,7 +25,7 @@ const validationListener = () => {
 | 
				
			|||||||
    fullDescriptionEntry,
 | 
					    fullDescriptionEntry,
 | 
				
			||||||
].forEach(input => input.addEventListener("input", validationListener));
 | 
					].forEach(input => input.addEventListener("input", validationListener));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
form.addEventListener("submit", e => {
 | 
					form.addEventListener("submit", async e => {
 | 
				
			||||||
    e.preventDefault();
 | 
					    e.preventDefault();
 | 
				
			||||||
    if (!form.reportValidity()) return;
 | 
					    if (!form.reportValidity()) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -43,17 +45,20 @@ form.addEventListener("submit", e => {
 | 
				
			|||||||
    // Don't allow several requests to be sent at the same time
 | 
					    // Don't allow several requests to be sent at the same time
 | 
				
			||||||
    addBtn.disabled = true;
 | 
					    addBtn.disabled = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fetch("/api/v1/datasets", {
 | 
					    let response = await fetch("/api/v1/datasets", {
 | 
				
			||||||
        method: "POST",
 | 
					        method: "POST",
 | 
				
			||||||
        body: JSON.stringify(newContent),
 | 
					        body: JSON.stringify(newContent),
 | 
				
			||||||
        headers: {
 | 
					        headers: {
 | 
				
			||||||
            "Content-Type": "application/json;charset=utf-8"
 | 
					            "Content-Type": "application/json;charset=utf-8"
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }).then(response => {
 | 
					
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    let data = await response.json();
 | 
				
			||||||
 | 
					    let dataset = new Dataset(data);
 | 
				
			||||||
 | 
					    dataset.storageSetKey("createdLocally", true);
 | 
				
			||||||
    if (response.status == 200) {
 | 
					    if (response.status == 200) {
 | 
				
			||||||
        location.assign("/");
 | 
					        location.assign("/");
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        addBtn.disabled = !form.checkValidity();
 | 
					        addBtn.disabled = !form.checkValidity();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user