Skip to content
Snippets Groups Projects
Commit 086dbe41 authored by Gabriel Nyman's avatar Gabriel Nyman
Browse files

fixed so projects are created and bugg with adding members on project

parent 8482c4ce
No related branches found
No related tags found
2 merge requests!139The members of the project should be showing now in pgsa pages, but there are...,!134The members of the project should be showing now in pgsa pages, but there are...
Pipeline #110578 passed
......@@ -84,13 +84,13 @@ function createImprovementWork(id, name, currentStage, content, // Är detta des
unitId, purpose, //Bör tas bort motsvaras av p2- mål med projektet
patientRiskLevel, area,
//Questions in planning stage
p1, p2, p3, p4, p5, p6, p7,
p1 = "", p2 = "", p3 = "", p4 = "", p5 = "", p6 = "", p7 = "",
//Questions in Doing (G) stage
g1, g2, g3, g4, g5,
g1 = "", g2 = "", g3 = "", g4 = "", g5 = "",
//Questions in stydy stage
s1, s2, s3,
s1 = "", s2 = "", s3 = "",
//Questions in acting stage
a1, a2, a3, a4) {
a1 = "", a2 = "", a3 = "", a4 = "") {
return __awaiter(this, void 0, void 0, function* () {
//ID has to be a string
try {
......@@ -328,6 +328,18 @@ unitId, departmentId, isPublic) {
}
});
}
function deleteSuggestion(suggestionId) {
return __awaiter(this, void 0, void 0, function* () {
try {
const suggestionRef = doc(suggestionCollection, suggestionId);
yield deleteDoc(suggestionRef);
}
catch (error) {
console.log("Error deleting suggestion: ", error);
throw error;
}
});
}
// Upvote a suggestion for a user
// takes in suggestion id, user HSAid
// returns error if transaction failed
......@@ -409,7 +421,7 @@ function addNoteToUser(userHsaId, content) {
});
}
// export to setters to be able to use in other files
export { createComment, createHospital, createImprovementWork, createSuggestion, createTaskOnImprovementWork, createUnit, createUser, createdDocumentInKnowledgeBank, addNoteToUser, addDocumentToImprovementWork, addMemberToImprovementWork, addMemberToTask, upvoteSuggestion, upvoteComment, };
export { createComment, createHospital, createImprovementWork, createSuggestion, createTaskOnImprovementWork, createUnit, createUser, createdDocumentInKnowledgeBank, addNoteToUser, addDocumentToImprovementWork, addMemberToImprovementWork, addMemberToTask, upvoteSuggestion, upvoteComment, deleteSuggestion };
//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////
// Get any object
// input is the database type as a string.
......
......@@ -179,28 +179,28 @@ async function createImprovementWork(
patientRiskLevel: string,
area: string,
//Questions in planning stage
p1: string,
p2: string,
p3: string,
p4: string,
p5: string,
p6: string,
p7: string,
p1: string = "",
p2: string = "",
p3: string = "",
p4: string = "",
p5: string = "",
p6: string = "",
p7: string = "",
//Questions in Doing (G) stage
g1: string,
g2: string,
g3: string,
g4: string,
g5: string,
g1: string = "",
g2: string = "",
g3: string = "",
g4: string = "",
g5: string = "",
//Questions in stydy stage
s1: string,
s2: string,
s3: string,
s1: string = "",
s2: string = "",
s3: string = "",
//Questions in acting stage
a1: string,
a2: string,
a3: string,
a4: string
a1: string = "",
a2: string = "",
a3: string = "",
a4: string = ""
): Promise<void> {
//ID has to be a string
try {
......@@ -518,6 +518,16 @@ async function createSuggestion(
throw error;
}
}
async function deleteSuggestion(suggestionId: string): Promise<void> {
try {
const suggestionRef = doc(suggestionCollection, suggestionId);
await deleteDoc(suggestionRef);
} catch (error) {
console.log("Error deleting suggestion: ", error);
throw error;
}
}
// Upvote a suggestion for a user
// takes in suggestion id, user HSAid
......@@ -619,6 +629,7 @@ export {
addMemberToTask,
upvoteSuggestion,
upvoteComment,
deleteSuggestion
};
//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////
......
......@@ -13,25 +13,26 @@
</head>
<body>
<div class="initiateIdeaWholePage" id="initiateIdeaWholePage">
<div class="initiateIdeaUpHbox" id="initiateIdeaUpHbox">
<div class="participatingBox">
<div class="selectManager">
<p >För att göra ett förbättringsarbete till ett projekt behöver du ange en projektansvarig och övriga deltagande personer. Detta går att ändra senare.</p>
</div>
<div class="selectEmployees">
<p class ="ideaCardFont" >Vem ska vara ansvarig för projektet?</p>
<select class="projectLeaderSelect" name="projectLeader" id="projectLeader">
<option class ="ideaCardFont" value="" disabled selected>Välj ansvarig</option>
</select>
<p class ="ideaCardFont" >Vilka ska delta i projetet?</p>
<select class="employeeSelect" name="selectEmployee" id="selectEmployee">
<option class ="ideaCardFont" value="" disabled selected>Välj deltagande</option>
</select>
</div>
<div class="selectedEmployees" id="selectedEmployees"></div>
<div class="initiateIdeaUpHbox" id="initiateIdeaUpHbox">
<div class="participatingBox">
<div class="selectManager">
<p >För att göra ett förbättringsarbete till ett projekt behöver du ange en projektansvarig och övriga deltagande personer. Detta går att ändra senare.</p>
</div>
<div class="selectEmployees">
<p class ="ideaCardFont" >Vem ska vara ansvarig för projektet?</p>
<select class="projectLeaderSelect" name="projectLeader" id="projectLeader">
<option class ="ideaCardFont" value="" disabled selected>Välj ansvarig</option>
</select>
<p class ="ideaCardFont" >Vilka ska delta i projetet?</p>
<select class="employeeSelect" name="selectEmployee" id="selectEmployee">
<option class ="ideaCardFont" value="" disabled selected>Välj deltagande</option>
</select>
</div>
<div class="selectedEmployees" id="selectedEmployees"></div>
</div>
</div>
</div>
<button id="createProjectFromSuggestionButton">Skapa förbättringsarbete!</button>
</body>
</html>
\ No newline at end of file
......@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { getObjectById, getUsers, getHospitals, getUnits } from "../Database/database.js";
import { getObjectById, getUsers, getHospitals, getUnits, createImprovementWork, deleteSuggestion } from "../Database/database.js";
//Globala varibler för projekledare & Users
let selectedEmployees = [];
function loadEmployees() {
......@@ -75,12 +75,6 @@ function createAssignedEmployeeDesign(s, x, employeeList) {
container.append(textSpan, deleteButton); // Append the span and button to the div container
return container;
}
//Functions to load the page
function clearFromEventListeners(container) {
const clonedContainer = container.cloneNode(true);
container.replaceWith(clonedContainer);
console.log("cleared");
}
export function loadPage(id) {
return __awaiter(this, void 0, void 0, function* () {
console.log(id);
......@@ -111,25 +105,26 @@ export function loadPage(id) {
const tempContainer = document.createElement('div');
tempContainer.innerHTML = data;
// Select the specific element with the class you want
const specificElement = tempContainer.querySelector('.initiateIdeaWholePage');
const specificElement = tempContainer.querySelector('#initiateIdeaWholePage');
//Eventlistenerbuttons:
const createButton = document.getElementById('createProjectFromSuggestionButton');
const selectEmployeeButton = document.getElementById('selectEmployee');
document.addEventListener("click", function (event) {
const target = event.target;
//adds an event listener for the initiate page
if (target.id === "createProjectFromSuggestionButton") {
createProject();
}
});
document.addEventListener("change", function (event) {
const target = event.target;
//adds an event listener for the initiate page
if (target.id === "selectEmployee") {
assignedEmployer();
}
});
const createButton = tempContainer.querySelector('#createProjectFromSuggestionButton');
const selectEmployeeChangeSection = tempContainer.querySelector('#selectEmployee');
if (createButton) {
createButton.addEventListener('click', () => createProject(id));
}
else {
console.error("Error: 'createButton' not found");
}
if (selectEmployeeChangeSection) {
selectEmployeeChangeSection.addEventListener('change', assignedEmployer);
console.error("funkar 22");
}
else {
console.error("Error: 'changebutton' not found");
}
if (specificElement) {
console.error("spec element ok");
container.insertBefore(createButton, container.firstChild);
// Insert the generated element before the specific element
container.insertBefore(generatedElement, container.firstChild);
// Insert the specific element into the target element
......@@ -143,7 +138,7 @@ export function loadPage(id) {
});
});
}
function createProject() {
function createProject(id) {
const inputSelectProjectleaderInput = document.getElementById("projectLeader");
const selectDepartment = document.getElementById("selectHospital");
const selectUnit = document.getElementById("selectDepartment");
......@@ -165,6 +160,18 @@ function createProject() {
+ inputBoxFormMeasureInput.value + "\n"
+ inputBoxFormIdeasInput.value + "\n");
console.log(selectedEmployees);
try {
{
createImprovementWork(null, inputBoxFormNameInput.value, "första stadiet?", inputBoxFormContentInput.value, selectUnit.value, inputBoxFormPurposeInput.value, "patient risklevel?", inputBoxFormAreaInput.value);
}
// Call the createSuggestion function with the obtained values
alert("created successfully");
//loadCurrentProjects();
}
catch (_a) {
alert("Error creating");
}
deleteSuggestion(id);
}
function generateQuestionHTML(suggestionID) {
return __awaiter(this, void 0, void 0, function* () {
......@@ -333,7 +340,6 @@ function generateQuestionHTML(suggestionID) {
</form>
</div>
</div>
</div>
<button id="createProjectFromSuggestionButton">Skapa förbättringsarbete!</button>`;
</div>`;
});
}
import {getObjectById, getUsers, getHospitals, getUnits} from "../Database/database.js";
import {getObjectById, getUsers, getHospitals, getUnits, createImprovementWork, deleteSuggestion} from "../Database/database.js";
import { loadCurrentProjects } from "../SidebarAndHeader/pageHandler.js";
//Globala varibler för projekledare & Users
let selectedEmployees: string[] = [];
......@@ -81,13 +82,6 @@ function createAssignedEmployeeDesign(s: string, x: JQuery<HTMLElement>, employe
return container;
}
//Functions to load the page
function clearFromEventListeners(container: Element) {
const clonedContainer = container.cloneNode(true);
container.replaceWith(clonedContainer);
console.log("cleared");
}
export async function loadPage (id: string) {
console.log(id);
const container = document.querySelector('#container-fluid');
......@@ -122,32 +116,31 @@ export async function loadPage (id: string) {
const tempContainer = document.createElement('div');
tempContainer.innerHTML = data;
// Select the specific element with the class you want
const specificElement = tempContainer.querySelector('.initiateIdeaWholePage');
const specificElement = tempContainer.querySelector('#initiateIdeaWholePage');
//Eventlistenerbuttons:
const createButton = document.getElementById('createProjectFromSuggestionButton') as HTMLButtonElement | null;
const selectEmployeeButton = document.getElementById('selectEmployee');
const createButton = tempContainer.querySelector('#createProjectFromSuggestionButton') as HTMLButtonElement;
const selectEmployeeChangeSection = tempContainer.querySelector('#selectEmployee') as HTMLButtonElement;
document.addEventListener("click", function (event) {
const target = event.target as HTMLElement;
//adds an event listener for the initiate page
if (target.id === "createProjectFromSuggestionButton") {
createProject();
}
});
document.addEventListener("change", function (event) {
const target = event.target as HTMLElement;
//adds an event listener for the initiate page
if (target.id === "selectEmployee") {
assignedEmployer();
}
});
if (createButton) {
createButton.addEventListener('click', () => createProject(id));
} else {
console.error("Error: 'createButton' not found");
}
if (selectEmployeeChangeSection) {
selectEmployeeChangeSection.addEventListener('change', assignedEmployer);
console.error("funkar 22");
} else {
console.error("Error: 'changebutton' not found");
}
if (specificElement) {
console.error("spec element ok");
container.insertBefore(createButton, container.firstChild);
// Insert the generated element before the specific element
container.insertBefore(generatedElement, container.firstChild);
// Insert the specific element into the target element
container.insertBefore(specificElement, container.firstChild);
selectedEmployees=[]; //clears the global employee list
loadEmployees();
}
......@@ -156,7 +149,7 @@ export async function loadPage (id: string) {
console.error('Failed to load the external HTML file:', error);
});
}
function createProject(){
function createProject(id: string){
const inputSelectProjectleaderInput = document.getElementById(
"projectLeader"
) as HTMLSelectElement;
......@@ -200,6 +193,27 @@ function createProject(){
+ inputBoxFormIdeasInput.value + "\n" );
console.log(selectedEmployees);
try { {
createImprovementWork(
null,
inputBoxFormNameInput.value,
"första stadiet?",
inputBoxFormContentInput.value,
selectUnit.value,
inputBoxFormPurposeInput.value,
"patient risklevel?",
inputBoxFormAreaInput.value
);
}
// Call the createSuggestion function with the obtained values
alert("created successfully");
//loadCurrentProjects();
} catch {
alert("Error creating");
}
deleteSuggestion(id);
}
async function generateQuestionHTML(suggestionID: string) : Promise<string> {
......@@ -368,6 +382,5 @@ async function generateQuestionHTML(suggestionID: string) : Promise<string> {
</form>
</div>
</div>
</div>
<button id="createProjectFromSuggestionButton">Skapa förbättringsarbete!</button>`
</div>`
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment